Hi,

On Fri, Nov 09, 2001 at 10:00:10PM -0500, Brian Jones wrote:
> I was able to compile kissme after updating from cvs tonight.  I had
> to get the latest antlr from http://www.antlr.org instead of KOPI as
> in the BUILDING file.  I haven't been able to make any use of it yet
> though.

Yeah. I also got it to compile from CVS. I was even able to make the
VMClassLoader change. And make my hellotype program run with it.

Attached is the diff for Classpath (which includes a compatibility method
so VMs don't have to switch implementations if they don't want or can
immediatly) and a diff for kissme against the current CVS (Kissme can
probably be cleaned up a bit to use the newly added functions also
internally so it has to do a little less strcmps.)

Cheers,

Mark
-- 
Stuff to read:
    <http://www.toad.com/gnu/whatswrong.html>
  What's Wrong with Copy Protection, by John Gilmore
public class hellotype {

public static void main(String[] argv) 
    {
      System.out.println(Integer.TYPE);
      System.out.println(Character.TYPE);
      System.out.println(Double.TYPE);
      System.out.println(Float.TYPE);
      System.out.println(Long.TYPE);
      System.out.println(Short.TYPE);
      System.out.println(Boolean.TYPE);
      System.out.println(Byte.TYPE);
      System.out.println(Void.TYPE);
    }

}
Index: java/lang/Boolean.java
===================================================================
RCS file: /cvs/classpath/java/lang/Boolean.java,v
retrieving revision 1.16
diff -u -r1.16 Boolean.java
--- java/lang/Boolean.java      2001/07/17 23:06:09     1.16
+++ java/lang/Boolean.java      2001/11/10 16:49:56
@@ -60,7 +60,7 @@
      * The primitive type <code>boolean</code> is represented by this 
      * <code>Class</code> object.
      */
-    public static final Class TYPE = VMClassLoader.getPrimitiveClass("boolean");
+    public static final Class TYPE = VMClassLoader.getPrimitiveClass('Z');
     
     /**
      * The immutable value of this Boolean.
Index: java/lang/Byte.java
===================================================================
RCS file: /cvs/classpath/java/lang/Byte.java,v
retrieving revision 1.17
diff -u -r1.17 Byte.java
--- java/lang/Byte.java 2001/07/23 20:01:44     1.17
+++ java/lang/Byte.java 2001/11/10 16:49:56
@@ -57,7 +57,7 @@
    * The primitive type <code>byte</code> is represented by this 
    * <code>Class</code> object.
    */
-  public static final Class TYPE = VMClassLoader.getPrimitiveClass("byte");
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('B');
 
   /**
    * The immutable value of this Byte.
Index: java/lang/Character.java
===================================================================
RCS file: /cvs/classpath/java/lang/Character.java,v
retrieving revision 1.16
diff -u -r1.16 Character.java
--- java/lang/Character.java    2001/09/05 19:30:55     1.16
+++ java/lang/Character.java    2001/11/10 16:49:56
@@ -460,7 +460,7 @@
   /**
    * Class object representing the primitive char data type.
    */
-  public static final Class TYPE = VMClassLoader.getPrimitiveClass("char");
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('C');
 
   /**
    * Cn = Other, Not Assigned (Normative)
Index: java/lang/Double.java
===================================================================
RCS file: /cvs/classpath/java/lang/Double.java,v
retrieving revision 1.21
diff -u -r1.21 Double.java
--- java/lang/Double.java       2001/10/20 01:08:15     1.21
+++ java/lang/Double.java       2001/11/10 16:49:56
@@ -80,7 +80,7 @@
    * The primitive type <code>double</code> is represented by this
    * <code>Class</code> object.
    */
-  public static final Class TYPE = VMClassLoader.getPrimitiveClass ("double");
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('D');
 
   /**
    * The immutable value of this Double.
Index: java/lang/Float.java
===================================================================
RCS file: /cvs/classpath/java/lang/Float.java,v
retrieving revision 1.20
diff -u -r1.20 Float.java
--- java/lang/Float.java        2001/10/20 01:08:15     1.20
+++ java/lang/Float.java        2001/11/10 16:49:57
@@ -79,7 +79,7 @@
    * The primitive type <code>float</code> is represented by this 
    * <code>Class</code> object.
    */
-  public static final Class TYPE = VMClassLoader.getPrimitiveClass ("float");
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('F');
 
   /**
    * The immutable value of this Float.
Index: java/lang/Integer.java
===================================================================
RCS file: /cvs/classpath/java/lang/Integer.java,v
retrieving revision 1.20
diff -u -r1.20 Integer.java
--- java/lang/Integer.java      2001/07/30 17:41:09     1.20
+++ java/lang/Integer.java      2001/11/10 16:49:57
@@ -58,7 +58,7 @@
    * The primitive type <code>int</code> is represented by this 
    * <code>Class</code> object.
    */
-  public static final Class TYPE = VMClassLoader.getPrimitiveClass ("int");
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass ('I');
 
   /**
    * The immutable value of this Integer.
Index: java/lang/Long.java
===================================================================
RCS file: /cvs/classpath/java/lang/Long.java,v
retrieving revision 1.11
diff -u -r1.11 Long.java
--- java/lang/Long.java 2001/07/23 20:01:44     1.11
+++ java/lang/Long.java 2001/11/10 16:49:57
@@ -60,7 +60,7 @@
    * The primitive type <code>long</code> is represented by this 
    * <code>Class</code> object.
    */
-  public static final Class TYPE = VMClassLoader.getPrimitiveClass ("long");
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass ('J');
 
   /**
    * The immutable value of this Long.
Index: java/lang/Short.java
===================================================================
RCS file: /cvs/classpath/java/lang/Short.java,v
retrieving revision 1.10
diff -u -r1.10 Short.java
--- java/lang/Short.java        2001/07/23 20:01:44     1.10
+++ java/lang/Short.java        2001/11/10 16:49:57
@@ -56,7 +56,7 @@
    * The primitive type <code>short</code> is represented by this 
    * <code>Class</code> object.
    */
-  public static final Class TYPE = VMClassLoader.getPrimitiveClass("short");
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('S');
 
   /**
    * The immutable value of this Short.
Index: java/lang/Void.java
===================================================================
RCS file: /cvs/classpath/java/lang/Void.java,v
retrieving revision 1.11
diff -u -r1.11 Void.java
--- java/lang/Void.java 2001/09/30 23:00:33     1.11
+++ java/lang/Void.java 2001/11/10 16:49:57
@@ -47,7 +47,7 @@
    * The return type <code>void</code> is represented by this 
    * <code>Class</code> object.
    */
-  public static final Class TYPE = VMClassLoader.getPrimitiveClass("void");
+  public static final Class TYPE = VMClassLoader.getPrimitiveClass('V');
 
   /**
    * Don't allow Void objects to be made.
Index: vm/reference/java/lang/VMClassLoader.java
===================================================================
RCS file: /cvs/classpath/vm/reference/java/lang/VMClassLoader.java,v
retrieving revision 1.7
diff -u -r1.7 VMClassLoader.java
--- vm/reference/java/lang/VMClassLoader.java   1999/12/12 17:42:58     1.7
+++ vm/reference/java/lang/VMClassLoader.java   2001/11/10 16:49:58
@@ -58,6 +58,42 @@
      * @param type name of the primitive type; i.e. "int", "byte", etc.
      * @return a "bogus" class representing the primitive type.
      */
-    final static native Class getPrimitiveClass(String type);
+    final static Class getPrimitiveClass(char type)
+    {
+      String t;
+      switch (type) {
+       case 'Z':
+         t = "boolean";
+         break;
+       case 'B':
+         t = "byte";
+         break;
+       case 'C':
+         t = "char";
+         break;
+       case 'D':
+         t = "double";
+         break;
+       case 'F':
+         t = "float";
+         break;
+       case 'I':
+         t = "int";
+         break;
+       case 'J':
+         t = "long";
+         break;
+       case 'S':
+         t = "short";
+         break;
+       case 'V':
+         t = "void";
+         break;
+       default:
+         throw new NoClassDefFoundError("Invalid type specifier: " + type);
+      }
+      return getPrimitiveClass(t);
+    }
 
+    final static native Class getPrimitiveClass(String type);
 }
Index: classes/java/lang/VMClassLoader.java
===================================================================
RCS file: /cvsroot/kissme/classes/java/lang/VMClassLoader.java,v
retrieving revision 1.1
diff -u -r1.1 VMClassLoader.java
--- classes/java/lang/VMClassLoader.java        2001/03/25 04:04:37     1.1
+++ classes/java/lang/VMClassLoader.java        2001/11/10 16:41:17
@@ -52,5 +52,5 @@
         **             etc.
         ** @return a "bogus" class representing the primitive type.
         **/
-       final static native Class getPrimitiveClass(String type);
+       final static native Class getPrimitiveClass(char type);
 }
Index: lib/indigenous/java.lang/VMClassLoader.c
===================================================================
RCS file: /cvsroot/kissme/lib/indigenous/java.lang/VMClassLoader.c,v
retrieving revision 1.11
diff -u -r1.11 VMClassLoader.c
--- lib/indigenous/java.lang/VMClassLoader.c    2001/10/06 20:40:10     1.11
+++ lib/indigenous/java.lang/VMClassLoader.c    2001/11/10 16:41:18
@@ -67,6 +67,47 @@
   return -1;
 }
 
+static jclass primitiveCharToClass(const jchar type)
+{
+  int i;
+  switch (type) {
+    case 'Z': /* boolean */
+      i = 0;
+      break;
+    case 'C': /* char */
+      i = 1;
+      break;
+    case 'F': /* float */
+      i = 2;
+      break;
+    case 'D': /* double */
+      i = 3;
+      break;
+    case 'B': /* byte */
+      i = 4;
+      break;
+    case 'S': /* short */
+      i = 5;
+      break;
+    case 'I': /* int */
+      i = 6;
+      break;
+    case 'J': /* long */
+      i = 7;
+      break;
+    case 'V': /* void */
+      i = 8;
+      break;
+    default:
+      i = -1;
+  }
+
+  if (i >= 0)
+    return primTypes[i].classObject;
+  else
+    return NULL;
+}
+
 /* Makes the actual tClass* structure for a primitive type, and also creates a class 
object 
    Stores the result in a special structure for primitive types
    The prim->type field is already set when this method is called
@@ -243,17 +284,21 @@
 jclass java_lang_VMClassLoader_getPrimitiveClass( 
   JNIEnv* env, 
   jclass clazz, 
-  jobject string 
+  jchar type
   ) 
 { 
-  jclass ret;
   //Note clazz is allowed to be NULL! 
-  char* name = (char*) INTERP_AscizFromString(env, string); 
-  ret = java_lang_VMClassLoader_getPrimitiveClassFromAsciz (env, name);
-  sys_free(name);
+  jclass ret;
+
+  //just check that the primitive types have been created
+  assert(primTypes[0].type == T_BOOLEAN);
+
+  ret = primitiveCharToClass(type);
+  if (ret == NULL)
+    (*env)->Throw(env, INTERP_NewObjectFromName(env, 
+"java/lang/NoClassDefFoundError"));
+
   return ret; 
 } 
-
 
 
        /** Helper to resolve all references to other classes from this class.
Index: lib/indigenous/java.lang/VMClassLoader.h
===================================================================
RCS file: /cvsroot/kissme/lib/indigenous/java.lang/VMClassLoader.h,v
retrieving revision 1.3
diff -u -r1.3 VMClassLoader.h
--- lib/indigenous/java.lang/VMClassLoader.h    2001/04/29 18:17:06     1.3
+++ lib/indigenous/java.lang/VMClassLoader.h    2001/11/10 16:41:18
@@ -3,7 +3,7 @@
 jclass java_lang_VMClassLoader_getPrimitiveClass(
   JNIEnv* env,
   jclass clazz,
-  jobject string
+  jchar type
   );
 
 void java_lang_VMClassLoader_resolveClass( 
Index: vm/native/java_lang_VMClassLoader_natives.h
===================================================================
RCS file: /cvsroot/kissme/vm/native/java_lang_VMClassLoader_natives.h,v
retrieving revision 1.1
diff -u -r1.1 java_lang_VMClassLoader_natives.h
--- vm/native/java_lang_VMClassLoader_natives.h 2001/07/01 16:24:12     1.1
+++ vm/native/java_lang_VMClassLoader_natives.h 2001/11/10 16:41:18
@@ -1,5 +1,5 @@
 //There are no longer any native methods for ClassLoader in the Classpath version
 //All native stuff is in VMClassLoader
-       {"java/lang/VMClassLoader", "getPrimitiveClass", 
"(Ljava/lang/String;)Ljava/lang/Class;", (void*) 
java_lang_VMClassLoader_getPrimitiveClass},
+        {"java/lang/VMClassLoader", "getPrimitiveClass", "(C)Ljava/lang/Class;", 
+(void*) java_lang_VMClassLoader_getPrimitiveClass},
        {"java/lang/VMClassLoader", "defineClass", 
"(Ljava/lang/ClassLoader;Ljava/lang/String;[BII)Ljava/lang/Class;", (void*) 
java_lang_VMClassLoader_defineClass},
        {"java/lang/VMClassLoader", "resolveClass", "(Ljava/lang/Class;)V", (void*) 
java_lang_VMClassLoader_resolveClass},

Reply via email to