summaryrefslogtreecommitdiffstats
path: root/src/java/com/jogamp/common/util
diff options
context:
space:
mode:
authorMark Rothwell <[email protected]>2010-06-26 15:36:02 +0000
committerMark Rothwell <[email protected]>2010-06-26 15:36:02 +0000
commitffde1f44409bc7d49ceb18554c660bf9091cac42 (patch)
tree97642dddd8c2d14b9caef962ee9a75114d2ef66a /src/java/com/jogamp/common/util
parent198cccab882db0409ee8b18fcafb20f079d9e01e (diff)
parentae37ac16a13aa62cd6e7a6ff0346403c5aa6b3e5 (diff)
Merge branch 'master' of git://github.com/mbien/gluegen into freebsd-fixes
Diffstat (limited to 'src/java/com/jogamp/common/util')
-rw-r--r--src/java/com/jogamp/common/util/MiscUtils.java57
-rw-r--r--src/java/com/jogamp/common/util/ReflectionUtil.java36
2 files changed, 18 insertions, 75 deletions
diff --git a/src/java/com/jogamp/common/util/MiscUtils.java b/src/java/com/jogamp/common/util/MiscUtils.java
deleted file mode 100644
index dd32951..0000000
--- a/src/java/com/jogamp/common/util/MiscUtils.java
+++ /dev/null
@@ -1,57 +0,0 @@
-/*
- * Copyright (c) 2010, Sven Gothel
- * All rights reserved.
- *
- * Redistribution and use in source and binary forms, with or without
- * modification, are permitted provided that the following conditions are met:
- * * Redistributions of source code must retain the above copyright
- * notice, this list of conditions and the following disclaimer.
- * * Redistributions in binary form must reproduce the above copyright
- * notice, this list of conditions and the following disclaimer in the
- * documentation and/or other materials provided with the distribution.
- * * Neither the name of Sven Gothel nor the
- * names of its contributors may be used to endorse or promote products
- * derived from this software without specific prior written permission.
- *
- * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
- * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
- * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
- * DISCLAIMED. IN NO EVENT SHALL Sven Gothel BE LIABLE FOR ANY
- * DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
- * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
- * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND
- * ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
- * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
- * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
- */
-
-package com.jogamp.common.util;
-
-import java.util.*;
-
-public class MiscUtils {
-
- public static StringBuffer append(StringBuffer sb, List list) {
- sb.append("[");
- if(null!=list&&list.size()>0) {
- boolean comma = false;
- for(Iterator iter=list.iterator(); iter.hasNext(); ) {
- if(comma) { sb.append(", "); }
- Object o = iter.next();
- if(o instanceof List) {
- sb = append(sb, (List)o);
- } else {
- sb.append(o);
- }
- comma = true;
- }
- }
- sb.append("]");
- return sb;
- }
-
- public static String toString(List list) {
- return append(new StringBuffer(), list).toString();
- }
-}
-
diff --git a/src/java/com/jogamp/common/util/ReflectionUtil.java b/src/java/com/jogamp/common/util/ReflectionUtil.java
index b9c6ef0..fc4352f 100644
--- a/src/java/com/jogamp/common/util/ReflectionUtil.java
+++ b/src/java/com/jogamp/common/util/ReflectionUtil.java
@@ -47,9 +47,9 @@ public final class ReflectionUtil {
/**
* Returns true only if the class could be loaded.
*/
- public static final boolean isClassAvailable(String clazzName) {
+ public static final boolean isClassAvailable(String clazzName, ClassLoader cl) {
try {
- return null != Class.forName(clazzName, false, ReflectionUtil.class.getClassLoader());
+ return null != Class.forName(clazzName, false, cl);
} catch (ClassNotFoundException e) {
return false;
}
@@ -59,26 +59,26 @@ public final class ReflectionUtil {
* Loads and returns the class or null.
* @see Class#forName(java.lang.String, boolean, java.lang.ClassLoader)
*/
- public static final Class getClass(String clazzName, boolean initialize)
+ public static final Class getClass(String clazzName, boolean initialize, ClassLoader cl)
throws JogampRuntimeException {
try {
- return getClassImpl(clazzName, initialize);
+ return getClassImpl(clazzName, initialize, cl);
} catch (ClassNotFoundException e) {
throw new JogampRuntimeException(clazzName + " not available", e);
}
}
- private static Class getClassImpl(String clazzName, boolean initialize) throws ClassNotFoundException {
- return Class.forName(clazzName, initialize, ReflectionUtil.class.getClassLoader());
+ private static Class getClassImpl(String clazzName, boolean initialize, ClassLoader cl) throws ClassNotFoundException {
+ return Class.forName(clazzName, initialize, cl);
}
/**
* @throws JogampRuntimeException if the constructor can not be delivered.
*/
- public static final Constructor getConstructor(String clazzName, Class[] cstrArgTypes)
+ public static final Constructor getConstructor(String clazzName, ClassLoader cl, Class[] cstrArgTypes)
throws JogampRuntimeException {
try {
- return getConstructor(getClassImpl(clazzName, true), cstrArgTypes);
+ return getConstructor(getClassImpl(clazzName, true, cl), cstrArgTypes);
} catch (ClassNotFoundException ex) {
throw new JogampRuntimeException(clazzName + " not available", ex);
}
@@ -109,9 +109,9 @@ public final class ReflectionUtil {
}
}
- public static final Constructor getConstructor(String clazzName)
+ public static final Constructor getConstructor(String clazzName, ClassLoader cl)
throws JogampRuntimeException {
- return getConstructor(clazzName, new Class[0]);
+ return getConstructor(clazzName, cl, new Class[0]);
}
/**
@@ -147,30 +147,30 @@ public final class ReflectionUtil {
return createInstance(clazz, cstrArgTypes, cstrArgs);
}
- public static final Object createInstance(String clazzName, Class[] cstrArgTypes, Object[] cstrArgs)
+ public static final Object createInstance(String clazzName, ClassLoader cl, Class[] cstrArgTypes, Object[] cstrArgs)
throws JogampRuntimeException, RuntimeException
{
try {
- return createInstance(getClassImpl(clazzName, true), cstrArgTypes, cstrArgs);
+ return createInstance(getClassImpl(clazzName, true, cl), cstrArgTypes, cstrArgs);
} catch (ClassNotFoundException ex) {
throw new JogampRuntimeException(clazzName + " not available", ex);
}
}
- public static final Object createInstance(String clazzName, Object[] cstrArgs)
+ public static final Object createInstance(String clazzName, ClassLoader cl, Object[] cstrArgs)
throws JogampRuntimeException, RuntimeException
{
Class[] cstrArgTypes = new Class[cstrArgs.length];
for(int i=0; i<cstrArgs.length; i++) {
cstrArgTypes[i] = cstrArgs[i].getClass();
}
- return createInstance(clazzName, cstrArgTypes, cstrArgs);
+ return createInstance(clazzName, cl, cstrArgTypes, cstrArgs);
}
- public static final Object createInstance(String clazzName)
+ public static final Object createInstance(String clazzName, ClassLoader cl)
throws JogampRuntimeException, RuntimeException
{
- return createInstance(clazzName, new Class[0], null);
+ return createInstance(clazzName, cl, new Class[0], null);
}
public static final boolean instanceOf(Object obj, String clazzName) {
@@ -214,12 +214,12 @@ public final class ReflectionUtil {
/**
* @throws JogampRuntimeException if the instance can not be created.
*/
- public static final Object callStaticMethod(String clazzName, String methodName, Class[] argTypes, Object[] args)
+ public static final Object callStaticMethod(String clazzName, ClassLoader cl, String methodName, Class[] argTypes, Object[] args)
throws JogampRuntimeException, RuntimeException
{
Class clazz;
try {
- clazz = getClassImpl(clazzName, true);
+ clazz = getClassImpl(clazzName, true, cl);
} catch (ClassNotFoundException ex) {
throw new JogampRuntimeException(clazzName + " not available", ex);
}