Executing the main method of a nested class?

David Holmes david.holmes at oracle.com
Fri Sep 15 04:38:48 UTC 2017


I have the following:

/*
  * @test
  * @bug 8046171
  * @compile -XDdisablePrivateAccessors CrashTheJIT.java
  * @run main/othervm -Xcomp CrashTheJIT$Nested
  */

public class CrashTheJIT {

     static class Nested2 {
         private Nested2() { }
     }

     public static class Nested {
         public static void main(String[] args) {
             run();
         }
         private static void run() {
             Nested2 n = new Nested2();
         }
     }
}

but it fails because it seems as part of @run jtreg wants to compile 
CrashTheJIT$Nested:

ACTION: compile -- Passed. Compilation successful
REASON: User specified action: run compile -XDdisablePrivateAccessors 
CrashTheJIT.java
TIME:   1.591 seconds
messages:
command: compile -XDdisablePrivateAccessors 
/export/users/dh198349/valhalla/valhalla-base/hotspot/test/runtime/Nestmates/CrashTheJIT.java
reason: User specified action: run compile -XDdisablePrivateAccessors 
CrashTheJIT.java
Mode: othervm
elapsed time (seconds): 1.591
...
STDOUT:
STDERR:

ACTION: build -- Not run. Test running...
REASON: Named class compiled on demand
TIME:   JIT$Nested seconds
messages:
command: build CrashTheJIT$Nested
reason: Named class compiled on demand

TEST RESULT: Error. can't find CrashTheJIT$Nested in test directory or 
libraries

----

Note the messed up "TIME:   JIT$Nested seconds" as well!

Is there any way to tell jtreg the @compile already handled everything ??

Thanks,
David


More information about the jtreg-use mailing list