Uploaded image for project: 'JDK'
  1. JDK
  2. JDK-8067914

Redundant type cast nodes in AST (follow up from JDK-8043741)

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: P4 P4
    • 9
    • 9
    • tools
    • b46
    • generic
    • Verified

        Given the following program:

        class S<T> { T t; }
        class C { class I { }; }
        class E extends S<C> {{
          t = new C();
          ((C) t).new I() { };
        }};
        public class X {
          public static void main(String[] args) { new E(); }
        }

        (the customer suggested workaround for https://bugs.openjdk.java.net/browse/JDK-8043741),
        the compiler ends up creating an abstract syntax tree for class E whose textual representation
        looks like:

        class E extends S {
            
            E() {
                super();
            }
            {
                t = new C();
                new E$1(this, <*nullchk*>((C)(C)t));
            }
        }

        i.e. there is a compiler inserted redundant type cast operation.

        While this is harmless (in fact this redundant cast does not make it to class files being trimmed
        by Gen.visitTypeCast), this is best avoided.

              sadayapalam Srikanth Adayapalam (Inactive)
              sadayapalam Srikanth Adayapalam (Inactive)
              Votes:
              0 Vote for this issue
              Watchers:
              3 Start watching this issue

                Created:
                Updated:
                Resolved: