784 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
785 return mirror().getAnnotation(annotationClass);
786 }
787
788 /**
789 * Performs a fast-path check that this type is resolved in the context of a given accessing
790 * class. A negative result does not mean this type is not resolved with respect to
791 * {@code accessingClass}. That can only be determined by
792 * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean)
793 * re-resolving} the type.
794 */
795 public boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass) {
796 assert accessingClass != null;
797 ResolvedJavaType elementType = getElementalType();
798 if (elementType.isPrimitive()) {
799 // Primitive type resolution is context free.
800 return true;
801 }
802 if (elementType.getName().startsWith("Ljava/")) {
803 // Classes in a java.* package can only be defined by the
804 // boot class loader. This is enforced by ClassLoader.preDefineClass()
805 assert mirror().getClassLoader() == null;
806 return true;
807 }
808 ClassLoader thisCl = mirror().getClassLoader();
809 ClassLoader accessingClassCl = ((HotSpotResolvedObjectTypeImpl) accessingClass).mirror().getClassLoader();
810 return thisCl == accessingClassCl;
811 }
812
813 @Override
814 public ResolvedJavaType resolve(ResolvedJavaType accessingClass) {
815 if (isDefinitelyResolvedWithRespectTo(requireNonNull(accessingClass))) {
816 return this;
817 }
818 HotSpotResolvedObjectTypeImpl accessingType = (HotSpotResolvedObjectTypeImpl) accessingClass;
819 return (ResolvedJavaType) runtime().lookupType(getName(), accessingType, true);
820 }
821
822 /**
823 * Gets the metaspace Klass boxed in a {@link JavaConstant}.
824 */
825 public Constant klass() {
|
784 public <T extends Annotation> T getAnnotation(Class<T> annotationClass) {
785 return mirror().getAnnotation(annotationClass);
786 }
787
788 /**
789 * Performs a fast-path check that this type is resolved in the context of a given accessing
790 * class. A negative result does not mean this type is not resolved with respect to
791 * {@code accessingClass}. That can only be determined by
792 * {@linkplain HotSpotJVMCIRuntime#lookupType(String, HotSpotResolvedObjectType, boolean)
793 * re-resolving} the type.
794 */
795 public boolean isDefinitelyResolvedWithRespectTo(ResolvedJavaType accessingClass) {
796 assert accessingClass != null;
797 ResolvedJavaType elementType = getElementalType();
798 if (elementType.isPrimitive()) {
799 // Primitive type resolution is context free.
800 return true;
801 }
802 if (elementType.getName().startsWith("Ljava/")) {
803 // Classes in a java.* package can only be defined by the
804 // boot or platform class loader.
805 return true;
806 }
807 ClassLoader thisCl = mirror().getClassLoader();
808 ClassLoader accessingClassCl = ((HotSpotResolvedObjectTypeImpl) accessingClass).mirror().getClassLoader();
809 return thisCl == accessingClassCl;
810 }
811
812 @Override
813 public ResolvedJavaType resolve(ResolvedJavaType accessingClass) {
814 if (isDefinitelyResolvedWithRespectTo(requireNonNull(accessingClass))) {
815 return this;
816 }
817 HotSpotResolvedObjectTypeImpl accessingType = (HotSpotResolvedObjectTypeImpl) accessingClass;
818 return (ResolvedJavaType) runtime().lookupType(getName(), accessingType, true);
819 }
820
821 /**
822 * Gets the metaspace Klass boxed in a {@link JavaConstant}.
823 */
824 public Constant klass() {
|