-
Notifications
You must be signed in to change notification settings - Fork 19
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Arrays.copyOf - no such method error in java 1.5 #1
Comments
Yes. Arrays.copyOf is a Java 1.6 method. |
Updated Java docs to reflect the current state of affairs.
Array.copyOf is replaced with System.arraycopy.. Original - Updated: |
The same problem is still exists for android 2.1 (api 8): java.lang.NoSuchMethodError: java.util.Arrays.copyOf |
HI vovkab, Thanks, |
Hi anujgandharv, [Arrays.copyOf](http://developer.android.com/reference/java/util/Arrays.html#copyOf%28U[], int, java.lang.Class<? extends T[]>%29) is available on android only starting from api 9. If you try to run it on api 8 you will get an error. The solution can be replacing all Arrays.copyOf with System.arraycopy Thanks! |
Thanks Vladimir. |
Hi Anuj Looks like I'm on wrong "forum" :) I use latest jackson: And looks like some part of it uses Arrays.copyOf Just opened a new ticket on fasterxml repo: Issue #131 Thanks for help! |
Hi Anuj,
I am seeing below exception, I think this is due to Arrays.copyOf method is introduced in 1.6,
As we are saying we support version 1.5 also, I think we need to provide our own method for this function.
java.lang.NoSuchMethodError: java/util/Arrays.copyOf([Ljava/lang/Object;I)[Ljava/lang/Object;
at org.easetech.easytest.loader.CSVDataLoader.writeData(CSVDataLoader.java:182)
at org.easetech.easytest.util.RunAftersWithOutputData.evaluate(RunAftersWithOutputData.java:120)
I saw below code from , http://stackoverflow.com/questions/2789193/java-copyof-method-problem-with-an-array-of-objects
/**
Reallocates an array with a new size, and copies the contents
of the old array to the new array.
@param oldArray the old array, to be reallocated.
@param newSize the new array size.
@return A new array with the same contents.
*/
private static Object resizeArray (Object oldArray, int newSize) {
int oldSize = java.lang.reflect.Array.getLength(oldArray);
Class elementType = oldArray.getClass().getComponentType();
Object newArray = java.lang.reflect.Array.newInstance(
elementType,newSize);
int preserveLength = Math.min(oldSize,newSize);
if (preserveLength > 0)
System.arraycopy (oldArray,0,newArray,0,preserveLength);
return newArray;
}
The text was updated successfully, but these errors were encountered: