1/* 2 * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. 3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. 4 * 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 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 */ 23package org.graalvm.compiler.bytecode; 24 25import jdk.vm.ci.meta.ConstantPool; 26import jdk.vm.ci.meta.ExceptionHandler; 27import jdk.vm.ci.meta.LineNumberTable; 28import jdk.vm.ci.meta.LocalVariableTable; 29import jdk.vm.ci.meta.ProfilingInfo; 30import jdk.vm.ci.meta.ResolvedJavaMethod; 31 32/** 33 * Direct access to the bytecode of a {@link ResolvedJavaMethod} that will reflect any 34 * instrumentation and rewriting performed on the {@link ResolvedJavaMethod}. 35 */ 36public class ResolvedJavaMethodBytecode implements Bytecode { 37 38 private final ResolvedJavaMethod method; 39 40 public ResolvedJavaMethodBytecode(ResolvedJavaMethod method) { 41 this.method = method; 42 } 43 44 @Override 45 public ResolvedJavaMethod getMethod() { 46 return method; 47 } 48 49 @Override 50 public byte[] getCode() { 51 return method.getCode(); 52 } 53 54 @Override 55 public int getCodeSize() { 56 return method.getCodeSize(); 57 } 58 59 @Override 60 public int getMaxStackSize() { 61 return method.getMaxStackSize(); 62 } 63 64 @Override 65 public int getMaxLocals() { 66 return method.getMaxLocals(); 67 } 68 69 @Override 70 public ConstantPool getConstantPool() { 71 return method.getConstantPool(); 72 } 73 74 @Override 75 public LineNumberTable getLineNumberTable() { 76 return method.getLineNumberTable(); 77 } 78 79 @Override 80 public LocalVariableTable getLocalVariableTable() { 81 return method.getLocalVariableTable(); 82 } 83 84 @Override 85 public ExceptionHandler[] getExceptionHandlers() { 86 return method.getExceptionHandlers(); 87 } 88 89 @Override 90 public StackTraceElement asStackTraceElement(int bci) { 91 return method.asStackTraceElement(bci); 92 } 93 94 @Override 95 public ProfilingInfo getProfilingInfo() { 96 return method.getProfilingInfo(); 97 } 98 99 @Override 100 public String toString() { 101 return getClass().getSimpleName() + method.format("<%h.%n(%p)>"); 102 } 103} 104