From a61894d88fabe45677f491c9f6bde30059a49026 Mon Sep 17 00:00:00 2001 From: Mathieu Chartier Date: Thu, 23 Apr 2015 16:32:54 -0700 Subject: Fix reflection handling and test flakiness Fixed reflection invoke to handle exceptions which occur from FindClass or NewObject by throwing these instead of the expected InvocationTargetException. Added test case to 080 for this reflection invoke. Fixed println throwing OOM in 104-growth-limit. Change-Id: I65766e7c3478e299da06fdc3a521fe3f3e8fdba9 --- test/104-growth-limit/src/Main.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'test/104-growth-limit') diff --git a/test/104-growth-limit/src/Main.java b/test/104-growth-limit/src/Main.java index d666377..d31cbf1 100644 --- a/test/104-growth-limit/src/Main.java +++ b/test/104-growth-limit/src/Main.java @@ -29,26 +29,28 @@ public class Main { final Method get_runtime = vm_runtime.getDeclaredMethod("getRuntime"); final Object runtime = get_runtime.invoke(null); final Method clear_growth_limit = vm_runtime.getDeclaredMethod("clearGrowthLimit"); + List l = new ArrayList(); try { - List l = new ArrayList(); while (true) { // Allocate a MB at a time l.add(new byte[1048576]); alloc1++; } } catch (OutOfMemoryError e) { + l = null; } // Expand the heap to the maximum size. clear_growth_limit.invoke(runtime); int alloc2 = 1; + l = new ArrayList(); try { - List l = new ArrayList(); while (true) { // Allocate a MB at a time l.add(new byte[1048576]); alloc2++; } } catch (OutOfMemoryError e2) { + l = null; if (alloc1 > alloc2) { System.out.println("ERROR: Allocated less memory after growth" + "limit cleared (" + alloc1 + " MBs > " + alloc2 + " MBs"); -- cgit v1.1