question about JDK-7153958 "add constant pool reference to class containing inlined constants"
Dmitry Batkovich
dmitry.batkovich at jetbrains.com
Wed Sep 7 14:44:06 UTC 2016
Hi.
1. There seems to be a problem while javac writes inlined constant
references to .class-file
Initial enhancement was implemented in
https://bugs.openjdk.java.net/browse/JDK-7153958.
To understand my problem consider a little example:
---Const1.java:
public class Const1 {
public static final String CONST = "";
}
---Const2.java:
public class Const2 {
public static final String CONST = "";
}
---Main.java:
public class Main {
public static void main(String[] args) {
if (Const1.CONST == "q" && Const2.CONST == "w") {
SomeClass.doSome();
}
}
}
Here I have a constant condition "Const1.CONST == "q" && Const2.CONST ==
"w"" that will be inlined by javac.
Since it was inlined I expect to see Const1 and Const2 in constant pool of
Main.class. But I see only Const1.
Seems there is a bug around of Lower#addPrunedInfo() method usages and test
case CPoolRefClassContainingInlinedCts
is poor because it tests only simplest cases.
2. https://bugs.openjdk.java.net/browse/JDK-7153958 was introduced to help
analyze dependencies(!).
Consider example above: here then-statement (SomeClass.doSome()) is inlined
since if-statement condition is always false and reference to SomeClass is
not presented
in constant pool of Main.class. But it's required to analyze dependencies
of Main class.
So, do you have any plans to fix/enhance these problems?
I think that JDK-7153958 is useless and confusing at this moment with
current implementation but can be very useful for tools developers.
Dmitry Batkovich
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.openjdk.java.net/pipermail/compiler-dev/attachments/20160907/e2af1969/attachment-0001.html>
More information about the compiler-dev
mailing list