Bug 541096 - "Unexpected internal error" trying to convert stream to array
Summary: "Unexpected internal error" trying to convert stream to array
Status: CLOSED WORKSFORME
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Core (show other bugs)
Version: 4.10   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Core-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords: needinfo
Depends on:
Blocks:
 
Reported: 2018-11-13 11:32 EST by Garret Wilson CLA
Modified: 2019-01-23 00:56 EST (History)
2 users (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Garret Wilson CLA 2018-11-13 11:32:38 EST
With Eclipse Enterprise 2018-12 M2 and OpenJDK 11 I'm implementing `Collection.toArray(T[] array)`, getting my information from a `Stream<>`.

    @Override
    public <T> T[] toArray(T[] array) {
      try (final Stream<FooBar> stream = getStream()) {
        T[] result = (T[])stream.map(foo::doSomething).toArray(length -> Array.newInstance(array.getClass(), length));
        //TODO do other stuff here
      }
    }

I can't even try this code yet, because Eclipse says "Problem detected during type inference: Unknown error at invocation of toArray(IntFunction<Object[])". (The error log is below. Note that I'm not even using modules.)

Turns out of course that the code has an error; it should be something like this:

    @Override
    public <T> T[] toArray(T[] array) {
      try (final Stream<FooBar> stream = getStream()) {
        T[] result = stream.map(foo::doSomething).toArray(length -> (T[])Array.newInstance(array.getClass(), length));
        //TODO do other stuff here
      }
    }

Still, the point is that the internal parser breaks; it encounters its own error before it can tell me mine. So I thought I'd report it so you can track it down. I hope this is helpful.

eclipse.buildId=4.10.0.I20181031-1800
java.version=11
java.vendor=Oracle Corporation
BootLoader constants: OS=win32, ARCH=x86_64, WS=win32, NL=en_US
Framework arguments:  -product org.eclipse.epp.package.jee.product
Command-line arguments:  -os win32 -ws win32 -arch x86_64 -product org.eclipse.epp.package.jee.product

This is a continuation of log file …\.metadata\.bak_0.log
Created Time: 2018-11-13 10:08:03.885

org.eclipse.jdt.core
Error
Tue Nov 13 10:21:45 CST 2018
Unexpected internal error

Java Model Exception: Java Model Status [module-info.class [in <default> [in …\.m2\repository\org\ow2\asm\asm\6.0_ALPHA\asm-6.0_ALPHA.jar]] does not exist]
	at org.eclipse.jdt.internal.core.JavaElement.newNotPresentException(JavaElement.java:573)
	at org.eclipse.jdt.internal.core.ModularClassFile.getModule(ModularClassFile.java:300)
	at org.eclipse.jdt.internal.core.PackageFragmentRoot.getSourceModuleDescription(PackageFragmentRoot.java:914)
	at org.eclipse.jdt.internal.core.PackageFragmentRoot.getModuleDescription(PackageFragmentRoot.java:890)
	at org.eclipse.jdt.internal.core.JarPackageFragmentRoot.getModuleDescription(JarPackageFragmentRoot.java:321)
	at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.addModuleClassPathInfo(JavaSearchNameEnvironment.java:195)
	at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.mapToClassPathLocation(JavaSearchNameEnvironment.java:189)
	at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.computeClasspathLocations(JavaSearchNameEnvironment.java:134)
	at org.eclipse.jdt.internal.core.search.matching.JavaSearchNameEnvironment.<init>(JavaSearchNameEnvironment.java:78)
	at org.eclipse.jdt.internal.core.search.matching.IndexBasedJavaSearchEnvironment.create(IndexBasedJavaSearchEnvironment.java:334)
	at org.eclipse.jdt.internal.core.search.indexing.SourceIndexer.resolveDocument(SourceIndexer.java:169)
	at org.eclipse.jdt.internal.core.search.JavaSearchParticipant.resolveDocument(JavaSearchParticipant.java:94)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager.indexResolvedDocument(IndexManager.java:552)
	at org.eclipse.jdt.internal.core.search.indexing.IndexManager$1.execute(IndexManager.java:1071)
	at org.eclipse.jdt.internal.core.search.processing.JobManager.run(JobManager.java:401)
	at java.base/java.lang.Thread.run(Thread.java:834)
Comment 1 Jay Arthanareeswaran CLA 2018-11-14 00:32:16 EST
Can you please attach the complete class as source or perhaps the project itself. I am unable to reproduce (at least with 4.10 M1) after inferring the missing elements such as doSomething, necessary imports.
Comment 2 Stephan Herrmann CLA 2018-11-14 18:54:21 EST
Please explain in particular, what relation your project has to asm-6.0_ALPHA.jar? Is this a stale maven dependency? Perhaps the ALPHA jar was removed after a release arrived?

Even though your own code doesn't use modules (which in Java 11 simply means it lives in the unnamed module), s.t. tries to access asm *as a module*.

In case you are unable to provide a full project, these following are of particular interest for investigation:
   .classpath
   pom.xml
Comment 3 Garret Wilson CLA 2018-11-14 22:31:55 EST
I'm working on a branch for a few days. Within a week or two I can provide you with the entire public repository after I merge the branch.

> Please explain in particular, what relation your project has to asm-6.0_ALPHA.jar?

None whatsoever that I know of. I have no idea what that is. I've never seen it before. I simply typed in the line I indicated, and the flyover said an unknown error occurred.
Comment 4 Stephan Herrmann CLA 2019-01-08 13:36:02 EST
We don't have enough information for investigation. Please re-open if you can provide a sample project demonstrating the issue.
Comment 5 Garret Wilson CLA 2019-01-23 00:56:52 EST
I'm not working on this project at the moment, but when I work on it again I'll let you know if there are any problems.

> Please explain in particular, what relation your project has to
> asm-6.0_ALPHA.jar?

Just to follow up, this project was using an old version of cglib, which probably had a dependency to some old version of ASM (whatever that is). This may not even be relevant anymore. But if it is, I'll let you know. Thanks!