Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

API tooling reports 300 false positive errors on SWT #1093

Merged
merged 1 commit into from
Jan 30, 2024

Conversation

iloveeclipse
Copy link
Member

@iloveeclipse iloveeclipse commented Jan 30, 2024

Before the change ApiBaseline.resolveSystemLibrary() did following:

  1. Collected all JVM installs matching all given execution environments id's
  2. Iterated over all found installs in random order
  3. For every JVM install ApiBaseline tried to initialize itself from that install
  4. The condition used to stop the loop (almost) never worked as it always compared either null or previously initialized JVM with the current one, so for all different JVM's ApiBaseline initialized itself from that JVM - and that in random order.
  5. The last iterated JVM install defined the maximal "supported" execution environment. In case of installed Java 1.8, 11, 17, 21 it could be any one if the target platform contained bundles required different execution environments.

With that, SWT bundle (that requires 17 environment) from saved API baseline was not resolved with given baseline if any of lower environments "won the race" in resolveSystemLibrary().

Because SWT bundle was not resolved, none of SWT classes were found in the baseline and so not considered "API" in
ApiComparator.internalCompare(). Because there were no API classes in the baseline, ALL public API types from workspace SWT project were considered as new API and "missing @since tags" errors were created.

With the change ApiBaseline.resolveSystemLibrary() does following:

  1. Collects all JVM installs matching all given execution environments id's
  2. Sorts them by their Java version, with highest version first
  3. Iterates over all found installs in descending order
  4. The first (highest Java version) matching JVM install will be used to initialize ApiBaseline
  5. The loop continues only if the API baseline fails to initialize from given JVM

With that, the highest supported JVM install that is required by given execution environments defines the maximal "supported" execution environment for the baseline.

Additional changes:

  1. ApiBaselineManager.readBaselineComponents() will sort bundles to get more stable behavior of the API tooling.
  2. ApiBaseline.rebindVM() will use same ApiBaselineManagerRule that is used by ApiBaselineManager to dispose baselines. This will prevent that API analysis jobs may run in parallel with JVM re-initialization of the baseline or baseline JVM update will interfere with baseline disposal.

Fixes #1073

Before the change ApiBaseline.resolveSystemLibrary() did following:
1) Collected all JVM installs matching all given execution environments
id's
2) Iterated over all found installs **in random order**
3) For every JVM install ApiBaseline tried to initialize itself from
that install
4) The condition used to stop the loop (almost) never worked as it
always compared either null or previously initialized JVM with the
current one, so for all **different** JVM's ApiBaseline  initialized
itself from that JVM - and that in random order.
5) The **last** iterated JVM install defined the maximal "supported"
execution environment. In case of installed Java 1.8, 11, 17, 21 it
could be **any one** if the target platform contained bundles required
different execution environments.

With that, SWT bundle (that requires 17 environment) from saved API
baseline was not resolved with given baseline if any of lower
environments "won the race" in resolveSystemLibrary().

Because SWT bundle was not resolved, none of SWT classes were found in
the baseline and so not considered "API" in
ApiComparator.internalCompare(). Because there were no API classes in
the baseline, ALL public API types from workspace SWT project were
considered as new API and "missing @SInCE tags" errors were created.

With the change ApiBaseline.resolveSystemLibrary() does following:
1) Collects all JVM installs matching all given execution environments
id's
2) Sorts them by their Java version, with highest version first
3) Iterates over all found installs **in descending order**
4) The first (highest Java version) matching JVM install will be used to
initialize ApiBaseline
5) The loop continues only if the API baseline fails to initialize from
given JVM

With that, the **highest supported** JVM install that is required by
given execution environments defines the maximal "supported" execution
environment for the baseline.

Additional changes:

1) ApiBaselineManager.readBaselineComponents() will sort bundles to get
more stable behavior of the API tooling.
2) ApiBaseline.rebindVM() will use same ApiBaselineManagerRule that is
used by ApiBaselineManager to dispose baselines. This will prevent that
API analysis jobs may run in parallel with JVM re-initialization of the
baseline or baseline JVM update will interfere with baseline disposal.

Fixes eclipse-pde#1073
@merks
Copy link
Contributor

merks commented Jan 30, 2024

That sounds awesome! 🥇

Copy link

Test Results

   290 files  +   97     290 suites  +97   1h 6m 43s ⏱️ + 34m 21s
 3 526 tests ±    0   3 467 ✅ +    1   58 💤  -  1  1 ❌ ±0 
10 823 runs  +3 625  10 658 ✅ +3 567  164 💤 +58  1 ❌ ±0 

For more details on these failures, see this check.

Results for commit 841b522. ± Comparison against base commit f26df87.

@iloveeclipse
Copy link
Member Author

Unrelated maven warning

[WARNING] MavenProject: org.eclipse.pde:org.eclipse.e4.tools.persistence.feature:1.1.300-SNAPSHOT @ /home/jenkins/agent/workspace/eclipse.pde_PR-1093/e4tools/features/org.eclipse.e4.tools.persistence.feature/.polyglot.feature.xml: baseline and build artifacts have same version but different contents

@iloveeclipse iloveeclipse merged commit 9e70658 into eclipse-pde:master Jan 30, 2024
12 of 17 checks passed
@iloveeclipse iloveeclipse deleted the issue_1073 branch January 30, 2024 21:13
@jukzi
Copy link
Contributor

jukzi commented Jan 30, 2024

good job, thanks for fixing long standing bug

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.

API tooling reports 300 false positive errors on SWT
3 participants