< prev index next >

src/jdk.vm.ci/share/classes/jdk.vm.ci.hotspot/src/jdk/vm/ci/hotspot/HotSpotSignature.java

Print this page




   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 package jdk.vm.ci.hotspot;
  24 
  25 import java.util.ArrayList;
  26 import java.util.List;
  27 
  28 import jdk.vm.ci.common.JVMCIError;
  29 import jdk.vm.ci.meta.JavaKind;
  30 import jdk.vm.ci.meta.JavaType;
  31 import jdk.vm.ci.meta.ResolvedJavaType;
  32 import jdk.vm.ci.meta.Signature;
  33 
  34 /**
  35  * Represents a method signature.
  36  */
  37 public class HotSpotSignature implements Signature {
  38 
  39     private final List<String> parameters = new ArrayList<>();
  40     private final String returnType;
  41     private final String originalString;
  42     private ResolvedJavaType[] parameterTypes;
  43     private ResolvedJavaType returnTypeCache;
  44     private final HotSpotJVMCIRuntimeProvider runtime;
  45 
  46     public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, String signature) {
  47         this.runtime = runtime;
  48         assert signature.length() > 0;


  88         } while (first == '[');
  89 
  90         switch (first) {
  91             case 'L':
  92                 while (signature.charAt(cur) != ';') {
  93                     cur++;
  94                 }
  95                 cur++;
  96                 break;
  97             case 'V':
  98             case 'I':
  99             case 'B':
 100             case 'C':
 101             case 'D':
 102             case 'F':
 103             case 'J':
 104             case 'S':
 105             case 'Z':
 106                 break;
 107             default:
 108                 throw new JVMCIError("Invalid character at index %d in signature: %s", cur, signature);
 109         }
 110         return cur;
 111     }
 112 
 113     @Override
 114     public int getParameterCount(boolean withReceiver) {
 115         return parameters.size() + (withReceiver ? 1 : 0);
 116     }
 117 
 118     @Override
 119     public JavaKind getParameterKind(int index) {
 120         return JavaKind.fromTypeString(parameters.get(index));
 121     }
 122 
 123     private static boolean checkValidCache(ResolvedJavaType type, ResolvedJavaType accessingClass) {
 124         assert accessingClass != null;
 125         if (type == null) {
 126             return false;
 127         } else if (type instanceof HotSpotResolvedObjectTypeImpl) {
 128             return ((HotSpotResolvedObjectTypeImpl) type).isDefinitelyResolvedWithRespectTo(accessingClass);




   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 package jdk.vm.ci.hotspot;
  24 
  25 import java.util.ArrayList;
  26 import java.util.List;
  27 

  28 import jdk.vm.ci.meta.JavaKind;
  29 import jdk.vm.ci.meta.JavaType;
  30 import jdk.vm.ci.meta.ResolvedJavaType;
  31 import jdk.vm.ci.meta.Signature;
  32 
  33 /**
  34  * Represents a method signature.
  35  */
  36 public class HotSpotSignature implements Signature {
  37 
  38     private final List<String> parameters = new ArrayList<>();
  39     private final String returnType;
  40     private final String originalString;
  41     private ResolvedJavaType[] parameterTypes;
  42     private ResolvedJavaType returnTypeCache;
  43     private final HotSpotJVMCIRuntimeProvider runtime;
  44 
  45     public HotSpotSignature(HotSpotJVMCIRuntimeProvider runtime, String signature) {
  46         this.runtime = runtime;
  47         assert signature.length() > 0;


  87         } while (first == '[');
  88 
  89         switch (first) {
  90             case 'L':
  91                 while (signature.charAt(cur) != ';') {
  92                     cur++;
  93                 }
  94                 cur++;
  95                 break;
  96             case 'V':
  97             case 'I':
  98             case 'B':
  99             case 'C':
 100             case 'D':
 101             case 'F':
 102             case 'J':
 103             case 'S':
 104             case 'Z':
 105                 break;
 106             default:
 107                 throw new InternalError(String.format("Invalid character at index %d in signature: %s", cur, signature));
 108         }
 109         return cur;
 110     }
 111 
 112     @Override
 113     public int getParameterCount(boolean withReceiver) {
 114         return parameters.size() + (withReceiver ? 1 : 0);
 115     }
 116 
 117     @Override
 118     public JavaKind getParameterKind(int index) {
 119         return JavaKind.fromTypeString(parameters.get(index));
 120     }
 121 
 122     private static boolean checkValidCache(ResolvedJavaType type, ResolvedJavaType accessingClass) {
 123         assert accessingClass != null;
 124         if (type == null) {
 125             return false;
 126         } else if (type instanceof HotSpotResolvedObjectTypeImpl) {
 127             return ((HotSpotResolvedObjectTypeImpl) type).isDefinitelyResolvedWithRespectTo(accessingClass);


< prev index next >