-
Notifications
You must be signed in to change notification settings - Fork 7
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
Crash fix for UnionType parameter in Issue #38 #45
Conversation
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.
I think overall this code is good. But as you say, this current version will only work if both the two types in the union type are solvable, which is not guaranteed in real life. So we should also consider creating synthetic class files if one or both of the types are unsolved.
if (parameter.getType() instanceof UnionType) { | ||
UnionType unionType = parameter.getType().asUnionType(); | ||
for (var param : unionType.getElements()) { | ||
param.resolve().describe(); |
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.
As you can see in the original codes, the purpose of this try block is to check if a parameter is unsolved. If it is, the parameter will be sent to the catch block where Specimin will create a synthetic class file for it. So I think we also need to do the samething with param
. If it is unsolved (that is to say, an exception is thrown when we try to resolve it), param
should be sent to the catch block so Specimin can create a synthetic class file for it.
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.
I have pushed a commit addressing this comment
As expected, resolving Adding the I believe this issue will occur for every java.lang types that not imported. |
I don't understand the problem that you are raising here. All java.lang types are automatically imported by javac at the start of each file. Based on @LoiNguyenCS's previous comment, you should write test cases that 1) uses an exception class that's defined as part of the input, and 2) uses an exception class that is unsolvable (i.e., is from a library that would presumably be on the classpath when actually compiling the code). Please re-assign me as a reviewer once you've done this. |
Looking into it |
Even if the ALSO brought some change from Loi's unmerged PR. |
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.
ALSO brought some change from Loi's unmerged PR.
When making a comment like this, you should link the specific PR you're referring to rather than being vague. In fact, Loi has multiple open, unmerged PRs, so this is ambiguous (which made this harder to review).
src/main/java/org/checkerframework/specimin/TargetMethodFinderVisitor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/checkerframework/specimin/TargetMethodFinderVisitor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/checkerframework/specimin/TargetMethodFinderVisitor.java
Outdated
Show resolved
Hide resolved
…t's not necessary
Few points we have discussed in today's meeting. (1) Add a test case with arbitrary number of nested blocks inside catch clause and check if that test case completes successfully. --> Added a test case. It's safe to use the (2) When creating a unsolved class for an exception, current implementation check if the reference type is from catch block. Professor, you suggested to check if any parents of this type is Exception type. I can check that way. However, Since the current way works for nested case, i am keeping current way (3) I observed that if
|
It will be good if we merge this PR after PR #57 |
src/main/java/org/checkerframework/specimin/TargetMethodFinderVisitor.java
Outdated
Show resolved
Hide resolved
src/main/java/org/checkerframework/specimin/TargetMethodFinderVisitor.java
Show resolved
Hide resolved
…er chain to remove duplication, adding comments on workaround for parameter of catch clause
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.
Also, please merge from main
so that you incorporate the changes from #57 before you request another review.
src/main/java/org/checkerframework/specimin/TargetMethodFinderVisitor.java
Show resolved
Hide resolved
Professor, branch is updated with main |
* This method sets the number of type variables for the current class | ||
* | ||
* @param numberOfTypeVariables number of type variable in this class. | ||
*/ |
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.
This change is harmless, but it wasn't necessary. I'm going to leave it in, but if we were in less of a hurry-up mode right now I'd insist you PR it separately.
Issue statement: Casting
UnionType
parameter asClassOrInterfaceType
to resolve the parameter causes a crash inUnsolvedSymbolVisitor.java
.Current Fix Since both
InstantiationException
andIllegalAccessException
are built in Java language, they should have been resolved successfully instead of throwing an exception. To resolve this I get each element of UnionType and resolve them separately.Threat
since InstantiationException , IllegalAccessException is built in java, resolve is successful. Custom exception types need to be handled.