1 /*
   2  * Copyright (c) 2018, 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  * @test
  26  * @bug 8203435
  27  * @summary Test JVMs 5.4.3.6 with respect to a dynamically-computed constant and circularity.
  28  * @modules java.base/jdk.internal.misc
  29  * @library /test/lib
  30  * @compile CondyNestedResolution.jcod
  31  * @run main/othervm -Xverify:all CondyNestedResolutionTest
  32  */
  33 
  34 import jdk.test.lib.process.ProcessTools;
  35 import jdk.test.lib.process.OutputAnalyzer;
  36 import jdk.test.lib.compiler.InMemoryJavaCompiler;
  37 
  38 /*
  39  * JVMs section 5.4.3.6 Dynamically-Computed Constant and Call Site Resolution
  40  *     "Let X be the symbolic reference currently being resolved, and let Y be a static argument of X
  41  *      to be resolved as described above. If X and Y are both dynamically-computed constants, and if Y
  42  *      is either the same as X or has a static argument that references X through its static arguments,
  43  *      directly or indirectly, resolution fails with a StackOverflowError.
  44  */
  45 public class CondyNestedResolutionTest {
  46     public static void main(String args[]) throws Throwable {
  47         ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("CondyNestedResolution");
  48         OutputAnalyzer oa = new OutputAnalyzer(pb.start());
  49         oa.shouldContain("StackOverflowError");
  50         oa.shouldContain("bsm1arg");
  51         oa.shouldContain("hello1");
  52         oa.shouldContain("hello2");
  53         oa.shouldContain("hello4");
  54         oa.shouldContain("hello6");
  55         oa.shouldNotContain("hello3");
  56         oa.shouldNotContain("hello5");
  57         oa.shouldNotContain("bsm2arg");
  58         oa.shouldNotContain("bsm3arg");
  59         oa.shouldNotContain("bsm4arg");
  60         oa.shouldHaveExitValue(1);
  61     }
  62 }