| Summary: | [JUnit5] ClassCastException in CompilationUnitProblemFinder.process | ||
|---|---|---|---|
| Product: | [Eclipse Project] JDT | Reporter: | Andreas Sewe <sewe> |
| Component: | Core | Assignee: | Stephan Herrmann <stephan.herrmann> |
| Status: | CLOSED DUPLICATE | QA Contact: | |
| Severity: | normal | ||
| Priority: | P3 | CC: | stephan.herrmann |
| Version: | 4.12 | ||
| Target Milestone: | 4.12 M3 | ||
| Hardware: | PC | ||
| OS: | Linux | ||
| Whiteboard: | |||
> The file in question is a JUnit5 test (@ParameterizedTest + @MethodSource), but I am not sure whether I can share its full source code here.
The fact that we are dealing with JUnit 5 here seems to be relevant. A few hours ago, the test got ported from JUnit 4 to 5 and now Eclipse won't compile it.
FYI, the problem occurs with 2019-03 and 2019-06 M1 as well.
Further information:
The tooltip of the problem marker in line 1 of the file says
Internal compiler error: java.lang.ClassCastException: org.eclipse.jdt.internal.compiler.ast.SingleNameReference cannot be
cast to org.eclipse.jdt.internal.compiler.ast.StringLiteral at
org.eclipse.jdt.internal.compiler.ast.TypeDeclaration.getJUnitMethodSourceValue(TypeDeclaration.java:796)
Maybe that helps to narrow it down.
(In reply to Andreas Sewe from comment #1) > The tooltip of the problem marker in line 1 of the file says > > Internal compiler error: java.lang.ClassCastException: > org.eclipse.jdt.internal.compiler.ast.SingleNameReference cannot be > cast to org.eclipse.jdt.internal.compiler.ast.StringLiteral at > org.eclipse.jdt.internal.compiler.ast.TypeDeclaration. > getJUnitMethodSourceValue(TypeDeclaration.java:796) > > Maybe that helps to narrow it down. Reading the above again, the problem seems almost obvious: The code contains the following @MethodSource(GENERATE_TEST_PARAMETERS_METHOD_NAME) with GENERATE_TEST_PARAMETERS_METHOD_NAME being a private static final String constant defined in the same compilation unit. Apparently, some part of JDT expects a String literal and can't deal with constants here. Should be fixed in recent builds. *** This bug has been marked as a duplicate of bug 546084 *** |
Got this for a particular file with 2019-06 M2 (Java EPP package). Errors occurred during the build. Errors running builder 'Java Builder' on project 'eu.cqse.check'. org.eclipse.jdt.internal.compiler.ast.SingleNameReference cannot be cast to org.eclipse.jdt.internal.compiler.ast.StringLiteral Enabling a couple of tracing options resulted in !ENTRY org.eclipse.jdt.ui 4 2 2019-05-16 13:49:54.643 !MESSAGE Problems occurred when invoking code from plug-in: "org.eclipse.jdt.ui". !STACK 1 Java Model Exception: java.lang.ClassCastException at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:324) at org.eclipse.jdt.internal.core.CompilationUnitProblemFinder.process(CompilationUnitProblemFinder.java:346) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.makeConsistent(ReconcileWorkingCopyOperation.java:193) at org.eclipse.jdt.internal.core.ReconcileWorkingCopyOperation.executeOperation(ReconcileWorkingCopyOperation.java:94) at org.eclipse.jdt.internal.core.JavaModelOperation.run(JavaModelOperation.java:736) at org.eclipse.jdt.internal.core.JavaModelOperation.runOperation(JavaModelOperation.java:802) at org.eclipse.jdt.internal.core.CompilationUnit.reconcile(CompilationUnit.java:1322) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:131) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.access$0(JavaReconcilingStrategy.java:113) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy$1.run(JavaReconcilingStrategy.java:93) at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:45) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:90) at org.eclipse.jdt.internal.ui.text.java.JavaReconcilingStrategy.reconcile(JavaReconcilingStrategy.java:157) at org.eclipse.jdt.internal.ui.text.CompositeReconcilingStrategy.reconcile(CompositeReconcilingStrategy.java:92) at org.eclipse.jdt.internal.ui.text.JavaCompositeReconcilingStrategy.reconcile(JavaCompositeReconcilingStrategy.java:107) at org.eclipse.jface.text.reconciler.MonoReconciler.process(MonoReconciler.java:76) at org.eclipse.jface.text.reconciler.AbstractReconciler$BackgroundThread.run(AbstractReconciler.java:210) Caused by: java.lang.ClassCastException Caused by: java.lang.ClassCastException !SUBENTRY 1 org.eclipse.jdt.core 4 1005 2019-05-16 13:49:54.643 !MESSAGE java.lang.ClassCastException !STACK 0 java.lang.ClassCastException !SUBENTRY 1 org.eclipse.jdt.core 4 1005 2019-05-16 13:49:54.643 !MESSAGE java.lang.ClassCastException !STACK 0 java.lang.ClassCastException The file in question is a JUnit5 test (@ParameterizedTest + @MethodSource), but I am not sure whether I can share its full source code here. That being said, I am pretty sure that the test in question has no compile errors, as javac compiles it just fine, so I don't really know why the CompilationUnitProblemFinder is called.