CLDC 8: Object
This commit is contained in:
parent
ffb73cefec
commit
33645983ba
@ -118,19 +118,19 @@ const static struct native_method native_method[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.class_name = "java/lang/Class",
|
.class_name = "java/lang/Class",
|
||||||
.method_name = "getClassName",
|
.method_name = "_getName",
|
||||||
.method_descriptor = "()Ljava/lang/String;",
|
.method_descriptor = "()Ljava/lang/String;",
|
||||||
.func = native_java_lang_class_getclassname_1,
|
.func = native_java_lang_class_getname_1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.class_name = "java/lang/Object",
|
.class_name = "java/lang/Object",
|
||||||
.method_name = "getClass",
|
.method_name = "_getClass",
|
||||||
.method_descriptor = "()Ljava/lang/Class;",
|
.method_descriptor = "()Ljava/lang/Class;",
|
||||||
.func = native_java_lang_object_getclass_1,
|
.func = native_java_lang_object_getclass_1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.class_name = "java/lang/Object",
|
.class_name = "java/lang/Object",
|
||||||
.method_name = "hashCode",
|
.method_name = "_hashCode",
|
||||||
.method_descriptor = "()I",
|
.method_descriptor = "()I",
|
||||||
.func = native_java_lang_object_hashcode_1,
|
.func = native_java_lang_object_hashcode_1,
|
||||||
},
|
},
|
||||||
|
@ -2,7 +2,7 @@
|
|||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
#include "vm_instance.h"
|
#include "vm_instance.h"
|
||||||
|
|
||||||
void native_java_lang_class_getclassname_1(struct vm * vm, uint32_t * args)
|
void native_java_lang_class_getname_1(struct vm * vm, uint32_t * args)
|
||||||
{
|
{
|
||||||
struct objectref * objectref = (struct objectref *)args[0];
|
struct objectref * objectref = (struct objectref *)args[0];
|
||||||
assert(objectref != nullptr);
|
assert(objectref != nullptr);
|
||||||
|
@ -4,4 +4,4 @@
|
|||||||
|
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
|
|
||||||
void native_java_lang_class_getclassname_1(struct vm * vm, uint32_t * args);
|
void native_java_lang_class_getname_1(struct vm * vm, uint32_t * args);
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public class Class {
|
public final class Class<T> {
|
||||||
private Object object;
|
private Object object;
|
||||||
private String name;
|
private String name;
|
||||||
|
|
||||||
private Class() {
|
private Class() {
|
||||||
}
|
}
|
||||||
|
|
||||||
private native String getClassName();
|
private native String _getName();
|
||||||
|
|
||||||
public String getName() {
|
public String getName() {
|
||||||
if (this.name == null) {
|
if (this.name == null) {
|
||||||
this.name = getClassName();
|
this.name = _getName();
|
||||||
}
|
}
|
||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
@ -3,11 +3,28 @@ package java.lang;
|
|||||||
public class Object {
|
public class Object {
|
||||||
public Object() {}
|
public Object() {}
|
||||||
|
|
||||||
public final native Class getClass();
|
protected Object clone()
|
||||||
|
throws CloneNotSupportedException {
|
||||||
|
throw new CloneNotSupportedException();
|
||||||
|
}
|
||||||
|
|
||||||
public native int hashCode();
|
public boolean equals(Object obj) {
|
||||||
|
return this == obj;
|
||||||
|
}
|
||||||
|
|
||||||
|
private final native Class<?> _getClass();
|
||||||
|
|
||||||
|
public final Class<?> getClass() {
|
||||||
|
return _getClass();
|
||||||
|
}
|
||||||
|
|
||||||
|
private native int _hashCode();
|
||||||
|
|
||||||
|
public int hashCode() {
|
||||||
|
return _hashCode();
|
||||||
|
}
|
||||||
|
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return getClass().getName() + "@" + Integer.toString(hashCode());
|
return getClass().getName() + "@" + Integer.toHexString(hashCode());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user