comparison graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java @ 13971:3e5b9a4d5986

added Array.getLength substitution
author twisti
date Tue, 18 Feb 2014 13:21:11 -0800
parents aca7481e71d1
children cc76575f485c
comparison
equal deleted inserted replaced
13970:bbf84e85b775 13971:3e5b9a4d5986
1 /* 1 /*
2 * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. 2 * Copyright (c) 2013, 2014, 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.
34 34
35 @MethodSubstitution 35 @MethodSubstitution
36 public static Object newInstance(Class<?> componentType, int length) throws NegativeArraySizeException { 36 public static Object newInstance(Class<?> componentType, int length) throws NegativeArraySizeException {
37 return DynamicNewArrayNode.newArray(GuardingPiNode.guardingNonNull(componentType), length); 37 return DynamicNewArrayNode.newArray(GuardingPiNode.guardingNonNull(componentType), length);
38 } 38 }
39
40 @MethodSubstitution
41 public static int getLength(Object array) {
42 if (!array.getClass().isArray()) {
43 throw new IllegalArgumentException("Argument is not an array");
44 }
45 return ArrayLengthNode.arrayLength(array);
46 }
47
39 } 48 }