0

i'm currently attaching to a java webstart application (anything from here: https://docs.oracle.com/javase/tutorial/uiswing/examples/misc/index.html#security) using the Java Attach API.

That works without problems, but now i want to iterate over all available Frames using

for (Frame f : java.awt.Frame.getFrames())

But this results in

java.lang.NullPointerException
at java.awt.Window.getWindows(Unknown Source)
at java.awt.Window.getWindows(Unknown Source)
at java.awt.Frame.getFrames(Unknown Source)
at com.asc.screen.scan.javascan.javascanagent.util.GuiWalkerTexasRanger.walkGui(GuiWalkerTexasRanger.java:151)
at com.asc.screen.scan.javascan.javascanagent.ComponentRegistry.initialScan(ComponentRegistry.java:124)
at com.asc.screen.scan.javascan.javascanagent.ComponentRegistry.init(ComponentRegistry.java:76)
at com.asc.screen.scan.javascan.javascanagent.JavaScanAgent.loadFilter(JavaScanAgent.java:291)
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source)
at java.lang.reflect.Method.invoke(Unknown Source)
at sun.rmi.server.UnicastServerRef.dispatch(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at sun.rmi.transport.Transport$1.run(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
at sun.rmi.transport.Transport.serviceCall(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport.handleMessages(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.run0(Unknown Source)
at sun.rmi.transport.tcp.TCPTransport$ConnectionHandler.lambda$run$0(Unknown Source)
at java.security.AccessController.doPrivileged(Native Method)
...

Maybe i'm missing something here, but shouldn't it be possible to access all frames within the applet? This method works fine for non applet applications.

The problem is that the error is thrown inside the java code, so there is no way for me to avoid or handle this nullpointer, and i'm not getting any frames back.

Thanks in advance.

xuckz
  • 43
  • 4
  • 1
    All Swing and AWT operations need to be executed in the AWT event dispatch thread. Doing otherwise results in unpredictable behavior. See https://docs.oracle.com/javase/tutorial/uiswing/concurrency/. – VGR Feb 13 '18 at 15:14
  • Thanks for your answer, it led me down the right path to: https://stackoverflow.com/questions/17275259/nullpointerexception-in-invokelater-while-running-through-java-webstart with the comment solving my problem in addition to the Swingutilities: https://stackoverflow.com/a/20102779/5242340 – xuckz Feb 14 '18 at 07:25

0 Answers0