Giter Site home page Giter Site logo

Implementation of javax.lang.model.util.Elements#getTypeElement(String) returns TypeElement with empty metadata about eclipse.jdt.core HOT 2 OPEN

ijioio avatar ijioio commented on July 18, 2024
Implementation of javax.lang.model.util.Elements#getTypeElement(String) returns TypeElement with empty metadata

from eclipse.jdt.core.

Comments (2)

srikanth-sankaran avatar srikanth-sankaran commented on July 18, 2024

Attaching a standalone test program that shows the actual problem will elicit faster investigation - share a program that can be compiled and run with javac and ecj that shows differing behavior.

from eclipse.jdt.core.

ijioio avatar ijioio commented on July 18, 2024

Attaching a standalone test program that shows the actual problem will elicit faster investigation - share a program that can be compiled and run with javac and ecj that shows differing behavior.

Sorry, I'm not sure how to test/run annotation processor application using ecj, but I've attached simple gradle project that just logs element's states on processing.

apt-test.zip

Here is an instructions of how the problem can be reproduced running it with Eclipse IDE:

Import project

Select File -> Import -> Existing Gradle Project, press Next. Within Project root directory field press Browse and locate the directory containing project, i.e. apt-test, press Finish to import.

Build the processor

Select Window -> Show View -> Other... -> Gradle Tasks to open gradle task panel. Run build task under processor subproject. In Project Explorer, right click on project apt-test and select Refresh.

Setup annotation processor

In Project Explorer, right click on subproject application and select Properties. Expand Java Compiler branch and select Annotaiton Processor, check the Enable project specific settings checkbox and make sure other comboboxes Enable annotation processor and Enable processing in editor are checked as well. Now expand Annotation Processor branch and select Factory Path. Check the Enable project specific settings checkbox, press Add JARs... button, locate processor subproject, expand build/libs and select processor.jar, press Apply and Close.

Compile all

In Eclipse select Project -> Clean.... Check the eclipse log file .log located under .metadata directory of the workspace:

!ENTRY org.eclipse.jdt.apt.pluggable.core 1 1 2024-01-11 00:03:28.677
!MESSAGE annotated elements -> [com.example.apt.test.application.A, com.example.apt.test.application.B]

!ENTRY org.eclipse.jdt.apt.pluggable.core 1 1 2024-01-11 00:03:28.678
!MESSAGE A -> com.example.apt.test.application.A, mirrors -> [@com.example.apt.test.annotation.Foo(name = "A")]

!ENTRY org.eclipse.jdt.apt.pluggable.core 1 1 2024-01-11 00:03:28.678
!MESSAGE B -> com.example.apt.test.application.B, mirrors -> [@com.example.apt.test.annotation.Foo(name = "B")]

Compile A.java

Open source file A.java located in application subproject, add new line and select File -> Save, check the logs:

!ENTRY org.eclipse.jdt.apt.pluggable.core 1 1 2024-01-11 00:06:25.428
!MESSAGE annotated elements -> [com.example.apt.test.application.A]

!ENTRY org.eclipse.jdt.apt.pluggable.core 1 1 2024-01-11 00:06:25.429
!MESSAGE A -> com.example.apt.test.application.A, mirrors -> [@com.example.apt.test.annotation.Foo(name = "A")]

!ENTRY org.eclipse.jdt.apt.pluggable.core 1 1 2024-01-11 00:06:25.429
!MESSAGE B -> com.example.apt.test.application.B, mirrors -> []

Compile B.java

Open source file B.java located in application subproject, add new line and select File -> Save, check the logs:

!ENTRY org.eclipse.jdt.apt.pluggable.core 1 1 2024-01-11 00:07:10.737
!MESSAGE annotated elements -> [com.example.apt.test.application.B]

!ENTRY org.eclipse.jdt.apt.pluggable.core 1 1 2024-01-11 00:07:10.737
!MESSAGE A -> com.example.apt.test.application.A, mirrors -> []

!ENTRY org.eclipse.jdt.apt.pluggable.core 1 1 2024-01-11 00:07:10.738
!MESSAGE B -> com.example.apt.test.application.B, mirrors -> [@com.example.apt.test.annotation.Foo(name = "B")]

As it is shown above, only elements that was explicitly triggered by the processor (i.e. included in the round environment) have all annotation mirrors in place on lookup, while other elements that are not triggered by the processor returned without annotation mirrors on lookup.

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.