Just out of curiosity, I'm trying to setup Eclipse to allow it to compile and run an application with a standard library class being patched.
I have 2 Java projects patch
and consumer
: one containing a string patch class (with a new method size()
, identical to length()
) and the other which should use said method size()
. The setup is the following one:
- patch
- bin (contains class files)
- src
- java
- lang
- String.java
- consumer
- src
- consumer
- Main.java
- module-info.java
Main.java:
package consumer;
public class Main {
public static void main(String[] args) {
String s = new String("hello");
System.out.println(s.size());
}
}
After compiling patch
(thereby getting String.class
inside patch/bin/java/lang/
) I know I can easily use:
java --patch-module java.base=patchpjt/bin/ consumer/src/consumer/Main.java
To correctly call the newly added method size()
, obtainining the result of 5
.
The problem is that in Eclipse method size
is still not recognized (the error is Method Size() is underfined for type String):
So my question is:
- How to configure Eclipse in order for the project
consumer
to correctly compile, run and show no errors? - How to configure Eclipse in order to show on the Content Assist the method
size()
?
I know I need to use the Build Path -> Module Path -> Edit Is Modular -> Details Tab -> Patched module
but I don't know how to configure both projects.
Some info you might find useful:
- Eclipse 2018-12 (4.10.0) Build id: 20181214-0600
Thanks for any kind reply.