-
Notifications
You must be signed in to change notification settings - Fork 301
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
isEnum method for JavaClass #5
Comments
Hey, glad it helps you :-) I actually thought about this myself in the past, the reason it's not in, is simply, that I wanted to wait, if this is really relevant in daily life. Which you just proved it is ;-) A PR would be highly appreciated of course :-) In case it helps to get started, I think this would involve
I wonder, if it would make sense, to support |
I've made some simple changes in PR #6 |
Thanks a lot, I've merged your PR :-) If you want to try the current 0.5.0-SNAPSHOT version with your changes, you can include the Sonatype snapshot repo
(note that there is a breaking change where As for Anyway, thanks for contributing, I'll close this issue. |
Thank you too, @codecholeric. |
…e three try catch blocks start from a handler label. At least with my JDK 7 it looks like this: ``` private void method(int, boolean); descriptor: (IZ)V flags: (0x0002) ACC_PRIVATE Code: stack=4, locals=6, args_size=3 0: new TNG#3 // class java/net/Socket 3: dup 4: ldc TNG#4 // String 6: iconst_0 7: invokespecial TNG#5 // Method java/net/Socket."<init>":(Ljava/lang/String;I)V 10: astore_3 11: new TNG#6 // class java/io/BufferedReader 14: dup 15: aconst_null 16: invokespecial TNG#7 // Method java/io/BufferedReader."<init>":(Ljava/io/Reader;)V 19: astore 4 21: aload 4 23: invokevirtual TNG#8 // Method java/io/BufferedReader.close:()V 26: return 27: astore 5 29: aload 4 31: invokevirtual TNG#8 // Method java/io/BufferedReader.close:()V 34: aload 5 36: athrow 37: astore_3 38: return Exception table: from to target type 27 29 27 any 0 26 37 Class java/lang/Exception 27 37 37 Class java/lang/Exception ``` We can possibly ignore this, since we will drop JDK 7 support soon anyway, but let's maybe ponder about it, why it looks so different. That of the two declared try-catch-blocks only one try catch block is visible is definitely strange (and worse than having 3 try-catch-blocks where one is synthetic). But this example is anyway quite strange, because the bytecode immediately changes e.g. if we remove one of the unused method parameters. Signed-off-by: Peter Gafert <peter.gafert@tngtech.com>
Hi @codecholeric,
Thank you for this great library. It is awesome and saves me a lot of time.
Recently I've faced a case where i wanted to check that
JavaClass
isenum
.Currently I can solve this by:
javaClass.reflect().isEnum()
, but it would be more convenient to have such check inJavaClass
.If you don't mind I'll create corresponding PR.
The text was updated successfully, but these errors were encountered: