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

Warnings about $SWITCH_TABLE reported in Eclipse #1313

Closed
iloveeclipse opened this issue Sep 29, 2020 · 0 comments · Fixed by #1337
Closed

Warnings about $SWITCH_TABLE reported in Eclipse #1313

iloveeclipse opened this issue Sep 29, 2020 · 0 comments · Fixed by #1337
Assignees

Comments

@iloveeclipse
Copy link
Member

iloveeclipse commented Sep 29, 2020

I'm observing lot of warnings reported in Eclipse 4.17+ running on Java 11 (and Java project JLS level set to 11), all similar to the below one.
Spotbugs 4.1.4.202009290501-7a891fe

This is caused by recent (4.17) Eclipse compiler changes, where the $SWITCH_TABLE field created for enums by compiler is marked as volatile, see https://bugs.eclipse.org/bugs/show_bug.cgi?id=544521

Spotbugs (VolatileUsage detector) should simply ignore the synthetic code in general or this concrete $SWITCH_TABLE field.

eclipse.buildId=4.18.0.I20200928-1800
java.version=11.0.8
java.vendor=N/A
BootLoader constants: OS=linux, ARCH=x86_64, WS=gtk, NL=en_US
Command-line arguments:  -data /data/4x_platform_workspace -os linux -ws gtk -arch x86_64

com.github.spotbugs.plugin.eclipse
Warning
Tue Sep 29 10:12:46 CEST 2020
Can not complete field annotation Field edu.umd.cs.findbugs.workflow.CopyBuggySource.$SWITCH_TABLE$edu$umd$cs$findbugs$workflow$CopyBuggySource$SrcKind for the field: $SWITCH_TABLE$edu$umd$cs$findbugs$workflow$CopyBuggySource$SrcKind (not open) [in CopyBuggySource [in CopyBuggySource.java [in edu.umd.cs.findbugs.workflow [in src/main/java [in spotbugs-spotbugs]]]]] in class: edu.umd.cs.findbugs.workflow.CopyBuggySource, type CopyBuggySource (not open) [in CopyBuggySource.java [in edu.umd.cs.findbugs.workflow [in src/main/java [in spotbugs-spotbugs]]]], bug VO: A volatile reference to an array doesn't treat the array elements as volatile

Java Model Exception: Java Model Status [$SWITCH_TABLE$edu$umd$cs$findbugs$workflow$CopyBuggySource$SrcKind [in CopyBuggySource [in CopyBuggySource.java [in edu.umd.cs.findbugs.workflow [in src/main/java [in spotbugs-spotbugs]]]]] does not exist]
	at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:573)
	at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:616)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:326)
	at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:312)
	at org.eclipse.jdt.internal.core.Member.getNameRange(Member.java:353)
	at de.tobject.findbugs.reporter.MarkerUtil.completeFieldInfo(MarkerUtil.java:350)
	at de.tobject.findbugs.reporter.MarkerUtil.getJavaElement(MarkerUtil.java:331)
	at de.tobject.findbugs.reporter.MarkerUtil.createMarkerParameter(MarkerUtil.java:182)
	at de.tobject.findbugs.reporter.MarkerUtil.createBugParameters(MarkerUtil.java:170)
	at de.tobject.findbugs.reporter.MarkerUtil.createMarkers(MarkerUtil.java:124)
	at de.tobject.findbugs.builder.FindBugsWorker.updateBugCollection(FindBugsWorker.java:358)
	at de.tobject.findbugs.builder.FindBugsWorker.work(FindBugsWorker.java:227)
	at de.tobject.findbugs.builder.FindBugsBuilder$StartedFromBuilderJob.runWithProgress(FindBugsBuilder.java:219)
	at de.tobject.findbugs.FindBugsJob.run(FindBugsJob.java:142)
	at org.eclipse.core.internal.jobs.Worker.run(Worker.java:63)
trancexpress added a commit to trancexpress/spotbugs that referenced this issue Oct 16, 2020
fix for issue 1313, do not report volatile problems in synthetic code

With the fix for Eclipse bug 544521,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=544521, the Eclipse 4.17+
Java compiler will generate synthetic code for switch expressions.
spotbugs reports VO_VOLATILE_REFERENCE_TO_ARRAY issues in this synthetic
code.

This changes makes spotbugs ignore synthetic fields during
VO_VOLATILE_REFERENCE_TO_ARRAY analysis.
@KengoTODA KengoTODA mentioned this issue Oct 16, 2020
1 task
iloveeclipse pushed a commit that referenced this issue Oct 16, 2020
fix for issue 1313, do not report volatile problems in synthetic code

With the fix for Eclipse bug 544521,
https://bugs.eclipse.org/bugs/show_bug.cgi?id=544521, the Eclipse 4.17+
Java compiler will generate synthetic code for switch expressions.
spotbugs reports VO_VOLATILE_REFERENCE_TO_ARRAY issues in this synthetic
code.

This changes makes spotbugs ignore synthetic fields during
VO_VOLATILE_REFERENCE_TO_ARRAY analysis.
@iloveeclipse iloveeclipse linked a pull request Oct 16, 2020 that will close this issue
1 task
@iloveeclipse iloveeclipse self-assigned this Oct 16, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant