|
From: <sp...@us...> - 2011-07-12 19:29:22
|
Revision: 3577
http://java-game-lib.svn.sourceforge.net/java-game-lib/?rev=3577&view=rev
Author: spasi
Date: 2011-07-12 19:29:15 +0000 (Tue, 12 Jul 2011)
Log Message:
-----------
Added friendly error message when a non-static inner class is registered with the transformer.
Modified Paths:
--------------
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java
trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-12 18:30:56 UTC (rev 3576)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedForeach.java 2011-07-12 19:29:15 UTC (rev 3577)
@@ -40,8 +40,8 @@
*/
public class MappedForeach<T extends MappedObject> implements Iterable<T> {
- private final T mapped;
- private final int elementCount;
+ final T mapped;
+ final int elementCount;
MappedForeach(T mapped, int elementCount) {
this.mapped = mapped;
Modified: trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java
===================================================================
--- trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-12 18:30:56 UTC (rev 3576)
+++ trunk/LWJGL/src/java/org/lwjgl/util/mapped/MappedObjectTransformer.java 2011-07-12 19:29:15 UTC (rev 3577)
@@ -36,7 +36,7 @@
static final boolean PRINT_ACTIVITY = false;//LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintActivity");
static final boolean PRINT_BYTECODE = false; //LWJGLUtil.DEBUG && LWJGLUtil.getPrivilegedBoolean("org.lwjgl.util.mapped.PrintBytecode");
- private static final Map<String, MappedSubtypeInfo> className_to_subtype;
+ static final Map<String, MappedSubtypeInfo> className_to_subtype;
static {
className_to_subtype = new HashMap<String, MappedSubtypeInfo>();
@@ -80,6 +80,9 @@
if ( mapped == null )
throw new InternalError("missing " + MappedType.class.getName() + " annotation");
+ if ( type.getEnclosingClass() != null && !Modifier.isStatic(type.getModifiers()) )
+ throw new InternalError("only top-level or static inner classes are allowed");
+
String className = jvmClassName(type);
MappedSubtypeInfo mappedType = new MappedSubtypeInfo(className, mapped.sizeof(), mapped.align());
@@ -88,7 +91,7 @@
for ( Field field : type.getDeclaredFields() ) {
// static fields are never mapped
- if ( (field.getModifiers() & Modifier.STATIC) != 0 )
+ if ( Modifier.isStatic(field.getModifiers()) )
continue;
// we only support primitives and ByteBuffers
@@ -135,7 +138,7 @@
}
}
- private static final String view_constructor_method = "_construct_view_";
+ static final String view_constructor_method = "_construct_view_";
static byte[] transformFieldAccess(final String className, byte[] bytecode) {
int flags = 0;//ClassWriter.COMPUTE_FRAMES;
@@ -525,7 +528,7 @@
}
}
- private static void pushInt(MethodVisitor mv, int value) {
+ static void pushInt(MethodVisitor mv, int value) {
if ( value == -1 )
mv.visitInsn(ICONST_M1);
else if ( value == 0 )
@@ -548,7 +551,7 @@
mv.visitLdcInsn(Integer.valueOf(value));
}
- private static String jvmClassName(Class<?> type) {
+ static String jvmClassName(Class<?> type) {
return type.getName().replace('.', '/');
}
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|