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

AnnotateAssistTest1d8 test failed #736

Open
noopur2507 opened this issue Aug 24, 2023 · 19 comments · Fixed by #1478
Open

AnnotateAssistTest1d8 test failed #736

noopur2507 opened this issue Aug 24, 2023 · 19 comments · Fixed by #1478
Assignees
Labels
help wanted Extra attention is needed null relating to (annotation-based) null analysis test junit test related things

Comments

@noopur2507
Copy link
Member

AnnotateAssistTest1d8.testAnnotateParameter_Varargs2 test failed on mac in I20230824-0400.

java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:208)
at java.base/java.util.Arrays$ArrayList.<init>(Arrays.java:4137)
at java.base/java.util.Arrays.asList(Arrays.java:4122)
at org.eclipse.jdt.ui.tests.quickfix.AbstractAnnotateAssistTests.collectAnnotateProposals(AbstractAnnotateAssistTests.java:82)
at org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_Varargs2(AnnotateAssistTest1d8.java:895)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
@noopur2507 noopur2507 changed the title AnnotateAssistTest1d8.testAnnotateParameter_Varargs2 test failed AnnotateAssistTest1d8 test failed Nov 17, 2023
@noopur2507
Copy link
Member Author

org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_WildcardBound failed in I20231115-1800, macosx.cocoa.x86_64 java17.

java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:208)
at java.base/java.util.Arrays$ArrayList.<init>(Arrays.java:4137)
at java.base/java.util.Arrays.asList(Arrays.java:4122)
at org.eclipse.jdt.ui.tests.quickfix.AbstractAnnotateAssistTests.collectAnnotateProposals(AbstractAnnotateAssistTests.java:82)
at org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_WildcardBound(AnnotateAssistTest1d8.java:303)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)

@jukzi
Copy link
Contributor

jukzi commented Jan 24, 2024

AnnotateAssistTest1d8 frequentl fails on I-Build I20240123-1800 on all platforms with various exceptions for example NPE or "Wrong number of proposals"
https://download.eclipse.org/eclipse/downloads/drops4/I20240123-1800/testresults/html/org.eclipse.jdt.ui.tests_ep431I-unit-mac64-java17_macosx.cocoa.x86_64_17.html

@jukzi jukzi pinned this issue Jan 25, 2024
@jukzi
Copy link
Contributor

jukzi commented Jan 25, 2024

also frequently fails on CI jenkins

@jukzi jukzi added the test junit test related things label Jan 25, 2024
@noopur2507
Copy link
Member Author

org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8
testAnnotateParameter_Varargs1

Failed on I20240522-1800, java17_macosx.

java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:208)
at java.base/java.util.Arrays$ArrayList.<init>(Arrays.java:4137)
at java.base/java.util.Arrays.asList(Arrays.java:4122)
at org.eclipse.jdt.ui.tests.quickfix.AbstractAnnotateAssistTests.collectAnnotateProposals(AbstractAnnotateAssistTests.java:82)
at org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_Varargs1(AnnotateAssistTest1d8.java:872)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)

@stephan-herrmann stephan-herrmann added the null relating to (annotation-based) null analysis label Jun 16, 2024
@stephan-herrmann
Copy link
Contributor

org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_WildcardBound failed in I20231115-1800, macosx.cocoa.x86_64 java17.

java.lang.NullPointerException
at java.base/java.util.Objects.requireNonNull(Objects.java:208)
at java.base/java.util.Arrays$ArrayList.<init>(Arrays.java:4137)
at java.base/java.util.Arrays.asList(Arrays.java:4122)
at org.eclipse.jdt.ui.tests.quickfix.AbstractAnnotateAssistTests.collectAnnotateProposals(AbstractAnnotateAssistTests.java:82)
at org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_WildcardBound(AnnotateAssistTest1d8.java:303)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)

This suggests a problem in this code section of ExternalNullAnnotationQuickAssistProcessor.computeQuickAssistProposals()

	IClassFile classFile= ((IClassFileEditorInput) part.getEditorInput()).getClassFile();
	cu= classFile.getWorkingCopy((WorkingCopyOwner) null, null);
	if (cu == null || classFile.getSource() == null)
		return null;
...
} catch (JavaModelException e) {
	fErrorMessage= e.getMessage();
	JavaPlugin.log(e);
	return null;
}

Candidates:

  • JavaModelException in getWorkingCopy() or getSource()
    • when this happens the exception is logged, has this been observed?
  • null return from getWorkingCopy() -- can PerWorkingCopyInfo.getWorkingCopy() possibly return nul??
  • null return from getSource()
    • this could be a result from a problem with a source mapper, or other reasons why no buffer could be accessed

At the bottom line this doesn't look like a problem specific to the functionality being tested, but more like a problem in general handling of buffers for a classfile.

As I'm unable to reproduce locally, I don't think I can help much to resolve this.

Anyway, please let me know if ever a JavaModelException is logged by this test.

@jukzi jukzi self-assigned this Jun 17, 2024
@jukzi
Copy link
Contributor

jukzi commented Jun 17, 2024

I plan to review that Buffer code.

jukzi pushed a commit to jukzi/eclipse.jdt.core that referenced this issue Jun 18, 2024
Some field accesses had not been synchronized which may have caused NPEs
in access from different thread.

eclipse-jdt/eclipse.jdt.ui#736
jukzi pushed a commit to jukzi/eclipse.jdt.core that referenced this issue Jun 18, 2024
Some field accesses had not been synchronized which may have caused NPEs
in access from different thread.

eclipse-jdt/eclipse.jdt.ui#736
jukzi pushed a commit to jukzi/eclipse.jdt.ui that referenced this issue Jun 18, 2024
jukzi pushed a commit to eclipse-jdt/eclipse.jdt.core that referenced this issue Jun 19, 2024
Some field accesses had not been synchronized which may have caused NPEs
in access from different thread.

eclipse-jdt/eclipse.jdt.ui#736
@jukzi
Copy link
Contributor

jukzi commented Jun 26, 2024

failed again with updated error message - @stephan-herrmann does that help?
https://download.eclipse.org/eclipse/downloads/drops4/I20240625-1800/testresults/html/org.eclipse.jdt.ui.tests_ep433I-unit-mac64-java17_macosx.cocoa.x86_64_17.html

java.lang.AssertionError: cu=[Working copy] X.class [in pack.age [in lib.jar [in TestSetupProject1d8]]]
package pack.age
interface X
java.lang.String test(java.util.List<java.lang.String>, java.lang.String ...) source=null
at org.junit.Assert.fail(Assert.java:89)
at org.junit.Assert.assertTrue(Assert.java:42)
at org.junit.Assert.assertNotNull(Assert.java:713)
at org.eclipse.jdt.ui.tests.quickfix.AbstractAnnotateAssistTests.collectAnnotateProposals(AbstractAnnotateAssistTests.java:90)
at org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_Varargs3(AnnotateAssistTest1d8.java:1032)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
java.lang.ClassCastException: class bndtools.jareditor.internal.JAREditor cannot be cast to class org.eclipse.jdt.internal.ui.javaeditor.JavaEditor (bndtools.jareditor.internal.JAREditor is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @8e689d4; org.eclipse.jdt.internal.ui.javaeditor.JavaEditor is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @336f7e67)
at org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_WildcardBound(AnnotateAssistTest1d8.java:310)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)

@jukzi
Copy link
Contributor

jukzi commented Jun 26, 2024

The logfile
https://download.eclipse.org/eclipse/downloads/drops4/I20240625-1800/testresults/ep433I-unit-mac64-java17_macosx.cocoa.x86_64_17/org.eclipse.jdt.ui.tests.AutomatedSuite.txt starts with an indexer error and follows up with other exceptions like eclipse-platform/eclipse.platform.ui#2004

!ENTRY org.eclipse.jdt.core 4 4 2024-06-26 01:38:28.817
!MESSAGE Error checking whether PackageFragmentRoot is on module path!
!STACK 1
Java Model Exception: Error in Java Model (code 1006): /Users/genie.releng/workspace/AutomatedTests/ep433I-unit-mac64-java17/workarea/I20240625-1800/eclipse-testing/test-eclipse/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.jdt.ui.tests_3.15.500.v20240621-0244/testresources/rtstubs13.jar is not on its project's build path
	at org.eclipse.jdt.internal.core.PackageFragmentRoot.getRawClasspathEntry(PackageFragmentRoot.java:616)
	at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.computeModuleFor(JavaSearchNameEnvironment.java:611)
	at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.mapToClassPathLocation(JavaSearchNameEnvironment.java:303)
	at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.computeClasspathLocations(JavaSearchNameEnvironment.java:216)
	at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.computeClasspathLocations(JavaSearchNameEnvironment.java:188)
	at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.<init>(JavaSearchNameEnvironment.java:96)
	at org.eclipse.jdt.internal.core.search.indexing.SourceIndexer.resolveDocument(SourceIndexer.java:167)
	at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.resolveDocument(JavaSearchParticipant.java:116)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexResolvedDocument(IndexManager.java:679)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager$2.execute(IndexManager.java:1283)
	at org.eclipse.jdt.internal.core.search.processing.JobManager.indexerLoop(JobManager.java:542)
	at java.base/java.lang.Thread.run(Thread.java:833)
!SUBENTRY 1 org.eclipse.jdt.core 4 1006 2024-06-26 01:38:28.819
!MESSAGE /Users/genie.releng/workspace/AutomatedTests/ep433I-unit-mac64-java17/workarea/I20240625-1800/eclipse-testing/test-eclipse/Eclipse.app/Contents/Eclipse/plugins/org.eclipse.jdt.ui.tests_3.15.500.v20240621-0244/testresources/rtstubs13.jar is not on its project's build path

@jukzi
Copy link
Contributor

jukzi commented Jun 26, 2024

bndtools.jareditor.internal.JAREditor cannot be cast to class org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

Sounds wrong that org.eclipse.jdt.ui.JavaUI.openInEditor(IJavaElement) for a .class file returns Editor from bndtools which is registered for .jar files.
@iloveeclipse any idea?

@stephan-herrmann
Copy link
Contributor

bndtools.jareditor.internal.JAREditor cannot be cast to class org.eclipse.jdt.internal.ui.javaeditor.JavaEditor

Sounds wrong that org.eclipse.jdt.ui.JavaUI.openInEditor(IJavaElement) for a .class file returns Editor from bndtools which is registered for .jar files.

I agree, this looks weird.

In the good case, org.eclipse.ui.ide.IDE.getEditorDescriptor(String, boolean, boolean) determines the content type for "X.class" to "org.eclipse.jdt.core.javaClass" for which a default editor is found as EditorDescriptor(id=org.eclipse.jdt.ui.ClassFileEditor, label=Class File Viewer).

If another editor is registered for .class, then either

  • one is selected as default in the preferences, or
  • the first editor is selected, i.e., selection is order-dependent.

The failing cast happens in the test class, not in productive code, so we could get away in tests by either

  • ensuring that no other editor is registered for .class during tests (how das bndtools enter the picture during tests anyway?)
  • setting a preference to select the JDT classfile editor as the default. this looks like the simplest solution

stephan-herrmann added a commit to stephan-herrmann/eclipse.jdt.ui that referenced this issue Jun 26, 2024
addresses the ClassCastException

fixes eclipse-jdt#736
stephan-herrmann added a commit that referenced this issue Jun 26, 2024
addresses the ClassCastException

fixes #736
@stephan-herrmann
Copy link
Contributor

I hope the ClassCastException will no longer occur after #1478

Seeing also changes in Buffer synchronization (eclipse-jdt/eclipse.jdt.core#2596) let's keep fingers crossed.

To be re-opened if the problem persists.

@jukzi
Copy link
Contributor

jukzi commented Jun 27, 2024

still happens:
https://download.eclipse.org/eclipse/downloads/drops4/I20240626-1800/testresults/html/org.eclipse.jdt.ui.tests_ep433I-unit-mac64-java17_macosx.cocoa.x86_64_17.html
(Jun 26, 2024, 6:54:29 PM)

java.lang.ClassCastException: class bndtools.jareditor.internal.JAREditor cannot be cast to class org.eclipse.jdt.internal.ui.javaeditor.JavaEditor (bndtools.jareditor.internal.JAREditor is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @8e689d4; org.eclipse.jdt.internal.ui.javaeditor.JavaEditor is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @336f7e67)
at org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_Array4(AnnotateAssistTest1d8.java:551)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)

@jukzi jukzi reopened this Jun 28, 2024
stephan-herrmann added a commit to stephan-herrmann/eclipse.jdt.ui that referenced this issue Jul 2, 2024
explicitly request a ClassfileEditor

2nd attempt at eclipse-jdt#736
@stephan-herrmann
Copy link
Contributor

Previous theory was, that a "foreign" editor for .class (from bndtools) was selected randomly (which would have been fixed by making JDT's editor the default in preferences).

In #1486 I'm short-cutting the selection of an editor ID, by directly requesting an editor for ID JavaUI.ID_CF_EDITOR. This might give a clue if that editor is in fact unavailable. (Perhaps on MacOS initializing the editor throws an exception?).

stephan-herrmann added a commit that referenced this issue Jul 2, 2024
explicitly request a ClassfileEditor

2nd attempt at #736
@jukzi
Copy link
Contributor

jukzi commented Jul 8, 2024

the error message changed to:

java.lang.ClassCastException: class org.eclipse.ui.internal.ErrorEditorPart cannot be cast to class org.eclipse.jdt.internal.ui.javaeditor.JavaEditor (org.eclipse.ui.internal.ErrorEditorPart is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @6887886a; org.eclipse.jdt.internal.ui.javaeditor.JavaEditor is in unnamed module of loader org.eclipse.osgi.internal.loader.EquinoxClassLoader @2fd9dc97)
at org.eclipse.jdt.ui.tests.quickfix.AbstractAnnotateAssistTests.openInClassfileEditor(AbstractAnnotateAssistTests.java:104)
at org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_Array3(AnnotateAssistTest1d8.java:471)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)

https://download.eclipse.org/eclipse/downloads/drops4/I20240707-1800/testresults/html/org.eclipse.jdt.ui.tests_ep433I-unit-mac64-java17_macosx.cocoa.x86_64_17.html

@iloveeclipse
Copy link
Member

ErrorEditorPart means Java editor failed to initialize, this is reported to the log:
https://download.eclipse.org/eclipse/downloads/drops4/I20240707-1800/testresults/ep433I-unit-mac64-java17_macosx.cocoa.x86_64_17/org.eclipse.jdt.ui.tests.AutomatedSuite.txt

!ENTRY org.eclipse.ui 4 4 2024-07-07 21:53:37.790
!MESSAGE Unable to create part
!STACK 1
org.eclipse.ui.PartInitException: The Class File Viewer cannot handle the given input ('org.eclipse.ui.part.FileEditorInput').
	at org.eclipse.ui.texteditor.AbstractTextEditor.internalInit(AbstractTextEditor.java:3202)
	at org.eclipse.ui.texteditor.AbstractTextEditor.init(AbstractTextEditor.java:3213)
	at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.lambda$0(ClassFileEditor.java:656)
	at org.eclipse.jdt.core.JavaCore.lambda$0(JavaCore.java:6196)
	at org.eclipse.jdt.internal.core.JavaModelManager.cacheZipFiles(JavaModelManager.java:5762)
	at org.eclipse.jdt.internal.core.JavaModelManager.callReadOnly(JavaModelManager.java:5751)
	at org.eclipse.jdt.core.JavaCore.callReadOnly(JavaCore.java:6180)
	at org.eclipse.jdt.core.JavaCore.runReadOnly(JavaCore.java:6195)
	at org.eclipse.jdt.internal.ui.javaeditor.ClassFileEditor.init(ClassFileEditor.java:656)
	at org.eclipse.ui.internal.EditorReference.initialize(EditorReference.java:353)
	at org.eclipse.ui.internal.e4.compatibility.CompatibilityPart.create(CompatibilityPart.java:344)
	at jdk.internal.reflect.GeneratedMethodAccessor98.invoke(Unknown Source)
	at java.base/jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
	at java.base/java.lang.reflect.Method.invoke(Method.java:568)
	at org.eclipse.e4.core.internal.di.MethodRequestor.execute(MethodRequestor.java:56)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:977)
	at org.eclipse.e4.core.internal.di.InjectorImpl.processAnnotated(InjectorImpl.java:939)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalInject(InjectorImpl.java:139)
	at org.eclipse.e4.core.internal.di.InjectorImpl.internalMake(InjectorImpl.java:386)
	at org.eclipse.e4.core.internal.di.InjectorImpl.make(InjectorImpl.java:312)
	at org.eclipse.e4.core.contexts.ContextInjectionFactory.make(ContextInjectionFactory.java:203)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.createFromBundle(ReflectionContributionFactory.java:90)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.doCreate(ReflectionContributionFactory.java:59)
	at org.eclipse.e4.ui.internal.workbench.ReflectionContributionFactory.create(ReflectionContributionFactory.java:42)
	at org.eclipse.e4.ui.workbench.renderers.swt.ContributedPartRenderer.createWidget(ContributedPartRenderer.java:132)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createWidget(PartRenderingEngine.java:991)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:658)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.safeCreateGui(PartRenderingEngine.java:762)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine$2.run(PartRenderingEngine.java:727)
	at org.eclipse.core.runtime.SafeRunner.run(SafeRunner.java:47)
	at org.eclipse.e4.ui.internal.workbench.swt.PartRenderingEngine.createGui(PartRenderingEngine.java:711)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.lambda$0(PartServiceImpl.java:105)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.lambda$0(UIEventHandler.java:38)
	at org.eclipse.swt.widgets.Synchronizer.syncExec(Synchronizer.java:183)
	at org.eclipse.ui.internal.UISynchronizer.syncExec(UISynchronizer.java:133)
	at org.eclipse.swt.widgets.Display.syncExec(Display.java:5264)
	at org.eclipse.e4.ui.workbench.swt.DisplayUISynchronize.syncExec(DisplayUISynchronize.java:34)
	at org.eclipse.e4.ui.services.internal.events.UIEventHandler.handleEvent(UIEventHandler.java:38)
	at org.eclipse.equinox.internal.event.EventHandlerWrapper.handleEvent(EventHandlerWrapper.java:206)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:201)
	at org.eclipse.equinox.internal.event.EventHandlerTracker.dispatchEvent(EventHandlerTracker.java:1)
	at org.eclipse.osgi.framework.eventmgr.EventManager.dispatchEvent(EventManager.java:230)
	at org.eclipse.osgi.framework.eventmgr.ListenerQueue.dispatchEventSynchronous(ListenerQueue.java:151)
	at org.eclipse.equinox.internal.event.EventAdminImpl.dispatchEvent(EventAdminImpl.java:131)
	at org.eclipse.equinox.internal.event.EventAdminImpl.sendEvent(EventAdminImpl.java:73)
	at org.eclipse.equinox.internal.event.EventComponent.sendEvent(EventComponent.java:44)
	at org.eclipse.e4.ui.services.internal.events.EventBroker.send(EventBroker.java:55)
	at org.eclipse.e4.ui.internal.workbench.UIEventPublisher.notifyChanged(UIEventPublisher.java:60)
	at org.eclipse.emf.common.notify.impl.BasicNotifierImpl.eNotify(BasicNotifierImpl.java:424)
	at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElementGen(ElementContainerImpl.java:168)
	at org.eclipse.e4.ui.model.application.ui.impl.ElementContainerImpl.setSelectedElement(ElementContainerImpl.java:187)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.showElementInWindow(ModelServiceImpl.java:654)
	at org.eclipse.e4.ui.internal.workbench.ModelServiceImpl.bringToTop(ModelServiceImpl.java:618)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.delegateBringToTop(PartServiceImpl.java:796)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.bringToTop(PartServiceImpl.java:401)
	at org.eclipse.e4.ui.internal.workbench.PartServiceImpl.showPart(PartServiceImpl.java:1271)
	at org.eclipse.ui.internal.WorkbenchPage.busyOpenEditor(WorkbenchPage.java:3228)
	at org.eclipse.ui.internal.WorkbenchPage.lambda$11(WorkbenchPage.java:3118)
	at org.eclipse.swt.custom.BusyIndicator.showWhile(BusyIndicator.java:67)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3116)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3086)
	at org.eclipse.ui.internal.WorkbenchPage.openEditor(WorkbenchPage.java:3077)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInEditor(EditorUtility.java:390)
	at org.eclipse.jdt.internal.ui.javaeditor.EditorUtility.openInSpecificEditor(EditorUtility.java:191)
	at org.eclipse.jdt.ui.tests.quickfix.AbstractAnnotateAssistTests.openInClassfileEditor(AbstractAnnotateAssistTests.java:100)
	at org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateMethod_Array2(AnnotateAssistTest1d8.java:791)

stephan-herrmann added a commit to stephan-herrmann/eclipse.jdt.ui that referenced this issue Jul 9, 2024
Assert that the java element is child of a classfile

debugging eclipse-jdt#736
@stephan-herrmann
Copy link
Contributor

stephan-herrmann commented Jul 9, 2024

org.eclipse.ui.PartInitException: The Class File Viewer cannot handle the given input ('org.eclipse.ui.part.FileEditorInput').

@iloveeclipse thanks for collecting this error output!

At first look this seems to imply, that IJavaProject.findType() answered a source compilation unit, although the type should be found in a jar file.
Reasoning: there are only 2 ways that EditorUtil.getEditorInput() can produce a FileEditorInput:

  • when input is an IFile, which is impossible in these tests (we know we have an IType, which is unrelated to IFile)
  • when input is an ICompilationUnit (or contained within)

Next attempt in #1501: assert that the java element is indeed a child of a classfile, otherwise let failure report the actual element.

stephan-herrmann added a commit that referenced this issue Jul 9, 2024
Assert that the java element is child of a classfile

debugging #736
@jukzi
Copy link
Contributor

jukzi commented Jul 12, 2024

error changed to:

java.lang.AssertionError: cu=[Working copy] X.class [in pack.age [in lib.jar [in TestSetupProject1d8]]]
package pack.age
interface X
java.lang.String test(int[][], java.util.List<java.lang.String>) source=null
at org.junit.Assert.fail(Assert.java:89)
at org.junit.Assert.assertTrue(Assert.java:42)
at org.junit.Assert.assertNotNull(Assert.java:713)
at org.eclipse.jdt.ui.tests.quickfix.AbstractAnnotateAssistTests.collectAnnotateProposals(AbstractAnnotateAssistTests.java:121)
at org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_Array2(AnnotateAssistTest1d8.java:395)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)
java.lang.AssertionError: Should be child of a classfile: interface X [in [Working copy] X.class [in pack.age [in lib.jar [in TestSetupProject1d8]]]]
java.lang.String test(int[][], java.util.List<java.lang.String>)
at org.junit.Assert.fail(Assert.java:89)
at org.junit.Assert.assertTrue(Assert.java:42)
at org.junit.Assert.assertNotNull(Assert.java:713)
at org.eclipse.jdt.ui.tests.quickfix.AbstractAnnotateAssistTests.openInClassfileEditor(AbstractAnnotateAssistTests.java:101)
at org.eclipse.jdt.ui.tests.quickfix.AnnotateAssistTest1d8.testAnnotateParameter_Array3(AnnotateAssistTest1d8.java:471)
at java.base/java.lang.reflect.Method.invoke(Method.java:568)

https://download.eclipse.org/eclipse/downloads/drops4/I20240711-1800/testresults/html/org.eclipse.jdt.ui.tests_ep433I-unit-mac64-java17_macosx.cocoa.x86_64_17.html

@stephan-herrmann
Copy link
Contributor

error changed to:
... source=null

So the first of 4 failures is caused by a missing buffer, only after that we get IJavaElements saying "in [Working copy] X.class" without having an IClassFile parent.

Missing buffer could be caused by a problem in AbstractClassFile.validateClassFile() or problem in buffer management.

robstryker pushed a commit to robstryker/eclipse.jdt.core that referenced this issue Jul 18, 2024
Some field accesses had not been synchronized which may have caused NPEs
in access from different thread.

eclipse-jdt/eclipse.jdt.ui#736
gayanper pushed a commit to gayanper/eclipse.jdt.core that referenced this issue Sep 7, 2024
Some field accesses had not been synchronized which may have caused NPEs
in access from different thread.

eclipse-jdt/eclipse.jdt.ui#736
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed null relating to (annotation-based) null analysis test junit test related things
Projects
None yet
Development

Successfully merging a pull request may close this issue.

4 participants