src/jdk.internal.vm.ci/share/classes/jdk.vm.ci.meta/src/jdk/vm/ci/meta/ResolvedJavaMethod.java
changeset 54669 ad45b3802d4e
parent 50858 2d3e99a72541
equal deleted inserted replaced
54668:0bda2308eded 54669:ad45b3802d4e
     1 /*
     1 /*
     2  * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved.
     2  * Copyright (c) 2009, 2019, 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.
    23 package jdk.vm.ci.meta;
    23 package jdk.vm.ci.meta;
    24 
    24 
    25 import java.lang.annotation.Annotation;
    25 import java.lang.annotation.Annotation;
    26 import java.lang.reflect.AnnotatedElement;
    26 import java.lang.reflect.AnnotatedElement;
    27 import java.lang.reflect.Array;
    27 import java.lang.reflect.Array;
    28 import java.lang.reflect.InvocationTargetException;
       
    29 import java.lang.reflect.Method;
    28 import java.lang.reflect.Method;
    30 import java.lang.reflect.Modifier;
    29 import java.lang.reflect.Modifier;
    31 import java.lang.reflect.Type;
    30 import java.lang.reflect.Type;
    32 
    31 
    33 /**
    32 /**
    37 public interface ResolvedJavaMethod extends JavaMethod, InvokeTarget, ModifiersProvider, AnnotatedElement {
    36 public interface ResolvedJavaMethod extends JavaMethod, InvokeTarget, ModifiersProvider, AnnotatedElement {
    38 
    37 
    39     /**
    38     /**
    40      * Returns the bytecode of this method, if the method has code. The returned byte array does not
    39      * Returns the bytecode of this method, if the method has code. The returned byte array does not
    41      * contain breakpoints or non-Java bytecodes. This may return null if the
    40      * contain breakpoints or non-Java bytecodes. This may return null if the
    42      * {@link #getDeclaringClass() holder} is not {@link ResolvedJavaType#isLinked() linked}.
    41      * {@linkplain #getDeclaringClass() declaring class} is not
       
    42      * {@linkplain ResolvedJavaType#isLinked() linked}.
    43      *
    43      *
    44      * The contained constant pool indices may not be the ones found in the original class file but
    44      * The contained constant pool indices may not be the ones found in the original class file but
    45      * they can be used with the JVMCI API (e.g. methods in {@link ConstantPool}).
    45      * they can be used with the JVMCI API (e.g. methods in {@link ConstantPool}).
    46      *
    46      *
    47      * @return the bytecode of the method, or {@code null} if {@code getCodeSize() == 0} or if the
    47      * @return the bytecode of the method, or {@code null} if {@code getCodeSize() == 0} or if the
   437         }
   437         }
   438         return result;
   438         return result;
   439     }
   439     }
   440 
   440 
   441     /**
   441     /**
   442      * Checks whether the method has bytecodes associated with it. Methods without bytecodes are
   442      * Checks whether the method has bytecodes associated with it. Note that even if this method
   443      * either abstract or native methods.
   443      * returns {@code true}, {@link #getCode} can return {@code null} if
   444      *
   444      * {@linkplain #getDeclaringClass() declaring class} is not
   445      * @return whether the definition of this method is Java bytecodes
   445      * {@linkplain ResolvedJavaType#isLinked() linked}.
       
   446      *
       
   447      * @return {@code this.getCodeSize() != 0}
   446      */
   448      */
   447     default boolean hasBytecodes() {
   449     default boolean hasBytecodes() {
   448         return isConcrete() && !isNative();
   450         return getCodeSize() != 0;
   449     }
   451     }
   450 
   452 
   451     /**
   453     /**
   452      * Checks whether the method has a receiver parameter - i.e., whether it is not static.
   454      * Checks whether the method has a receiver parameter - i.e., whether it is not static.
   453      *
   455      *
   462      */
   464      */
   463     default boolean isJavaLangObjectInit() {
   465     default boolean isJavaLangObjectInit() {
   464         return getDeclaringClass().isJavaLangObject() && getName().equals("<init>");
   466         return getDeclaringClass().isJavaLangObject() && getName().equals("<init>");
   465     }
   467     }
   466 
   468 
       
   469     /**
       
   470      * Gets a speculation log that can be used when compiling this method to make new speculations
       
   471      * and query previously failed speculations. The implementation may return a new
       
   472      * {@link SpeculationLog} object each time this method is called so its the caller's
       
   473      * responsibility to ensure the same speculation log is used throughout a compilation.
       
   474      */
   467     SpeculationLog getSpeculationLog();
   475     SpeculationLog getSpeculationLog();
   468 
       
   469     /**
       
   470      *
       
   471      * @param object
       
   472      * @param args
       
   473      * @throws InvocationTargetException
       
   474      * @throws IllegalAccessException
       
   475      */
       
   476     default JavaConstant invoke(JavaConstant object, JavaConstant... args) throws InvocationTargetException, IllegalAccessException {
       
   477         throw new InternalError("unimplemented");
       
   478     }
       
   479 }
   476 }