diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ModifiersProvider.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ModifiersProvider.java index 637cb65111c..2a193cc79b3 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ModifiersProvider.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ModifiersProvider.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 @@ -137,9 +137,11 @@ public interface ModifiersProvider { } /** - * Checks that the method is concrete and not abstract. + * Returns true if this element is a method with a concrete implementation, or a type that can + * be instantiated. For example, array types return true for both {@link #isAbstract()} and this + * method. * - * @return whether the method is a concrete method + * @see ResolvedJavaType#isConcrete() */ default boolean isConcrete() { return !isAbstract(); diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaType.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaType.java index fff2a6dc2b2..272f821b7ca 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaType.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaType.java @@ -402,4 +402,9 @@ public interface ResolvedJavaType extends JavaType, ModifiersProvider, Annotated default ResolvedJavaField resolveField(UnresolvedJavaField unresolvedJavaField, ResolvedJavaType accessingClass) { return null; } + + @Override + default boolean isConcrete() { + return isArray() || !isAbstract(); + } } diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java index 9540b965520..14dbcdd6989 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaType.java @@ -196,6 +196,16 @@ public class TestResolvedJavaType extends TypeUniverse { } } + @Test + public void isConcreteTest() { + for (Class c : classes) { + ResolvedJavaType type = metaAccess.lookupJavaType(c); + boolean expected = c.isArray() || !isAbstract(c.getModifiers()); + boolean actual = type.isConcrete(); + assertEquals(expected, actual); + } + } + @Test public void lambdaInternalNameTest() { // Verify that the last dot in lambda types is properly handled when transitioning from