Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .mvn/extensions.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,6 @@
<extension>
<groupId>com.gradle</groupId>
<artifactId>develocity-maven-extension</artifactId>
<version>1.22.2</version>
<version>2.6.1</version>
</extension>
</extensions>
8 changes: 4 additions & 4 deletions java-frontend/src/main/java/org/sonar/java/model/JParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -41,14 +41,14 @@ private JParser() {
}

/**
* Parses and attributes one compilation unit on its own, against the running JDK only. Batch analysis goes
* through {@link JParserConfig}, which scans every file of the project before translating.
* Parses and attributes one compilation unit against the running JDK only. Batch analysis goes
* through {@link JParserConfig}, which scans the current batch before translating.
*/
public static JavaTree.CompilationUnitTreeImpl parse(String version, String unitName, String source) {
return parse(version, unitName, source, List.of());
}

/** {@link #parse(String, String, String)} with a classpath, as ECJ attributed single sources. */
/** The classpath parameter is retained for compatibility and is not forwarded to SemSitter. */
public static JavaTree.CompilationUnitTreeImpl parse(String version, String unitName, String source, List<File> classpath) {
Objects.requireNonNull(version);
Objects.requireNonNull(unitName);
Expand All @@ -61,7 +61,7 @@ public static JavaTree.CompilationUnitTreeImpl parse(String version, String unit
Files.writeString(file, source, StandardCharsets.UTF_8);
JsonObject document;
synchronized (bridge) {
bridge.analyze(directory, List.of(file), JParserConfig.bridgeClasspath(classpath));
bridge.analyze(directory, List.of(file), JParserConfig.jdkClasspath());
document = bridge.cst(file.toString());
}
JSema sema = new JSema();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -212,26 +212,16 @@ void openBridge(List<? extends InputFile> files) {
bridge.analyze(
root == null ? Path.of(".") : root,
files.stream().map(file -> file.path().toAbsolutePath()).toList(),
bridgeClasspath(classpath));
jdkClasspath());
}
} catch (Exception failure) {
closeBridge();
LOG.warn("SemSitter bridge did not start ({})", failure.toString());
}
}

/**
* The project classpath preceded by the runtime image of the running JDK, which is the JDK ECJ resolved
* against, so JDK classes win over a library copy as on the boot classpath.
*/
static List<String> bridgeClasspath(List<File> classpath) {
List<String> entries = new ArrayList<>();
Path image = Path.of(System.getProperty("java.home"), "lib", "modules");
if (image.toFile().isFile()) {
entries.add(image.toString());
}
classpath.stream().map(File::getAbsolutePath).forEach(entries::add);
return entries;
static List<String> jdkClasspath() {
return List.of(Path.of(System.getProperty("java.home"), "lib", "modules").toString());
}

void closeBridge() {
Expand Down