[jboss-cvs] JBossAS SVN: r63961 - in trunk: jmx/src/main/org/jboss/mx/loading and 6 other directories.
jboss-cvs-commits at lists.jboss.org
jboss-cvs-commits at lists.jboss.org
Tue Jul 10 23:57:42 EDT 2007
Author: adrian at jboss.org
Date: 2007-07-10 23:57:42 -0400 (Tue, 10 Jul 2007)
New Revision: 63961
Added:
trunk/testsuite/src/main/org/jboss/test/isolation/mbean/
trunk/testsuite/src/main/org/jboss/test/isolation/mbean/JavaClassIsolation.java
trunk/testsuite/src/main/org/jboss/test/isolation/mbean/JavaClassIsolationMBean.java
trunk/testsuite/src/main/org/jboss/test/isolation/test/JavaClassIsolationUnitTestCase.java
trunk/testsuite/src/resources/isolation/META-INF/
trunk/testsuite/src/resources/isolation/META-INF/jboss-service.xml
Modified:
trunk/j2se/src/main/org/jboss/mx/loading/RepositoryClassLoader.java
trunk/jmx/src/main/org/jboss/mx/loading/UnifiedLoaderRepository3.java
trunk/testsuite/imports/sections/isolation.xml
Log:
Port JBAS-4536 from 4.2
Modified: trunk/j2se/src/main/org/jboss/mx/loading/RepositoryClassLoader.java
===================================================================
--- trunk/j2se/src/main/org/jboss/mx/loading/RepositoryClassLoader.java 2007-07-11 03:23:50 UTC (rev 63960)
+++ trunk/j2se/src/main/org/jboss/mx/loading/RepositoryClassLoader.java 2007-07-11 03:57:42 UTC (rev 63961)
@@ -203,6 +203,13 @@
throw new ClassNotFoundException("Class Not Found(blacklist): " + name);
}
+ // For java classes go straight to the system classloader
+ if (name.startsWith("java."))
+ {
+ ClassLoader systemClassLoader = ClassLoader.getSystemClassLoader();
+ return systemClassLoader.loadClass(name);
+ }
+
try
{
result = super.loadClass(name, resolve);
Modified: trunk/jmx/src/main/org/jboss/mx/loading/UnifiedLoaderRepository3.java
===================================================================
--- trunk/jmx/src/main/org/jboss/mx/loading/UnifiedLoaderRepository3.java 2007-07-11 03:23:50 UTC (rev 63960)
+++ trunk/jmx/src/main/org/jboss/mx/loading/UnifiedLoaderRepository3.java 2007-07-11 03:57:42 UTC (rev 63961)
@@ -210,6 +210,11 @@
public Set getPackageClassLoaders(String className)
{
String pkgName = ClassLoaderUtils.getPackageName(className);
+
+ // Don't try to load java.* classes, it is impossible
+ if (pkgName.startsWith("java."))
+ return null;
+
Set pkgSet = (Set) packagesMap.get(pkgName);
if (dynamicClassLoaders.size() > 0)
{
Modified: trunk/testsuite/imports/sections/isolation.xml
===================================================================
--- trunk/testsuite/imports/sections/isolation.xml 2007-07-11 03:23:50 UTC (rev 63960)
+++ trunk/testsuite/imports/sections/isolation.xml 2007-07-11 03:57:42 UTC (rev 63961)
@@ -74,5 +74,24 @@
<include name="META-INF/*.xml"/>
</fileset>
</jar>
+
+ <!-- build test-java-class-isolation.sar -->
+ <mkdir dir="${build.resources}/isolation/java/org/jboss/test"/>
+ <copy file="${build.classes}/org/jboss/test/isolation/mbean/JavaClassIsolationMBean.class"
+ tofile="${build.resources}/isolation/java/org/jboss/test/Test.class"/>
+
+ <mkdir dir="${build.resources}/isolation/java/rmi/registry"/>
+ <copy file="${build.classes}/org/jboss/test/isolation/mbean/JavaClassIsolationMBean.class"
+ tofile="${build.resources}/isolation/java/rmi/registry/Registry.class"/>
+
+ <jar destfile="${build.lib}/test-java-class-isolation.sar">
+ <fileset dir="${build.classes}">
+ <include name="org/jboss/test/isolation/mbean/**"/>
+ </fileset>
+ <fileset dir="${build.resources}/isolation/">
+ <include name="META-INF/*.xml"/>
+ <include name="java/**"/>
+ </fileset>
+ </jar>
</target>
</project>
Added: trunk/testsuite/src/main/org/jboss/test/isolation/mbean/JavaClassIsolation.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/isolation/mbean/JavaClassIsolation.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/isolation/mbean/JavaClassIsolation.java 2007-07-11 03:57:42 UTC (rev 63961)
@@ -0,0 +1,63 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.isolation.mbean;
+
+import java.net.URL;
+
+import org.jboss.logging.Logger;
+
+/**
+ * JavaClassIsolation.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavaClassIsolation implements JavaClassIsolationMBean
+{
+ private static final Logger log = Logger.getLogger(JavaClassIsolation.class);
+
+ public void test() throws Exception
+ {
+ // Use our scoped classloader
+ ClassLoader cl = getClass().getClassLoader();
+
+ // Should be able to find the class as a resource
+ URL resource = cl.getResource("java/org/jboss/test/Test.class");
+ if (resource == null)
+ throw new RuntimeException("Unable to find resource java/org/jboss/test/Test.class");
+
+ // Should not be able to load the resource
+ try
+ {
+ cl.loadClass("java.org.jboss.test.Test");
+ throw new RuntimeException("Should not be able to load class");
+ }
+ catch (ClassNotFoundException expected)
+ {
+ // Should not be able to load it
+ log.info("Got expected exception", expected);
+ }
+
+ // Should be able to load the resgistry class even though it is in our deployment
+ cl.loadClass("java.rmi.registry.Registry");
+ }
+}
Added: trunk/testsuite/src/main/org/jboss/test/isolation/mbean/JavaClassIsolationMBean.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/isolation/mbean/JavaClassIsolationMBean.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/isolation/mbean/JavaClassIsolationMBean.java 2007-07-11 03:57:42 UTC (rev 63961)
@@ -0,0 +1,33 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.isolation.mbean;
+
+/**
+ * JavaClassIsolationMBean.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public interface JavaClassIsolationMBean
+{
+ public void test() throws Exception;
+}
Added: trunk/testsuite/src/main/org/jboss/test/isolation/test/JavaClassIsolationUnitTestCase.java
===================================================================
--- trunk/testsuite/src/main/org/jboss/test/isolation/test/JavaClassIsolationUnitTestCase.java (rev 0)
+++ trunk/testsuite/src/main/org/jboss/test/isolation/test/JavaClassIsolationUnitTestCase.java 2007-07-11 03:57:42 UTC (rev 63961)
@@ -0,0 +1,56 @@
+/*
+* JBoss, Home of Professional Open Source
+* Copyright 2006, JBoss Inc., and individual contributors as indicated
+* by the @authors tag. See the copyright.txt in the distribution for a
+* full listing of individual contributors.
+*
+* This is free software; you can redistribute it and/or modify it
+* under the terms of the GNU Lesser General Public License as
+* published by the Free Software Foundation; either version 2.1 of
+* the License, or (at your option) any later version.
+*
+* This software is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+* Lesser General Public License for more details.
+*
+* You should have received a copy of the GNU Lesser General Public
+* License along with this software; if not, write to the Free
+* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
+* 02110-1301 USA, or see the FSF site: http://www.fsf.org.
+*/
+package org.jboss.test.isolation.test;
+
+import javax.management.MBeanServerConnection;
+import javax.management.ObjectName;
+
+import org.jboss.test.JBossTestCase;
+
+/**
+ * JavaClassIsolationUnitTestCase.
+ *
+ * @author <a href="adrian at jboss.com">Adrian Brock</a>
+ * @version $Revision: 1.1 $
+ */
+public class JavaClassIsolationUnitTestCase extends JBossTestCase
+{
+ public JavaClassIsolationUnitTestCase(String name)
+ {
+ super(name);
+ }
+
+ public void testJavaClassIsNotLoadedFromIsolatedClassLoader() throws Exception
+ {
+ ObjectName name = new ObjectName("jboss.test:test=JavaClassIsolation");
+ deploy("test-java-class-isolation.sar");
+ try
+ {
+ MBeanServerConnection server = getServer();
+ server.invoke(name, "test", null, null);
+ }
+ finally
+ {
+ undeploy("test-java-class-isolation.sar");
+ }
+ }
+}
Added: trunk/testsuite/src/resources/isolation/META-INF/jboss-service.xml
===================================================================
--- trunk/testsuite/src/resources/isolation/META-INF/jboss-service.xml (rev 0)
+++ trunk/testsuite/src/resources/isolation/META-INF/jboss-service.xml 2007-07-11 03:57:42 UTC (rev 63961)
@@ -0,0 +1,10 @@
+<?xml version="1.0" encoding="UTF-8"?>
+
+<server>
+
+ <loader-repository>jboss.test:loader=JavaClassIsolation</loader-repository>
+
+ <mbean code="org.jboss.test.isolation.mbean.JavaClassIsolation"
+ name="jboss.test:test=JavaClassIsolation"/>
+
+</server>
More information about the jboss-cvs-commits
mailing list