aboutsummaryrefslogtreecommitdiff
path: root/src/main/javassist/runtime/Desc.java
diff options
context:
space:
mode:
Diffstat (limited to 'src/main/javassist/runtime/Desc.java')
-rw-r--r--src/main/javassist/runtime/Desc.java33
1 files changed, 16 insertions, 17 deletions
diff --git a/src/main/javassist/runtime/Desc.java b/src/main/javassist/runtime/Desc.java
index fa86a74..c733b30 100644
--- a/src/main/javassist/runtime/Desc.java
+++ b/src/main/javassist/runtime/Desc.java
@@ -1,11 +1,12 @@
/*
* Javassist, a Java-bytecode translator toolkit.
- * Copyright (C) 1999-2007 Shigeru Chiba. All Rights Reserved.
+ * Copyright (C) 1999- Shigeru Chiba. All Rights Reserved.
*
* The contents of this file are subject to the Mozilla Public License Version
* 1.1 (the "License"); you may not use this file except in compliance with
* the License. Alternatively, the contents of this file may be used under
- * the terms of the GNU Lesser General Public License Version 2.1 or later.
+ * the terms of the GNU Lesser General Public License Version 2.1 or later,
+ * or the Apache License Version 2.0.
*
* Software distributed under the License is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the License
@@ -27,27 +28,25 @@ public class Desc {
* Specifies how a <code>java.lang.Class</code> object is loaded.
*
* <p>If true, it is loaded by:
- * <ul><pre>Thread.currentThread().getContextClassLoader().loadClass()</pre></ul>
+ * <pre>Thread.currentThread().getContextClassLoader().loadClass()</pre>
* <p>If false, it is loaded by <code>Class.forName()</code>.
* The default value is false.
*/
public static boolean useContextClassLoader = false;
- private static Class getClassObject(String name)
+ private static Class<?> getClassObject(String name)
throws ClassNotFoundException
{
if (useContextClassLoader)
- return Thread.currentThread().getContextClassLoader()
- .loadClass(name);
- else
- return Class.forName(name);
+ return Class.forName(name, true, Thread.currentThread().getContextClassLoader());
+ return Class.forName(name);
}
/**
* Interprets the given class name.
* It is used for implementing <code>$class</code>.
*/
- public static Class getClazz(String name) {
+ public static Class<?> getClazz(String name) {
try {
return getClassObject(name);
}
@@ -63,7 +62,7 @@ public class Desc {
* Interprets the given type descriptor representing a method
* signature. It is used for implementing <code>$sig</code>.
*/
- public static Class[] getParams(String desc) {
+ public static Class<?>[] getParams(String desc) {
if (desc.charAt(0) != '(')
throw new RuntimeException("$sig: internal error");
@@ -74,17 +73,17 @@ public class Desc {
* Interprets the given type descriptor.
* It is used for implementing <code>$type</code>.
*/
- public static Class getType(String desc) {
- Class[] result = getType(desc, desc.length(), 0, 0);
+ public static Class<?> getType(String desc) {
+ Class<?>[] result = getType(desc, desc.length(), 0, 0);
if (result == null || result.length != 1)
throw new RuntimeException("$type: internal error");
return result[0];
}
- private static Class[] getType(String desc, int descLen,
+ private static Class<?>[] getType(String desc, int descLen,
int start, int num) {
- Class clazz;
+ Class<?> clazz;
if (start >= descLen)
return new Class[num];
@@ -124,12 +123,12 @@ public class Desc {
return new Class[num];
}
- Class[] result = getType(desc, descLen, start + 1, num + 1);
+ Class<?>[] result = getType(desc, descLen, start + 1, num + 1);
result[num] = clazz;
return result;
}
- private static Class[] getClassType(String desc, int descLen,
+ private static Class<?>[] getClassType(String desc, int descLen,
int start, int num) {
int end = start;
while (desc.charAt(end) == '[')
@@ -147,7 +146,7 @@ public class Desc {
else
cname = desc.substring(start, end + 1);
- Class[] result = getType(desc, descLen, end + 1, num + 1);
+ Class<?>[] result = getType(desc, descLen, end + 1, num + 1);
try {
result[num] = getClassObject(cname.replace('/', '.'));
}