test/langtools/tools/javac/classfiles/attributes/ConstantValue/HasBrokenConstantValue.jcod
author jlahoda
Tue, 13 Aug 2019 10:27:34 +0200
changeset 57725 ffc34eaf7b49
permissions -rw-r--r--
8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object Summary: Produce an error when reading a classfile with a field with ConstantValue with a wrong type. Reviewed-by: vromero
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
57725
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
     1
/*
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
     2
 * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
     3
 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
     4
 *
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
     5
 * This code is free software; you can redistribute it and/or modify it
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
     6
 * under the terms of the GNU General Public License version 2 only, as
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
     7
 * published by the Free Software Foundation.
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
     8
 *
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
     9
 * This code is distributed in the hope that it will be useful, but WITHOUT
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    10
 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    11
 * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    12
 * version 2 for more details (a copy is included in the LICENSE file that
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    13
 * accompanied this code).
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    14
 *
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    15
 * You should have received a copy of the GNU General Public License version
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    16
 * 2 along with this work; if not, write to the Free Software Foundation,
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    17
 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    18
 *
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    19
 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    20
 * or visit www.oracle.com if you need additional information or have any
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    21
 * questions.
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    22
 */
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    23
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    24
// ConstantValue attribute on a field that has wrong type (j.l.Object):
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    25
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    26
class HasBrokenConstantValue {
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    27
  0xCAFEBABE;
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    28
  0; // minor version
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    29
  55; // version
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    30
  [] { // Constant Pool
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    31
    ; // first element is empty
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    32
    Method #3 #14; // #1
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    33
    class #15; // #2
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    34
    class #16; // #3
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    35
    Utf8 "VALUE"; // #4
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    36
    Utf8 "Ljava/lang/Object;"; // #5
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    37
    Utf8 "ConstantValue"; // #6
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    38
    String #17; // #7
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    39
    Utf8 "<init>"; // #8
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    40
    Utf8 "()V"; // #9
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    41
    Utf8 "Code"; // #10
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    42
    Utf8 "LineNumberTable"; // #11
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    43
    Utf8 "SourceFile"; // #12
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    44
    Utf8 "HasBrokenConstantValue.java"; // #13
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    45
    NameAndType #8 #9; // #14
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    46
    Utf8 "HasBrokenConstantValue"; // #15
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    47
    Utf8 "java/lang/Object"; // #16
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    48
    Utf8 ""; // #17
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    49
  } // Constant Pool
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    50
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    51
  0x0021; // access
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    52
  #2;// this_cpx
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    53
  #3;// super_cpx
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    54
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    55
  [] { // Interfaces
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    56
  } // Interfaces
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    57
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    58
  [] { // fields
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    59
    { // Member
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    60
      0x0019; // access
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    61
      #4; // name_cpx
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    62
      #5; // sig_cpx
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    63
      [] { // Attributes
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    64
        Attr(#6) { // ConstantValue
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    65
          #7;
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    66
        } // end ConstantValue
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    67
      } // Attributes
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    68
    } // Member
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    69
  } // fields
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    70
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    71
  [] { // methods
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    72
    { // Member
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    73
      0x0001; // access
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    74
      #8; // name_cpx
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    75
      #9; // sig_cpx
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    76
      [] { // Attributes
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    77
        Attr(#10) { // Code
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    78
          1; // max_stack
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    79
          1; // max_locals
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    80
          Bytes[]{
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    81
            0x2AB70001B1;
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    82
          }
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    83
          [] { // Traps
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    84
          } // end Traps
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    85
          [] { // Attributes
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    86
            Attr(#11) { // LineNumberTable
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    87
              [] { // LineNumberTable
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    88
                0  1;
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    89
              }
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    90
            } // end LineNumberTable
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    91
          } // Attributes
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    92
        } // end Code
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    93
      } // Attributes
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    94
    } // Member
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    95
  } // methods
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    96
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    97
  [] { // Attributes
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    98
    Attr(#12) { // SourceFile
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
    99
      #13;
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
   100
    } // end SourceFile
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
   101
  } // Attributes
ffc34eaf7b49 8228502: javac crashed on a broken classfile with ConstantValue attribute on a field of type Object
jlahoda
parents:
diff changeset
   102
} // end class HasBrokenConstantValue