Mercurial > hg > truffle
annotate test/serviceability/jvmti/GetObjectSizeOverflowAgent.java @ 21204:4a5df5570b7f
Truffle: make ReplaceObserver return a boolean in order to consume replace events. It can be useful for nodes to consume all replace events if they are always executed behind a @TruffleBoundary.
author | Christian Humer <christian.humer@gmail.com> |
---|---|
date | Mon, 04 May 2015 11:24:13 +0200 |
parents | 997fd9660dd5 |
children |
rev | line source |
---|---|
17946
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
1 /* |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
2 * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
4 * |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
5 * This code is free software; you can redistribute it and/or modify it |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
6 * under the terms of the GNU General Public License version 2 only, as |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
7 * published by the Free Software Foundation. |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
8 * |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
9 * This code is distributed in the hope that it will be useful, but WITHOUT |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
10 * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
11 * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
12 * version 2 for more details (a copy is included in the LICENSE file that |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
13 * accompanied this code). |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
14 * |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
15 * You should have received a copy of the GNU General Public License version |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
16 * 2 along with this work; if not, write to the Free Software Foundation, |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
17 * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
18 * |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
19 * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
20 * or visit www.oracle.com if you need additional information or have any |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
21 * questions. |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
22 */ |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
23 import java.lang.instrument.*; |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
24 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
25 public class GetObjectSizeOverflowAgent { |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
26 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
27 static Instrumentation instrumentation; |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
28 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
29 public static void premain(String agentArgs, Instrumentation instrumentation) { |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
30 GetObjectSizeOverflowAgent.instrumentation = instrumentation; |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
31 } |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
32 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
33 public static void main(String[] args) throws Exception { |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
34 int[] a = new int[600_000_000]; |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
35 long size = instrumentation.getObjectSize(a); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
36 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
37 if (size < 2_400_000_000L) { |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
38 throw new RuntimeException("Invalid size of array, expected >= 2400000000, got " + size); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
39 } |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
40 |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
41 System.out.println("GetObjectSizeOverflow passed"); |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
42 } |
997fd9660dd5
8027230: Overflow in java.lang.instrument.Instrumentation.getObjectSize() method
allwin
parents:
diff
changeset
|
43 } |