Giter Site home page Giter Site logo

Add Java 8 support about javaparser HOT 25 CLOSED

javaparser avatar javaparser commented on May 23, 2024
Add Java 8 support

from javaparser.

Comments (25)

talios avatar talios commented on May 23, 2024

+1 on this - I just started updating my codebase to using JDK8 and I have a maven-enforcer-plugin extension that's using the javaparser ( +1 works AWESOME ) and would love to see JDK8 support soon.

from javaparser.

shoito avatar shoito commented on May 23, 2024

+1

from javaparser.

 avatar commented on May 23, 2024

+1

from javaparser.

matozoid avatar matozoid commented on May 23, 2024

Nobody is working on this, so pick it up if you like.

from javaparser.

rpau avatar rpau commented on May 23, 2024

Hi,

I have recently added Java 8 support to walkmod (check https://github.com/rpau/javalang). This open source project started from the Javaparser 1.6 grammar, so you feel free to add my grammar changes to Javaparser.

I have tested my Java 8 parser with expressions extracted from the JSR 335. So, it would be nice to test the parser with your Java 8 code before adding my changes to this project and publish an official version to Maven. My parser also passes your parsing (Java 7) tests.

from javaparser.

talios avatar talios commented on May 23, 2024

+1 will give it a shot on my JDK8 code and report back what I find...

from javaparser.

rpau avatar rpau commented on May 23, 2024

Hi,
Today I have read Java 8 allows to annotate create expressions, cast, implements and exceptions.
Check (http://docs.oracle.com/javase/tutorial/java/annotations/basics.html). I need to add the syntax into my Java8 grammar. I will notify you when the annotations are added (probably this weekend).

from javaparser.

ptitjes avatar ptitjes commented on May 23, 2024

@rpau In fact, this is any TypeReference that have to hold the annotations. (And not the expressions that contain TypeReferences.)

I'm quite sure the Checker Framework team (washington university) have already done that work on their fork of JavaParser for their initial experiments (almost one year and a half ago). Maybe you could get some stuff from them.

from javaparser.

rpau avatar rpau commented on May 23, 2024

Thanks @ptitjes for your help. Java 8 Annotations for any TypeReference added in my repo ( https://github.com/rpau/javalang). So, any comment is always welcome :)

from javaparser.

ptitjes avatar ptitjes commented on May 23, 2024

Well done! Hope this will go nicely into JavaParser!

from javaparser.

ftomassetti avatar ftomassetti commented on May 23, 2024

Any news? We are looking forward to have Java 8 support :D

from javaparser.

martoeng avatar martoeng commented on May 23, 2024

I've seen many Java 8 constructs in the code. Any information on when there will be a release that supports the Java 8 changes?

from javaparser.

ftomassetti avatar ftomassetti commented on May 23, 2024

I suggest we start a separate branch, in that branch I would insert as many examples as possible of code written in Java 8. Do you think it is a good plan?
Does someone knows where to find good examples of code written in Java 8? Perhaps a common set of files used for testing some compiler or tool...

from javaparser.

ftomassetti avatar ftomassetti commented on May 23, 2024

I wanted to take the source code from OpenJDK8 to test our Java8 compiler but it was released under GPL2. Maybe I should find something else

from javaparser.

sebastiankirsch avatar sebastiankirsch commented on May 23, 2024

I don't know javacc at all, but for what it's worth: I found a (presumably fully working) grammar file over at PMD: http://sourceforge.net/p/pmd/code/ci/master/tree/pmd-java/etc/grammar/Java.jjt

from javaparser.

ftomassetti avatar ftomassetti commented on May 23, 2024

Interesting, it could help. Our grammar is a bit different and it could require some effort to insert the lambda expressions into it. The problem is that they are rather ambiguos from a parser point of view. It si definitely going to be not trivial to implement... for now I started creating a class for this new AST node and adapt a bunch of visitors to consider it. Now we have to do the difficult part: updating the grammar.

from javaparser.

rpau avatar rpau commented on May 23, 2024

As I have commented before, in the javalang project we have an updated version of the javacc grammar of javaparser in the project. It can help. We can also have tests that include examples of the Java 8 specification (lambda amb type expressions) to validate the parsing.

from javaparser.

ftomassetti avatar ftomassetti commented on May 23, 2024

I started writing one test using JBehave (in my fork, branch java8). Probably it is easier to steal it from walkmod (given it is basically a fork of JavaParser)

from javaparser.

SmiddyPence avatar SmiddyPence commented on May 23, 2024

There is a fair bit of divergence from memory.

I had already had a go at it here: https://github.com/SmiddyPence/javaparser/tree/Milestone2

Feel free to lift the grammar and try the examples.

from javaparser.

ftomassetti avatar ftomassetti commented on May 23, 2024

oh, sorry Smiddy, I missed that. Anyway I did not go far at all so not very much duplicate effort :D
Have you already updated the grammar? Can you update on the status? Anything I could help with or is it everything already brilliantly solved :D ?

from javaparser.

ftomassetti avatar ftomassetti commented on May 23, 2024

P.S. one thing I started to do was updating references to "Java 1.5 parser" into "Java 1.8 parser", promoting the brand first of all!

from javaparser.

SmiddyPence avatar SmiddyPence commented on May 23, 2024

Brilliantly solved or maybe just discretely broken. I have just had a look at the differences again to refresh my memory. The javalang version handles comments differently and doesn't have the NameExpr concept so I had to try and retain those from the original and merge in lambda and type expression changes.

I still need to put together some more tests, to it will take a while to put a pull request together. Or feel free to just lift the grammar out. There is also one Lambda test in the parsing_scenarios.story file.

from javaparser.

SmiddyPence avatar SmiddyPence commented on May 23, 2024

Fire at will:

<dependency>
    <groupId>com.github.javaparser</groupId>
    <artifactId>javaparser-core</artifactId>
    <version>2.0.0</version>
</dependency>

Lets have new issues for specific problems. Thanks

from javaparser.

martoeng avatar martoeng commented on May 23, 2024

Thanks!
I just integrated it and adjusted the package names. Will have a go at some Java 8 code next week.

from javaparser.

talios avatar talios commented on May 23, 2024

Working well in my project here so far. Tho I've not stressed much JDK8 code yet..

from javaparser.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.