Trouble using the Java source itself as the source code of a project

Answered

Hi,

 I have a "project"  whose source is the Java 13 source itself. I put project in quotes because I don't expect IJ to compile the Java source even if I point it to the modules   and yadda yadda yadda. What I was hoping for was IJ would recognize that say,

sun.text.BidiBase

and

sun.text.BidiLine 

(just to grab a couple of source files out of the air which are  in the same package and in the same module sitting right next to each other in the project's Project View) are included in the project such that goto source on the definition of BidiLine or BidiBase symbol will navigate to the respective  .java files which are defined in the modules and NOT go to the JDK library, decompile the .class files and present me with the decompiled files AND/OR go to the JDK source and present that file to me. 

 

Things I've tried:

1) Define the JDK source in the JDK definition to be my own project's files in the project settings instead of the src.zip that comes with the JDK.

2) Zipping my own project's files up and naming them src.zip then substituting them for the src.zip that does come  with the JDK. 

3) Move my project files's up to the top of any list of places to look for anything that smells like (or even doesn't) an ordered list of "places too look for any purpose" in any IJ configuration screen I could find anywhere. 

4) Deleting the src.zip in the JDK definition screen so it has no source in the eyes of IJ.

All in all the project cannot see its neighbor classes in the same package in the same module and merrily autogenerates Beckett-level absurdist warnings like:

"package java.awt" is declared in module "java.desktop" but module "java.desktop" doesn't read it.  

which, if you take it at its word and accept the offered "fix" results in java.desktop requiring java.desktop in its module-info.java which is promptly flagged by the same system as a circular reference, which at least is true.

No matter what I do, goto symbol definition will navigate to the source in the library or, absent that, be blind to its own classes and mark everything as an unknown symbol .

Once again I am not looking to be able to build this project, just deal with it on a symbolic level. 

I am seeking the advice of anyone who has actually achieved what I am trying to do.

Thank you.

5 comments
Comment actions Permalink

Hello,

Please go to the Project Structure -> Project Settings -> Modules.

For usual projects JDK here is defined at the first place. If you develop the JDK, "Module source" should be moved up.

 

Please tell if it helps in your case. Thanks

0
Comment actions Permalink

Even though your suggestion clearly falls under the category 3:

3) Move my project files's up to the top of any list of places to look for anything that smells like (or even doesn't) an ordered list of "places too look for any purpose" in any IJ configuration screen I could find anywhere. 

 

nevertheless, I had not done that. I will report back when I am sure it solved my problem.

 

Thank you , Olga

0
Comment actions Permalink

If I change a variable name in a class the code insight feature of IJ knows about the new name but the parser doesn't and gives me symbol not found error in the editor. 

So I can press ctrl+space after a class instance then the dot operator: 

myClassInstance.

to see a list of field names I might access and the renamed field does show in code insight but when I choose it from code insight, it marks it as red meaning "unknown symbol".

I also get errors at the top of the editor saying things like "Library source does not match the byte code for StandardGlyphVector" which is true, it doesn't. 

 

To give more context, this problem surfaces in the context of inner classes of the class whose variable I have renamed. Example:

 

public class A

{

   int myRenamedVariable;

 ......

  class InnerClassOfClassA

  {

       A myClassAFieldInsideMyInnerClass;

   ....

    myClassAFieldInsideMyInnerClass. <------- kaboom

}

}

What I *think* is happening is code insight is getting its info from the source file and the parser is getting its info from the (a ? ) .class file (which is never changed). But then why does this ever work because in non-JDK code I can rename a variable and the parser understands it's been renamed no issues; I don't have to recompile every time I rename a variable. So I don't know what's happening actually. 

 

Latest update

 

I went through more of the modules, more than just the one which contained the code I was rewriting, and did as you said and this seems to have resolved the issues I had cited above.  

0
Comment actions Permalink

Update

 

I went through and did as you described for every single module in the entire jdk / java . The results are that when I have the project view open and I click on a class in the project view, the project view takes me down to external libraries and shows me the code there instead of the code in the source modules. The exact same thing with respect to navigating to a symbol. It's like the project view and the symbol finder prefer the jdk's sources to the project's. Rule is acting like :  if the source is known to belong to the JDK, just go straight there, full stop. This is very persistent behavior and I don't seem to be able to control it in any of the ways I tried or you described. \

 

update 2

Oh yeah that's what it does. Clicking on any type or class in Project View or the editor makes the Project View shuttle down to external libraries , find the class in the jdk and open it up. 

0
Comment actions Permalink

Hello java developer,

Please tell if you work with built modules of JDK? Which modules do you try to work with (please share the links to git if possible)? Thank you 

0

Please sign in to leave a comment.