From: Brian Carlstrom Date: Wed, 3 Jun 2015 04:53:14 +0000 (-0700) Subject: Fix "run-test --jvm 067-preemptive-unpark" X-Git-Tag: android-x86-7.1-r1~889^2~1096^2 X-Git-Url: http://git.osdn.net/view?a=commitdiff_plain;h=5f57d2d2ade3639eaef61c2101e186304250255e;p=android-x86%2Fart.git Fix "run-test --jvm 067-preemptive-unpark" Change-Id: I3afd86510091354d79fbb008e9670940d71a0721 --- diff --git a/test/067-preemptive-unpark/src/Main.java b/test/067-preemptive-unpark/src/Main.java index 2c099b946..beb3262a6 100644 --- a/test/067-preemptive-unpark/src/Main.java +++ b/test/067-preemptive-unpark/src/Main.java @@ -40,22 +40,24 @@ public class Main { /** * Set up {@link #UNSAFE}. */ - public static void setUp() { + public static void setUp() throws Exception{ /* * Subvert the access check to get the unique Unsafe instance. * We can do this because there's no security manager * installed when running the test. */ + Field field = null; try { - Field field = Unsafe.class.getDeclaredField("THE_ONE"); - field.setAccessible(true); - - UNSAFE = (Unsafe) field.get(null); - } catch (NoSuchFieldException ex) { - throw new RuntimeException(ex); - } catch (IllegalAccessException ex) { - throw new RuntimeException(ex); + field = Unsafe.class.getDeclaredField("THE_ONE"); + } catch (NoSuchFieldException e1) { + try { + field = Unsafe.class.getDeclaredField("theUnsafe"); + } catch (NoSuchFieldException e2) { + throw new RuntimeException("Failed to find THE_ONE or theUnsafe"); + } } + field.setAccessible(true); + UNSAFE = (Unsafe) field.get(null); } /**