Revision: 5737
          http://jnode.svn.sourceforge.net/jnode/?rev=5737&view=rev
Author:   lsantha
Date:     2010-03-28 16:29:10 +0000 (Sun, 28 Mar 2010)

Log Message:
-----------
Simplified VM type to Class conversion.

Modified Paths:
--------------
    trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java

Modified: trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java
===================================================================
--- trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2010-03-27 
06:08:08 UTC (rev 5736)
+++ trunk/core/src/core/org/jnode/vm/classmgr/ClassDecoder.java 2010-03-28 
16:29:10 UTC (rev 5737)
@@ -978,34 +978,7 @@
                         Class r_class;
                         VmType vtm = mts.getReturnType();
                         if (vtm.isPrimitive()) {
-                            switch (vtm.getJvmType()) {
-                                case JvmType.BOOLEAN:
-                                    vtm = VmType.fromClass(Boolean.class);
-                                    break;
-                                case JvmType.BYTE:
-                                    vtm = VmType.fromClass(Byte.class);
-                                    break;
-                                case JvmType.SHORT:
-                                    vtm = VmType.fromClass(Short.class);
-                                    break;
-                                case JvmType.CHAR:
-                                    vtm = VmType.fromClass(Character.class);
-                                    break;
-                                case JvmType.INT:
-                                    vtm = VmType.fromClass(Integer.class);
-                                    break;
-                                case JvmType.FLOAT:
-                                    vtm = VmType.fromClass(Float.class);
-                                    break;
-                                case JvmType.LONG:
-                                    vtm = VmType.fromClass(Long.class);
-                                    break;
-                                case JvmType.DOUBLE:
-                                    vtm = VmType.fromClass(Double.class);
-                                    break;
-
-                            }
-                            r_class = vtm.asClass();
+                            r_class = getClassForJvmType(vtm.getJvmType());
                         } else {
                             try {
                                 r_class = Class.forName(vtm.getName(), false, 
vtm.getLoader().asClassLoader());
@@ -1014,7 +987,7 @@
                             }
                         }
                         Object defo = 
AnnotationParser.parseMemberValue(r_class, data, new VmConstantPool(cls),
-                            cls.asClass());
+                            org.jnode.vm.Vm.isRunningVm() ? cls.asClass() : 
cls.asClassDuringBootstrap());
                         mts.setAnnotationDefault(defo);
                     } else {
                         skip(data, length);
@@ -1046,6 +1019,31 @@
         }
     }
 
+    private static Class getClassForJvmType(int type) {
+        switch (type) {
+            case JvmType.BOOLEAN:
+                return boolean.class;
+            case JvmType.BYTE:
+                return byte.class;
+            case JvmType.SHORT:
+                return short.class;
+            case JvmType.CHAR:
+                return char.class;
+            case JvmType.INT:
+                return int.class;
+            case JvmType.FLOAT:
+                return float.class;
+            case JvmType.LONG:
+                return long.class;
+            case JvmType.DOUBLE:
+                return double.class;
+            case JvmType.VOID:
+                return void.class;
+            default:
+                throw new IllegalArgumentException("Invalid JVM type: " + 
type);
+        }
+    }
+
     /**
      * Read a runtime parameter annotations attributes.
      *
@@ -1226,34 +1224,7 @@
                     Class r_class;
                     VmType vtm = mts.getReturnType();
                     if (vtm.isPrimitive()) {
-                        switch (vtm.getJvmType()) {
-                            case JvmType.BOOLEAN:
-                                vtm = VmType.fromClass(Boolean.class);
-                                break;
-                            case JvmType.BYTE:
-                                vtm = VmType.fromClass(Byte.class);
-                                break;
-                            case JvmType.SHORT:
-                                vtm = VmType.fromClass(Short.class);
-                                break;
-                            case JvmType.CHAR:
-                                vtm = VmType.fromClass(Character.class);
-                                break;
-                            case JvmType.INT:
-                                vtm = VmType.fromClass(Integer.class);
-                                break;
-                            case JvmType.FLOAT:
-                                vtm = VmType.fromClass(Float.class);
-                                break;
-                            case JvmType.LONG:
-                                vtm = VmType.fromClass(Long.class);
-                                break;
-                            case JvmType.DOUBLE:
-                                vtm = VmType.fromClass(Double.class);
-                                break;
-
-                        }
-                        r_class = vtm.asClass();
+                        r_class = getClassForJvmType(vtm.getJvmType());
                     } else {
                         try {
                             r_class = 
vtm.getLoader().asClassLoader().loadClass(vtm.getName());


This was sent by the SourceForge.net collaborative development platform, the 
world's largest Open Source development site.

------------------------------------------------------------------------------
Download Intel® Parallel Studio Eval
Try the new software tools for yourself. Speed compiling, find bugs
proactively, and fine-tune applications for parallel performance.
See why Intel Parallel Studio got high marks during beta.
http://p.sf.net/sfu/intel-sw-dev
_______________________________________________
Jnode-svn-commits mailing list
Jnode-svn-commits@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/jnode-svn-commits

Reply via email to