-
Notifications
You must be signed in to change notification settings - Fork 216
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
8288303: C1: Miscompilation due to broken Class.getModifiers intrinsic
Backport-of: 8cd87e731bcaff2d7838995c68056742d577ad3b
- Loading branch information
Showing
2 changed files
with
135 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
118 changes: 118 additions & 0 deletions
118
test/hotspot/jtreg/compiler/intrinsics/klass/TestGetModifiers.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,118 @@ | ||
/* | ||
* Copyright (c) 2022, Red Hat, Inc. All rights reserved. | ||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. | ||
* | ||
* This code is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU General Public License version 2 only, as | ||
* published by the Free Software Foundation. | ||
* | ||
* This code is distributed in the hope that it will be useful, but WITHOUT | ||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or | ||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License | ||
* version 2 for more details (a copy is included in the LICENSE file that | ||
* accompanied this code). | ||
* | ||
* You should have received a copy of the GNU General Public License version | ||
* 2 along with this work; if not, write to the Free Software Foundation, | ||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. | ||
* | ||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA | ||
* or visit www.oracle.com if you need additional information or have any | ||
* questions. | ||
* | ||
*/ | ||
|
||
/* | ||
* @test | ||
* @library /test/lib | ||
* @run main/othervm -Xint | ||
* -XX:CompileCommand=dontinline,*TestGetModifiers.test | ||
* compiler.intrinsics.klass.TestGetModifiers | ||
*/ | ||
|
||
/* | ||
* @test | ||
* @requires vm.compiler1.enabled | ||
* @library /test/lib | ||
* @run main/othervm -XX:TieredStopAtLevel=1 -XX:+TieredCompilation | ||
* -XX:CompileCommand=dontinline,*TestGetModifiers.test | ||
* compiler.intrinsics.klass.TestGetModifiers | ||
*/ | ||
|
||
/* | ||
* @test | ||
* @requires vm.compiler2.enabled | ||
* @library /test/lib | ||
* @run main/othervm -XX:-TieredCompilation | ||
* -XX:CompileCommand=dontinline,*TestGetModifiers.test | ||
* compiler.intrinsics.klass.TestGetModifiers | ||
*/ | ||
|
||
package compiler.intrinsics.klass; | ||
|
||
import java.lang.reflect.Modifier; | ||
import static java.lang.reflect.Modifier.*; | ||
|
||
import jdk.test.lib.Asserts; | ||
|
||
public class TestGetModifiers { | ||
public static class T1 { | ||
} | ||
|
||
public static final class T2 { | ||
} | ||
|
||
private static class T3 { | ||
} | ||
|
||
protected static class T4 { | ||
} | ||
|
||
class T5 { | ||
} | ||
|
||
interface T6 { | ||
} | ||
|
||
static void test(Class cl, int expectedMods) { | ||
for (int i = 0; i < 100_000; i++) { | ||
int actualMods = cl.getModifiers(); | ||
if (actualMods != expectedMods) { | ||
throw new IllegalStateException("Error with: " + cl); | ||
} | ||
} | ||
} | ||
|
||
public static void main(String... args) { | ||
test(T1.class, PUBLIC | STATIC); | ||
test(T2.class, PUBLIC | FINAL | STATIC); | ||
test(T3.class, PRIVATE | STATIC); | ||
test(T4.class, PROTECTED | STATIC); | ||
test(new TestGetModifiers().new T5().getClass(), 0); | ||
test(T6.class, ABSTRACT | STATIC | INTERFACE); | ||
|
||
test(int.class, PUBLIC | ABSTRACT | FINAL); | ||
test(long.class, PUBLIC | ABSTRACT | FINAL); | ||
test(double.class, PUBLIC | ABSTRACT | FINAL); | ||
test(float.class, PUBLIC | ABSTRACT | FINAL); | ||
test(char.class, PUBLIC | ABSTRACT | FINAL); | ||
test(byte.class, PUBLIC | ABSTRACT | FINAL); | ||
test(short.class, PUBLIC | ABSTRACT | FINAL); | ||
test(void.class, PUBLIC | ABSTRACT | FINAL); | ||
test(int[].class, PUBLIC | ABSTRACT | FINAL); | ||
test(long[].class, PUBLIC | ABSTRACT | FINAL); | ||
test(double[].class, PUBLIC | ABSTRACT | FINAL); | ||
test(float[].class, PUBLIC | ABSTRACT | FINAL); | ||
test(char[].class, PUBLIC | ABSTRACT | FINAL); | ||
test(byte[].class, PUBLIC | ABSTRACT | FINAL); | ||
test(short[].class, PUBLIC | ABSTRACT | FINAL); | ||
test(Object[].class, PUBLIC | ABSTRACT | FINAL); | ||
test(TestGetModifiers[].class, PUBLIC | ABSTRACT | FINAL); | ||
|
||
test(new TestGetModifiers().getClass(), PUBLIC); | ||
test(new T1().getClass(), PUBLIC | STATIC); | ||
test(new T2().getClass(), PUBLIC | FINAL | STATIC); | ||
test(new T3().getClass(), PRIVATE | STATIC); | ||
test(new T4().getClass(), PROTECTED | STATIC); | ||
} | ||
} |
72603ff
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Review
Issues