1 // -*- Mode: Java; indent-tabs-mode: t; tab-width: 4 -*-
2 // ---------------------------------------------------------------------------
4 // Copyright (C) Stephanie Gawroriski <xer@multiphasicapps.net>
5 // ---------------------------------------------------------------------------
6 // SquirrelJME is under the GNU General Public License v3+, or later.
7 // See license.mkd for licensing and copyright information.
8 // ---------------------------------------------------------------------------
10 package cc
.squirreljme
.jvm
;
13 * Adjustments to class loading.
17 public final class ClassLoadingAdjustments
20 * Is this class deferred loaded?
22 * @param __cl The class to check.
23 * @return If the class is deferred loaded.
24 * @throws NullPointerException On null arguments.
27 public static boolean isDeferredLoad(String __cl
)
28 throws NullPointerException
31 throw new NullPointerException("NARG");
33 // If this is an array type, check the component since some arrays
34 // we will not want to specially handle. Naturally if this is an
35 // array of an array it will be expanded accordingly.
36 if (__cl
.startsWith("[L") && __cl
.endsWith(";"))
37 return ClassLoadingAdjustments
.isDeferredLoad(
38 __cl
.substring(2, __cl
.length() - 1));
40 // Primitive or normal class
54 // Primitive array types
65 // Common Java objects
66 case "java/io/IOException":
67 case "java/io/PrintStream":
68 case "java/lang/Appendable":
69 case "java/lang/ArithmeticException":
70 case "java/lang/ArrayIndexOutOfBoundsException":
71 case "java/lang/AssertionError":
72 case "java/lang/AutoCloseable":
73 case "java/lang/Boolean":
74 case "java/lang/Byte":
75 case "java/lang/Character":
76 case "java/lang/Class":
77 case "java/lang/ClassCastException":
78 case "java/lang/Cloneable":
79 case "java/lang/Closeable":
80 case "java/lang/Comparable":
81 case "java/lang/Double":
82 case "java/lang/Enum":
83 case "java/lang/Error":
84 case "java/lang/Float":
85 case "java/lang/IllegalArgumentException":
86 case "java/lang/IllegalMonitorStateException":
87 case "java/lang/IllegalStateException":
88 case "java/lang/IllegalThreadStateException":
89 case "java/lang/IndexOutOfBoundsException":
90 case "java/lang/Integer":
91 case "java/lang/InterruptedException":
92 case "java/lang/Long":
93 case "java/lang/Math":
94 case "java/lang/NegativeArraySizeException":
95 case "java/lang/NoClassDefFoundError":
96 case "java/lang/NoSuchElementException":
97 case "java/lang/NullPointerException":
98 case "java/lang/Number":
99 case "java/lang/Object":
100 case "java/lang/OutOfMemoryError":
101 case "java/lang/Runtime":
102 case "java/lang/RuntimeException":
103 case "java/lang/Short":
104 case "java/lang/String":
105 case "java/lang/StringBuffer":
106 case "java/lang/StringBuilder":
107 case "java/lang/StringIndexOutOfBoundsException":
108 case "java/lang/System":
109 case "java/lang/Thread":
110 case "java/lang/Throwable":
111 case "java/lang/VirtualMachineError":
112 case "java/lang/ref/Reference":
113 case "java/lang/ref/ReferenceQueue":
114 case "java/lang/ref/WeakReference":
115 case "java/util/Deque":
116 case "java/util/Formatter":
117 case "java/util/Iterable":
118 case "java/util/Iterator":
119 case "java/util/List":
120 case "java/util/Map":
121 case "java/util/Objects":
122 case "java/util/Queue":
123 case "java/util/Random":
124 case "java/util/Set":
127 // SquirrelJME special classes
131 case "cc/squirreljme/jvm/Assembly":
132 case "cc/squirreljme/jvm/Constants":
133 case "cc/squirreljme/runtime/cldc/debug/Debugging":
134 case "cc/squirreljme/jvm/IPCCallback":
135 case "cc/squirreljme/jvm/IPCException":
136 case "cc/squirreljme/jvm/IPCManager":
137 case "cc/squirreljme/runtime/cldc/Poking":
138 case "cc/squirreljme/jvm/SoftDouble":
139 case "cc/squirreljme/jvm/SoftFloat":
140 case "cc/squirreljme/jvm/SoftInteger":
141 case "cc/squirreljme/jvm/SoftLong":
142 case "cc/squirreljme/jvm/SystemCallError":
143 case "cc/squirreljme/jvm/SystemCallIndex":
144 case "cc/squirreljme/runtime/cldc/SquirrelJME":
148 // Certain classes within packages must be loaded in order
149 // for the VM to properly work
150 return !__cl
.startsWith("java/lang/") &&
151 !__cl
.startsWith("java/util/") &&
152 !__cl
.startsWith("java/io/") &&
153 !__cl
.startsWith("cc/squirreljme/jvm/") &&
154 !__cl
.startsWith("cc/squirreljme/runtime/cldc/");
159 * Is this class deferred loaded in relation to the current class?
161 * @param __self The current class.
162 * @param __cl The class to check.
163 * @return If the class is deferred loaded.
164 * @throws NullPointerException On null arguments.
167 public static boolean isDeferredLoad(String __self
, String __cl
)
168 throws NullPointerException
170 if (__self
== null || __cl
== null)
171 throw new NullPointerException("NARG");
173 // Same class is never deferred
174 if (__self
.equals(__cl
))
177 // Is within the same package?
178 int ls
= __self
.lastIndexOf('/');
179 if (ls
>= 0 && __self
.regionMatches(0, __cl
, 0, ls
))
182 // Use default defer logic
183 return ClassLoadingAdjustments
.isDeferredLoad(__cl
);