This repository was archived by the owner on Nov 10, 2023. It is now read-only.
File tree 5 files changed +42
-1
lines changed
src/com/facebook/buck/java
test/com/facebook/buck/java
5 files changed +42
-1
lines changed Original file line number Diff line number Diff line change @@ -92,7 +92,7 @@ public Javac getJavac() {
92
92
ProcessExecutorParams params = ImmutableProcessExecutorParams .builder ()
93
93
.setCommand (ImmutableList .of (externalJavac .get ().toString (), "-version" ))
94
94
.build ();
95
- ProcessExecutor .Result result = null ;
95
+ ProcessExecutor .Result result ;
96
96
try {
97
97
result = getProcessExecutor ().get ().launchAndExecute (params );
98
98
} catch (InterruptedException | IOException e ) {
@@ -119,6 +119,9 @@ public void appendOptionsToList(
119
119
optionsBuilder .add ("-source" , getSourceLevel ());
120
120
optionsBuilder .add ("-target" , getTargetLevel ());
121
121
122
+ // Set the sourcepath to stop us reading source files out of jars by mistake.
123
+ optionsBuilder .add ("-sourcepath" , "" );
124
+
122
125
if (isDebug ()) {
123
126
optionsBuilder .add ("-g" );
124
127
}
Original file line number Diff line number Diff line change @@ -381,6 +381,23 @@ public void ensureChangingDepFromProvidedToTransitiveTriggersRebuild() throws IO
381
381
workspace .getBuildLog ().assertTargetBuiltLocally ("//:library" );
382
382
}
383
383
384
+ @ Test
385
+ public void ensureThatSourcePathIsSetSensibly () throws IOException {
386
+ ProjectWorkspace workspace = TestDataHelper .createProjectWorkspaceForScenario (
387
+ this ,
388
+ "sourcepath" ,
389
+ tmp );
390
+ workspace .setUp ();
391
+
392
+ ProcessResult result = workspace .runBuckBuild ("//:b" );
393
+
394
+ // This should fail, since we expect the symbol for A not to be found.
395
+ result .assertFailure ();
396
+ String stderr = result .getStderr ();
397
+
398
+ assertTrue (stderr , stderr .contains ("cannot find symbol" ));
399
+ }
400
+
384
401
/**
385
402
* Asserts that the specified file exists and returns its contents.
386
403
*/
Original file line number Diff line number Diff line change
1
+ // In the default package
2
+
3
+ class A {
4
+
5
+ }
Original file line number Diff line number Diff line change
1
+ // Default package
2
+
3
+ class B extends A {
4
+ }
5
+
Original file line number Diff line number Diff line change
1
+ java_library (
2
+ name = 'a' ,
3
+ resources = ['A.java' ],
4
+ )
5
+
6
+ java_library (
7
+ name = 'b' ,
8
+ srcs = ['B.java' ],
9
+ deps = [':a' ],
10
+ )
11
+
You can’t perform that action at this time.
0 commit comments