1 /*
   2  * Copyright (c) 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 /*
  25  * The classfile does not fail verification but would fail when
  26  * getMethod
  27  */
  28 public class HiddenCantReflect implements HiddenTest {
  29 
  30     HiddenCantReflect other = null;
  31 
  32     private String realTest() {
  33         Object o = other;
  34         HiddenCantReflect local = this;
  35         local = other;
  36         local = (HiddenCantReflect) o;
  37         local = new HiddenCantReflect();
  38 
  39         set_other(null);
  40 
  41         local = getThis();
  42 
  43         set_other_maybe(new Object());
  44         set_other_maybe(this);
  45         return "HiddenCantReflect";
  46     }
  47 
  48     private HiddenCantReflect getThis() {
  49         return null;
  50     }
  51 
  52     private void set_other(HiddenCantReflect t) {
  53         other = t;
  54     }
  55 
  56     private void set_other_maybe(Object o) {
  57         if (o instanceof HiddenCantReflect) {
  58         }
  59     }
  60 
  61     public void test() {
  62         String result = realTest();
  63         // Make sure that the Utf8 constant pool entry for "HiddenCantReflect" is okay.
  64         if (!result.substring(0, 7).equals("HiddenC") ||
  65             !result.substring(7).equals("antReflect")) {
  66             throw new RuntimeException("'HiddenCantReflect string is bad: " + result);
  67         }
  68 
  69     }
  70 }