Saturday, April 11, 2009

"Autoboxing" Array is Illegal

Wrote some array methods today then I had a question about auto-converting an int[] to Integer[] (auto-boxing) while I was driving back home.

For instance, this works,
public static  V wrapper(V v, Class clazz){
return v;
}

int i = wrapper(1, Integer.class);

But this is not compilable,
public static  V[] wrapperArray(V[] v, Class clazz){
return v;
}

int[] i2 = wrapperArray(i2, int.class);

int.class will be auto-converted to Integer.class but int[] will not. I can't find the exact line in JLS describing this, do leave a comment if you could.

Friday, April 10, 2009

Strange Maven Plugin Metadata Problem

Not too sure when, my Maven Eclipse plugin has been upgraded to 2.6 and probably due to some metadata "corruption", its dependencies were not downloaded, running it caused ClassNotFoundException:

[INFO] ------------------------------------------------------------------------
[INFO] Building Whatever
[INFO] task-segment: [eclipse:eclipse]
[INFO] ------------------------------------------------------------------------
[INFO] Preparing eclipse:eclipse
...
-----------------------------------------------------
this realm = app0.child-container[org.apache.maven.plugins:maven-eclipse-plugin:2.6]
urls[0] = file:/home/yclian/.m2/repository/org/apache/maven/plugins/maven-eclipse-plugin/2.6/maven-eclipse-plugin-2.6.jar
urls[1] = file:/home/yclian/.m2/repository/org/codehaus/plexus/plexus-utils/1.1/plexus-utils-1.1.jar
Number of imports: 10
import: org.codehaus.classworlds.Entry@a6c57a42
import: org.codehaus.classworlds.Entry@12f43f3b
import: org.codehaus.classworlds.Entry@20025374
import: org.codehaus.classworlds.Entry@f8e44ca4
import: org.codehaus.classworlds.Entry@92758522
import: org.codehaus.classworlds.Entry@ebf2705b
import: org.codehaus.classworlds.Entry@bb25e54
import: org.codehaus.classworlds.Entry@bece5185
import: org.codehaus.classworlds.Entry@3fee8e37
import: org.codehaus.classworlds.Entry@3fee19d8


this realm = plexus.core
urls[0] = file:/opt/maven-2/lib/maven-2.1.0-uber.jar
Number of imports: 10
import: org.codehaus.classworlds.Entry@a6c57a42
import: org.codehaus.classworlds.Entry@12f43f3b
import: org.codehaus.classworlds.Entry@20025374
import: org.codehaus.classworlds.Entry@f8e44ca4
import: org.codehaus.classworlds.Entry@92758522
import: org.codehaus.classworlds.Entry@ebf2705b
import: org.codehaus.classworlds.Entry@bb25e54
import: org.codehaus.classworlds.Entry@bece5185
import: org.codehaus.classworlds.Entry@3fee8e37
import: org.codehaus.classworlds.Entry@3fee19d8
-----------------------------------------------------
[INFO] ------------------------------------------------------------------------
[ERROR] BUILD ERROR
[INFO] ------------------------------------------------------------------------
[INFO] Internal error in the plugin manager executing goal 'org.apache.maven.plugins:maven-eclipse-plugin:2.6:eclipse': Unable to load the mojo 'org.apache.maven.plugins:maven-eclipse-plugin:2.6:eclipse' in the plugin 'org.apache.maven.plugins:maven-eclipse-plugin'. A required class is missing: org/codehaus/plexus/resource/loader/ResourceNotFoundException
org.codehaus.plexus.resource.loader.ResourceNotFoundException

Tried running Maven with the -cpu argument but it didn't help. maven-metadata-central.xml showed the latest as 2.5.1 and others got 2.6. Fixed by deleting metadata files then re-run Maven.

Bah.