Last active
May 3, 2023 15:44
-
-
Save kalharbi/63de1fd5639b96e064b199e0e16460dd to your computer and use it in GitHub Desktop.
what seems to be a bug in getDeclaredConstructors(). Will check back later.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
public class OuterClass | |
{ | |
private int x; | |
private OuterClass(int x){ | |
this.x =x; | |
} | |
public static void main( String[] args ) | |
{ | |
// Should print 1 constructor not 2 | |
System.out.println(OuterClass.class.getDeclaredConstructors().length); // prints 2 | |
} | |
public static class NestedClass{ | |
private int x =0; | |
public NestedClass(int x){} | |
// This is not a constructor. Yet, App.class.getDeclaredConstructors() counts it as a constructor! | |
public OuterClass foo(){ | |
return new OuterClass(10); | |
} | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment