Testcase:
Bound.java
package bug;
public class Bound {}
Bug.java
package bug;
public class Bug<T extends Bound> {}
Jaif File: 0.jaif
package qual:
annotation @A:
package bug:
class Bug:
insert-annotation Class.typeParameter 0: @qual.A
insert-annotation Class.typeParameter 0, TypeParameter.bound 0: @qual.A
method <init>()V:
insert-annotation Method.type: @qual.A
Command to run:
../annotation-tools/annotation-file-utilities/scripts/insert-annotations-to-source -v -d . testinput/inference/bug/0.jaif testinput/inference/bug/Bug.java testinput/inference/bug/Bound.java
Console Output:
Warning: IndexFileSpecification did not find classfile for: bug.Bug
Read 4 annotations from testinput/inference/bug/0.jaif
Processing testinput/inference/bug/Bug.java
Parsed testinput/inference/bug/Bug.java
Exception in thread "main" java.lang.Error
at annotator.find.Insertions$TypeTree.javacTypeToType(Insertions.java:1357)
at annotator.find.Insertions$TypeTree.javacTypeToType(Insertions.java:1326)
at annotator.find.Insertions$TypeTree.javacTypeToType(Insertions.java:1309)
at annotator.find.Insertions$TypeTree.fromJavacType(Insertions.java:1289)
at annotator.find.Insertions.organizeTypedInsertions(Insertions.java:581)
at annotator.find.Insertions.forClass(Insertions.java:148)
at annotator.find.Insertions.forOuterClass(Insertions.java:128)
at annotator.find.TreeFinder.getPositions(TreeFinder.java:1872)
at annotator.Main.main(Main.java:708)
Expected: no errors
Actual: Got exception
I changed the file order:
../annotation-tools/annotation-file-utilities/scripts/insert-annotations-to-source -v -d . testinput/inference/bug/0.jaif testinput/inference/bug/Bound.java testinput/inference/bug/Bug.java
Console Output:
Warning: IndexFileSpecification did not find classfile for: bug.Bug
Read 4 annotations from testinput/inference/bug/0.jaif
Processing testinput/inference/bug/Bound.java
Parsed testinput/inference/bug/Bound.java
getPositions returned 0 positions in tree for testinput/inference/bug/Bound.java
Writing ./bug/Bound.java
Processing testinput/inference/bug/Bug.java
Parsed testinput/inference/bug/Bug.java
getPositions returned 2 positions in tree for testinput/inference/bug/Bug.java
..Writing ./bug/Bug.java
Expected: no errors
Bound.java
package bug;
public class Bound {}
Bug.java
package bug;
import qual.A;
public class Bug<@A T extends @A Bound> {}
Actual: no errors
Insertion result is the same as expected.
If I change T extends Bound to T extends Object, insertion result is as expected and there is not error.
After running the second command(which is successful), I ran the first command(which failed before) but the result was as expected and there wasn't error anymore. I tried removing Bound.java from output directory, and then ran the first command again(the one that had error). This time, I got the same failure result again.
Reasoning: it looks like java source file of class type variable's upper bound must exist in output directory to make the whole insertion succeed. The first command succeeded because the second command output Bound.java into the output directory, and it was picked up when I ran the first command right after second command. But this would cause trivial ordering when inserting annotation.
Testcase:
Bound.javaBug.javaJaif File:
0.jaifCommand to run:
Console Output:
Expected: no errors
Actual: Got exception
I changed the file order:
Console Output:
Expected: no errors
Bound.javaBug.javaActual: no errors
Insertion result is the same as expected.
If I change
T extends BoundtoT extends Object, insertion result is as expected and there is not error.After running the second command(which is successful), I ran the first command(which failed before) but the result was as expected and there wasn't error anymore. I tried removing
Bound.javafrom output directory, and then ran the first command again(the one that had error). This time, I got the same failure result again.Reasoning: it looks like java source file of class type variable's upper bound must exist in output directory to make the whole insertion succeed. The first command succeeded because the second command output
Bound.javainto the output directory, and it was picked up when I ran the first command right after second command. But this would cause trivial ordering when inserting annotation.