Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Modeling » EMF » Problem Reloading Genmodel. `<>` operator is not allowed for source level below 1.7
Problem Reloading Genmodel. `<>` operator is not allowed for source level below 1.7 [message #1791098] Fri, 22 June 2018 19:39 Go to next message
Matthew Janssen is currently offline Matthew JanssenFriend
Messages: 5
Registered: June 2018
Junior Member
Eclipse Version: Oxygen.3 (4.7.3) M20180301-0715
EMF Plugin Version 2.13.0.v20170609-0928

I'm getting an error when I try to reload the genmodel for my code. The error says that there was a problem while parsing a Java file. The problem being that the `<>` operator is not allowed for source level below 1.7. But I can't figure out why it thinks I'm on Java 1.6 or below.

Within Eclipse I right click on the .genmodel > Reload... Then hitting Next causes the error to occur. I'm not sure what I'm doing wrong or what other configuration I'm missing. The maven project is set to Java 1.7 compliance. I'm using a Java 8 jdk in my Eclipse workspace. And the EMF genmodel is set to Java 1.7 compliance. Is there anything else that I'm missing?

I've attached screenshots of the problems and a text file with the full stack trace.
I've also built a small example project[1] in which I'm able to recreate the issue. If the `AnotherClass` file is commented out or type arguments are added to the ArrayList<> then the genmodel reloads just fine.

Any pointers on how to fix this would be appreciated.

[1]: https://github.com/mttjj/emf-example
Re: Problem Reloading Genmodel. `<>` operator is not allowed for source level below 1.7 [message #1791472 is a reply to message #1791098] Sat, 30 June 2018 07:11 Go to previous messageGo to next message
Ed Merks is currently offline Ed MerksFriend
Messages: 29545
Registered: July 2009
Senior Member
Sorry, this won't even work with EMF 2.14 either. Java files are currently always parsed using JDT's JLS4 (Java Language Specification level). But now there are JLS8, JLS9, and JLS10 available as well. All the older ones become deprecated so it's hard to maintain compatibility in EMF with older versions of JDT. Using reflection to pick the latest level mostly works, but some older methods on the AST throw exceptions when called in that case and that causes test failures.

In any case, there is no workaround other than not using the newer language features that cause such problems. Please open a Bugzilla and I can try to figure out how to handle this more flexibly for EMF 2.15.
Re: Problem Reloading Genmodel. `<>` operator is not allowed for source level below 1.7 [message #1791488 is a reply to message #1791472] Sat, 30 June 2018 14:00 Go to previous messageGo to next message
Matthew Janssen is currently offline Matthew JanssenFriend
Messages: 5
Registered: June 2018
Junior Member
Thanks Ed.

Turns out that by the time I posted this and the time the post was approved (a week :)) I actually figured out what was going on. I had my Java Compliance level in my Eclipse preferences set to 1.6. Changing that to at least 1.7 solved the issue and I'm able to generate code even while using Java 7 features such as the diamond operator.
Re: Problem Reloading Genmodel. `<>` operator is not allowed for source level below 1.7 [message #1791489 is a reply to message #1791488] Sat, 30 June 2018 14:12 Go to previous message
Ed Willink is currently offline Ed WillinkFriend
Messages: 6040
Registered: July 2009
Senior Member
Hi

Although EMF hasn't really moved on from Java 5, EMF is very resilient to higher versions. Prior to the Photon release, I briefly tried Java 10. Everything seemed fine. I only had to revert to Java 8 because of a JDT bug in the computation of a non-modular classpath for the purposes of JUnit testing. See https://bugs.eclipse.org/bugs/show_bug.cgi?id=535067

Regards

Ed Willink
Previous Topic:Package.eINSTANCE.getElement not equals reference.etype - ResourceFactory or Registry Problem?
Next Topic:"a registered resource factory is needed" outside the generated editor
Goto Forum:
  


Current Time: Sat Sep 22 16:49:32 GMT 2018

Powered by FUDForum. Page generated in 0.01818 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top