question about JDK-7153958 "add constant pool reference to class containing inlined constants"

Dmitry Batkovich dmitry.batkovich at
Wed Sep 7 14:44:06 UTC 2016


1. There seems to be a problem while javac writes inlined constant
references to .class-file
Initial enhancement was implemented in
To understand my problem consider a little example:
public class Const1 {
  public static final String CONST = "";
public class Const2 {
  public static final String CONST = "";
public class Main {
    public static void main(String[] args) {
        if (Const1.CONST == "q" && Const2.CONST == "w") {

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. 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: <>

More information about the compiler-dev mailing list