Skip to content

SONARJAVA-7279 Resolve the JDK API of the target release through the new jdt-package option - #6459

Open
leonardo-pilastri-sonarsource wants to merge 12 commits into
masterfrom
use-jdt-release-option
Open

leonardo-pilastri-sonarsource wants to merge 12 commits into
masterfrom
use-jdt-release-option

Conversation

@leonardo-pilastri-sonarsource

@leonardo-pilastri-sonarsource leonardo-pilastri-sonarsource commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

Summary by Gitar

  • Release API resolution:
    • Resolve the JDK API of the target release from the runtime image via SystemReleaseClasspath in JParserConfig
    • Gated behind the sonar.java.useJdkReleaseOption property, enabled by default and registered in JavaPlugin
  • Dependency change:
    • Downgrade jdt-package to 1.9.0.12280 in java-frontend/pom.xml
  • Test updates:
    • Add unit and parser tests covering release API selection and fallbacks
    • Update RunFinalizersCheckTest expectations for Java 10 API visibility
    • Replace SequencedCollection mutator calls with List equivalents in CollectorsToListCheckSample
  • Collector mutator coverage:
    • Add CollectorsToListCheckSequencedSample covering SequencedCollection mutators on Java 21
  • Ruling expectations:
    • Remove obsolete S5738 and S2387 expectations and the guava S3551 expectation file

This will update automatically on new commits.

@hashicorp-vault-sonar-prod

hashicorp-vault-sonar-prod Bot commented Nov 2, 2026 •

Copy link
Copy Markdown
Contributor

SONARJAVA-7279

…ollectorsToListCheck

The main sample runs at Java 16, where addFirst, addLast, removeFirst and
removeLast no longer resolve, so it uses the older List methods instead. A
dedicated sample checked at Java 21 keeps one compliant case for each of the
four methods, and a noncompliant case as a control.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 2, 2026

Copy link
Copy Markdown
Contributor

⚖️ Ruling update ready for review: #6461

@datadog-sonarsource

datadog-sonarsource Bot commented Nov 2, 2026 •

Copy link
Copy Markdown

Pipelines

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 5b66d3d | Docs | Give us feedback!

Guava is analyzed with sonar.java.source=17, so the API of Java 17 is now seen
instead of the one of the JDK running the analysis:
- ThreadDeath (deprecated for removal in 20) and Object.finalize() (in 18) are
  no longer reported by S5738,
- the unsynchronized mark() and reset() overrides in HashingInputStream are now
  reported by S3551, as FilterInputStream declares them synchronized in 17.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
The analysis now sees the API of the Java release it targets instead of the one
of the JDK running it, so two sets of expected issues disappear:
- eclipse-jetty S5738: Jetty targets Java 11, where SecurityManager and
  AccessController are not yet deprecated for removal (Java 17),
- guava S2387: the shadowed fields (Reference.next, AbstractMap.keySet) are not
  public API, and are not part of the API of the release anymore.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…similar-to-main

Same reason as for eclipse-jetty: Jetty targets Java 11, where SecurityManager
is not deprecated for removal yet, so the issues of ContextHandler are gone.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…sDebugEnabled

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@sonarqube-next

sonarqube-next Bot commented Nov 3, 2026

Copy link
Copy Markdown
Contributor

@leonardo-pilastri-sonarsource

Copy link
Copy Markdown
Contributor Author

/pvf

@hashicorp-vault-sonar-prod

Copy link
Copy Markdown
Contributor

⚠️ Performance Validation finished without publishing a dashboard. See run logs.

Projects with unexpected PVF results:

  • org.codehaus.sonar-plugins.l10n-sonar-l10n-fr-plugin
  • xwiki-commons_master

Comment thread java-frontend/pom.xml
<groupId>${project.groupId}</groupId>
<artifactId>jdt-package</artifactId>
<version>1.10.0.12296</version>
<version>1.9.0.12280</version>

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Cross-PR: Merge downgrades jdt-package and drops master's Java 27 JDT update · SonarSource/sonar-java-jdt #169

Breaks when this PR merges into master while java-frontend/pom.xml still pins jdt-package 1.9.0.12280 and no jdt-package release yet contains both sonar-java-jdt PR SonarSource/sonar-java-jdt#169 and the Java 27 JDT update.

How

  1. Commit 7509a6b bumped jdt-package to 1.9.0.12280 (java-frontend/pom.xml:24) so that org.eclipse.jdt.core.dom.SystemReleaseClasspath is available. That class comes from SonarSource/sonar-java-jdt#169 (src/main/java/org/eclipse/jdt/core/dom/SystemReleaseClasspath.java).
  2. Master moved to 1.10.0.12296 in SONARJAVA-7303 Update Sonar JDT #6489 (SONARJAVA-7303, Java 27 support). The merge commit kept 1.9.0.12280, so merging this PR would roll master's JDT back to the version without Java 27 support.
  3. JParserConfig.java:25,145-146,189-191 needs SystemReleaseClasspath.OPTION_RELEASE, OPTION_JAVA_HOME and isApplicable, and nothing shows that 1.10.0.12296 contains them. So neither pinned version gives you both features.

Fix

  • This PR: Depend on a jdt-package build that has both SonarSource/sonar-java-jdt#169 and master's 1.10 (Java 27) JDT update, instead of keeping 1.9.0.12280.
  • SonarSource/sonar-java-jdt#169: Rebase onto the JDT version shipped as 1.10.0.12296 and publish a release that includes SystemReleaseClasspath and the patched ASTParser.getClasspath().

Compared 555a24a with SonarSource/sonar-java-jdt#169 at fed37d2

Was this helpful? React with 👍 / 👎

The release API of the analyzed Java version is now used by default. The property stays as the way out for a project whose
analysis regressed: setting it to false makes the whole API of the JDK visible again. The parser already falls back to that
when the JDK cannot serve the release.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…elease API being enabled by default

RunFinalizersCheckTest: for Java 10, the APIs of that release are visible, so the issues are raised on the sample.

Ruling: with the API of the analyzed release, guava and eclipse-jetty no longer raise the issues of S5738 and S2387 that depended
on APIs of later JDKs, and guava gets two new S3551 issues. The expectations are those of the ruling run of the PR.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
…ns (RunFinalizers, guava S5738 and S3551)

The previous commit only contained the deletion of the two ruling expectation files. This one adds the rest:
- RunFinalizersCheckTest: for Java 10, the APIs of that release are visible, so the issues are raised on the sample;
- guava: S5738 no longer raises 4 issues that depended on APIs of later JDKs, and S3551 has 2 new issues.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@github-actions

github-actions Bot commented Nov 13, 2026 •

Copy link
Copy Markdown
Contributor

Ruling Diff Summary

Detected changes in 5 rule files: 30 issues removed, 2 issues added.

S5738 (java) on eclipse-jetty - 12 issues removed, 0 issues added - deleted ruling file

Removed jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java (line 212, column 52, end column 70)

Remove this call to a deprecated method, it has been marked for removal.
(source file not found in checkout: jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java)

Removed jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java (line 320, column 44, end column 62)

Remove this call to a deprecated method, it has been marked for removal.
(source file not found in checkout: jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java)

Removed jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java (line 2509, column 33, end column 49)

Remove this call to a deprecated class, it has been marked for removal.
(source file not found in checkout: jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java)

Removed jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java (line 169, column 16, end column 32)

Remove this call to a deprecated class, it has been marked for removal.
(source file not found in checkout: jetty-slf4j-impl/src/main/java/org/eclipse/jetty/logging/JettyLoggerConfiguration.java)

Removed jetty-util/src/main/java/org/eclipse/jetty/util/MemoryUtils.java (line 37, column 38, end column 54)

Remove this call to a deprecated class, it has been marked for removal.
(source file not found in checkout: jetty-util/src/main/java/org/eclipse/jetty/util/MemoryUtils.java)

Removed jetty-util/src/main/java/org/eclipse/jetty/util/TypeUtil.java (line 680, column 39, end column 55)

Remove this call to a deprecated class, it has been marked for removal.
(source file not found in checkout: jetty-util/src/main/java/org/eclipse/jetty/util/TypeUtil.java)

Removed jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java (line 198, column 58, end column 69)

Remove this call to a deprecated class, it has been marked for removal.
(source file not found in checkout: jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java)

Removed jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java (line 216, column 58, end column 69)

Remove this call to a deprecated class, it has been marked for removal.
(source file not found in checkout: jetty-util/src/test/java/org/eclipse/jetty/util/TypeUtilTest.java)

Removed jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java (line 730, column 27, end column 38)

Remove this call to a deprecated class, it has been marked for removal.
(source file not found in checkout: jetty-util/src/test/java/org/eclipse/jetty/util/thread/QueuedThreadPoolTest.java)

Removed jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java (line 1761, column 13, end column 29)

Remove this call to a deprecated class, it has been marked for removal.
(source file not found in checkout: jetty-xml/src/main/java/org/eclipse/jetty/xml/XmlConfiguration.java)
S5738 (java) on eclipse-jetty-similar-to-main - 5 issues removed, 0 issues added - deleted ruling file

Removed jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java (line 212, column 52, end column 70)

Remove this call to a deprecated method, it has been marked for removal.
(source file not found in checkout: jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java)

Removed jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java (line 320, column 44, end column 62)

Remove this call to a deprecated method, it has been marked for removal.
(source file not found in checkout: jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java)

Removed jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java (line 2509, column 33, end column 49)

Remove this call to a deprecated class, it has been marked for removal.
(source file not found in checkout: jetty-server/src/main/java/org/eclipse/jetty/server/handler/ContextHandler.java)
S2387 (java) on guava - 9 issues removed, 0 issues added - deleted ruling file

Removed src/com/google/common/cache/LocalCache.java (line 1370, column 32, end column 36)

"next" is the name of a field in "Reference".
      1365 |     }
      1366 | 
      1367 |     // The code below is exactly the same for each entry type.
      1368 | 
      1369 |     final int hash;
>>>   1370 |     final ReferenceEntry<K, V> next;
      1371 |     volatile ValueReference<K, V> valueReference = unset();
      1372 | 
      1373 |     @Override
      1374 |     public ValueReference<K, V> getValueReference() {
      1375 |       return valueReference;

Removed src/com/google/common/cache/LocalCache.java (line 4230, column 10, end column 16)

"keySet" is the name of a field in "AbstractMap".
      4225 |     for (Object key : keys) {
      4226 |       remove(key);
      4227 |     }
      4228 |   }
      4229 | 
>>>   4230 |   Set<K> keySet;
      4231 | 
      4232 |   @Override
      4233 |   public Set<K> keySet() {
      4234 |     // does not impact recency ordering
      4235 |     Set<K> ks = keySet;

Removed src/com/google/common/cache/LocalCache.java (line 4239, column 17, end column 23)

"values" is the name of a field in "AbstractMap".
      4234 |     // does not impact recency ordering
      4235 |     Set<K> ks = keySet;
      4236 |     return (ks != null) ? ks : (keySet = new KeySet(this));
      4237 |   }
      4238 | 
>>>   4239 |   Collection<V> values;
      4240 | 
      4241 |   @Override
      4242 |   public Collection<V> values() {
      4243 |     // does not impact recency ordering
      4244 |     Collection<V> vs = values;

Removed src/com/google/common/collect/MapMakerInternalMap.java (line 1241, column 32, end column 36)

"next" is the name of a field in "Reference".
      1236 |     }
      1237 | 
      1238 |     // The code below is exactly the same for each entry type.
      1239 | 
      1240 |     final int hash;
>>>   1241 |     final ReferenceEntry<K, V> next;
      1242 |     volatile ValueReference<K, V> valueReference = unset();
      1243 | 
      1244 |     @Override
      1245 |     public ValueReference<K, V> getValueReference() {
      1246 |       return valueReference;

Removed src/com/google/common/collect/MapMakerInternalMap.java (line 1499, column 32, end column 36)

"next" is the name of a field in "Reference".
      1494 |     }
      1495 | 
      1496 |     // The code below is exactly the same for each entry type.
      1497 | 
      1498 |     final int hash;
>>>   1499 |     final ReferenceEntry<K, V> next;
      1500 |     volatile ValueReference<K, V> valueReference = unset();
      1501 | 
      1502 |     @Override
      1503 |     public ValueReference<K, V> getValueReference() {
      1504 |       return valueReference;

Removed src/com/google/common/collect/MapMakerInternalMap.java (line 3566, column 20, end column 26)

"keySet" is the name of a field in "AbstractMap".
      3561 |     for (Segment<K, V> segment : segments) {
      3562 |       segment.clear();
      3563 |     }
      3564 |   }
      3565 | 
>>>   3566 |   transient Set<K> keySet;
      3567 | 
      3568 |   @Override
      3569 |   public Set<K> keySet() {
      3570 |     Set<K> ks = keySet;
      3571 |     return (ks != null) ? ks : (keySet = new KeySet());

Removed src/com/google/common/collect/Maps.java (line 3384, column 30, end column 36)

"keySet" is the name of a field in "AbstractMap".
      3379 |     @Override public Set<Entry<K, V>> entrySet() {
      3380 |       Set<Entry<K, V>> result = entrySet;
      3381 |       return (result == null) ? entrySet = createEntrySet() : result;
      3382 |     }
      3383 | 
>>>   3384 |     private transient Set<K> keySet;
      3385 | 
      3386 |     @Override public Set<K> keySet() {
      3387 |       Set<K> result = keySet;
      3388 |       return (result == null) ? keySet = createKeySet() : result;
      3389 |     }

Removed src/com/google/common/collect/Maps.java (line 3395, column 37, end column 43)

"values" is the name of a field in "AbstractMap".
      3390 |     
      3391 |     Set<K> createKeySet() {
      3392 |       return new KeySet<K, V>(this);
      3393 |     }
      3394 | 
>>>   3395 |     private transient Collection<V> values;
      3396 | 
      3397 |     @Override public Collection<V> values() {
      3398 |       Collection<V> result = values;
      3399 |       return (result == null) ? values = createValues() : result;
      3400 |     }
S3551 (java) on guava - 0 issues removed, 2 issues added - new ruling file

Added src/com/google/common/hash/HashingInputStream.java (line 88, column 15, end column 19)

Make this method "synchronized" to match the parent class implementation.
        83 | 
        84 |   /**
        85 |    * mark() is not supported for HashingInputStream
        86 |    */
        87 |   @Override
>>>     88 |   public void mark(int readlimit) {}
        89 | 
        90 |   /**
        91 |    * reset() is not supported for HashingInputStream.
        92 |    * @throws IOException this operation is not supported
        93 |    */

Added src/com/google/common/hash/HashingInputStream.java (line 95, column 15, end column 20)

Make this method "synchronized" to match the parent class implementation.
        90 |   /**
        91 |    * reset() is not supported for HashingInputStream.
        92 |    * @throws IOException this operation is not supported
        93 |    */
        94 |   @Override
>>>     95 |   public void reset() throws IOException {
        96 |     throw new IOException("reset not supported");
        97 |   }
        98 | 
        99 |   /**
       100 |    * Returns the {@link HashCode} based on the data read from this stream. The result is
S5738 (java) on guava - 4 issues removed, 0 issues added

Removed src/com/google/common/base/Throwables.java (line 337, column 14, end column 25)

Remove this call to a deprecated class, it has been marked for removal.
       332 |        * would result in compilation failure if we directly refer to these classes.
       333 |        */
       334 |       Class<?> sharedSecrets = Class.forName(SHARED_SECRETS_CLASSNAME, false, null);
       335 |       Method langAccess = sharedSecrets.getMethod("getJavaLangAccess");
       336 |       return langAccess.invoke(null);
>>>    337 |     } catch (ThreadDeath death) {
       338 |       throw death;
       339 |     } catch (Throwable t) {
       340 |       /*
       341 |        * This is not one of AppEngine's whitelisted classes, so even in Sun JDKs, this can fail with
       342 |        * a NoClassDefFoundError. Other apps might deny access to sun.misc packages.

Removed src/com/google/common/base/Throwables.java (line 367, column 86, end column 97)

Remove this call to a deprecated class, it has been marked for removal.
       362 |   private static Method getSizeMethod() {
       363 |     return getJlaMethod("getStackTraceDepth", Throwable.class);
       364 |   }
       365 | 
       366 |   @Nullable
>>>    367 |   private static Method getJlaMethod(String name, Class<?>... parameterTypes) throws ThreadDeath {
       368 |     try {
       369 |       return Class.forName(JAVA_LANG_ACCESS_CLASSNAME, false, null).getMethod(name, parameterTypes);
       370 |     } catch (ThreadDeath death) {
       371 |       throw death;
       372 |     } catch (Throwable t) {

Removed src/com/google/common/base/Throwables.java (line 370, column 14, end column 25)

Remove this call to a deprecated class, it has been marked for removal.
       365 | 
       366 |   @Nullable
       367 |   private static Method getJlaMethod(String name, Class<?>... parameterTypes) throws ThreadDeath {
       368 |     try {
       369 |       return Class.forName(JAVA_LANG_ACCESS_CLASSNAME, false, null).getMethod(name, parameterTypes);
>>>    370 |     } catch (ThreadDeath death) {
       371 |       throw death;
       372 |     } catch (Throwable t) {
       373 |       /*
       374 |        * Either the JavaLangAccess class itself is not found, or the method is not supported on the
       375 |        * JVM.

Removed src/com/google/common/io/FileBackedOutputStream.java (line 103, column 34, end column 42)

Don't override this deprecated method, it has been marked for removal.
        98 |         @Override
        99 |         public InputStream openStream() throws IOException {
       100 |           return openInputStream();
       101 |         }
       102 | 
>>>    103 |         @Override protected void finalize() {
       104 |           try {
       105 |             reset();
       106 |           } catch (Throwable t) {
       107 |             t.printStackTrace(System.err);
       108 |           }

…similar-to-main

With the API of the analyzed release, the 5 issues of ContextHandler.java are no longer raised, as for eclipse-jetty. Checked by running
JavaRulingTest#eclipse_jetty_incremental locally: it passes without this file.

Co-Authored-By: Claude Sonnet 5.5 <noreply@anthropic.com>
@gitar-bot

gitar-bot Bot commented Nov 13, 2026

Copy link
Copy Markdown
Code Review ⚠️ Changes requested 🟡 Medium risk 3 closed / 4 findings

Enabling release-specific JDK APIs by default changes semantic resolution and could alter rule findings for projects targeting older Java versions.

Adds a jdt-package option that resolves the JDK API of the target release, with ruling expectations and CollectorsToListCheck coverage updated accordingly. Changes are requested because the merge pins jdt-package to 1.9.0.12280, which would roll master back from its Java 27 JDT update (1.10.0.12296) and lacks a release that contains both SystemReleaseClasspath and the Java 27 support. Bumping to a build that includes both, and publishing a matching sonar-java-jdt release, is needed before merge.

⚠️ Cross-PR: Merge downgrades jdt-package and drops master's Java 27 JDT update · SonarSource/sonar-java-jdt #169

📄 java-frontend/pom.xml:24 📄 java-frontend/src/main/java/org/sonar/java/model/JParserConfig.java:25 📄 java-frontend/src/main/java/org/sonar/java/model/JParserConfig.java:145-146 📄 java-frontend/src/main/java/org/sonar/java/model/JParserConfig.java:189-191

Breaks when this PR merges into master while java-frontend/pom.xml still pins jdt-package 1.9.0.12280 and no jdt-package release yet contains both sonar-java-jdt PR SonarSource/sonar-java-jdt#169 and the Java 27 JDT update.

How

  1. Commit 7509a6b bumped jdt-package to 1.9.0.12280 (java-frontend/pom.xml:24) so that org.eclipse.jdt.core.dom.SystemReleaseClasspath is available. That class comes from SonarSource/sonar-java-jdt#169 (src/main/java/org/eclipse/jdt/core/dom/SystemReleaseClasspath.java).
  2. Master moved to 1.10.0.12296 in SONARJAVA-7303 Update Sonar JDT #6489 (SONARJAVA-7303, Java 27 support). The merge commit kept 1.9.0.12280, so merging this PR would roll master's JDT back to the version without Java 27 support.
  3. JParserConfig.java:25,145-146,189-191 needs SystemReleaseClasspath.OPTION_RELEASE, OPTION_JAVA_HOME and isApplicable, and nothing shows that 1.10.0.12296 contains them. So neither pinned version gives you both features.

Fix

  • This PR: Depend on a jdt-package build that has both SonarSource/sonar-java-jdt#169 and master's 1.10 (Java 27) JDT update, instead of keeping 1.9.0.12280.
  • SonarSource/sonar-java-jdt#169: Rebase onto the JDT version shipped as 1.10.0.12296 and publish a release that includes SystemReleaseClasspath and the patched ASTParser.getClasspath().

Compared 555a24a with SonarSource/sonar-java-jdt#169 at fed37d2

✅ 3 closed
✅ Quality: SequencedCollection mutators of CollectorsToListCheck lose all coverage

📄 java-checks-test-sources/default/src/main/java/checks/CollectorsToListCheckSample.java:126-140
CollectorsToListCheck still lists addFirst, addLast, removeFirst and removeLast (Java 21 SequencedCollection methods) as list mutators (CollectorsToListCheck.java:61-62). Those were the only calls exercising them in the sample. The sample is checked with withJavaVersion(16), and the release-API change means those methods no longer resolve at that version, so the PR swapped them for add(0, ..), add(..), remove(0) and remove("C"). add and remove were already covered, and a grep finds no other CollectorsToList sample that uses the sequenced methods. A regression in how they are matched (for example, dropping them from names(...)) would now go unnoticed. One fix: add a small sample checked with withJavaVersion(21) (or higher) that keeps the addFirst/addLast/removeFirst/removeLast compliant cases.

✅ Quality: Merge drops release-option ruling coverage and its updated expectations

📄 java-frontend/src/main/java/org/sonar/java/SonarComponents.java:511
The conflict-resolution merge removes .setProperty("sonar.java.useJdkReleaseOption", "true") from JavaRulingTest, which commit 81bd8ce had added. SonarComponents defaults this property to false (SonarComponents.java:511), so the ruling ITs no longer exercise the --release / jdt-package path this PR introduces. The merge also deletes guava/java-S3551.json without adding a .sarif equivalent, and keeps master's guava/java-S2387.sarif, guava/java-S5738.sarif and eclipse-jetty*/java-S5738.sarif. In effect, the PR's expectation commits (b00b439, ad95d3a, 13b3176) are reverted in the new SARIF baseline format.

What happens now: the ruling stays green only because the feature is turned off there, so a regression in release-API resolution would not show up. If someone later adds the property back without porting those expectations to SARIF, the ruling will fail on the guava HashingInputStream S3551 issues (lines 88, 95) and on the S5738/S2387 issues that went away.

Fix: add the property back in JavaRulingTest and redo the expectation changes in the .sarif files: add guava S3551, remove the stale guava S2387, and update the S5738 entries for guava, eclipse-jetty and eclipse-jetty-similar-to-main.

Closed: Cross-PR: Merging with #6451 silently drops the release-specific JDK API

📄 java-frontend/src/main/java/org/sonar/java/model/JParserConfig.java:136-146 📄 java-frontend/src/main/java/org/sonar/java/model/JParserConfig.java:168-182
Breaks when this PR and #6451 both merge and the conflict in JParserConfig.astParser() is resolved toward #6451's EcjFrontendBackend.newParser(configuration) delegation. A project targeting an older Java release with sonar.java.jdkHome set to a newer JDK then sees that JDK's full API again.

How

  1. This PR sets SystemReleaseClasspath.OPTION_RELEASE in astParser() and calls useReleaseApiOfConfiguredJdk(options) (JParserConfig.java:136-137). That call reads the classpath/javaVersion fields and removes lib/jrt-fs.jar (JParserConfig.java:168-189).
  2. In SONARJAVA-7284 Introduce frontend sessions and deterministic resource ownership #6451, astParser() only delegates to EcjFrontendBackend.newParser(configuration) (EcjFrontendBackend.java:14). That method rebuilds the options and environment from FrontendConfiguration.
  3. EcjFrontendBackend.newParser never sets OPTION_RELEASE or OPTION_JAVA_HOME, and it passes jrt-fs.jar straight to setEnvironment. FrontendSession/FrontendBackend.open is the only parse path and has no hook for these options.
  4. This PR's tests (JParserConfigTest calling useReleaseApiOfConfiguredJdk, and JParserTest calling .astParser()) depend on the old JParserConfig shape and stop compiling against SONARJAVA-7284 Introduce frontend sessions and deterministic resource ownership #6451.

Fix

  • This PR: If it merges second, port OPTION_RELEASE and the useReleaseApiOfConfiguredJdk environment filtering into EcjFrontendBackend.newParser, driven by FrontendConfiguration, and adapt the new tests.
  • SONARJAVA-7284 Introduce frontend sessions and deterministic resource ownership #6451: If it merges second, carry the release option and the jrt-fs.jar replacement into EcjFrontendBackend.newParser so the release behavior survives the refactor.

Compared 7509a6b with #6451 at b07e3d4

🤖 Prompt for agents
Code Review: Adds a `jdt-package` option that resolves the JDK API of the target release, with ruling expectations and CollectorsToListCheck coverage updated accordingly. Changes are requested because the merge pins `jdt-package` to 1.9.0.12280, which would roll master back from its Java 27 JDT update (1.10.0.12296) and lacks a release that contains both `SystemReleaseClasspath` and the Java 27 support. Bumping to a build that includes both, and publishing a matching sonar-java-jdt release, is needed before merge.

1. ⚠️ Cross-PR: Merge downgrades jdt-package and drops master's Java 27 JDT update · [SonarSource/sonar-java-jdt #169](<https://github.com/SonarSource/sonar-java-jdt/pull/169>)
   Files: java-frontend/pom.xml:24, java-frontend/src/main/java/org/sonar/java/model/JParserConfig.java:25, java-frontend/src/main/java/org/sonar/java/model/JParserConfig.java:145-146, java-frontend/src/main/java/org/sonar/java/model/JParserConfig.java:189-191

   **Breaks when** this PR merges into master while `java-frontend/pom.xml` still pins `jdt-package` 1.9.0.12280 and no jdt-package release yet contains both sonar-java-jdt PR [SonarSource/sonar-java-jdt#169](<https://github.com/SonarSource/sonar-java-jdt/pull/169>) and the Java 27 JDT update.
   
   **How**
   
   1. Commit 7509a6b bumped `jdt-package` to `1.9.0.12280` (`java-frontend/pom.xml:24`) so that `org.eclipse.jdt.core.dom.SystemReleaseClasspath` is available. That class comes from [SonarSource/sonar-java-jdt#169](<https://github.com/SonarSource/sonar-java-jdt/pull/169>) (`src/main/java/org/eclipse/jdt/core/dom/SystemReleaseClasspath.java`).
   2. Master moved to `1.10.0.12296` in #6489 (SONARJAVA-7303, Java 27 support). The merge commit kept `1.9.0.12280`, so merging this PR would roll master's JDT back to the version without Java 27 support.
   3. `JParserConfig.java:25,145-146,189-191` needs `SystemReleaseClasspath.OPTION_RELEASE`, `OPTION_JAVA_HOME` and `isApplicable`, and nothing shows that `1.10.0.12296` contains them. So neither pinned version gives you both features.
   
   **Fix**
   
   - **This PR:** Depend on a jdt-package build that has both [SonarSource/sonar-java-jdt#169](<https://github.com/SonarSource/sonar-java-jdt/pull/169>) and master's 1.10 (Java 27) JDT update, instead of keeping 1.9.0.12280.
   - **[SonarSource/sonar-java-jdt#169](<https://github.com/SonarSource/sonar-java-jdt/pull/169>):** Rebase onto the JDT version shipped as 1.10.0.12296 and publish a release that includes `SystemReleaseClasspath` and the patched `ASTParser.getClasspath()`.
   
   _Compared `555a24a` with [SonarSource/sonar-java-jdt#169](<https://github.com/SonarSource/sonar-java-jdt/pull/169>) at `fed37d2`_

Verification Rules 2/2 met Repos 5 inspected · PRs 4 inspected

Functional validation No results

Rules 2 passed 2 not applicable

✅ Internal artifact registries
✅ Repository license compliance

Broader impact Repos 5 inspected PRs 4 inspected
Cross-repo 5 repositories inspected 0 open impacts

SonarSource/sonarqube Inspected
SonarSource/sonarlint-vscode Inspected
SonarSource/sonarlint-intellij Inspected
SonarSource/sonarlint-eclipse Inspected
SonarSource/sonar-java-symbolic-execution Inspected

Cross-PR 4 PRs inspected 1 open impact

PR 169: SONARJAVA-7278 Override ASTParser to expose the JDK API of a requested release (JEP 247) Inspected
PR 6503: Simplify the parser interface Inspected
PR 6485: SONARJAVA-7300 Decouple the Sonar Java frontend from Eclipse JDT core Inspected
PR 6308: SONARJAVA-7137 Optionally rely on source paths to resolve types during analyses Inspected

Auto-approval Not enabled

Set up

For more verification details, comment gitar display:verbose.

Options

Auto-apply is off → Gitar will not commit updates to this branch.
Display: compact → Showing compact verification results.
Unblock → Override a blocking verdict and allow merging.

Comment with these commands to change the behavior for this request:

Auto-apply Compact Unblock
gitar auto-apply:on         
gitar display:verbose         
gitar unblock         

Was this helpful? React with 👍 / 👎 | Gitar

@sonarqube-next

Copy link
Copy Markdown
Contributor

Quality Gate failed Quality Gate failed

Failed conditions
1 New issue

See analysis details on SonarQube

Catch issues before they fail your Quality Gate with our IDE extension SonarQube for IDE SonarQube for IDE

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant