diff --git a/.ci/ci.jsonnet b/.ci/ci.jsonnet index a29ecb869df..efaa8aabbe3 100644 --- a/.ci/ci.jsonnet +++ b/.ci/ci.jsonnet @@ -1,10 +1,12 @@ -# To process this file using Jsonnet commandline interpreter -# Use the following command: jsonnet .ci/ci.jsonnet +# This file is rendered into JSON with: +# +# sjsonnet .ci/ci.jsonnet +# +# See: https://github.com/databricks/sjsonnet/releases -# https://github.com/graalvm/labs-openjdk/blob/master/doc/testing.md +# JDK tests to run local run_test_spec = 'test/hotspot/jtreg/compiler/jvmci test/jdk/tools/jlink/plugins/SaveJlinkArgfilesPluginTest.java'; - local common = import 'common.libsonnet'; { @@ -33,7 +35,7 @@ local common = import 'common.libsonnet'; notify_emails: [defs.build_failure_notify], publishArtifacts: [ { - name: 'jdk-%s-%s-%s_tlda' % [release.name, major_java_version, release.version], + name: 'jdk-%s-%s-%s_tlda' % [release.name, major_java_version, release.build], dir: '.', patterns: [prebuild_artifact_url], }, @@ -55,7 +57,7 @@ local common = import 'common.libsonnet'; '--fingerprint=' + 'prebuild.fingerprint', '--graalvm-version=%s' % release.name, '--check-exists', - release.version, + release.build, 'labsjdk-ee', 'jdk_tlda', ], @@ -64,7 +66,7 @@ local common = import 'common.libsonnet'; }, - # Creates a builder object. + # Creates a builder object. This builds all variants (i.e. jdk, llvm and static libs). # # number major_java_version: major Java version (e.g. 25) # string edition: "ce" or "ee" @@ -165,7 +167,7 @@ local common = import 'common.libsonnet'; local requireTLDAArtifacts = if edition == 'ee' then [ { - name: 'jdk-%s-%s-%s_tlda' % [release.name, major_java_version, release.version], + name: 'jdk-%s-%s-%s_tlda' % [release.name, major_java_version, release.build], dir: '.', }, ] else [], @@ -180,7 +182,7 @@ local common = import 'common.libsonnet'; '--log=' + if os == 'windows' then 'info' else 'warn', '--java-major-version=' + major_java_version, '--java-build-number=' + build_number, - '--jvmci-version=' + release.version, + '--jvmci-version=' + release.build, '--boot-jdk=${BOOT_JDK}', '--patches=' + jdk_src_dir + '/patches.tar.gz', '--clean-after-build', @@ -267,7 +269,7 @@ local common = import 'common.libsonnet'; ] + static_libs_platforms(major_java_version, release, defs), # For building musl boot JDKs SourceBuild(java_version, release, defs):: common.LinuxAMD64(defs, java_version) + common.AMD64 + common.OCI + common.DefaultBootJDK + common.Packages + common.mxDependencies + { - local jvmci_build_number = release.version, + local jvmci_build_number = release.build, local repo_name = 'labsjdk-ee', local jdk_conf_name = 'linux-x86_64-server-release', local src_bundle_suffixes = ['', '-security'], @@ -305,21 +307,21 @@ local common = import 'common.libsonnet'; '--enable-jvm-feature-shenandoahgc', '--with-version-build=${JAVA_VERSION_BUILD}', '--with-version-pre=', - '--with-version-opt=LTS-jvmci-' + release.name + '-' + release.version, + '--with-version-opt=LTS-jvmci-' + release.name + '-' + release.build, ], ['make', 'source'], ] + [self.copy_source_bundle(suffix) for suffix in src_bundle_suffixes] + [ ['zip', '-ur', '../results/jdk-${JAVA_VERSION}+${JAVA_VERSION_BUILD}_src.zip', '$BUILD_MAIN/closed/make/conf/*'], - ['tar', 'czf', '../' + 'labsjdk-ee-${JAVA_VERSION}+${JAVA_VERSION_BUILD}-jvmci-%s-%s-${SNAPSHOT_ID}-src.tar.gz' % [release.name, release.version], '../results'], + ['tar', 'czf', '../' + 'labsjdk-ee-${JAVA_VERSION}+${JAVA_VERSION_BUILD}-jvmci-%s-%s-${SNAPSHOT_ID}-src.tar.gz' % [release.name, release.build], '../results'], ['cd', '$JDK_SOURCE/jvmci'], ] + [self.unzip_source_bundle(suffix) for suffix in src_bundle_suffixes] + [ [ 'sh', 'configure', '--with-version-pre=', - '--with-version-opt=jvmci-' + release.version, + '--with-version-opt=jvmci-' + release.build, '--with-devkit=$DEVKIT_ROOT', '--with-boot-jdk=$BOOT_JDK', '--with-version-build=${JAVA_VERSION_BUILD}', @@ -330,10 +332,10 @@ local common = import 'common.libsonnet'; ['make', 'images', 'static-libs-bundles'], [ 'artifact_uploader.py', - '../' + 'labsjdk-ee-${JAVA_VERSION}+${JAVA_VERSION_BUILD}-jvmci-%s-%s-${SNAPSHOT_ID}-src.tar.gz' % [release.name, release.version], - 'labsjdk/' + 'labsjdk-ee-${JAVA_VERSION}+${JAVA_VERSION_BUILD}-jvmci-%s-%s-${SNAPSHOT_ID}-src.tar.gz' % [release.name, release.version], + '../' + 'labsjdk-ee-${JAVA_VERSION}+${JAVA_VERSION_BUILD}-jvmci-%s-%s-${SNAPSHOT_ID}-src.tar.gz' % [release.name, release.build], + 'labsjdk/' + 'labsjdk-ee-${JAVA_VERSION}+${JAVA_VERSION_BUILD}-jvmci-%s-%s-${SNAPSHOT_ID}-src.tar.gz' % [release.name, release.build], 'labsjdk', - '--version', '${JAVA_VERSION}+${JAVA_VERSION_BUILD}-jvmci-%s-%s-${SNAPSHOT_ID}' % [release.name, release.version], + '--version', '${JAVA_VERSION}+${JAVA_VERSION_BUILD}-jvmci-%s-%s-${SNAPSHOT_ID}' % [release.name, release.build], '--jdk', java_version + '', '--revision', ['git', '-C', '$JDK_SOURCE/' + repo_name + '/open', 'rev-parse', 'HEAD'], '--edition', 'ee', @@ -361,75 +363,8 @@ local common = import 'common.libsonnet'; ], }, - CreateGraalIntegrationPR(release, defs):: common.Linux + common.AMD64 + common.OCI { - name: 'graal-integration-automation-release-%s' % release.name, - targets: ['ondemand'], - notify_emails: [defs.build_failure_notify], - packages+: { - 'pip:requests': '2.25.1', - 'pip:python-dateutil': '2.8.2', - }, - capabilities+: ['e4_36_256'], - docker: { - image: defs.linux_docker_image_amd64, - }, - python_version: '3', - run: common.clone_labsjdk_builder(defs, false) + [ - ['set-export', 'BUILD_MAIN', '$PWD'], - ['cp', '${LABSJDK_BUILDER_DIR}/update_ci_imports.py', '.'], - ['cp', '${LABSJDK_BUILDER_DIR}/util.py', '.'], - ['cp', '${LABSJDK_BUILDER_DIR}/snapshot_id.py', '.'], - ['cp', '${LABSJDK_BUILDER_DIR}/release_labsjdks.py', '.'], - ['git', 'config', '--global', 'user.email', defs.ol_automation_user], - ['git', 'config', '--global', 'user.name', 'ol-automation_ww'], - ['git', 'clone', '--config', 'core.autocrlf=input', '--branch', 'master', '--quiet', defs.graal_url, '$BUILD_MAIN/graal'], - ['git', 'clone', '--config', 'core.autocrlf=input', '--branch', 'master', '--quiet', defs.graal_enterprise_url, '$BUILD_MAIN/graal-enterprise'], - ['git', 'clone', '--config', 'core.autocrlf=input', '--branch', 'master', '--quiet', defs.graalos_url, '$BUILD_MAIN/graalos'], - ['git', 'clone', '--config', 'core.autocrlf=input', '--quiet', defs.buildbot_ci_url, '$BUILD_MAIN/buildbot-ci'], - - [ 'python3', '-u', '${LABSJDK_BUILDER_DIR}/graal_automation.py', - '--buildbot-ci-path', '$BUILD_MAIN/buildbot-ci/pr_creator.py', - '--graal-path', '$BUILD_MAIN/graal', - '--graal-enterprise-path', '$BUILD_MAIN/graal-enterprise', - '--graalos-path', '$BUILD_MAIN/graalos', - '--target-branch', 'master', - '--candidate-jvmci-release', '%s' % release.candidate_jvmci_release, - '--reviewers', defs.graal_prs_default_reviewers + ',' + '${BLAME_LIST}', - ], - ], - }, - - GraalDeployAutomationJob(release, defs):: common.Linux + common.AMD64 + common.OCI { - name: 'labsjdk-deploy-automation-release-%s' % release.name, - targets: ['ondemand'], - notify_emails: [defs.build_failure_notify], - packages+: { - 'pip:requests': '2.25.1', - 'pip:python-dateutil': '2.8.2', - }, - docker: { - image: defs.linux_docker_image_amd64, - }, - capabilities+: ['e4_36_256'], - python_version: '3', - run: common.clone_labsjdk_builder(defs, false) + [ - ['set-export', 'BUILD_MAIN', '$PWD'], - ['set-export', 'HTTP_HTTPS_PROXY', defs.proxy_url], - ['cp', '${LABSJDK_BUILDER_DIR}/release_labsjdks.py', '.'], - ['cp', '${LABSJDK_BUILDER_DIR}/util.py', '.'], - ['cp', '${LABSJDK_BUILDER_DIR}/snapshot_id.py', '.'], - - ['python3', '-u', '${LABSJDK_BUILDER_DIR}/deploy_automation.py', - '--graal-workdir', '$BUILD_MAIN', - '--candidate-jvmci-release', '%s' % release.candidate_jvmci_release, - '--graal-integration-branch', 'master', - '--allow-missing', 'patches', - '--upload-ce-artifact', '%s' % release.github_upload_labsjdk_ce, - '--pass-snapshots-file', 'true', - ], - ], - }, - + # Only used by gate jobs to test that building labsjdk works. + # It omits builds of static libs and llvm and also does no uploading. BuildValidation(defs, conf, is_musl_build, graalvm_version):: conf + setupJDKSources(conf) + (if is_musl_build then common.MuslBootJDK else common.DefaultBootJDK) + { name: 'gate-build-jdk' + conf.name, timelimit: '3:00:00', # Windows is the long pole @@ -456,11 +391,7 @@ local common = import 'common.libsonnet'; run+: (if !is_musl_build then [ # Checks that each devkit mentioned in this file corresponds to a devkit in make/conf/jib-profiles.js ['python3', '-u', conf.path('${PWD}/.ci/check_devkit_versions.py')], - ] else []) + [ - ['set-export', 'LABSJDK_BUILDER_DIR', conf.path('${PWD}/../labsjdk-builder')], - ['git', 'clone', '--quiet', '--config', 'core.autocrlf=input', defs.labsjdk_builder_url, '${LABSJDK_BUILDER_DIR}'], - ['git', '-C', '${LABSJDK_BUILDER_DIR}', 'checkout', common.labsjdk_builder_version], - + ] else []) + common.clone_labsjdk_builder(defs, conf.os == 'windows') + [ # This restricts cygwin to be on the PATH only while using jib. # It must not be on the PATH when building Graal. ['set-export', 'OLD_PATH', '${PATH}'], @@ -484,14 +415,13 @@ local common = import 'common.libsonnet'; common.LinuxDockerAMD64Musl(defs), ], - DefineBuilds(defs):: [self.BuildValidation(defs, conf, is_musl_build=false, graalvm_version=25.1) for conf in build_confs(defs)] + - [self.BuildValidation(defs, conf, is_musl_build=true, graalvm_version=25.1) for conf in amd64_musl_confs(defs)], + DefineBuilds(defs):: + [self.BuildValidation(defs, conf, is_musl_build=false, graalvm_version=25.1) for conf in build_confs(defs)] + + [self.BuildValidation(defs, conf, is_musl_build=true, graalvm_version=25.1) for conf in amd64_musl_confs(defs)], CreateBuilds(major_java_version, releases, defs):: [self.Prebuild(major_java_version, release, defs) for release in releases] + - [self.SourceBuild(major_java_version, release, defs) for release in releases] + - [self.CreateGraalIntegrationPR(release, defs) for release in releases] + - [self.GraalDeployAutomationJob(release, defs) for release in releases] + [self.SourceBuild(major_java_version, release, defs) for release in releases] + produce_builds(major_java_version, releases, false, false, defs) + produce_builds(major_java_version, releases, true, false, defs) diff --git a/.ci/common.libsonnet b/.ci/common.libsonnet index 80ad4ae572b..c03f34a9017 100644 --- a/.ci/common.libsonnet +++ b/.ci/common.libsonnet @@ -1,57 +1,58 @@ -# One-off snapshots metadata -local one_off_release = { - name: '25.1', - version: 'b10', - candidate_jvmci_release: '25.0.1+8-jvmci-25.1-b10', - github_upload_labsjdk_ce: 'true', - java_versions: [25], - musl: [25], - llvm: [25], -}; - - { + # The JVMCI releases that can be built from this repo. + jvmci_releases:: [ + self.JVMCIRelease(name='25.1', build='b10', jdk_version='25.0.1+8') + ], + + # Specifies a JVMCI release. + # + # name: + # The release name (see GR-70870). The value is an arbitrary string. + # It may look like a version (e.g. "25.1") but can just as easily be + # something like "Feature". + # See: jdk.graal.compiler.hotspot.JVMCIVersionCheck.Version#releaseName + # + # build: + # The JVMCI build number string (e.g. "b03" or "b10") + # See: jdk.graal.compiler.hotspot.JVMCIVersionCheck.Version#jvmciBuild + # + # jdk_version: + # The JDK version info to include in artifact names (e.g. "25.0.1+8") + # + JVMCIRelease(name, build, jdk_version):: { + name: name, + build: build + }, - labsjdk_builder_version:: '243066362288ec0c8557bf96140c2578630448cd', - -# This function is used to clone closed and open JDK repository -# Always checkout branch jdk25 for labsjdk-ee repository -# Always checkout the revision defined in MAIN_REVISION environement variable for labsjdk-ce repository - clone(defs, repo, release, dst_dir, is_windows=false, is_closed=false):: [ - ['git', 'clone', '--config', 'core.autocrlf=input', '--quiet', defs.bitbucket_base_url + repo + '.git', dst_dir], -] + (if is_closed then [ - ['git', '-C', dst_dir, 'checkout', 'jdk25'], -] else [ - ['git', '-C', dst_dir, 'checkout', '${MAIN_REVISION}'], -]), - -# This function is used to clone labsjdk-builder repository - clone_labsjdk_builder(defs, is_windows=false):: (if !is_windows then [ - ['set-export', 'LABSJDK_BUILDER_DIR', '${PWD}/labsjdk-builder'], -] else [ - ['set-export', 'LABSJDK_BUILDER_DIR', '${PWD}' + '\\' + 'labsjdk-builder'], -]) + [ - ['git', 'clone', '--quiet', '--config', 'core.autocrlf=input', defs.labsjdk_builder_url, '${LABSJDK_BUILDER_DIR}'], - ['git', '-C', '${LABSJDK_BUILDER_DIR}', 'checkout', self.labsjdk_builder_version], -], + # Version of the labsjdk-builder scripts to use + labsjdk_builder_version:: '243066362288ec0c8557bf96140c2578630448cd', + + # Clones a JDK repository + # If `!is_closed`, then the cloned repo is checked out to branch ${MAIN_REVISION}. + # If `is_closed`, then the cloned repo is checked out to branch jdk25. + clone(defs, repo, release, dst_dir, is_windows=false, is_closed=false):: [ + ['git', 'clone', '--config', 'core.autocrlf=input', '--quiet', defs.bitbucket_base_url + repo + '.git', dst_dir], + ] + (if is_closed then [ + ['git', '-C', dst_dir, 'checkout', 'jdk25'], + ] else [ + ['git', '-C', dst_dir, 'checkout', '${MAIN_REVISION}'], + ]), + + # Clones the labsjdk-builder repository to ${PWD}/labsjdk-builder + clone_labsjdk_builder(defs, is_windows=false):: (if !is_windows then [ + ['set-export', 'LABSJDK_BUILDER_DIR', '${PWD}/../labsjdk-builder'], + ] else [ + ['set-export', 'LABSJDK_BUILDER_DIR', '${PWD}\\..\\labsjdk-builder'], + ]) + [ + ['git', 'clone', '--quiet', '--config', 'core.autocrlf=input', defs.labsjdk_builder_url, '${LABSJDK_BUILDER_DIR}'], + ['git', '-C', '${LABSJDK_BUILDER_DIR}', 'checkout', self.labsjdk_builder_version], + ], # Returns the value of the `name` field if it exists in `obj` otherwise `default`. get(obj, name, default=null):: if obj == null then default else if std.objectHas(obj, name) then obj[name] else default, - # Specifies a JVMCI release currently in development and - JVMCIRelease(name, version, java_versions, candidate_jvmci_release, github_upload_labsjdk_ce, has_musl_static_libs, has_llvm_libs):: { - name: name, - version: version, - java_versions: java_versions, - candidate_jvmci_release: candidate_jvmci_release, - github_upload_labsjdk_ce: github_upload_labsjdk_ce, - has_musl_static_libs: has_musl_static_libs, - has_llvm_libs: has_llvm_libs, - }, - jvmci_releases:: [self.JVMCIRelease(one_off_release.name, one_off_release.version, one_off_release.java_versions, one_off_release.candidate_jvmci_release, one_off_release.github_upload_labsjdk_ce, true, false)], - # Returns true if `str` contains `needle` as a substring. contains(str, needle):: std.findSubstr(needle, str) != [], @@ -274,6 +275,4 @@ local one_off_release = { name+: '-aarch64', arch:: 'aarch64', }, - - } diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJDKReflection.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJDKReflection.java index 280e5ee2aad..dab33a6c86e 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJDKReflection.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJDKReflection.java @@ -22,23 +22,21 @@ */ package jdk.vm.ci.hotspot; -import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; +import jdk.vm.ci.common.JVMCIError; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.JavaKind; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; -import java.lang.annotation.Annotation; import java.lang.reflect.Array; -import java.lang.reflect.Constructor; import java.lang.reflect.Executable; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Type; import java.util.HashMap; -import jdk.vm.ci.common.JVMCIError; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.JavaKind; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; +import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; /** * Implementation of {@link HotSpotJVMCIReflection} in terms of standard JDK reflection API. This is @@ -68,24 +66,6 @@ boolean isAssignableFrom(HotSpotResolvedObjectTypeImpl holder, HotSpotResolvedOb } - @Override - Annotation[] getAnnotations(HotSpotResolvedObjectTypeImpl holder) { - Class javaMirror = getMirror(holder); - return javaMirror.getAnnotations(); - } - - @Override - Annotation[] getDeclaredAnnotations(HotSpotResolvedObjectTypeImpl holder) { - Class javaMirror = getMirror(holder); - return javaMirror.getDeclaredAnnotations(); - } - - @Override - T getAnnotation(HotSpotResolvedObjectTypeImpl holder, Class annotationClass) { - Class javaMirror = getMirror(holder); - return javaMirror.getAnnotation(annotationClass); - } - @Override boolean isLocalClass(HotSpotResolvedObjectTypeImpl holder) { Class javaMirror = getMirror(holder); @@ -132,46 +112,11 @@ ResolvedJavaMethod.Parameter[] getParameters(HotSpotResolvedJavaMethodImpl javaM return res; } - @Override - Annotation[][] getParameterAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - return getMethod(javaMethod).getParameterAnnotations(); - } - @Override Type[] getGenericParameterTypes(HotSpotResolvedJavaMethodImpl javaMethod) { return getMethod(javaMethod).getGenericParameterTypes(); } - @Override - Annotation[] getFieldAnnotations(HotSpotResolvedJavaFieldImpl javaField) { - return getField(javaField).getAnnotations(); - } - - @Override - Annotation[] getMethodAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - return getMethod(javaMethod).getAnnotations(); - } - - @Override - Annotation[] getMethodDeclaredAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - return getMethod(javaMethod).getDeclaredAnnotations(); - } - - @Override - Annotation[] getFieldDeclaredAnnotations(HotSpotResolvedJavaFieldImpl javaField) { - return getField(javaField).getDeclaredAnnotations(); - } - - @Override - T getMethodAnnotation(HotSpotResolvedJavaMethodImpl javaMethod, Class annotationClass) { - return getMethod(javaMethod).getAnnotation(annotationClass); - } - - @Override - T getFieldAnnotation(HotSpotResolvedJavaFieldImpl javaField, Class annotationClass) { - return getField(javaField).getAnnotation(annotationClass); - } - @Override HotSpotResolvedObjectTypeImpl getType(HotSpotObjectConstantImpl object) { Object value = resolveObject(object); @@ -191,8 +136,7 @@ String asString(HotSpotObjectConstantImpl object) { @Override ResolvedJavaType asJavaType(HotSpotObjectConstantImpl object) { Object value = resolveObject(object); - if (value instanceof Class) { - Class javaClass = (Class) value; + if (value instanceof Class javaClass) { return runtime().fromClass(javaClass); } if (value instanceof ResolvedJavaType) { @@ -306,11 +250,7 @@ static Executable getMethod(HotSpotResolvedJavaMethodImpl method) { /** * Gets a {@link Field} object corresponding to {@code field}. This method guarantees the same - * {@link Field} object is returned if called twice on the same {@code field} value. This is - * required to ensure the results of {@link HotSpotResolvedJavaFieldImpl#getAnnotations()} and - * {@link HotSpotResolvedJavaFieldImpl#getAnnotation(Class)} are stable (i.e., for a given field - * {@code f} and annotation class {@code a}, the same object is returned for each call to - * {@code f.getAnnotation(a)}). + * {@link Field} object is returned if called twice on the same {@code field} value. */ static Field getField(HotSpotResolvedJavaFieldImpl field) { HotSpotResolvedObjectTypeImpl declaringClass = field.getDeclaringClass(); diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIReflection.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIReflection.java index 7d37739069d..24a2fd1ac0e 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIReflection.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotJVMCIReflection.java @@ -22,13 +22,12 @@ */ package jdk.vm.ci.hotspot; -import java.lang.annotation.Annotation; -import java.lang.reflect.Type; - import jdk.vm.ci.meta.JavaConstant; import jdk.vm.ci.meta.ResolvedJavaMethod; import jdk.vm.ci.meta.ResolvedJavaType; +import java.lang.reflect.Type; + /** * API for reflecting on the internals of HotSpot JVMCI types and objects. */ @@ -38,12 +37,6 @@ abstract class HotSpotJVMCIReflection { abstract boolean isAssignableFrom(HotSpotResolvedObjectTypeImpl holder, HotSpotResolvedObjectTypeImpl otherType); - abstract Annotation[] getAnnotations(HotSpotResolvedObjectTypeImpl holder); - - abstract Annotation[] getDeclaredAnnotations(HotSpotResolvedObjectTypeImpl holder); - - abstract T getAnnotation(HotSpotResolvedObjectTypeImpl holder, Class annotationClass); - abstract boolean isLocalClass(HotSpotResolvedObjectTypeImpl holder); abstract boolean isMemberClass(HotSpotResolvedObjectTypeImpl holder); @@ -56,20 +49,8 @@ abstract class HotSpotJVMCIReflection { abstract ResolvedJavaMethod.Parameter[] getParameters(HotSpotResolvedJavaMethodImpl javaMethod); - abstract Annotation[][] getParameterAnnotations(HotSpotResolvedJavaMethodImpl javaMethod); - abstract Type[] getGenericParameterTypes(HotSpotResolvedJavaMethodImpl javaMethod); - abstract Annotation[] getFieldAnnotations(HotSpotResolvedJavaFieldImpl javaMethod); - - abstract Annotation[] getMethodAnnotations(HotSpotResolvedJavaMethodImpl javaField); - - abstract Annotation[] getMethodDeclaredAnnotations(HotSpotResolvedJavaMethodImpl javaMethod); - - abstract Annotation[] getFieldDeclaredAnnotations(HotSpotResolvedJavaFieldImpl javaMethod); - - abstract T getMethodAnnotation(HotSpotResolvedJavaMethodImpl javaMethod, Class annotationClass); - abstract HotSpotResolvedObjectTypeImpl getType(HotSpotObjectConstantImpl object); abstract String asString(HotSpotObjectConstantImpl object); @@ -95,8 +76,6 @@ abstract class HotSpotJVMCIReflection { abstract JavaConstant boxPrimitive(JavaConstant source); - abstract T getFieldAnnotation(HotSpotResolvedJavaFieldImpl javaField, Class annotationClass); - /** * Resolves {@code objectHandle} to a raw object if possible. * diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java index a0fbfaf3283..eaeae7a1eb9 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaFieldImpl.java @@ -29,11 +29,8 @@ import jdk.vm.ci.meta.annotation.AbstractAnnotated; import jdk.vm.ci.meta.annotation.AnnotationsInfo; -import java.lang.annotation.Annotation; - import static jdk.internal.misc.Unsafe.ADDRESS_SIZE; import static jdk.vm.ci.hotspot.CompilerToVM.compilerToVM; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; import static jdk.vm.ci.hotspot.HotSpotVMConfig.config; import static jdk.vm.ci.hotspot.UnsafeAccess.UNSAFE; @@ -204,30 +201,6 @@ private boolean hasAnnotations(boolean typeAnnotations) { return false; } - @Override - public Annotation[] getAnnotations() { - if (!hasAnnotations(false)) { - return new Annotation[0]; - } - return runtime().reflection.getFieldAnnotations(this); - } - - @Override - public Annotation[] getDeclaredAnnotations() { - if (!hasAnnotations(false)) { - return new Annotation[0]; - } - return runtime().reflection.getFieldDeclaredAnnotations(this); - } - - @Override - public T getAnnotation(Class annotationClass) { - if (!hasAnnotations(false)) { - return null; - } - return runtime().reflection.getFieldAnnotation(this, annotationClass); - } - @Override public JavaConstant getConstantValue() { return holder.getFieldInfo(index).getConstantValue(holder); diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java index 2102eeb59f3..0a8a1ae7ebc 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedJavaMethodImpl.java @@ -40,7 +40,6 @@ import jdk.vm.ci.meta.TriState; import jdk.vm.ci.meta.annotation.AnnotationsInfo; -import java.lang.annotation.Annotation; import java.lang.reflect.Executable; import java.lang.reflect.Modifier; import java.lang.reflect.Type; @@ -449,7 +448,6 @@ public boolean hasCompiledCode() { } /** - * @param level * @return true if the currently installed code was generated at {@code level}. */ @Override @@ -506,38 +504,6 @@ public Parameter[] getParameters() { return runtime().reflection.getParameters(this); } - @Override - public Annotation[][] getParameterAnnotations() { - if (!hasAnnotations(HotSpotVMConfig.config().constMethodHasParameterAnnotations)) { - return new Annotation[signature.getParameterCount(false)][0]; - } - return runtime().reflection.getParameterAnnotations(this); - } - - @Override - public Annotation[] getAnnotations() { - if (!hasAnnotations(config().constMethodHasMethodAnnotations)) { - return new Annotation[0]; - } - return runtime().reflection.getMethodAnnotations(this); - } - - @Override - public Annotation[] getDeclaredAnnotations() { - if (!hasAnnotations(config().constMethodHasMethodAnnotations)) { - return new Annotation[0]; - } - return runtime().reflection.getMethodDeclaredAnnotations(this); - } - - @Override - public T getAnnotation(Class annotationClass) { - if (!hasAnnotations(config().constMethodHasMethodAnnotations)) { - return null; - } - return runtime().reflection.getMethodAnnotation(this, annotationClass); - } - /** * Returns whether this method has annotations in the category specified by {@code category}. * diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java index 2259e162d03..44118fdfbb9 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedObjectTypeImpl.java @@ -1023,30 +1023,6 @@ private boolean hasDirectAnnotations(boolean typeAnnotations) { private static final Annotation[] NO_ANNOTATIONS = {}; - @Override - public Annotation[] getAnnotations() { - if (!mayHaveAnnotations(true)) { - return NO_ANNOTATIONS; - } - return runtime().reflection.getAnnotations(this); - } - - @Override - public Annotation[] getDeclaredAnnotations() { - if (!mayHaveAnnotations(false)) { - return NO_ANNOTATIONS; - } - return runtime().reflection.getDeclaredAnnotations(this); - } - - @Override - public T getAnnotation(Class annotationClass) { - if (!mayHaveAnnotations(true)) { - return null; - } - return runtime().reflection.getAnnotation(this, annotationClass); - } - /** * Performs a fast-path check that this type is resolved in the context of a given accessing * class. A negative result does not mean this type is not resolved with respect to diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java index 4a0712483c7..20595894963 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/HotSpotResolvedPrimitiveType.java @@ -34,7 +34,6 @@ import jdk.vm.ci.meta.UnresolvedJavaType; import jdk.vm.ci.meta.annotation.AnnotationsInfo; -import java.lang.annotation.Annotation; import java.lang.reflect.Modifier; import java.util.List; @@ -254,21 +253,6 @@ public List getRecordComponents() { return null; } - @Override - public Annotation[] getAnnotations() { - return new Annotation[0]; - } - - @Override - public Annotation[] getDeclaredAnnotations() { - return new Annotation[0]; - } - - @Override - public T getAnnotation(Class annotationClass) { - return null; - } - @Override public AnnotationsInfo getTypeAnnotationInfo() { return null; diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedLibraryJVMCIReflection.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedLibraryJVMCIReflection.java index 8ac3742942e..9145753c7ae 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedLibraryJVMCIReflection.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/hotspot/SharedLibraryJVMCIReflection.java @@ -22,15 +22,14 @@ */ package jdk.vm.ci.hotspot; -import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; +import jdk.vm.ci.meta.JavaConstant; +import jdk.vm.ci.meta.ResolvedJavaMethod; +import jdk.vm.ci.meta.ResolvedJavaType; -import java.lang.annotation.Annotation; import java.lang.reflect.Array; import java.lang.reflect.Type; -import jdk.vm.ci.meta.JavaConstant; -import jdk.vm.ci.meta.ResolvedJavaMethod; -import jdk.vm.ci.meta.ResolvedJavaType; +import static jdk.vm.ci.hotspot.HotSpotJVMCIRuntime.runtime; /** * Implementation of {@link HotSpotJVMCIReflection} when running in a JVMCI shared library. @@ -104,91 +103,11 @@ ResolvedJavaMethod.Parameter[] getParameters(HotSpotResolvedJavaMethodImpl javaM return null; } - // Substituted by Target_jdk_vm_ci_hotspot_SharedLibraryJVMCIReflection - static Annotation[] getClassAnnotations(String className) { - throw new InternalError("missing substitution: " + className); - } - - // Substituted by Target_jdk_vm_ci_hotspot_SharedLibraryJVMCIReflection - static Annotation[][] getParameterAnnotations(String className, String methodName) { - throw new InternalError("missing substitution: " + className + " " + methodName); - } - - @Override - Annotation[] getAnnotations(HotSpotResolvedObjectTypeImpl holder) { - Annotation[] annotations = getClassAnnotations(holder.getName()); - return annotations == null ? new Annotation[0] : annotations; - } - - @Override - Annotation[] getDeclaredAnnotations(HotSpotResolvedObjectTypeImpl holder) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - T getAnnotation(HotSpotResolvedObjectTypeImpl holder, Class annotationClass) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - Annotation[][] getParameterAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - Annotation[][] annotations = getParameterAnnotations(javaMethod.getDeclaringClass().getName(), javaMethod.getName()); - if (annotations == null) { - return new Annotation[javaMethod.signature.getParameterCount(false)][0]; - } - return annotations; - } - @Override Type[] getGenericParameterTypes(HotSpotResolvedJavaMethodImpl javaMethod) { throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); } - @Override - Annotation[] getFieldAnnotations(HotSpotResolvedJavaFieldImpl javaField) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - Annotation[] getMethodAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - Annotation[] annotations = getMethodAnnotationsInternal(javaMethod); - return annotations == null ? new Annotation[0] : annotations; - } - - @Override - T getMethodAnnotation(HotSpotResolvedJavaMethodImpl javaMethod, Class annotationClass) { - Annotation[] methodAnnotations = getMethodAnnotations(javaMethod); - if (methodAnnotations != null) { - for (Annotation ann : methodAnnotations) { - if (annotationClass.isInstance(ann)) { - return annotationClass.cast(ann); - } - } - } - return null; - } - - // Substituted by Target_jdk_vm_ci_hotspot_SharedLibraryJVMCIReflection - @SuppressWarnings("unused") - private static Annotation[] getMethodAnnotationsInternal(ResolvedJavaMethod javaMethod) { - throw new InternalError("missing substitution"); - } - - @Override - Annotation[] getMethodDeclaredAnnotations(HotSpotResolvedJavaMethodImpl javaMethod) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - Annotation[] getFieldDeclaredAnnotations(HotSpotResolvedJavaFieldImpl javaMethod) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - - @Override - T getFieldAnnotation(HotSpotResolvedJavaFieldImpl javaField, Class annotationClass) { - throw new HotSpotJVMCIUnsupportedOperationError("unimplemented"); - } - @Override HotSpotResolvedObjectTypeImpl getType(HotSpotObjectConstantImpl object) { if (object instanceof DirectHotSpotObjectConstantImpl) { diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaField.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaField.java index 0de311571e3..09f3be6d163 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaField.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaField.java @@ -24,14 +24,13 @@ import jdk.vm.ci.meta.annotation.Annotated; -import java.lang.reflect.AnnotatedElement; import java.lang.reflect.Modifier; /** * Represents a reference to a resolved Java field. Fields, like methods and types, are resolved * through {@link ConstantPool constant pools}. */ -public interface ResolvedJavaField extends JavaField, ModifiersProvider, AnnotatedElement, Annotated { +public interface ResolvedJavaField extends JavaField, ModifiersProvider, Annotated { /** * {@inheritDoc} diff --git a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaMethod.java b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaMethod.java index 747ee325951..56e8fb58f3a 100644 --- a/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaMethod.java +++ b/src/jdk.internal.vm.ci/share/classes/jdk/vm/ci/meta/ResolvedJavaMethod.java @@ -25,9 +25,6 @@ import jdk.vm.ci.meta.annotation.Annotated; import jdk.vm.ci.meta.annotation.AnnotationsInfo; -import java.lang.annotation.Annotation; -import java.lang.reflect.AnnotatedElement; -import java.lang.reflect.Array; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.lang.reflect.Type; @@ -36,13 +33,13 @@ * Represents a resolved Java method. Methods, like fields and types, are resolved through * {@link ConstantPool constant pools}. */ -public interface ResolvedJavaMethod extends JavaMethod, InvokeTarget, ModifiersProvider, AnnotatedElement, Annotated { +public interface ResolvedJavaMethod extends JavaMethod, InvokeTarget, ModifiersProvider, Annotated { /** * Returns the method's bytecode. The returned bytecode does not contain breakpoints or non-Java * bytecodes. This will return {@code null} if {@link #getCodeSize()} returns {@code <= 0} or if * {@link #hasBytecodes()} returns {@code false}. - * + *

* The contained constant pool indexes may not be the ones found in the original class file but * they can be used with the JVMCI API (e.g. methods in {@link ConstantPool}). * @@ -107,7 +104,7 @@ default boolean isFinal() { /** * Returns {@code true} if this method is a default method; returns {@code false} otherwise. - * + *

* A default method is a public non-abstract instance method, that is, a non-static method with * a body, declared in an interface type. * @@ -188,7 +185,7 @@ default ProfilingInfo getProfilingInfo() { /** * A {@code Parameter} provides information about method parameters. */ - class Parameter implements AnnotatedElement { + class Parameter { private final String name; private final ResolvedJavaMethod method; private final int modifiers; @@ -284,21 +281,6 @@ public boolean isVarArgs() { return method.isVarArgs() && index == method.getSignature().getParameterCount(false) - 1; } - @Override - public T getAnnotation(Class annotationClass) { - return method.getParameterAnnotations(annotationClass)[index]; - } - - @Override - public Annotation[] getAnnotations() { - return method.getParameterAnnotations()[index]; - } - - @Override - public Annotation[] getDeclaredAnnotations() { - return getAnnotations(); - } - @Override public String toString() { Type type = getParameterizedType(); @@ -308,7 +290,7 @@ public String toString() { } final StringBuilder sb = new StringBuilder(Modifier.toString(getModifiers())); - if (sb.length() != 0) { + if (!sb.isEmpty()) { sb.append(' '); } return sb.append(typename).append(' ').append(getName()).toString(); @@ -338,14 +320,6 @@ default Parameter[] getParameters() { return null; } - /** - * Returns an array of arrays that represent the annotations on the formal parameters, in - * declaration order, of this method. - * - * @see Method#getParameterAnnotations() - */ - Annotation[][] getParameterAnnotations(); - /** * Returns an array of {@link Type} objects that represent the formal parameter types, in * declaration order, of this method. @@ -399,57 +373,14 @@ default Parameter[] getParameters() { */ boolean isInVirtualMethodTable(ResolvedJavaType resolved); - /** - * Gets the annotation of a particular type for a formal parameter of this method. - * - * @param annotationClass the Class object corresponding to the annotation type - * @param parameterIndex the index of a formal parameter of {@code method} - * @return the annotation of type {@code annotationClass} for the formal parameter present, else - * null - * @throws IndexOutOfBoundsException if {@code parameterIndex} does not denote a formal - * parameter - */ - default T getParameterAnnotation(Class annotationClass, int parameterIndex) { - if (parameterIndex >= 0) { - Annotation[][] parameterAnnotations = getParameterAnnotations(); - for (Annotation a : parameterAnnotations[parameterIndex]) { - if (a.annotationType() == annotationClass) { - return annotationClass.cast(a); - } - } - } - return null; - } - default JavaType[] toParameterTypes() { JavaType receiver = isStatic() || isConstructor() ? null : getDeclaringClass(); return getSignature().toParameterTypes(receiver); } /** - * Gets the annotations of a particular type for the formal parameters of this method. - * - * @param annotationClass the Class object corresponding to the annotation type - * @return the annotation of type {@code annotationClass} (if any) for each formal parameter - * present - */ - @SuppressWarnings("unchecked") - default T[] getParameterAnnotations(Class annotationClass) { - Annotation[][] parameterAnnotations = getParameterAnnotations(); - T[] result = (T[]) Array.newInstance(annotationClass, parameterAnnotations.length); - for (int i = 0; i < parameterAnnotations.length; i++) { - for (Annotation a : parameterAnnotations[i]) { - if (a.annotationType() == annotationClass) { - result[i] = annotationClass.cast(a); - } - } - } - return result; - } - - /** - * @see #getCodeSize() * @return {@code getCodeSize() > 0} + * @see #getCodeSize() */ default boolean hasBytecodes() { return getCodeSize() > 0; @@ -493,15 +424,11 @@ default boolean isScoped() { * Gets the class file info for the parameter annotations on this method * or {@code null} if no such info exists. */ - default AnnotationsInfo getParameterAnnotationInfo() { - return null; - } + AnnotationsInfo getParameterAnnotationInfo(); /** * Gets the class file info for the default value of the annotation element represented * by this method or {@code null} if no such info exists. */ - default AnnotationsInfo getAnnotationDefaultInfo() { - return null; - } + AnnotationsInfo getAnnotationDefaultInfo(); } 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 6a649734b35..209d8346c94 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 @@ -25,7 +25,6 @@ import jdk.vm.ci.meta.Assumptions.AssumptionResult; import jdk.vm.ci.meta.annotation.Annotated; -import java.lang.reflect.AnnotatedElement; import java.util.List; /** @@ -33,7 +32,7 @@ * thereof. Types, like fields and methods, are resolved through {@link ConstantPool constant pools} * . */ -public interface ResolvedJavaType extends JavaType, ModifiersProvider, AnnotatedElement, Annotated { +public interface ResolvedJavaType extends JavaType, ModifiersProvider, Annotated { /** * Checks whether this type has a finalizer method. * @@ -252,7 +251,6 @@ default ResolvedJavaType getElementalType() { * Returns {@code true} if and only if the underlying class is a hidden class. * * @return {@code true} if and only if this class is a hidden class - * * @see Class#isHidden() */ boolean isHidden(); diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java index 1c86e5c32f8..d62f32c916a 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaField.java @@ -55,7 +55,6 @@ import java.io.IOException; import java.io.InputStream; import java.io.PrintStream; -import java.lang.annotation.Annotation; import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Modifier; @@ -64,7 +63,6 @@ import java.util.Map; import java.util.Set; -import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotEquals; @@ -108,27 +106,6 @@ public void isSyntheticTest() { } } - @Test - public void getAnnotationsTest() { - for (Map.Entry e : fields.entrySet()) { - Annotation[] expected = e.getKey().getAnnotations(); - Annotation[] actual = e.getValue().getAnnotations(); - assertArrayEquals(expected, actual); - } - } - - @Test - public void getAnnotationTest() { - for (Map.Entry e : fields.entrySet()) { - for (Annotation expected : e.getKey().getAnnotations()) { - if (expected != null) { - Annotation actual = e.getValue().getAnnotation(expected.annotationType()); - assertEquals(expected, actual); - } - } - } - } - @Test public void getDeclaringClassTest() { for (Map.Entry e : fields.entrySet()) { @@ -306,7 +283,6 @@ public void testGetType() throws ClassNotFoundException { assertTrue(field.getName().equals("fieldWithUnresolvableType")); field.getType(); field.toString(); - field.getAnnotations(); } } diff --git a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java index eb1e336e89d..5c5a870256e 100644 --- a/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java +++ b/test/hotspot/jtreg/compiler/jvmci/jdk.vm.ci.runtime.test/src/jdk/vm/ci/runtime/test/TestResolvedJavaMethod.java @@ -85,7 +85,6 @@ import java.util.Objects; import java.util.Set; -import static org.junit.Assert.assertArrayEquals; import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertFalse; import static org.junit.Assert.assertNotNull; @@ -305,7 +304,6 @@ public void getParametersTest() { assertEquals(exp.getName(), act.getName()); assertEquals(exp.isNamePresent(), act.isNamePresent()); assertEquals(exp.getModifiers(), act.getModifiers()); - assertArrayEquals(exp.getAnnotations(), act.getAnnotations()); assertEquals(exp.getType().getName(), act.getType().toClassName()); assertEquals(exp.getParameterizedType(), act.getParameterizedType()); assertEquals(metaAccess.lookupJavaMethod(exp.getDeclaringExecutable()), act.getDeclaringMethod()); @@ -313,39 +311,6 @@ public void getParametersTest() { } } - @Retention(RetentionPolicy.RUNTIME) - @Target(ElementType.METHOD) - @interface TestAnnotation { - long value(); - } - - @Test - @TestAnnotation(value = 1000L) - public void getAnnotationTest() throws NoSuchMethodException { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("getAnnotationTest")); - TestAnnotation annotation = method.getAnnotation(TestAnnotation.class); - assertNotNull(annotation); - assertEquals(1000L, annotation.value()); - } - - @Test - @TestAnnotation(value = 1000L) - public void getAnnotationsTest() throws NoSuchMethodException { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("getAnnotationsTest")); - Annotation[] annotations = method.getAnnotations(); - assertNotNull(annotations); - assertEquals(2, annotations.length); - TestAnnotation annotation = null; - for (Annotation a : annotations) { - if (a instanceof TestAnnotation) { - annotation = (TestAnnotation) a; - break; - } - } - assertNotNull(annotation); - assertEquals(1000L, annotation.value()); - } - @Retention(RetentionPolicy.RUNTIME) @Target(ElementType.PARAMETER) @interface NonNull { @@ -355,23 +320,12 @@ public void getAnnotationsTest() throws NoSuchMethodException { @Target(ElementType.PARAMETER) @interface Special { String elementWithDefault() default "NO_NAME"; + long elementWithoutDefault(); } private static native void methodWithAnnotatedParameters(@NonNull HashMap p1, @Special(elementWithoutDefault = 42) @NonNull Class p2); - @Test - public void getParameterAnnotationsTest() throws NoSuchMethodException { - ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithAnnotatedParameters", HashMap.class, Class.class)); - Annotation[][] annotations = method.getParameterAnnotations(); - assertEquals(2, annotations.length); - assertEquals(1, annotations[0].length); - assertEquals(NonNull.class, annotations[0][0].annotationType()); - assertEquals(2, annotations[1].length); - assertEquals(Special.class, annotations[1][0].annotationType()); - assertEquals(NonNull.class, annotations[1][1].annotationType()); - } - @Test public void getGenericParameterTypesTest() throws NoSuchMethodException { ResolvedJavaMethod method = metaAccess.lookupJavaMethod(getClass().getDeclaredMethod("methodWithAnnotatedParameters", HashMap.class, Class.class)); 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 d3e7af2f1e1..0f339f9244b 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 @@ -922,7 +922,7 @@ public void resolveMethodTest() { ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); if (m.isPublic()) { ResolvedJavaMethod resolvedMethod = type.resolveMethod(m, context); - if (isSignaturePolymorphic(m)) { + if (isSignaturePolymorphic(decl)) { // Signature polymorphic methods must not be resolved assertNull(resolvedMethod); } else { @@ -948,7 +948,7 @@ public void resolveMethodTest() { } ResolvedJavaMethod decl = metaAccess.lookupJavaMethod(m); ResolvedJavaMethod impl = type.resolveMethod(decl, declaringClass); - ResolvedJavaMethod expected = isSignaturePolymorphic(decl) ? null : decl; + ResolvedJavaMethod expected = isSignaturePolymorphic(m) ? null : decl; assertEquals(m.toString(), expected, impl); } } @@ -976,7 +976,7 @@ public void resolveConcreteMethodTest() { ResolvedJavaMethod m = metaAccess.lookupJavaMethod(decl); if (m.isPublic()) { ResolvedJavaMethod resolvedMethod = type.resolveConcreteMethod(m, context); - if (isSignaturePolymorphic(m)) { + if (isSignaturePolymorphic(decl)) { // Signature polymorphic methods must not be resolved assertNull(String.format("Got: %s", resolvedMethod), resolvedMethod); } else { @@ -1256,8 +1256,6 @@ static class SubD extends D { private static ResolvedJavaMethod getClassInitializer(Class c) { ResolvedJavaMethod clinit = metaAccess.lookupJavaType(c).getClassInitializer(); if (clinit != null) { - assertEquals(0, clinit.getAnnotations().length); - assertEquals(0, clinit.getDeclaredAnnotations().length); assertNull(runtime.getMirror(clinit)); } return clinit; @@ -1276,24 +1274,6 @@ public void getClassInitializerTest() { } } - @Test - public void getAnnotationsTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - assertArrayEquals(c.getAnnotations(), type.getAnnotations()); - } - } - - @Test - public void getAnnotationTest() { - for (Class c : classes) { - ResolvedJavaType type = metaAccess.lookupJavaType(c); - for (Annotation a : c.getAnnotations()) { - assertEquals(a, type.getAnnotation(a.annotationType())); - } - } - } - @Test public void getSourceFileNameTest() { Class c = Object.class; @@ -1464,7 +1444,7 @@ public void testCoverage() { } } - private static boolean isSignaturePolymorphic(ResolvedJavaMethod method) { + private static boolean isSignaturePolymorphic(Method method) { return method.getAnnotation(SIGNATURE_POLYMORPHIC_CLASS) != null; } }