Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaSnoop Does Not Support Resources When Instrumenting #13

Open
GoogleCodeExporter opened this issue Jul 16, 2015 · 1 comment
Open

Comments

@GoogleCodeExporter
Copy link

What steps will reproduce the problem?
1. Snoop on an application that loads resources required for something
2. Wait for java.lang.NullPointerException

What is the expected output? What do you see instead?
When JavaSnoop instruments a class it magically pulls in all the resources for 
that class. It currently doesn't do this at the moment.


What version of the product are you using? On what operating system?
1 FINAL on WinXP SP3

Please provide any additional information below.

Here's the method pseudo-code:

XXXXX method:
foo = new ImageIcon(Some.class.getResource("/path/to/some.png"));
bar(foo.getImage());

ImageIcon isn't happy with the null from class.getResources it seems. The jar 
does contain the some.png resource at the correct path. JavaSnoop doesn't seem 
to load the resource correctly.

Here's a partial stack trace:

java.lang.NullPointerException
    at javax.swing.ImageIcon.<init>(ImageIcon.java:167)
    at XXXXX method
    at java.lang.Class.forName(Class.java:247)
    at com.aspect.snoop.ui.hook.FunctionSearchView.populateResults(FunctionSearchView.java:265)
    at com.aspect.snoop.ui.hook.FunctionSearchView.txtMethodKeyTyped(FunctionSearchView.java:229)
    at com.aspect.snoop.ui.hook.FunctionSearchView.access$100(FunctionSearchView.java:34)
    at com.aspect.snoop.ui.hook.FunctionSearchView$2.keyTyped(FunctionSearchView.java:120)
    at java.awt.Component.processKeyEvent(Component.java:6222)
[...]


Original issue reported on code.google.com by jon.pas...@aspectsecurity.com on 21 Jan 2011 at 3:38

@GoogleCodeExporter
Copy link
Author

I'm listing this as a defect because this is bad. Your analysis is correct: 
when JavaSnoop imports the classes into its ClassLoader, it doesn't get the 
resources. This is because classes are retrieved using the 
Instrumentation.getAllLoadedClasses() API, which properly does not return other 
resources that may reside in the JARs.

The model in JavaSnoop is totally class based, so I'm not sure how resources 
will fit into it, but I will take a long hard look at it.

Original comment by arshan.d...@gmail.com on 21 Jan 2011 at 4:19

  • Changed state: Accepted
  • Added labels: Priority-High
  • Removed labels: Priority-Medium

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant