aboutsummaryrefslogtreecommitdiffstats
path: root/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java
diff options
context:
space:
mode:
authorEvgeny Mandrikov <Godin@users.noreply.github.com>2016-08-16 04:06:56 +0200
committerMarc R. Hoffmann <hoffmann@mountainminds.com>2016-08-16 04:06:56 +0200
commit28a112ca6c6f46cd385f00aa932ec0e334e045a7 (patch)
tree9d92399e1a2e797a87d560e49fc092e0017a113d /org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java
parentc6f2b6b7e887eb645b8aba928ff0134cfe66ec28 (diff)
downloadplatform_external_jacoco-28a112ca6c6f46cd385f00aa932ec0e334e045a7.tar.gz
platform_external_jacoco-28a112ca6c6f46cd385f00aa932ec0e334e045a7.tar.bz2
platform_external_jacoco-28a112ca6c6f46cd385f00aa932ec0e334e045a7.zip
Do not violate JVMS regarding initialization of final fields (#434)
Without this change instrumented classes can't pass checks and cause IllegalAccessError starting from OpenJDK 9 EA b127 (see https://bugs.openjdk.java.net/browse/JDK-8157181).
Diffstat (limited to 'org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java')
-rw-r--r--org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java15
1 files changed, 12 insertions, 3 deletions
diff --git a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java
index 6cf84609..5e0084b9 100644
--- a/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java
+++ b/org.jacoco.core/src/org/jacoco/core/internal/instr/ProbeInserter.java
@@ -27,6 +27,12 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
private final IProbeArrayStrategy arrayStrategy;
+ /**
+ * <code>true</code> if method is a class or interface initialization
+ * method.
+ */
+ private final boolean clinit;
+
/** Position of the inserted variable. */
private final int variable;
@@ -37,7 +43,9 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
* Creates a new {@link ProbeInserter}.
*
* @param access
- * access flags of the adapted method.
+ * access flags of the adapted method
+ * @param name
+ * the method's name
* @param desc
* the method's descriptor
* @param mv
@@ -46,9 +54,10 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
* callback to create the code that retrieves the reference to
* the probe array
*/
- ProbeInserter(final int access, final String desc, final MethodVisitor mv,
+ ProbeInserter(final int access, final String name, final String desc, final MethodVisitor mv,
final IProbeArrayStrategy arrayStrategy) {
super(JaCoCo.ASM_API_VERSION, mv);
+ this.clinit = InstrSupport.CLINIT_NAME.equals(name);
this.arrayStrategy = arrayStrategy;
int pos = (Opcodes.ACC_STATIC & access) == 0 ? 1 : 0;
for (final Type t : Type.getArgumentTypes(desc)) {
@@ -82,7 +91,7 @@ class ProbeInserter extends MethodVisitor implements IProbeInserter {
@Override
public void visitCode() {
- accessorStackSize = arrayStrategy.storeInstance(mv, variable);
+ accessorStackSize = arrayStrategy.storeInstance(mv, clinit, variable);
mv.visitCode();
}