Coder Social home page Coder Social logo

jdt-core-ast-for-batch-of-compilation-units-bug's Introduction

Reproduce a bug in jdt-core when parsing a batch of compilation units

Reproduce the eclipse-jdt/eclipse.jdt.core issues/2050

Goal

Parsing a batch of 3 java files, A.java, B.java, C.java, using ASTParser.createASTs() method with a classpath that contains one missing class file to fully resolve B.java semantics.

Expected output

The createASTs() method should callback the FileASTRequestor 3 times, one for each file. Problems in the semantics should not prevent B.java to be parsed and the following files should also be parsed.

Actual output

The createASTs() method calls the FileASTRequestor only for A.java and silently ignore B.java and C.java files.

Steps to reproduce

Run:

mvn clean package

This will:

  • prepare the binary files to reproduce the bug
    • module1/src/main/java/org/example/Module1.java -> module1/target/classes/org/example/Module1.class and Module1$Inner.class
    • module2/src/main/java/org/example/Module2.java -> module2/target/classes/org/example/Module2.class
  • run module4-parser/src/test/java/org/example/ParserTest.java that reproduces the bug
    • check_accept_files_with_valid_semantic use a full classpath to resolve B.java semantics and is able to parse all 3 files
    • check_accept_files_with_missing_semantic use a classpath with a missing class file and is able to parse only A.java

The fact that the check_accept_files_with_missing_semantic test pass highlights the bug because of this assertion

containsExactlyInAnyOrder("A.java");

should be

containsExactlyInAnyOrder("A.java", "B.java", "C.java");

Workaround

Using org.eclipse.jdt:org.eclipse.jdt.core:3.35.0 instead of org.eclipse.jdt:org.eclipse.jdt.core:3.36.0 here fixes the issue. Running mvn clean package, the check_accept_files_with_missing_semantic will fail as expected.

Investigation

During B.java semantic resolution, the ProblemHandler is called while referenceContext is null which cause a AbortCompilation exception line 161. This exception may be related to issues/1915 but it's not because of an exception during semantic resolution that the parsing of the batch should silently stop. Stopping in the middle of a batch should not append, or should append by throwing an exception during the ASTParser.createASTs() call.

jdt-core-ast-for-batch-of-compilation-units-bug's People

Contributors

alban-auzeill avatar

Watchers

 avatar

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.