# HG changeset patch # User twisti # Date 1392758471 28800 # Node ID 3e5b9a4d5986338e67a611bb29bffb44632e21d3 # Parent bbf84e85b775ebe94f9a03bd8af76f2efcb7e3bf added Array.getLength substitution diff -r bbf84e85b775 -r 3e5b9a4d5986 graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java --- a/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java Tue Feb 18 11:16:48 2014 -0800 +++ b/graal/com.oracle.graal.replacements/src/com/oracle/graal/replacements/ArraySubstitutions.java Tue Feb 18 13:21:11 2014 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -36,4 +36,13 @@ public static Object newInstance(Class componentType, int length) throws NegativeArraySizeException { return DynamicNewArrayNode.newArray(GuardingPiNode.guardingNonNull(componentType), length); } + + @MethodSubstitution + public static int getLength(Object array) { + if (!array.getClass().isArray()) { + throw new IllegalArgumentException("Argument is not an array"); + } + return ArrayLengthNode.arrayLength(array); + } + }