eclipse.platform.swt icon indicating copy to clipboard operation
eclipse.platform.swt copied to clipboard

New unncessary code warnings due to not considered access restrictions

Open HannesWell opened this issue 9 months ago • 9 comments

On the master build, since today (yesterday was fine) there are ten new warnings, indicating that suppression of certain restriction warnings would not be necessary anymore, although this is necessary and also doesn't show up in the IDE when using the latest I-Build. Therefore I assume this is a false-positive:

Image

I'm resetting the quality-gate for the master to not further block unrelated PRs, but think that this should be investigate. @iloveeclipse could this be a JDT issue?

HannesWell avatar Apr 06 '25 11:04 HannesWell

could this be a JDT issue?

I'm not aware about recent related JDT changes, also if IDE doesn't show them it looks like maven/tycho build problem? Could be some maven/tycho snapshot issue?

Here what was changed in last build: https://github.com/eclipse-platform/eclipse.platform.releng.aggregator/commit/9de1608e9cff16d9bf6f7a9da70e41e8a60ee84e

iloveeclipse avatar Apr 06 '25 13:04 iloveeclipse

I'm not aware about recent related JDT changes, also if IDE doesn't show them it looks like maven/tycho build problem? Could be some maven/tycho snapshot issue?

Tycho only calls JDT compiler it does not report any problems itself. In any case last commit was 2days ago... It could be of course that there are compiler changes not yet deployed, then IDE / Maven might use different things.

laeubi avatar Apr 06 '25 16:04 laeubi

Here is direct link to report https://ci.eclipse.org/releng/job/eclipse.platform.swt/job/master/1079/eclipse/new/ where Unnecessary @SuppressWarnings("restriction") is reported for /org.eclipse.swt.tools.spies/src/org/eclipse/swt/tools/internal/Sleak.java

I'm not aware about recent related JDT changes, also if IDE doesn't show them it looks like maven/tycho build problem?

If I disable processing of SuppressWarnings annotations in the IDE via org.eclipse.jdt.core.compiler.problem.suppressWarnings=disabled

I see that few warnings are reported for Sleak, example:

Discouraged access: The type 'WidgetSpy.NonDisposedWidgetTracker' is not API (restriction on required project 'org.eclipse.swt.gtk.linux.x86_64')

Image

So the tycho build seem to calculate dependencies differently to PDE / see different access restrictions or no restgrictions at all?

iloveeclipse avatar Apr 07 '25 09:04 iloveeclipse

So the tycho build seem to calculate dependencies differently to PDE

I'm not sure what this means, PDE+Tycho using different ways to compute the classpath, but of course this should not matter as I hope we do not have one provider that restricts access and another that don't.

see different access restrictions or no restgrictions at all?

The restrictions are computed doing an OSGi resolve (at Tycho) PDE uses omething similar as far as I know (but based on the Target state), but again in what case could this matter at all?

The one thing that might be confusing compiler here is:

  • org.eclipse.ui is a "friend" of swt.internal and has visibility:=reexport
  • org.eclipse.swt.tools.spies require-bundle org.eclipse.ui so get its imports from there because of the reexport

So it might depend on the ordering what restriction is seen first (or not).

laeubi avatar Apr 07 '25 10:04 laeubi

I now created

  • https://github.com/eclipse-platform/eclipse.platform.swt/pull/2002

to see if it makes a difference.

laeubi avatar Apr 07 '25 10:04 laeubi

Okay this fails now, what makes me even wonder how it is supposed to work that SWT requires platform at all?

laeubi avatar Apr 07 '25 10:04 laeubi

Okay this fails now, what makes me even wonder how it is supposed to work that SWT requires platform at all?

SWT doesn't require platform.ui, but Sleak (from org.eclipse.swt.tools.spies) does.

iloveeclipse avatar Apr 07 '25 10:04 iloveeclipse

I'm not aware about recent related JDT changes, also if IDE doesn't show them it looks like maven/tycho build problem?

If I disable processing of SuppressWarnings annotations in the IDE via org.eclipse.jdt.core.compiler.problem.suppressWarnings=disabled

Maybe the build uses some different compiler settings with respect to warnings. IIRC we ignore some kind of warnings by default in the parent-pom respectively set it in the projects, but it's just a unverified guess. In general something must have changed somewhere in the chain of tools, because I see no code changes that explain this.

Btw. I now also see similar new warnings in platform.ui: https://ci.eclipse.org/platform/job/eclipse.platform.ui/job/master/947/eclipse/new/ Although these are new unused-code warnings regarding record components, so actually a different type of warning.

HannesWell avatar Apr 08 '25 06:04 HannesWell

Btw. I now also see similar new warnings in platform.ui: https://ci.eclipse.org/platform/job/eclipse.platform.ui/job/master/947/eclipse/new/ Although these are new unused-code warnings regarding record components, so actually a different type of warning.

Those warnings about unused record parameters should be gone now with latest nightly build, please re-run. See https://github.com/eclipse-jdt/eclipse.jdt.core/pull/3905

iloveeclipse avatar Apr 08 '25 06:04 iloveeclipse