-
Notifications
You must be signed in to change notification settings - Fork 42
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
checker for returnValue and contructor super call and auto add #69
base: main
Are you sure you want to change the base?
Conversation
Hello, code is ready with PR. I have just a doubt about impact of the classCreator close.
Else it is mostly store and load return handle so no impact because it call visitor ... |
I ma thinking to split isValid to isMissingReturnValue and isMissingSuper or this call in ctor.
wdyt ? |
|
||
@Override | ||
public AnnotationVisitor visitAnnotationDefault() { | ||
return new DummyVisitor(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why not return null like https://github.com/llbit/ow2-asm/blob/master/src/org/objectweb/asm/MethodVisitor.java ?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
current code do not handle it :
AnnotationUtils.visitAnnotationValue do not check if first param is null.
But you are right asm standard said that it can return null if no visitor is needed.
Other solution is to return null and check it in
if (value.getClass().isArray()) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@gsmet @stuartwdouglas I provide 2 solutions for that. current code with dummy visitor or return null and handle it in AnnotationUtils. What do you prefer ?
Anyway, I need a full review before going further.
@gsmet @stuartwdouglas @Sanne can you review it ? |
import org.objectweb.asm.Opcodes; | ||
import org.objectweb.asm.TypePath; | ||
|
||
public class MethodCheckerVisitor extends MethodVisitor { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this done as a visitor, rather than just checking that the bytecode is valid when it is generated?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
imagine you have a code with
public int myfunct(boolean foo, boolean bar) {
if (foo) return 1
else if (bar) return 0;
else
throw new RuntimeException();
}
so you have 2 branchs of return to check indeed.
My first think was to check that last operation was a return and it failed because of that.
You have the exception case too...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
you can not check just the methodMody, you have to enter in operation to check them.
Or you mean that I check generated code instead of AST ?
fix #67
fix #65