4
  • On Windows 10 I downloaded and installed Eclipse Oxygen [Release (4.7.1a) Build id: 20171005-1200] using the Eclipse Installer.

  • I then created a trivial Java project (no module stuff) using the New Project wizard:

public class Demo1 {

  public static void main(String[] args) {
      new Demo1().test(0L);
  }

  void test(int i) {
      doStuff();
  }

  void test(long l) {
      doStuff();
  }

  void doStuff() {
      String s = "abcde";
      s = s.substring(2,4);
      System.out.print("s=");
      System.out.println( s.toString());
  }

}
  • It runs OK, and if I do CTL=>Open Implementation for test() or doStuff() or System or String or toString() or substr() everything is fine.

  • However, for println() and print() an error message is displayed:

Open Implementation

  • Also, a stack trace is written to the Error Log:

!ENTRY org.eclipse.jdt.ui 4 0 2017-10-23 01:42:54.695 !MESSAGE An error occurred while searching for implementations of 'print'. See error log for details. !STACK 1 Java Model Exception: Java Model Status [ is not on its project's build path] at org.eclipse.jdt.internal.core.JavaElement.newJavaModelException(JavaElement.java:570) at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:247) at org.eclipse.jdt.internal.core.Openable.openAncestors(Openable.java:505) at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:241) at org.eclipse.jdt.internal.core.Openable.openAncestors(Openable.java:505) at org.eclipse.jdt.internal.core.Openable.generateInfos(Openable.java:241) at org.eclipse.jdt.internal.core.SourceRefElement.generateInfos(SourceRefElement.java:107) at org.eclipse.jdt.internal.core.JavaElement.openWhenClosed(JavaElement.java:583) at org.eclipse.jdt.internal.core.BinaryType.getElementInfo(BinaryType.java:287) at org.eclipse.jdt.internal.core.JavaElement.getElementInfo(JavaElement.java:306) at org.eclipse.jdt.internal.core.BinaryType.isInterface(BinaryType.java:725) at org.eclipse.jdt.internal.ui.javaeditor.JavaElementImplementationHyperlink$1.run(JavaElementImplementationHyperlink.java:237) at org.eclipse.jface.operation.ModalContext$ModalContextThread.run(ModalContext.java:119) !SUBENTRY 1 org.eclipse.jdt.core 4 1006 2017-10-23 01:42:54.695 !MESSAGE is not on its project's build path

  • However, after clicking OK, the Implementation popup is displayed as expected, and clicking PrintStream sends me to the correct method implementation:

Implementation

This looks like a bug in Eclipse or its installer, but the issue is very basic yet I don't see any reports for it. I have a few questions arising:

  • Does anyone else get this issue, or is it working?

  • Is there any configuration I could/should do to fix this?

  • Any ideas why Open Implementation would be giving the error only for print() and println()?

skomisa
  • 16,436
  • 7
  • 61
  • 102
  • 1
    Do you also mean to say that you are able to access other methods(other than `print()` and `println()`) from within the `java.base` module without this error? – Naman Oct 23 '17 at 06:29
  • 2
    I reproduced your error. Looks like a bug for me. – ZhekaKozlov Oct 23 '17 at 06:41
  • 3
    I found something similar in Eclipse bug database: https://bugs.eclipse.org/bugs/show_bug.cgi?id=521995 – ZhekaKozlov Oct 23 '17 at 06:44
  • @nullpointer Good question, and the answer is no. On further testing it seems that I can view the implementation of any Class in java.base (e.g. System, ArrayList) but no methods. – skomisa Oct 23 '17 at 06:56
  • @skomisa Ya seems to be aligned to the link shared by ZhekaKozlov. – Naman Oct 23 '17 at 07:01
  • @ZhekaKozlov Thanks - I had missed that bug. If you post that as an answer I will accept it. It's not an exact match, but close enough, and https://bugs.eclipse.org/bugs/show_bug.cgi?id=522057 also looks relevant. – skomisa Oct 23 '17 at 07:03
  • @skomisa Also on that note, did you add JDK while configuring the project? – Naman Oct 23 '17 at 07:05
  • @nullpointer No, I didn't add JDK since I assumed the installer was updating an existing install of Eclipse. (It's the first time I have used it.) Is there something I could/should do?.... – skomisa Oct 23 '17 at 07:12
  • @skomisa Probably the part *New Project wizard* is where you should look for how the project is configured with java sdk. There must be a path configured for java library. – Naman Oct 23 '17 at 07:14

1 Answers1

1

This seems to be a bug in the current implementation as pointed out by @ZhekaKozlov and from another thread where @Stephan has shared a work in progress documentation for the future release's New & Noteworthy for Photon M3 states that:-

Note: It is not mandatory to run Eclipse with Java Runtime 9 to get the Java 9 support. However, a Java runtime 9 is required to be on a project's build path to compile a modular project against the system modules.

When a Java Runtime 9 is added to a project's build path, the system modules are listed under the System library in the package explorer:

enter image description here

I am assuming the --add-modules=ALL-SYSTEM was solving this while users were appending this as a -vmargs arg to eclipse.ini.

Naman
  • 27,789
  • 26
  • 218
  • 353
  • 1
    Perhaps I'm missing something, but I am not sure this is relevant since my project is not modular. Also, when I created a second project with the wizard that used jdk9 rather than JavaSE-9 the "java.activation" and "java.corba" entries in your screen shot above disappeared. Otherwise the second project behaved exactly as the first. i.e. It compiled and ran OK, but still gave the "open implementation" error for some java.base methods, though I can "open implementation" for String.toString(). – skomisa Oct 23 '17 at 07:39
  • 2
    @skomisa `String.toString()` is also itself exported by `java.base` via `java.lang`. So I don't see the reason why it should be accessible while the `System..` should not be. Also on the note of creating a project with JDK9 - Ideal way should be to use JavaSE9, I was eager to know if you on the other hand explicitly modified that or not. – Naman Oct 23 '17 at 07:46