Review request: JDK-8159596 Add java --dry-run

Peter Levart peter.levart at gmail.com
Thu Jun 30 06:43:55 UTC 2016


On 06/30/2016 08:32 AM, Peter Levart wrote:
> But is it possible to check for the presence of a method in a class 
> without initializing it? Maybe the check for the presence of main 
> method could simply be dropped out of --dry-run?

It seems that it *is* possible to check for the presence of a method 
without initializing the class. The following:

public class Test {

     static class Nested {
         static {
             System.out.println("Hello from Nested.<clinit>");
         }

         static void m() {}
     }

     public static void main(String[] args) throws Exception {
         System.out.println(Nested.class.getDeclaredMethod("m"));
     }
}


...prints just:

static void Test$Nested.m()



Regards, Peter



More information about the jigsaw-dev mailing list