< prev index next >

test/compiler/calls/common/InvokeDynamicPatcher.java

Print this page
rev 11557 : 8132919: use package in compiler tests
Reviewed-by: duke


   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.calls.common;
  25 








  26 import java.io.FileInputStream;
  27 import java.io.IOException;
  28 import java.lang.invoke.CallSite;
  29 import java.lang.invoke.MethodHandles;
  30 import java.lang.invoke.MethodType;
  31 import java.net.URISyntaxException;
  32 import java.nio.file.Files;
  33 import java.nio.file.Path;
  34 import java.nio.file.Paths;
  35 import java.nio.file.StandardOpenOption;
  36 import jdk.internal.org.objectweb.asm.ClassReader;
  37 import jdk.internal.org.objectweb.asm.ClassVisitor;
  38 import jdk.internal.org.objectweb.asm.ClassWriter;
  39 import jdk.internal.org.objectweb.asm.Handle;
  40 import jdk.internal.org.objectweb.asm.Label;
  41 import jdk.internal.org.objectweb.asm.MethodVisitor;
  42 import jdk.internal.org.objectweb.asm.Opcodes;
  43 
  44 /**
  45  * A class which patch InvokeDynamic class bytecode with invokydynamic
  46  instruction, rewriting "caller" method to call "callee" method using
  47  invokedynamic
  48  */
  49 public class InvokeDynamicPatcher extends ClassVisitor {
  50 
  51     private static final String CLASS = InvokeDynamic.class.getName()
  52             .replace('.', '/');
  53     private static final String CALLER_METHOD_NAME = "caller";
  54     private static final String CALLEE_METHOD_NAME = "callee";
  55     private static final String NATIVE_CALLEE_METHOD_NAME = "calleeNative";
  56     private static final String BOOTSTRAP_METHOD_NAME = "bootstrapMethod";
  57     private static final String CALL_NATIVE_FIELD = "nativeCallee";
  58     private static final String CALL_NATIVE_FIELD_DESC = "Z";
  59     private static final String CALLEE_METHOD_DESC
  60             = "(L" + CLASS + ";IJFDLjava/lang/String;)Z";
  61     private static final String ASSERTTRUE_METHOD_DESC
  62             = "(ZLjava/lang/String;)V";




   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.
   8  *
   9  * This code is distributed in the hope that it will be useful, but WITHOUT
  10  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  11  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  12  * version 2 for more details (a copy is included in the LICENSE file that
  13  * accompanied this code).
  14  *
  15  * You should have received a copy of the GNU General Public License version
  16  * 2 along with this work; if not, write to the Free Software Foundation,
  17  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  18  *
  19  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  20  * or visit www.oracle.com if you need additional information or have any
  21  * questions.
  22  */
  23 
  24 package compiler.calls.common;
  25 
  26 import jdk.internal.org.objectweb.asm.ClassReader;
  27 import jdk.internal.org.objectweb.asm.ClassVisitor;
  28 import jdk.internal.org.objectweb.asm.ClassWriter;
  29 import jdk.internal.org.objectweb.asm.Handle;
  30 import jdk.internal.org.objectweb.asm.Label;
  31 import jdk.internal.org.objectweb.asm.MethodVisitor;
  32 import jdk.internal.org.objectweb.asm.Opcodes;
  33 
  34 import java.io.FileInputStream;
  35 import java.io.IOException;
  36 import java.lang.invoke.CallSite;
  37 import java.lang.invoke.MethodHandles;
  38 import java.lang.invoke.MethodType;
  39 import java.net.URISyntaxException;
  40 import java.nio.file.Files;
  41 import java.nio.file.Path;
  42 import java.nio.file.Paths;
  43 import java.nio.file.StandardOpenOption;







  44 
  45 /**
  46  * A class which patch InvokeDynamic class bytecode with invokydynamic
  47  instruction, rewriting "caller" method to call "callee" method using
  48  invokedynamic
  49  */
  50 public class InvokeDynamicPatcher extends ClassVisitor {
  51 
  52     private static final String CLASS = InvokeDynamic.class.getName()
  53             .replace('.', '/');
  54     private static final String CALLER_METHOD_NAME = "caller";
  55     private static final String CALLEE_METHOD_NAME = "callee";
  56     private static final String NATIVE_CALLEE_METHOD_NAME = "calleeNative";
  57     private static final String BOOTSTRAP_METHOD_NAME = "bootstrapMethod";
  58     private static final String CALL_NATIVE_FIELD = "nativeCallee";
  59     private static final String CALL_NATIVE_FIELD_DESC = "Z";
  60     private static final String CALLEE_METHOD_DESC
  61             = "(L" + CLASS + ";IJFDLjava/lang/String;)Z";
  62     private static final String ASSERTTRUE_METHOD_DESC
  63             = "(ZLjava/lang/String;)V";


< prev index next >