question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Runtime exception: Structural identity doesn't work for method references

See original GitHub issue

Describe the bug items.stream().map(item -> item.getId()).forEach(System.out::println)items.stream().map(Item::getId).forEach(System.out::println); 🆘

To Reproduce Test project: https://github.com/marksto/manifold-cast-exception mvn clean install

Expected behavior Structural identity works for method references in Java 8+.

Desktop (please complete the following information):

  • OS Type & Version: “mac os x”, version: “10.14.3”, arch: “x86_64”, family: “mac”
  • Java/JDK version: Java version: 1.8.0_172, vendor: Oracle Corporation
  • IntelliJ IDEA version: 2018.1.2
  • Manifold version: 0.59-alpha
  • Manifold IntelliJ plugin version: 0.59-alpha

Stack trace

Exception in thread "main" java.lang.ClassCastException: manifold.ext.DataBindings cannot be cast to abc.schema.Item
	at java.util.stream.ReferencePipeline$3$1.accept(ReferencePipeline.java:193)
	at java.util.ArrayList$ArrayListSpliterator.forEachRemaining(ArrayList.java:1382)
	at java.util.stream.AbstractPipeline.copyInto(AbstractPipeline.java:481)
	at java.util.stream.AbstractPipeline.wrapAndCopyInto(AbstractPipeline.java:471)
	at java.util.stream.ForEachOps$ForEachOp.evaluateSequential(ForEachOps.java:151)
	at java.util.stream.ForEachOps$ForEachOp$OfRef.evaluateSequential(ForEachOps.java:174)
	at java.util.stream.AbstractPipeline.evaluate(AbstractPipeline.java:234)
	at java.util.stream.ReferencePipeline.forEach(ReferencePipeline.java:418)
	at abc.RunMe.loadItemsArray_PlainInterface(RunMe.java:39)
	at abc.RunMe.main(RunMe.java:22)

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:8 (5 by maintainers)

github_iconTop GitHub Comments

1reaction
rsmckinneycommented, May 8, 2019

Fix available in release 0.65-alpha

1reaction
markstocommented, Apr 13, 2019

Ooo-key… I managed to figure out this inconsistency between debugger interpretation and the code being executed too (regardless the error in evaluator the app itself was running fine), and in the end this last ClassCastException turned out to be an invalid JSON Schema issue. 🤦‍♂️

Product was parsed with:

{
  ...
  "category": "string-value",
  ...
}

while the schema used for loading had:

{
  ...
  "category": {
    "type": "object",
    ...
  }
  ...
}

I’ve covered this scenario with a separate test case in updated test project, but still was not able to reproduce the exact same exception (in tests it fails with manifold.internal.javac.JavaCompileIssuesException: Error compiling Java class: abc.schema.java_lang_String_structuralproxy_abc_schema_Category).

Read more comments on GitHub >

github_iconTop Results From Across the Web

java - Runtime exception on method reference with bound ...
I have the following class, which represents an entity that can be identified by a String id: public abstract class IdentifiableEntity ...
Read more >
Resolve "ClassNotFoundExeption" errors from Java Lambda ...
The ClassNotFoundException error occurs when a Java runtime loads a class by its fully qualified name, but doesn't locate the class.
Read more >
Custom script runtime error - Forum - One Identity
I was able to import dependent libraries build in Visual studio. My script looks like below. #If Not SCRIPTDEBUGGER Then References netstandard.dll. References...
Read more >
Chapter 15. Expressions
Run-time exceptions are thrown by the predefined operators as follows: A class instance creation expression (§15.9.4), array creation expression (§15.10.2), ...
Read more >
How to test for reference equality (Identity) - C# guide
That is, only one instance of each unique literal string is maintained. However, the runtime does not guarantee that strings created at run...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found