-
Notifications
You must be signed in to change notification settings - Fork 2
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
Better Wala error message #1
Comments
@martinschaef Hi Martin, thanks for trying it out. Can you provide me the program which caused the problem? I can try to fix it if I can reproduce the error. The |
Thanks for the quick reply :) I can't give you the exact code, but I'll try to produce a smaller example that I can share here. It looks like this is actually a Wala problem (see here). Btw., is it, at least in theory, possible to tell Wala to create phantom classes if it cannot resolve something? Basically, an equivalent to |
@martinschaef It will be great if you can produce a smaller example.
instead of using the
should do the work I believe. I can try to add this support tomorrow. Now it is too late in Germany. |
I would recommend |
Excellent, thx. I tried to subtype WalaToSootIRConverter, but |
@martinschaef Hi Martin, after playing with an example I constructed, I believe the error message you got means that you didn't give the IRConverter library classes which are directly referenced by the source code.
This So to fix this issue, you should make sure all library classes which are directly referenced by the source code can be found in the library path. There is currently no configuration option in WALA to ignore such missing types in the source code front end. The After talking with Julian, currently there is no better warning message to tell which class is missed. I just released a new version of the IRConverter which allows you have access to ClassConverter https://github.com/MagpieBridge/IRConverter/packages/96202 |
Excellent, thx. I'll try to work with that. Like I said, I have one use case where it's hard to get any library class because we can't really run the build script to get the compile/runtime classpath. Is it theoretically possible to extend Java to create a phantom class in these cases, or is there a conceptual problem that makes this hard/impossible? I'm aware that we'd loose soundness because of missing exceptional flow, but that's the same if we use phantoms in bytecode. |
From my understanding the issue is that the Java source front end is now based on the Eclipse Java Compiler (ECJ), and ECJ APIs start doing unexpected things when referenced classes are missing (like returning |
Manu is right. The key is that, unlike for bytecode, unknown code can influence the IR that the source front needs to generate. For instance, imagine seeing a call like This could, potentially, be handled in some cases. The front end could look at the file and see what possibilities there are. Maybe the type hierarchy is complete, which would rule out super calls, and there is exactly one static import; in that case, we could generate a static invoke to foo in whatever class is imported. But that seems like a rat hole of special cases that anyway would not be able to work in general. (Note that, in bytecode analysis, the correct bytecode must have been generated by someone already, and they must have been able to compile the code.) |
Yeah, I was more thinking along the lines of snippet parsing. I remember that ASTParser in JDT has an option to set statement recovery and bindings recovery where it just puts some stuff in the AST to make it well-formed again. Did you ever look into snippet parsing? |
There is a long thread on this kind of issue here: I think someone has tried something like snippet parsing before and it didn't quite work: That said, with newer versions of Eclipe JDT / ECJ maybe the snippet parsing would work better. |
I got a little bit further with a custom WalaToSootIRConverter (see https://gist.github.com/martinschaef/56e070cd7a9c5ecd4a2957d72fd2b92f), but I still get exceptions for anything that's a little more complex. E.g.,
And, if I remove a little bit of code, I get an exception from Soot:
Does either of these look familiar? |
@martinschaef The first one exception could be an error in the InstructionConverter caused by an invoke statement. Can you paste the code you removed, especially the invoke statements? |
Unfortunately, I can't really past any of that code. I'll find some time later in the week to work on examples that can be shared. In the meantime, did you try it on projects that use fancy things, like Lombok, Guava, or AspectJ? Are there any known limitations that these things don't work? |
@martinschaef For the exception you pasted I do need code that I can use to debug the issue. I didn't use the IRConverter on incomplete code. |
Ugh ... that is a big limitation. Our coding guideline says to use Streams everywhere. @msridhar @juliandolby is there a roadmap for java 8+? If not, we might have to change plans a little |
I personally do not have any plans to work on the Java source front end at the moment. I know @mattkindy-praetorian may have poked around at support for lambdas, but not sure if he can share more |
@martinschaef To solve this problem, have you thought of using desugaring of Java 8 language features? I know Google does this for Android (D8). Currently, our group is building a new soot and we also uses WALA's source code front end, so supporting Java 8+ features is planned. |
D8 desugars bytecodes, not source code. If analysis of bytecodes is in scope, then WALA's bytecode frontend should work fine with Java 8 features. |
@msridhar True, but I meant the idea. I can image an automated tool which rewrites the source code before passing it to WALA's source code front end. |
@martinschaef It seems you would like two things in the WALA Java source
front end: support for Java 8 and some ability to parse incomplete code.
Incomplete code is hard to do, as I noted in a previous message, but would
Java 8 support be useful to you by itself?
…On Thu, Apr 16, 2020 at 10:47 AM Linghui Luo ***@***.***> wrote:
@msridhar <https://github.com/msridhar> True, but I meant the idea. I can
image an automated tool which rewrites the source code before passing to
WALA's source code front end.
—
You are receiving this because you were mentioned.
Reply to this email directly, view it on GitHub
<#1 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AAMTO7VQIFDNS2ZDUZIFLWLRM4K7HANCNFSM4MEA2B6A>
.
|
Yes, I think Java 8 is actually the bigger problem than snippets. If we have full Java 8 support, we can still cover a lot of use cases (including using MagpieBridge). Snippet parsing is a nice-to-have, but we can work around it. |
Unsure about whether I can contribute code, but I was able to get Java 8 support in place by introducing a
Then I had to modify some bootstrap functionality to support AST-based lambdas, so that involved also changing |
It can perhaps be useful to use something like the below to get a partial desugaring as well? I used this for testing at various points (assuming the code compiles) http://keweishang.blogspot.com/2016/04/how-compiler-understands-your-java-class.html |
@mattkindy-praetorian Your code looks very promising. You can certainly contribute code; a pull request complete with a few tests would be great. If you wrote your code yourself, then contributing should be quite easy and would be very much appreciated. |
I'm running some tests from command line. When I create a
WalaToSootIRConverter
for a source path that only contains simple files (i.e., they don't import non-jdk stuff) everything works fine. But when I add something more complicated and provide the classpath, I always end up with this exception:Is there a way to get a better error message that would tell me what it was looking for?
The text was updated successfully, but these errors were encountered: