Compare commits
3 Commits
89c0799767
...
332344073a
Author | SHA1 | Date | |
---|---|---|---|
332344073a | |||
73012dc048 | |||
391fcf6738 |
@ -409,7 +409,7 @@ void vm_exception(struct vm * vm, struct objectref * objectref)
|
|||||||
printc(')');
|
printc(')');
|
||||||
prints("\n ");
|
prints("\n ");
|
||||||
struct arrayref * arrayref = string_objectref->aref[0];
|
struct arrayref * arrayref = string_objectref->aref[0];
|
||||||
print__string(arrayref->u8, arrayref->length);
|
print_chars(arrayref->u16, arrayref->length);
|
||||||
printc('\n');
|
printc('\n');
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
16
c/native.c
16
c/native.c
@ -88,9 +88,21 @@ const static struct native_method native_method[] = {
|
|||||||
},
|
},
|
||||||
{
|
{
|
||||||
.class_name = "java/io/PrintStream",
|
.class_name = "java/io/PrintStream",
|
||||||
.method_name = "write",
|
.method_name = "_write",
|
||||||
.method_descriptor = "([B)V",
|
.method_descriptor = "([B)V",
|
||||||
.func = native_java_io_printstream_write_1,
|
.func = native_java_io_printstream_write_ba_1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.class_name = "java/io/PrintStream",
|
||||||
|
.method_name = "_write",
|
||||||
|
.method_descriptor = "([C)V",
|
||||||
|
.func = native_java_io_printstream_write_ca_1,
|
||||||
|
},
|
||||||
|
{
|
||||||
|
.class_name = "java/io/PrintStream",
|
||||||
|
.method_name = "_write",
|
||||||
|
.method_descriptor = "(Ljava/lang/String;)V",
|
||||||
|
.func = native_java_io_printstream_write_s_1,
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
.class_name = "jvm/internal/Loader",
|
.class_name = "jvm/internal/Loader",
|
||||||
|
@ -2,8 +2,21 @@
|
|||||||
#include "printstream.h"
|
#include "printstream.h"
|
||||||
#include "printf.h"
|
#include "printf.h"
|
||||||
|
|
||||||
void native_java_io_printstream_write_1(struct vm * vm, uint32_t * args)
|
void native_java_io_printstream_write_ba_1(struct vm * vm, uint32_t * args)
|
||||||
{
|
{
|
||||||
struct arrayref * arrayref = (struct arrayref *)args[0];
|
struct arrayref * arrayref = (struct arrayref *)args[0];
|
||||||
print_string((const char *)arrayref->u8, arrayref->length);
|
print_bytes(arrayref->u8, arrayref->length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void native_java_io_printstream_write_ca_1(struct vm * vm, uint32_t * args)
|
||||||
|
{
|
||||||
|
struct arrayref * arrayref = (struct arrayref *)args[0];
|
||||||
|
print_chars(arrayref->u16, arrayref->length);
|
||||||
|
}
|
||||||
|
|
||||||
|
void native_java_io_printstream_write_s_1(struct vm * vm, uint32_t * args)
|
||||||
|
{
|
||||||
|
struct objectref * objectref = (struct objectref *)args[0];
|
||||||
|
struct arrayref * arrayref = objectref->aref[0];
|
||||||
|
print_chars(arrayref->u16, arrayref->length);
|
||||||
}
|
}
|
||||||
|
@ -4,4 +4,6 @@
|
|||||||
|
|
||||||
#include "frame.h"
|
#include "frame.h"
|
||||||
|
|
||||||
void native_java_io_printstream_write_1(struct vm * vm, uint32_t * args);
|
void native_java_io_printstream_write_ba_1(struct vm * vm, uint32_t * args);
|
||||||
|
void native_java_io_printstream_write_ca_1(struct vm * vm, uint32_t * args);
|
||||||
|
void native_java_io_printstream_write_s_1(struct vm * vm, uint32_t * args);
|
||||||
|
14
c/printf.c
14
c/printf.c
@ -78,6 +78,20 @@ void print_string(const char * s, int length)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void print_bytes(const uint8_t * s, int length)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
print_char(s[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void print_chars(const uint16_t * s, int length)
|
||||||
|
{
|
||||||
|
for (int i = 0; i < length; i++) {
|
||||||
|
print_char(s[i]);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
void print_cstring(const char * s)
|
void print_cstring(const char * s)
|
||||||
{
|
{
|
||||||
while (*s != 0) {
|
while (*s != 0) {
|
||||||
|
@ -6,6 +6,8 @@
|
|||||||
#include <stdio.h>
|
#include <stdio.h>
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#include <stdint.h>
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
extern "C" {
|
extern "C" {
|
||||||
#endif
|
#endif
|
||||||
@ -20,6 +22,8 @@ static inline void print_char(char c)
|
|||||||
}
|
}
|
||||||
|
|
||||||
void print_string(const char * s, int length);
|
void print_string(const char * s, int length);
|
||||||
|
void print_bytes(const uint8_t * s, int length);
|
||||||
|
void print_chars(const uint16_t * s, int length);
|
||||||
void print_cstring(const char * s);
|
void print_cstring(const char * s);
|
||||||
|
|
||||||
void _printf(const char * format, ...);
|
void _printf(const char * format, ...);
|
||||||
|
@ -10,94 +10,94 @@ public class PrintStream
|
|||||||
|
|
||||||
private static final byte[] newline = {'\n'};
|
private static final byte[] newline = {'\n'};
|
||||||
|
|
||||||
public static native void write(byte[] buf);
|
private static native void _write(byte[] buf);
|
||||||
|
|
||||||
public static void write(String s) {
|
private static native void _write(char[] buf);
|
||||||
write(s.getBytes());
|
|
||||||
}
|
private static native void _write(String s);
|
||||||
|
|
||||||
public void print(byte[] buf) {
|
public void print(byte[] buf) {
|
||||||
write(buf);
|
_write(buf);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print(boolean b) {
|
public void print(boolean b) {
|
||||||
write(String.valueOf(b));
|
_write(String.valueOf(b));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print(char c) {
|
public void print(char c) {
|
||||||
write(String.valueOf(c));
|
_write(String.valueOf(c));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print(int i) {
|
public void print(int i) {
|
||||||
write(String.valueOf(i));
|
_write(String.valueOf(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print(long l) {
|
public void print(long l) {
|
||||||
write(String.valueOf(l));
|
_write(String.valueOf(l));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print(float f) {
|
public void print(float f) {
|
||||||
write(String.valueOf(f));
|
_write(String.valueOf(f));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print(double d) {
|
public void print(double d) {
|
||||||
write(String.valueOf(d));
|
_write(String.valueOf(d));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print(Object obj) {
|
public void print(Object obj) {
|
||||||
write(String.valueOf(obj));
|
_write(String.valueOf(obj));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void print(String s) {
|
public void print(String s) {
|
||||||
write(String.valueOf(s));
|
_write(String.valueOf(s));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void println() {
|
public void println() {
|
||||||
write(newline);
|
_write(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void println(byte[] buf) {
|
public void println(byte[] buf) {
|
||||||
write(buf);
|
_write(buf);
|
||||||
write(newline);
|
_write(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void println(boolean b) {
|
public void println(boolean b) {
|
||||||
write(String.valueOf(b));
|
_write(String.valueOf(b));
|
||||||
write(newline);
|
_write(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void println(char c) {
|
public void println(char c) {
|
||||||
write(String.valueOf(c));
|
_write(String.valueOf(c));
|
||||||
write(newline);
|
_write(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void println(int i) {
|
public void println(int i) {
|
||||||
write(String.valueOf(i));
|
_write(String.valueOf(i));
|
||||||
write(newline);
|
_write(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void println(long l) {
|
public void println(long l) {
|
||||||
write(String.valueOf(l));
|
_write(String.valueOf(l));
|
||||||
write(newline);
|
_write(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void println(float f) {
|
public void println(float f) {
|
||||||
write(String.valueOf(f));
|
_write(String.valueOf(f));
|
||||||
write(newline);
|
_write(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void println(double d) {
|
public void println(double d) {
|
||||||
write(String.valueOf(d));
|
_write(String.valueOf(d));
|
||||||
write(newline);
|
_write(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void println(Object obj) {
|
public void println(Object obj) {
|
||||||
write(String.valueOf(obj));
|
_write(String.valueOf(obj));
|
||||||
write(newline);
|
_write(newline);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void println(String s) {
|
public void println(String s) {
|
||||||
write(String.valueOf(s));
|
_write(String.valueOf(s));
|
||||||
write(newline);
|
_write(newline);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public class ArithmeticException extends RuntimeException {
|
public class ArithmeticException extends RuntimeException {
|
||||||
|
|
||||||
|
public ArithmeticException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArithmeticException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,16 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException {
|
public class ArrayIndexOutOfBoundsException extends IndexOutOfBoundsException {
|
||||||
|
|
||||||
|
ArrayIndexOutOfBoundsException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayIndexOutOfBoundsException(int index) {
|
||||||
|
super(String.valueOf(index));
|
||||||
|
}
|
||||||
|
|
||||||
|
ArrayIndexOutOfBoundsException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,11 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public class ArrayStoreException extends RuntimeException {
|
public class ArrayStoreException extends RuntimeException {
|
||||||
|
public ArrayStoreException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ArrayStoreException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
class Character {
|
class Character
|
||||||
|
implements Comparable<Character> {
|
||||||
public static final int MAX_RADIX = 36;
|
public static final int MAX_RADIX = 36;
|
||||||
|
|
||||||
public static final int MAX_VALUE = '\uFFFF';
|
public static final int MAX_VALUE = '\uFFFF';
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public class ClassCastException extends RuntimeException {
|
public class ClassCastException extends RuntimeException {
|
||||||
|
|
||||||
|
public ClassCastException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassCastException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
17
classes/java/lang/ClassNotFoundException.java
Normal file
17
classes/java/lang/ClassNotFoundException.java
Normal file
@ -0,0 +1,17 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class ClassNotFoundException extends RuntimeException {
|
||||||
|
|
||||||
|
public ClassNotFoundException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassNotFoundException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public ClassNotFoundException(String s,
|
||||||
|
Throwable ex) {
|
||||||
|
super(s, ex);
|
||||||
|
}
|
||||||
|
}
|
12
classes/java/lang/CloneNotSupportedException.java
Normal file
12
classes/java/lang/CloneNotSupportedException.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class CloneNotSupportedException extends RuntimeException {
|
||||||
|
|
||||||
|
public CloneNotSupportedException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public CloneNotSupportedException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
}
|
12
classes/java/lang/IllegalAccessException.java
Normal file
12
classes/java/lang/IllegalAccessException.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class IllegalAccessException extends Exception {
|
||||||
|
|
||||||
|
public IllegalAccessException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IllegalAccessException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
}
|
21
classes/java/lang/IllegalArgumentException.java
Normal file
21
classes/java/lang/IllegalArgumentException.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class IllegalArgumentException extends RuntimeException {
|
||||||
|
|
||||||
|
public IllegalArgumentException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IllegalArgumentException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IllegalArgumentException(String message,
|
||||||
|
Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IllegalArgumentException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
12
classes/java/lang/IllegalMonitorStateException.java
Normal file
12
classes/java/lang/IllegalMonitorStateException.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class IllegalMonitorStateException extends RuntimeException {
|
||||||
|
|
||||||
|
public IllegalMonitorStateException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IllegalMonitorStateException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
}
|
21
classes/java/lang/IllegalStateException.java
Normal file
21
classes/java/lang/IllegalStateException.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class IllegalStateException extends RuntimeException {
|
||||||
|
|
||||||
|
public IllegalStateException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IllegalStateException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IllegalStateException(String message,
|
||||||
|
Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public IllegalStateException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
12
classes/java/lang/IllegalThreadStateException.java
Normal file
12
classes/java/lang/IllegalThreadStateException.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class IllegalThreadStateException extends RuntimeException {
|
||||||
|
|
||||||
|
public IllegalThreadStateException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IllegalThreadStateException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,12 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public class IndexOutOfBoundsException extends RuntimeException {
|
public class IndexOutOfBoundsException extends RuntimeException {
|
||||||
|
|
||||||
|
public IndexOutOfBoundsException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public IndexOutOfBoundsException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
12
classes/java/lang/InstantiationException.java
Normal file
12
classes/java/lang/InstantiationException.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class InstantiationException extends Exception {
|
||||||
|
|
||||||
|
public InstantiationException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InstantiationException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
}
|
12
classes/java/lang/InterruptedException.java
Normal file
12
classes/java/lang/InterruptedException.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class InterruptedException extends Exception {
|
||||||
|
|
||||||
|
public InterruptedException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public InterruptedException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,12 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public class NegativeArraySizeException extends RuntimeException {
|
public class NegativeArraySizeException extends RuntimeException {
|
||||||
|
|
||||||
|
public NegativeArraySizeException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NegativeArraySizeException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,4 +1,12 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public class NullPointerException extends RuntimeException {
|
public class NullPointerException extends RuntimeException {
|
||||||
|
|
||||||
|
public NullPointerException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NullPointerException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
12
classes/java/lang/NumberFormatException.java
Normal file
12
classes/java/lang/NumberFormatException.java
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class NumberFormatException extends IllegalArgumentException {
|
||||||
|
|
||||||
|
public NumberFormatException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public NumberFormatException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
}
|
@ -1,4 +1,20 @@
|
|||||||
package java.lang;
|
package java.lang;
|
||||||
|
|
||||||
public class RuntimeException extends Exception {
|
public class RuntimeException extends Exception {
|
||||||
|
public RuntimeException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public RuntimeException(String message) {
|
||||||
|
super(message);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RuntimeException(String message,
|
||||||
|
Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public RuntimeException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
21
classes/java/lang/SecurityException.java
Normal file
21
classes/java/lang/SecurityException.java
Normal file
@ -0,0 +1,21 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class SecurityException extends RuntimeException {
|
||||||
|
|
||||||
|
public SecurityException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityException(String message,
|
||||||
|
Throwable cause) {
|
||||||
|
super(message, cause);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SecurityException(Throwable cause) {
|
||||||
|
super(cause);
|
||||||
|
}
|
||||||
|
}
|
16
classes/java/lang/StringIndexOutOfBoundsException.java
Normal file
16
classes/java/lang/StringIndexOutOfBoundsException.java
Normal file
@ -0,0 +1,16 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class StringIndexOutOfBoundsException extends IndexOutOfBoundsException {
|
||||||
|
|
||||||
|
public StringIndexOutOfBoundsException() {
|
||||||
|
super();
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringIndexOutOfBoundsException(int index) {
|
||||||
|
super(index);
|
||||||
|
}
|
||||||
|
|
||||||
|
public StringIndexOutOfBoundsException(String s) {
|
||||||
|
super(s);
|
||||||
|
}
|
||||||
|
}
|
4
classes/java/lang/UnsupportedOperationException.java
Normal file
4
classes/java/lang/UnsupportedOperationException.java
Normal file
@ -0,0 +1,4 @@
|
|||||||
|
package java.lang;
|
||||||
|
|
||||||
|
public class UnsupportedOperationException extends RuntimeException {
|
||||||
|
}
|
Loading…
x
Reference in New Issue
Block a user