mirror of
https://github.com/openjdk/jdk.git
synced 2026-07-28 20:03:39 +00:00
8325257: jshell reports NoSuchFieldError with instanceof primitive type
Reviewed-by: mcimadamore
This commit is contained in:
parent
f2f634448e
commit
e0d98dd301
@ -2998,7 +2998,7 @@ public class Lower extends TreeTranslator {
|
||||
boxIfNeeded(make.Ident(dollar_s), types.unboxedType(tree.expr.type)));
|
||||
} else {
|
||||
exactnessCheck = make.at(tree.pos())
|
||||
.TypeTest(tree.expr, make.Type(types.boxedClass(tree.pattern.type).type))
|
||||
.TypeTest(make.Ident(dollar_s), make.Type(types.boxedClass(tree.pattern.type).type))
|
||||
.setType(syms.booleanType);
|
||||
}
|
||||
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2024, Oracle and/or its affiliates. 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
|
||||
@ -22,7 +22,7 @@
|
||||
*/
|
||||
/*
|
||||
* @test
|
||||
* @bug 8304487
|
||||
* @bug 8304487 8325257
|
||||
* @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview)
|
||||
* @build KullaTesting TestingInputStream
|
||||
* @run testng PrimitiveInstanceOfTest
|
||||
@ -49,6 +49,17 @@ public class PrimitiveInstanceOfTest extends KullaTesting {
|
||||
assertEval("i instanceof Number");
|
||||
}
|
||||
|
||||
public void testInstanceOfObjectToPrimitive() {
|
||||
assertEval("Object o = 1L;");
|
||||
assertEval("o instanceof long");
|
||||
assertEval("o instanceof Long");
|
||||
}
|
||||
|
||||
public void testInstanceOfPrimitiveToPrimitiveInvokingExactnessMethod() {
|
||||
assertEval("int b = 1024;");
|
||||
assertEval("b instanceof byte");
|
||||
}
|
||||
|
||||
@org.testng.annotations.BeforeMethod
|
||||
public void setUp() {
|
||||
super.setUp(bc -> bc.compilerOptions("--source", System.getProperty("java.specification.version"), "--enable-preview").remoteVMOptions("--enable-preview"));
|
||||
|
||||
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2023, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2024, Oracle and/or its affiliates. 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
|
||||
@ -23,15 +23,17 @@
|
||||
|
||||
/*
|
||||
* @test
|
||||
* @bug 8304487
|
||||
* @bug 8304487 8325257
|
||||
* @summary Compiler Implementation for Primitive types in patterns, instanceof, and switch (Preview)
|
||||
* @enablePreview
|
||||
* @compile PrimitiveInstanceOfTypeComparisonOp.java
|
||||
* @run main/othervm PrimitiveInstanceOfTypeComparisonOp
|
||||
*/
|
||||
public class PrimitiveInstanceOfTypeComparisonOp {
|
||||
public static final int qualI = 42;
|
||||
|
||||
public static void main(String[] args) {
|
||||
assertEquals(true, qualifiedExprConversion());
|
||||
assertEquals(true, identityPrimitiveConversion());
|
||||
assertEquals(true, wideningPrimitiveConversion());
|
||||
assertEquals(true, narrowingPrimitiveConversion());
|
||||
@ -51,6 +53,10 @@ public class PrimitiveInstanceOfTypeComparisonOp {
|
||||
assertEquals(true, exprStaticallyQualified());
|
||||
}
|
||||
|
||||
public static boolean qualifiedExprConversion() {
|
||||
return PrimitiveInstanceOfTypeComparisonOp.qualI instanceof int;
|
||||
}
|
||||
|
||||
public static boolean identityPrimitiveConversion() {
|
||||
int i = 42;
|
||||
return i instanceof int;
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user