You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@felix.apache.org by cz...@apache.org on 2008/02/04 09:34:13 UTC
svn commit: r618199 - in /felix/trunk/scrplugin: pom.xml
src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaField.java
Author: cziegeler
Date: Mon Feb 4 00:34:12 2008
New Revision: 618199
URL: http://svn.apache.org/viewvc?rev=618199&view=rev
Log:
Felix-478: Fix classloading problems when trying to initialize a compiled class by adding slf4j to the classpath and provide a better error handling if classes can't be loaded.
Modified:
felix/trunk/scrplugin/pom.xml
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaField.java
Modified: felix/trunk/scrplugin/pom.xml
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/pom.xml?rev=618199&r1=618198&r2=618199&view=diff
==============================================================================
--- felix/trunk/scrplugin/pom.xml (original)
+++ felix/trunk/scrplugin/pom.xml Mon Feb 4 00:34:12 2008
@@ -73,6 +73,7 @@
<artifactId>maven-plugin-api</artifactId>
<version>2.0.7</version>
</dependency>
+
<dependency>
<groupId>org.apache.maven</groupId>
<artifactId>maven-archiver</artifactId>
@@ -84,5 +85,17 @@
<artifactId>qdox</artifactId>
<version>1.6.3</version>
</dependency>
+
+ <!-- Logging support -->
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-api</artifactId>
+ <version>1.4.3</version>
+ </dependency>
+ <dependency>
+ <groupId>org.slf4j</groupId>
+ <artifactId>slf4j-simple</artifactId>
+ <version>1.4.3</version>
+ </dependency>
</dependencies>
</project>
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java?rev=618199&r1=618198&r2=618199&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/JavaClassDescriptorManager.java Mon Feb 4 00:34:12 2008
@@ -37,6 +37,8 @@
import org.apache.maven.plugin.logging.Log;
import org.apache.maven.project.MavenProject;
import org.codehaus.plexus.util.IOUtil;
+import org.slf4j.Logger;
+import org.slf4j.LoggerFactory;
import com.thoughtworks.qdox.JavaDocBuilder;
import com.thoughtworks.qdox.model.JavaSource;
@@ -49,6 +51,8 @@
protected static final String SERVICE_COMPONENT = "Service-Component";
+ protected final Logger logger = LoggerFactory.getLogger(this.getClass());
+
/** The sources read by qdox. */
protected final JavaSource[] sources;
@@ -220,7 +224,7 @@
} catch (IOException ioe) {
throw new MojoFailureException("Unable to add target directory to classloader.");
}
- return new URLClassLoader(path);
+ return new URLClassLoader(path, this.getClass().getClassLoader());
}
protected Manifest getManifest(Artifact artifact) throws IOException {
Modified: felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaField.java
URL: http://svn.apache.org/viewvc/felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaField.java?rev=618199&r1=618198&r2=618199&view=diff
==============================================================================
--- felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaField.java (original)
+++ felix/trunk/scrplugin/src/main/java/org/apache/felix/scrplugin/tags/qdox/QDoxJavaField.java Mon Feb 4 00:34:12 2008
@@ -53,10 +53,25 @@
return value.toString();
}
return null;
+ } catch (NoClassDefFoundError e) {
+ // ignore and try qdox
} catch (Exception e) {
- // ignore and return null
- return null;
+ // ignore and try qdox
}
+ String value = this.field.getInitializationExpression();
+ if ( value != null ) {
+ int pos = value.indexOf("\"");
+ if ( pos != -1 ) {
+ try {
+ value = value.substring(pos + 1);
+ value = value.substring(0, value.lastIndexOf("\""));
+ } catch (ArrayIndexOutOfBoundsException aioobe) {
+ // ignore this as this is a qdox problem
+ value = this.field.getInitializationExpression();
+ }
+ }
+ }
+ return value;
}
/**