Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Browse the repository at this point in the history
fix(java extractor): Handle source files in jars (#4188)
When we encounter a source file in a jar, don't try to add it as an additional source path. This includes a special case where the classpath is searched for sources if no explicit sourcepath is given. 1) The URI generated by javac for files in a jar (JarFileObject) contains a null path so the normal logic here will produce a null pointer exception. 2) The hooks into javac that we already have notice and record the source jar usage, including the special case when it was specified as the classpath, not the sourcepath. Fixes #4186
- Loading branch information
1 parent
14592b8
commit df711e3
Showing
8 changed files
with
73 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
6 changes: 6 additions & 0 deletions
6
kythe/javatests/com/google/devtools/kythe/extractors/java/testdata/src_in_jar/C1.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
import pack.C2; | ||
import pack2.C3; | ||
|
||
class C1 { | ||
|
||
} |
6 changes: 6 additions & 0 deletions
6
kythe/javatests/com/google/devtools/kythe/extractors/java/testdata/src_in_jar/README
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
This test tests that sources found in jars are handled properly. | ||
|
||
The jar was built with: | ||
|
||
javac pack2/C3.java | ||
jar cf pack.jar pack/C2.java pack2/C3.class |
Binary file added
BIN
+773 Bytes
kythe/javatests/com/google/devtools/kythe/extractors/java/testdata/src_in_jar/pack.jar
Binary file not shown.
5 changes: 5 additions & 0 deletions
5
kythe/javatests/com/google/devtools/kythe/extractors/java/testdata/src_in_jar/pack/C2.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
package pack; | ||
|
||
public class C2 { | ||
|
||
} |
Binary file added
BIN
+184 Bytes
kythe/javatests/com/google/devtools/kythe/extractors/java/testdata/src_in_jar/pack2/C3.class
Binary file not shown.
4 changes: 4 additions & 0 deletions
4
kythe/javatests/com/google/devtools/kythe/extractors/java/testdata/src_in_jar/pack2/C3.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,4 @@ | ||
package pack2; | ||
|
||
public class C3 { | ||
} |