equal
deleted
inserted
replaced
1 /* |
1 /* |
2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 2016, 2018, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. |
7 * published by the Free Software Foundation. |
46 * compiler.jsr292.NonInlinedCall.RedefineTest |
46 * compiler.jsr292.NonInlinedCall.RedefineTest |
47 */ |
47 */ |
48 |
48 |
49 package compiler.jsr292.NonInlinedCall; |
49 package compiler.jsr292.NonInlinedCall; |
50 |
50 |
51 import jdk.internal.misc.Unsafe; |
|
52 import jdk.internal.org.objectweb.asm.ClassWriter; |
51 import jdk.internal.org.objectweb.asm.ClassWriter; |
53 import jdk.internal.org.objectweb.asm.MethodVisitor; |
52 import jdk.internal.org.objectweb.asm.MethodVisitor; |
54 import jdk.internal.vm.annotation.DontInline; |
53 import jdk.internal.vm.annotation.DontInline; |
55 import sun.hotspot.WhiteBox; |
54 import sun.hotspot.WhiteBox; |
56 |
55 |
66 import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER; |
65 import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER; |
67 import static jdk.internal.org.objectweb.asm.Opcodes.IRETURN; |
66 import static jdk.internal.org.objectweb.asm.Opcodes.IRETURN; |
68 |
67 |
69 public class RedefineTest { |
68 public class RedefineTest { |
70 static final MethodHandles.Lookup LOOKUP = MethodHandleHelper.IMPL_LOOKUP; |
69 static final MethodHandles.Lookup LOOKUP = MethodHandleHelper.IMPL_LOOKUP; |
71 static final Unsafe UNSAFE = Unsafe.getUnsafe(); |
|
72 |
|
73 static final String NAME = "compiler/jsr292/NonInlinedCall/RedefineTest$T"; |
70 static final String NAME = "compiler/jsr292/NonInlinedCall/RedefineTest$T"; |
74 |
71 |
75 static Class<?> getClass(int r) { |
72 static Class<?> getClass(int r) { |
76 byte[] classFile = getClassFile(r); |
73 byte[] classFile = getClassFile(r); |
77 return UNSAFE.defineClass(NAME, classFile, 0, classFile.length, null, null); |
74 try { |
|
75 return MethodHandles.lookup().defineClass(classFile); |
|
76 } catch (IllegalAccessException e) { |
|
77 throw new Error(e); |
|
78 } |
78 } |
79 } |
79 |
80 |
80 /** |
81 /** |
81 * Generates a class of the following shape: |
82 * Generates a class of the following shape: |
82 * static class T { |
83 * static class T { |