Blame SOURCES/codemodel-remove-istack-commons-dependency.patch

117f09
commit 1c15b90aa77cbc242bcec7ea3b38eb46e4c037cb
117f09
Author: Juan Hernandez <juan.hernandez@redhat.com>
117f09
Date:   Sat Mar 31 16:25:02 2012 +0200
117f09
117f09
    Remove the dependency on istack-commons
117f09
117f09
diff --git a/codemodel-annotation-compiler/pom.xml b/codemodel-annotation-compiler/pom.xml
117f09
index 100e084..e1459bc 100644
117f09
--- a/codemodel-annotation-compiler/pom.xml
117f09
+++ b/codemodel-annotation-compiler/pom.xml
117f09
@@ -60,17 +60,6 @@
117f09
             <version>2.6</version>
117f09
         </dependency>
117f09
         <dependency>
117f09
-            <groupId>com.sun.istack</groupId>
117f09
-            <artifactId>istack-commons-tools</artifactId>
117f09
-            <version>2.5</version>
117f09
-            <exclusions>
117f09
-                <exclusion>
117f09
-                    <groupId>org.apache.ant</groupId>
117f09
-                    <artifactId>ant</artifactId>
117f09
-                </exclusion>
117f09
-            </exclusions>
117f09
-        </dependency>
117f09
-        <dependency>
117f09
             <groupId>org.apache.ant</groupId>
117f09
             <artifactId>ant</artifactId>
117f09
             <version>1.7.0</version>
117f09
diff --git a/codemodel-annotation-compiler/src/main/java/com/sun/codemodel/ac/ACTask.java b/codemodel-annotation-compiler/src/main/java/com/sun/codemodel/ac/ACTask.java
117f09
index d5b0a14..c6d799d 100644
117f09
--- a/codemodel-annotation-compiler/src/main/java/com/sun/codemodel/ac/ACTask.java
117f09
+++ b/codemodel-annotation-compiler/src/main/java/com/sun/codemodel/ac/ACTask.java
117f09
@@ -64,7 +64,6 @@ import com.sun.codemodel.JDefinedClass;
117f09
 import com.sun.codemodel.JMod;
117f09
 import com.sun.codemodel.JPackage;
117f09
 import com.sun.codemodel.JType;
117f09
-import com.sun.istack.tools.MaskingClassLoader;
117f09
 import java.io.Closeable;
117f09
 import java.net.MalformedURLException;
117f09
 import java.net.URL;
117f09
diff --git a/codemodel-annotation-compiler/src/main/java/com/sun/codemodel/ac/MaskingClassLoader.java b/codemodel-annotation-compiler/src/main/java/com/sun/codemodel/ac/MaskingClassLoader.java
117f09
new file mode 100644
117f09
index 0000000..d303c11
117f09
--- /dev/null
117f09
+++ b/codemodel-annotation-compiler/src/main/java/com/sun/codemodel/ac/MaskingClassLoader.java
117f09
@@ -0,0 +1,84 @@
117f09
+/*
117f09
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS HEADER.
117f09
+ *
117f09
+ * Copyright (c) 1997-2010 Oracle and/or its affiliates. All rights reserved.
117f09
+ *
117f09
+ * The contents of this file are subject to the terms of either the GNU
117f09
+ * General Public License Version 2 only ("GPL") or the Common Development
117f09
+ * and Distribution License("CDDL") (collectively, the "License").  You
117f09
+ * may not use this file except in compliance with the License.  You can
117f09
+ * obtain a copy of the License at
117f09
+ * https://glassfish.dev.java.net/public/CDDL+GPL_1_1.html
117f09
+ * or packager/legal/LICENSE.txt.  See the License for the specific
117f09
+ * language governing permissions and limitations under the License.
117f09
+ *
117f09
+ * When distributing the software, include this License Header Notice in each
117f09
+ * file and include the License file at packager/legal/LICENSE.txt.
117f09
+ *
117f09
+ * GPL Classpath Exception:
117f09
+ * Oracle designates this particular file as subject to the "Classpath"
117f09
+ * exception as provided by Oracle in the GPL Version 2 section of the License
117f09
+ * file that accompanied this code.
117f09
+ *
117f09
+ * Modifications:
117f09
+ * If applicable, add the following below the License Header, with the fields
117f09
+ * enclosed by brackets [] replaced by your own identifying information:
117f09
+ * "Portions Copyright [year] [name of copyright owner]"
117f09
+ *
117f09
+ * Contributor(s):
117f09
+ * If you wish your version of this file to be governed by only the CDDL or
117f09
+ * only the GPL Version 2, indicate your decision by adding "[Contributor]
117f09
+ * elects to include this software in this distribution under the [CDDL or GPL
117f09
+ * Version 2] license."  If you don't indicate a single choice of license, a
117f09
+ * recipient has the option to distribute your version of this file under
117f09
+ * either the CDDL, the GPL Version 2 or to extend the choice of license to
117f09
+ * its licensees as provided above.  However, if you add GPL Version 2 code
117f09
+ * and therefore, elected the GPL Version 2 license, then the option applies
117f09
+ * only if the new code is made subject to such option by the copyright
117f09
+ * holder.
117f09
+ */
117f09
+
117f09
+package com.sun.codemodel.ac;
117f09
+
117f09
+import java.util.Collection;
117f09
+
117f09
+/**
117f09
+ * {@link ClassLoader} that masks a specified set of classes
117f09
+ * from its parent class loader.
117f09
+ *
117f09
+ * 

117f09
+ * This code is used to create an isolated environment.
117f09
+ *
117f09
+ * @author Kohsuke Kawaguchi
117f09
+ */
117f09
+public class MaskingClassLoader extends ClassLoader {
117f09
+
117f09
+    private final String[] masks;
117f09
+
117f09
+    public MaskingClassLoader(String... masks) {
117f09
+        this.masks = masks;
117f09
+    }
117f09
+
117f09
+    public MaskingClassLoader(Collection<String> masks) {
117f09
+        this(masks.toArray(new String[masks.size()]));
117f09
+    }
117f09
+
117f09
+    public MaskingClassLoader(ClassLoader parent, String... masks) {
117f09
+        super(parent);
117f09
+        this.masks = masks;
117f09
+    }
117f09
+
117f09
+    public MaskingClassLoader(ClassLoader parent, Collection<String> masks) {
117f09
+        this(parent, masks.toArray(new String[masks.size()]));
117f09
+    }
117f09
+
117f09
+    @Override
117f09
+    protected synchronized Class loadClass(String name, boolean resolve) throws ClassNotFoundException {
117f09
+        for (String mask : masks) {
117f09
+            if(name.startsWith(mask))
117f09
+                throw new ClassNotFoundException();
117f09
+        }
117f09
+
117f09
+        return super.loadClass(name, resolve);
117f09
+    }
117f09
+}