From 28a112ca6c6f46cd385f00aa932ec0e334e045a7 Mon Sep 17 00:00:00 2001 From: Evgeny Mandrikov Date: Tue, 16 Aug 2016 04:06:56 +0200 Subject: 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). --- .../test/validation/targets/BadCycleClass.java | 44 ++++++++++++++++++++++ 1 file changed, 44 insertions(+) create mode 100644 org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/BadCycleClass.java (limited to 'org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/BadCycleClass.java') diff --git a/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/BadCycleClass.java b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/BadCycleClass.java new file mode 100644 index 00000000..44e40cd1 --- /dev/null +++ b/org.jacoco.core.test/src/org/jacoco/core/test/validation/targets/BadCycleClass.java @@ -0,0 +1,44 @@ +/******************************************************************************* + * Copyright (c) 2009, 2016 Mountainminds GmbH & Co. KG and Contributors + * All rights reserved. This program and the accompanying materials + * are made available under the terms of the Eclipse Public License v1.0 + * which accompanies this distribution, and is available at + * http://www.eclipse.org/legal/epl-v10.html + * + * Contributors: + * Evgeny Mandrikov - initial API and implementation + * + *******************************************************************************/ +package org.jacoco.core.test.validation.targets; + +public class BadCycleClass { + + public static class Base { + static final Child b = new Child(); + + static { + b.someMethod(); + } + } + + public static class Child extends Base { + + static { + Stubs.nop("child clinit"); // $line-3$ + } + + public Child() { + Stubs.nop("child init"); // $line-1$ + } + + void someMethod() { + Stubs.nop("child someMethod"); // $line-2$ + } + + } + + public static void main(String[] args) { + new Child(); + } + +} -- cgit v1.2.3