0

Eclipse RCP 2020-09 , Java JDK 11 , Window10

Step

1 . Create A Simple Plugin Project( click [ next ] [ finish ] )

2 . Require-Bundle: org.eclipse.jdt.core

3 . Create A Java File

import javax.lang.model.type.NullType;

public class A {
    
    public static void main(String[] args) {
        NullType type ;
    }

}

Compilation error : The package javax.lang.model.type is accessible from more than one module: <unnamed>, java.compiler

I try not to rely on org.eclipse.jdt.core ( delete Require-Bundle: org.eclipse.jdt.core )

Compilation success !

It seems that there is a conflict between org.eclipse.jdt.core and javax.lang.model

I have imported almost all org.eclipse.xxx without this problem. Only org.eclipse.jdt.core has this problem

I also checked the internal information of org.eclipse.jdt.core and found no special settings

Why? How can I solve this problem ? Help me , please !

  • You have the package `javax.lang.model.type` (either in your code or in a dependency) which also exists in the system library, which is not allowed since Java 9. – howlger Jan 11 '22 at 01:00
  • Can you be more specific? My project is very simple, jdk11 and a new plug-in project. I don't find any dependencies –  Jan 11 '22 at 01:28
  • In your plug-in project, do you have the package `javax.lang.model.type`? If yes, rename it. Otherwise, please show what you have in _Project > Properties: Java Build Path_ in the tab _Libraries_ (top level nodes and child nodes of _Plug-in Dependencies_). – howlger Jan 11 '22 at 01:39
  • The plug-in project only contains standard jdk11 and org eclipse. jdt. core There are no other dependencies in the class path –  Jan 11 '22 at 02:54
  • In the _Open Type_ (Ctrl+Shift+T) dialog, when I enter `javax.lang.model.type`, I see that the `org.eclipse.jdt.compiler.tool` plugin contains `javax15api.jar` that also contains the `javax.lang.model.type` package, but it's not exported. I was not able to reproduce your issue with the `org.eclipse.jdt.core.manipulation` plugin that also contains this dependency, also not when using Java 17 instead of Java 8. Maybe you face this issue by using such an old Eclipse that is 5 releases behind. If you can reproduce this issue in the current Eclipse 2021-12, please show your `MANIFEST.MF` file. – howlger Jan 11 '22 at 08:20
  • 1
    @howlger I can't recreate this on 2021-12 with Java 17 following these exact steps – greg-449 Jan 11 '22 at 08:24
  • OK , Eclipse 2021-12 This problem cannot be reproduced e..... thank you , @howlger –  Jan 11 '22 at 12:49

1 Answers1

1

Upgrading to eclipse 2021-12 can solve the problem

Thank you , @howlger