8146201: [AOT] Class static initializers that are not pure should not be executed during static compilation
Reviewed-by: kvn
This commit is contained in:
parent
0df6b5baee
commit
91649ef44b
@ -480,6 +480,9 @@ C2V_END
|
||||
C2V_VMENTRY(jobject, resolveTypeInPool, (JNIEnv*, jobject, jobject jvmci_constant_pool, jint index))
|
||||
constantPoolHandle cp = CompilerToVM::asConstantPool(jvmci_constant_pool);
|
||||
Klass* resolved_klass = cp->klass_at(index, CHECK_NULL);
|
||||
if (resolved_klass->is_instance_klass()) {
|
||||
InstanceKlass::cast(resolved_klass)->link_class_or_fail(THREAD);
|
||||
}
|
||||
oop klass = CompilerToVM::get_jvmci_type(resolved_klass, CHECK_NULL);
|
||||
return JNIHandles::make_local(THREAD, klass);
|
||||
C2V_END
|
||||
|
@ -368,12 +368,6 @@ methodHandle JVMCIEnv::get_method_by_index_impl(const constantPoolHandle& cpool,
|
||||
if (holder_is_accessible) { // Our declared holder is loaded.
|
||||
constantTag tag = cpool->tag_ref_at(index);
|
||||
methodHandle m = lookup_method(accessor, holder, name_sym, sig_sym, bc, tag);
|
||||
if (!m.is_null() &&
|
||||
(bc == Bytecodes::_invokestatic
|
||||
? InstanceKlass::cast(m->method_holder())->is_not_initialized()
|
||||
: !InstanceKlass::cast(m->method_holder())->is_loaded())) {
|
||||
m = NULL;
|
||||
}
|
||||
if (!m.is_null()) {
|
||||
// We found the method.
|
||||
return m;
|
||||
|
@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright (c) 2011, 2017, Oracle and/or its affiliates. All rights reserved.
|
||||
* Copyright (c) 2011, 2018, 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
|
||||
@ -663,8 +663,12 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceWrapper
|
||||
}
|
||||
|
||||
@Override
|
||||
@SuppressWarnings("fallthrough")
|
||||
public void loadReferencedType(int cpi, int opcode) {
|
||||
loadReferencedType(cpi, opcode, true /* initialize */);
|
||||
}
|
||||
|
||||
@SuppressWarnings("fallthrough")
|
||||
public void loadReferencedType(int cpi, int opcode, boolean initialize) {
|
||||
int index;
|
||||
switch (opcode) {
|
||||
case Bytecodes.CHECKCAST:
|
||||
@ -718,9 +722,11 @@ public final class HotSpotConstantPool implements ConstantPool, MetaspaceWrapper
|
||||
case UnresolvedClass:
|
||||
case UnresolvedClassInError:
|
||||
final HotSpotResolvedObjectTypeImpl type = compilerToVM().resolveTypeInPool(this, index);
|
||||
Class<?> klass = type.mirror();
|
||||
if (!klass.isPrimitive() && !klass.isArray()) {
|
||||
UNSAFE.ensureClassInitialized(klass);
|
||||
if (initialize) {
|
||||
Class<?> klass = type.mirror();
|
||||
if (!klass.isPrimitive() && !klass.isArray()) {
|
||||
UNSAFE.ensureClassInitialized(klass);
|
||||
}
|
||||
}
|
||||
if (tag == JVM_CONSTANT.MethodRef) {
|
||||
if (Bytecodes.isInvokeHandleAlias(opcode) && isSignaturePolymorphicHolder(type)) {
|
||||
|
Loading…
Reference in New Issue
Block a user