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 for this class will be loaded directly and used to define
  26  *  a non-findable class.
  27  */
  28 public class NonFindable implements Test {
  29 
  30     NonFindable other = null;
  31 
  32     private String realTest() {
  33         Object o = other;
  34         NonFindable local = this;
  35         local = other;
  36         local = (NonFindable) o;
  37         local = new NonFindable();
  38 
  39         set_other(null);
  40 
  41         local = getThis();
  42 
  43         set_other_maybe(new Object());
  44         set_other_maybe(this);
  45         return "NonFindable";
  46     }
  47 
  48     private NonFindable getThis() {
  49         return null;
  50     }
  51 
  52     private void set_other(NonFindable t) {
  53         other = t;
  54     }
  55 
  56     private void set_other_maybe(Object o) {
  57         if (o instanceof NonFindable) {
  58         }
  59     }
  60 
  61     public void test() {
  62         String result = realTest();
  63         // Make sure that the Utf8 constant pool entry for "NonFindable" is okay.
  64         if (!result.substring(0, 7).equals("NonFind") ||
  65             !result.substring(7).equals("able")) {
  66             throw new RuntimeException("'NonFindable string is bad: " + result);
  67         }
  68 
  69     }
  70 }