Giter Site home page Giter Site logo

[22] Byte code backward compatibility for compilation targets < 22 violated with '-proceedOnError', because parser falsely identifies unnamed class about eclipse.jdt.core HOT 3 OPEN

kriegaex avatar kriegaex commented on July 18, 2024
[22] Byte code backward compatibility for compilation targets < 22 violated with '-proceedOnError', because parser falsely identifies unnamed class

from eclipse.jdt.core.

Comments (3)

kriegaex avatar kriegaex commented on July 18, 2024

Just in case you are wondering how I found such a weird example: In AspectJ, an old regression test ensuring compatibility between AJC and ECJ started to fail, because ECJ now behaves differently than before.

from eclipse.jdt.core.

stephan-herrmann avatar stephan-herrmann commented on July 18, 2024

This is a tricky one.

First observation: our grammar lacks suitable /:$compliance 22:/ declarations for this feature, but even with that, the example is parsed as an implicitly declared class. Only DiagnoseParser uses that information in order to produce suitable error messages (see usage of Parser.rules_compliance).

The core problem is: syntactically blahblahpackage pack; leaves no doubt that this is a variable declaration, and since we are not in a method context it must be a field declaration, which can only happen in a type declaration, explicit or implicit.

some ideas:
(1) should Parser.parse() directly check act similar to how DiagnoseParser does it? But then what?

(2) should we insert an empty token to the grammar, like:

ImplicitlyDeclaredClassBodyDeclarations ::= ClassMemberDeclaration StartImplicitType ImplicitlyDeclaredClassBodyDeclarations

Then we could let StartImplicitType trigger a consume method that does - what?

  • discard the previously parsed ClassMemberDeclaration?
  • reset stacks? which? how to ensure a consistent state?

(3) perhaps it's enough to make Parser.consumeInternalCompilationUnitWithPotentialImplicitlyDeclaredClass() conditional like this:

  • if the feature is not enabled, then
    • if we find exactly one type declaration, we could promote this to the toplevel of the CU, and then
      • report all fields and methods found outside the class as misplaced constructs

@mickaelistria as the author of Parser.consumeInternalCompilationUnitWithPotentialImplicitlyDeclaredClass(), do you want to follow up along the lines of idea (3)?

from eclipse.jdt.core.

mickaelistria avatar mickaelistria commented on July 18, 2024

Sorry, I don't plan to work on it on short term.

from eclipse.jdt.core.

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.