< prev index next >
src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotConstantPool.java
Print this page
rev 49261 : 8146201: [AOT] Class static initializers that are not pure should not be executed during static compilation
@@ -1,7 +1,7 @@
/*
- * 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
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
@@ -661,12 +661,16 @@
}
return compilerToVM().constantPoolRemapInstructionOperandFromCache(this, index);
}
@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:
case Bytecodes.INSTANCEOF:
case Bytecodes.NEW:
@@ -716,14 +720,16 @@
// fall through
case Class:
case UnresolvedClass:
case UnresolvedClassInError:
final HotSpotResolvedObjectTypeImpl type = compilerToVM().resolveTypeInPool(this, index);
+ 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)) {
final int methodRefCacheIndex = rawIndexToConstantPoolCacheIndex(cpi, opcode);
assert checkTag(compilerToVM().constantPoolRemapInstructionOperandFromCache(this, methodRefCacheIndex), JVM_CONSTANT.MethodRef);
compilerToVM().resolveInvokeHandleInPool(this, methodRefCacheIndex);
< prev index next >