From 6d27274aea57d5580edd9ca7f4192e5a49f2227f Mon Sep 17 00:00:00 2001 From: Joel Dice Date: Wed, 5 Aug 2009 15:57:51 +0000 Subject: [PATCH] update Class.PrimitiveFlag value to reflect change in machine.h; make Class.getName work for primitive types --- classpath/java/lang/Class.java | 30 +++++++++++++++++++++++++++++- 1 file changed, 29 insertions(+), 1 deletion(-) diff --git a/classpath/java/lang/Class.java b/classpath/java/lang/Class.java index 551bd710d8..f439ba3521 100644 --- a/classpath/java/lang/Class.java +++ b/classpath/java/lang/Class.java @@ -27,7 +27,7 @@ import java.security.Permissions; import java.security.AllPermission; public final class Class implements Type, GenericDeclaration { - private static final int PrimitiveFlag = 1 << 4; + private static final int PrimitiveFlag = 1 << 5; private short flags; private byte vmFlags; @@ -62,6 +62,34 @@ public final class Class implements Type, GenericDeclaration { } public String getName() { + if (name == null) { + if ((vmFlags & PrimitiveFlag) != 0) { + if (this == primitiveClass('V')) { + name = "void".getBytes(); + } else if (this == primitiveClass('Z')) { + name = "boolean".getBytes(); + } else if (this == primitiveClass('B')) { + name = "byte".getBytes(); + } else if (this == primitiveClass('C')) { + name = "char".getBytes(); + } else if (this == primitiveClass('S')) { + name = "short".getBytes(); + } else if (this == primitiveClass('I')) { + name = "int".getBytes(); + } else if (this == primitiveClass('F')) { + name = "float".getBytes(); + } else if (this == primitiveClass('J')) { + name = "long".getBytes(); + } else if (this == primitiveClass('D')) { + name = "double".getBytes(); + } else { + throw new AssertionError(); + } + } else { + throw new AssertionError(); + } + } + return new String (replace('/', '.', name, 0, name.length - 1), 0, name.length - 1, false); }