-
Notifications
You must be signed in to change notification settings - Fork 351
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
Working with code by cglib (aka dynamically generated code) - such as Spring Framework and MyBatis? #3139
Comments
The Checker Framework operates on Java source code. It doesn't inspect Java bytecode (besides reading type signatures from the classfile) and also doesn't inspect code generated using bytecode libraries like cglib. In your first example, you could annotate parameter In the second example, you could annotate the return type as Even with these frameworks, you will get some benefits out of using the Checker Framework. |
Thanks very much for the reply! I think programmers may forget to annotate each of such things (e.g. the two |
You are right. An analysis tool can only give warnings about the code it analyzes. If there is unanalyzed code, that code might misbehave. |
Ah thanks! It is so sad that I may have to go back to use |
I have added documentation mentioning dynamically generated code as an example of unchecked code. It was not mentioned in the manual previously. Thanks for bringing this up. |
You are welcome! |
There are some libraries which generate code when running (instead of compiling).
Example 1: Spring framework
Dynamically generated code are very common in the Spring framework... So I do not know whether there will be much more such things hidden in the dark, generating NPEs... For instance:
There is nowhere directly calling this method at all. Actually, the only guy who will call this, is the dynamically generated code using cglib by Spring. Moreover, the
p
can be null when Spring calls this, by some manuals of Spring. I think the Checker framework cannot find this bug... :( What can I do?Example 2: MyBatis
The full code looks like:
and nothing more - no implementation classes or anything more! MyBatis will generate code when starting the application. And note that the result
Blog
can be null (by their definition)...What can I do? Thanks so much! I am so sad if I have to not use this wonderful framework, and go to write ugly
assert
s orcheckArgument
s... :(The text was updated successfully, but these errors were encountered: