-/* DO NOT EDIT THIS FILE - it is machine generated */
-#include <jni.h>
-/* Header for class gnu_java_awt_peer_gtk_GdkFontPeer */
-
-#ifndef _Included_gnu_java_awt_peer_gtk_GdkFontPeer
-#define _Included_gnu_java_awt_peer_gtk_GdkFontPeer
-#ifdef __cplusplus
-extern "C" {
-#endif
-/* Inaccessible static: bundle */
+/* This file is machine generated, don't edit it !*/
+
+#ifndef _GNU_JAVA_AWT_PEER_GTK_GDKFONTPEER_H
+#define _GNU_JAVA_AWT_PEER_GTK_GDKFONTPEER_H
+
+/* Structure information for class: gnu/java/awt/peer/gtk/GdkFontPeer */
+
+typedef struct gnu_java_awt_peer_gtk_GdkFontPeer {
+ java_objectheader header;
+ struct java_lang_String* logicalName;
+ struct java_lang_String* familyName;
+ struct java_lang_String* faceName;
+ s4 style;
+ float size;
+ struct java_awt_geom_AffineTransform* transform;
+ s4 native_state;
+} gnu_java_awt_peer_gtk_GdkFontPeer;
+
+
/*
- * Class: gnu_java_awt_peer_gtk_GdkFontPeer
+ * Class: gnu/java/awt/peer/gtk/GdkFontPeer
* Method: initStaticState
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_initStaticState
- (JNIEnv *, jclass);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_initStaticState(JNIEnv *env, jclass clazz);
+
/*
- * Class: gnu_java_awt_peer_gtk_GdkFontPeer
+ * Class: gnu/java/awt/peer/gtk/GdkFontPeer
* Method: initState
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_initState
- (JNIEnv *, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_initState(JNIEnv *env, struct gnu_java_awt_peer_gtk_GdkFontPeer* this);
+
/*
- * Class: gnu_java_awt_peer_gtk_GdkFontPeer
+ * Class: gnu/java/awt/peer/gtk/GdkFontPeer
* Method: dispose
* Signature: ()V
*/
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_dispose
- (JNIEnv *, jobject);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_dispose(JNIEnv *env, struct gnu_java_awt_peer_gtk_GdkFontPeer* this);
+
/*
- * Class: gnu_java_awt_peer_gtk_GdkFontPeer
+ * Class: gnu/java/awt/peer/gtk/GdkFontPeer
* Method: setFont
* Signature: (Ljava/lang/String;IIZ)V
*/
-JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont
- (JNIEnv *, jobject, jstring, jint, jint, jboolean);
+JNIEXPORT void JNICALL Java_gnu_java_awt_peer_gtk_GdkFontPeer_setFont(JNIEnv *env, struct gnu_java_awt_peer_gtk_GdkFontPeer* this, struct java_lang_String* par1, s4 par2, s4 par3, s4 par4);
-#ifdef __cplusplus
-}
-#endif
#endif
+
Changes: Joseph Wenninger, Martin Platter
- $Id: jni.c 1771 2004-12-17 23:05:27Z jowenn $
+ $Id: jni.c 1774 2004-12-20 20:16:57Z jowenn $
*/
return 0;
}
#endif
-
- if (((!params) && (argcount != 0)) || (params && (params->header.size != argcount))) {
+ if (((params==0) && (argcount != 0)) || (params && (params->header.size != argcount))) {
*exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
return 0;
}
- if (!(methodID->flags & ACC_STATIC) && (!obj)) {
+ if (((methodID->flags & ACC_STATIC)==0) && (0==obj)) {
*exceptionptr =
new_exception_message(string_java_lang_NullPointerException,
"Static mismatch in Java_java_lang_reflect_Method_invokeNative");
if ((methodID->flags & ACC_STATIC) && (obj)) obj = 0;
+ if (obj) {
+ if ( (methodID->flags & ACC_ABSTRACT) || (methodID->class->flags & ACC_INTERFACE) ) {
+ methodID=get_virtual(obj,methodID);
+ }
+ }
+
blk = MNEW(jni_callblock, /*4 */argcount+2);
retT = fill_callblock_objA(obj, methodID->descriptor, blk, params);
Changes: Joseph Wenninger
- $Id: Field.c 1765 2004-12-15 17:25:04Z jowenn $
+ $Id: Field.c 1774 2004-12-20 20:16:57Z jowenn $
*/
#include "vm/loader.h"
#include "vm/tables.h"
#include "vm/loader.h"
+#include "vm/global.h"
+#include "vm/builtin.h"
+#include "vm/jit/stacktrace.h"
+#include "vm/exceptions.h"
#undef DEBUG
+#ifdef __GNUC__
+#warning FIXE SET NATIVES
+#endif
+
+#if (defined(__ALPHA__) || defined(__I386__))
+/*this = java_lang_reflect_Field, fi=fieldinfo, c=declaredClass (classinfo)*/
+#define CHECKFIELDACCESS(this,fi,c) \
+ /*log_text("Checking access rights");*/ \
+ if (!(getField(this,jboolean,getFieldID_critical(env,this->header.vftbl->class,"flag","Z")))) { \
+ int throwAccess=0; \
+ struct methodinfo *callingMethod; \
+ \
+ if ((fi->flags & ACC_PUBLIC)==0) { \
+ callingMethod=cacao_callingMethod(); \
+ \
+ if ((fi->flags & ACC_PRIVATE)!=0) { \
+ if (c!=callingMethod->class) { \
+ throwAccess=1; \
+ } \
+ } else { \
+ if ((fi->flags & ACC_PROTECTED)!=0) { \
+ if (!builtin_isanysubclass(callingMethod->class, c)) { \
+ throwAccess=1; \
+ } \
+ } else { \
+ /* default visibility*/ \
+ if (c->packagename!=callingMethod->class->packagename) { \
+ throwAccess=1; \
+ } \
+ } \
+ } \
+ } \
+ if (throwAccess) { \
+ *exceptionptr=0; \
+ *exceptionptr = new_exception(string_java_lang_IllegalAccessException); \
+ return 0; \
+ } \
+ }
+#else
+define CHECKFIELDACCESS(this,fi)
+#endif
+
+
+
+
+
+
+
/*
* Class: java/lang/reflect/Field
* Method: get
jfieldID fid; /* the JNI-fieldid of the field containing the value */
jobject o; /* the object for wrapping the primitive type */
classinfo *c = (classinfo *) this->declaringClass;
- int st = (this->flag & ACC_STATIC); /* true if field is static */
+ int st;
/* get the fieldid of the field represented by this Field-object */
- fid = class_findfield_approx((classinfo *) this->declaringClass,javastring_toutf(this->name, false));
+ fid=&((classinfo*)this->declaringClass)->fields[this->slot]; /*get field*/
+ /*fid = class_findfield_approx((classinfo *) this->declaringClass,javastring_toutf(this->name, false));*/
+ st = (fid->flags & ACC_STATIC); /* true if field is static */
+
+
+ CHECKFIELDACCESS(this,fid,c);
/* The fieldid is used to retrieve the value, for primitive types a new
object for wrapping the primitive type is created. */
JNIEXPORT s4 JNICALL Java_java_lang_reflect_Field_getBoolean(JNIEnv *env, java_lang_reflect_Field *this, java_lang_Object *obj)
{
jfieldID fid;
+ char *utf_ptr;
+ classinfo *c = (classinfo *) this->declaringClass;
- if (this->declaringClass && obj) {
- /* get the fieldid represented by the field-object */
- fid = class_findfield_approx((classinfo *) this->declaringClass,
- javastring_toutf(this->name, false));
-
- if (fid)
- /* call the JNI-function to retrieve the field */
- return (*env)->GetBooleanField(env, (jobject) obj, fid);
+#ifdef DEBUG
+ /* check if the specified slot could be a valid field of this class*/
+ if (this->slot>((classinfo*)this->declaringClass)->fieldscount) throw_cacao_exception_exit(string_java_lang_IncompatibleClassChangeError,
+ "declaring class: fieldscount mismatch");
+#endif
+ fid=&((classinfo*)this->declaringClass)->fields[this->slot]; /*get field*/
+ CHECKFIELDACCESS(this,fid,c);
+#ifdef DEBUG
+ /* check if the field really has the same name and check if the type descriptor is not empty*/
+ if (fid->name!=javastring_toutf(this->name,false)) throw_cacao_exception_exit(string_java_lang_IncompatibleClassChangeError,
+ "declaring class: field name mismatch");
+ if (fid->descriptor->blength<1) panic("Type-Descriptor is empty");
+#endif
+ /* check if obj would be needed (not static field), but is 0)*/
+ if ((!(fid->flags & ACC_STATIC)) && (obj==0)) {
+ *exceptionptr = new_exception(string_java_lang_NullPointerException);
+ return 0;
}
+
+ /*if (!(fid->flags & ACC_PUBLIC)) {
+ *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
+ return 0;
- /* raise exception */
- *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
+ } */
- return 0;
+ if (fid->flags & ACC_STATIC) {
+ /* initialize class if needed*/
+ class_init((classinfo*)this->declaringClass);
+ if (*exceptionptr) return 0;
+ /*return value*/
+ utf_ptr = fid->descriptor->text;
+ switch (*utf_ptr) {
+ case 'Z': return fid->value.i;
+ default:
+ *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
+ return 0;
+ }
+ } else {
+ if (!builtin_instanceof((java_objectheader*)obj,(classinfo*)this->declaringClass)) {
+ *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
+ return 0;
+ }
+ utf_ptr = fid->descriptor->text;
+ switch (*utf_ptr) {
+ case 'Z':return getField(obj,jboolean,fid);
+ default:
+ *exceptionptr = new_exception(string_java_lang_IllegalArgumentException);
+ return 0;
+ }
+ }
}
{
jfieldID fid;
char *utf_ptr;
+ classinfo *c = (classinfo *) this->declaringClass;
#ifdef DEBUG
/* check if the specified slot could be a valid field of this class*/
"declaring class: fieldscount mismatch");
#endif
fid=&((classinfo*)this->declaringClass)->fields[this->slot]; /*get field*/
+
+ CHECKFIELDACCESS(this,fid,c);
#ifdef DEBUG
/* check if the field really has the same name and check if the type descriptor is not empty*/
if (fid->name!=javastring_toutf(this->name,false)) throw_cacao_exception_exit(string_java_lang_IncompatibleClassChangeError,
{
jfieldID fid;
char *utf_ptr;
+ classinfo *c = (classinfo *) this->declaringClass;
#ifdef DEBUG
/* check if the specified slot could be a valid field of this class*/
"declaring class: fieldscount mismatch");
#endif
fid=&((classinfo*)this->declaringClass)->fields[this->slot]; /*get field*/
+ CHECKFIELDACCESS(this,fid,c);
+
#ifdef DEBUG
/* check if the field really has the same name and check if the type descriptor is not empty*/
if (fid->name!=javastring_toutf(this->name,false)) throw_cacao_exception_exit(string_java_lang_IncompatibleClassChangeError,
{
jfieldID fid;
char *utf_ptr;
+ classinfo *c = (classinfo *) this->declaringClass;
#ifdef DEBUG
/* check if the specified slot could be a valid field of this class*/
"declaring class: fieldscount mismatch");
#endif
fid=&((classinfo*)this->declaringClass)->fields[this->slot]; /*get field*/
+ CHECKFIELDACCESS(this,fid,c);
+
#ifdef DEBUG
/* check if the field really has the same name and check if the type descriptor is not empty*/
if (fid->name!=javastring_toutf(this->name,false)) throw_cacao_exception_exit(string_java_lang_IncompatibleClassChangeError,
{
jfieldID fid;
char *utf_ptr;
+ classinfo *c = (classinfo *) this->declaringClass;
#ifdef DEBUG
/* check if the specified slot could be a valid field of this class*/
"declaring class: fieldscount mismatch");
#endif
fid=&((classinfo*)this->declaringClass)->fields[this->slot]; /*get field*/
+ CHECKFIELDACCESS(this,fid,c);
+
#ifdef DEBUG
/* check if the field really has the same name and check if the type descriptor is not empty*/
if (fid->name!=javastring_toutf(this->name,false)) throw_cacao_exception_exit(string_java_lang_IncompatibleClassChangeError,
{
jfieldID fid;
char *utf_ptr;
+ classinfo *c = (classinfo *) this->declaringClass;
#ifdef DEBUG
/* check if the specified slot could be a valid field of this class*/
"declaring class: fieldscount mismatch");
#endif
fid=&((classinfo*)this->declaringClass)->fields[this->slot]; /*get field*/
+ CHECKFIELDACCESS(this,fid,c);
#ifdef DEBUG
/* check if the field really has the same name and check if the type descriptor is not empty*/
if (fid->name!=javastring_toutf(this->name,false)) throw_cacao_exception_exit(string_java_lang_IncompatibleClassChangeError,
{
jfieldID fid;
char *utf_ptr;
+ classinfo *c = (classinfo *) this->declaringClass;
#ifdef DEBUG
/* check if the specified slot could be a valid field of this class*/
"declaring class: fieldscount mismatch");
#endif
fid=&((classinfo*)this->declaringClass)->fields[this->slot]; /*get field*/
+ CHECKFIELDACCESS(this,fid,c);
+
#ifdef DEBUG
/* check if the field really has the same name and check if the type descriptor is not empty*/
if (fid->name!=javastring_toutf(this->name,false)) throw_cacao_exception_exit(string_java_lang_IncompatibleClassChangeError,
{
jfieldID fid;
char *utf_ptr;
+ classinfo *c = (classinfo *) this->declaringClass;
#ifdef DEBUG
/* check if the specified slot could be a valid field of this class*/
"declaring class: fieldscount mismatch");
#endif
fid=&((classinfo*)this->declaringClass)->fields[this->slot]; /*get field*/
+ CHECKFIELDACCESS(this,fid,c);
+
#ifdef DEBUG
/* check if the field really has the same name and check if the type descriptor is not empty*/
if (fid->name!=javastring_toutf(this->name,false)) throw_cacao_exception_exit(string_java_lang_IncompatibleClassChangeError,
jfieldID source_fid; /* the field containing the value to be written */
jfieldID fid; /* the field to be written */
classinfo *c;
+
int st = (this->flag & ACC_STATIC); /* true if the field is static */
fid = class_findfield_approx((classinfo *) this->declaringClass,
javastring_toutf(this->name, false));
+ CHECKFIELDACCESS(this,fid,((classinfo *) this->declaringClass));
if (val && (st || obj)) {
Changes: Joseph Wenninger
- $Id: Method.c 1735 2004-12-07 14:33:27Z twisti $
+ $Id: Method.c 1774 2004-12-20 20:16:57Z jowenn $
*/
#include "native/include/java_lang_Class.h"
#include "native/include/java_lang_reflect_Method.h"
#include "toolbox/logging.h"
-
+#include "vm/global.h"
+#include "vm/builtin.h"
+#include "vm/jit/stacktrace.h"
+#include "vm/exceptions.h"
/*
* Class: java_lang_reflect_Method
*/
JNIEXPORT java_lang_Object* JNICALL Java_java_lang_reflect_Method_invokeNative(JNIEnv *env, java_lang_reflect_Method *this, java_lang_Object *obj, java_objectarray *params, java_lang_Class *declaringClass, s4 slot)
{
- struct methodinfo *mi;
+ struct methodinfo *mi;
- classinfo *c = (classinfo *) declaringClass;
- if (slot < 0 || slot >= c->methodscount) {
- panic("error illegal slot for method in class(getParameterTypes)");
- }
+ classinfo *c = (classinfo *) declaringClass;
- mi = &(c->methods[slot]);
+ if (slot < 0 || slot >= c->methodscount) {
+ panic("error illegal slot for method in class(getParameterTypes)");
+ }
+ mi = &(c->methods[slot]);
+
+#if (defined(__ALPHA__) || defined(__I386__))
+ /*log_text("Checking access rights");*/
+ if (!(getField(this,jboolean,getFieldID_critical(env,this->header.vftbl->class,"flag","Z")))) {
+ int throwAccess=0;
+ struct methodinfo *callingMethod;
+
+ if ((mi->flags & ACC_PUBLIC)==0) {
+ callingMethod=cacao_callingMethod();
+
+ if ((mi->flags & ACC_PRIVATE)!=0) {
+ if (c!=callingMethod->class) {
+ throwAccess=1;
+ }
+ } else {
+ if ((mi->flags & ACC_PROTECTED)!=0) {
+ if (!builtin_isanysubclass(callingMethod->class, c)) {
+ throwAccess=1;
+ }
+ } else {
+ /* default visibility*/
+ if (c->packagename!=callingMethod->class->packagename) {
+ throwAccess=1;
+ }
+ }
+ }
+ }
+ if (throwAccess) {
+ *exceptionptr=0;
+ *exceptionptr = new_exception(string_java_lang_IllegalAccessException);
+ return 0;
+ }
+
+ }
+
+#endif
return (java_lang_Object *) jni_method_invokeNativeHelper(env, mi, (jobject) obj, params);
}
Changes: Joseph Wenninger
- $Id: VMClass.c 1735 2004-12-07 14:33:27Z twisti $
+ $Id: VMClass.c 1774 2004-12-20 20:16:57Z jowenn $
*/
/* ((java_lang_reflect_Field*)(o))->flag=f->flags;*/
/* save type in slot-field for faster processing */
/* setfield_critical(c,o,"flag", "I", jint, (jint) f->flags); */
- o->flag = f->flags;
+ /*o->flag = f->flags;*/
setfield_critical(c,o,"slot", "I", jint, (jint) idx);
setfield_critical(c,o,"name", "Ljava/lang/String;", jstring, (jstring) name);
/*setfield_critical(c,o,"type", "Ljava/lang/Class;", jclass, fieldtype);*/
calls instead of machine instructions, using the C calling
convention.
- $Id: builtin.c 1735 2004-12-07 14:33:27Z twisti $
+ $Id: builtin.c 1774 2004-12-20 20:16:57Z jowenn $
*/
return (sub->vftbl->interfacetablelength > super->index) &&
(sub->vftbl->interfacetable[-super->index] != NULL);
- /*
- while (sub != 0)
- if (sub == super)
- return 1;
- else
- sub = sub->super;
-
- return 0;
- */
-
-/*
- for (tmp=sub;tmp!=0;tmp=tmp->super) {
- printf("->");
- utf_display(tmp->name);
- }
- printf("\n\n");
-
- for (tmp=super;tmp!=0;tmp=tmp->super) {
- printf("->");
- utf_display(tmp->name);
- }
- printf("\n");
-
-
- printf("sub->vftbl->baseval %d, super->vftbl->baseval %d\n diff %d, super->vftbl->diffval %d\n",
- sub->vftbl->baseval, super->vftbl->baseval, (unsigned)(sub->vftbl->baseval - super->vftbl->baseval),
- super->vftbl->diffval); */
-
asm_getclassvalues_atomic(super->vftbl, sub->vftbl, &classvalues);
res = (unsigned) (classvalues.sub_baseval - classvalues.super_baseval) <=
Authors: Christian Thalinger
- $Id: exceptions.c 1735 2004-12-07 14:33:27Z twisti $
+ $Id: exceptions.c 1774 2004-12-20 20:16:57Z jowenn $
*/
char *string_java_lang_Exception =
"java/lang/Exception";
+char *string_java_lang_IllegalAccessException =
+ "java/lang/IllegalAccessException";
+
char *string_java_lang_IllegalArgumentException =
"java/lang/IllegalArgumentException";
Authors: Christian Thalinger
- $Id: exceptions.h 1735 2004-12-07 14:33:27Z twisti $
+ $Id: exceptions.h 1774 2004-12-20 20:16:57Z jowenn $
*/
extern char *string_java_lang_ClassNotFoundException;
extern char *string_java_lang_CloneNotSupportedException;
extern char *string_java_lang_Exception;
+extern char *string_java_lang_IllegalAccessException;
extern char *string_java_lang_IllegalArgumentException;
extern char *string_java_lang_IllegalMonitorStateException;
extern char *string_java_lang_IndexOutOfBoundsException;
Authors: Joseph Wenninger
- $Id: stacktrace.c 1771 2004-12-17 23:05:27Z jowenn $
+ $Id: stacktrace.c 1774 2004-12-20 20:16:57Z jowenn $
*/
#undef JWDEBUG
+/*JoWenn: simplify collectors (trace doesn't contain internal methods)*/
extern classinfo *class_java_lang_Class;
extern classinfo *class_java_lang_SecurityManager;
}
+static
+void callingMethodCollector(void **target, stackTraceBuffer *buffer) {
+ if (buffer->full >2) (*target)=buffer->start[2].method;
+ else (*target=0);
+}
+
+methodinfo *cacao_callingMethod() {
+ methodinfo *method;
+ cacao_stacktrace_fillInStackTrace(&method,&callingMethodCollector);
+ return method;
+}
+
/*
* These are local overrides for various environment variables in Emacs.
* Please do not remove this and leave it at the end of the file, where
Changes:
- $Id: stacktrace.h 1735 2004-12-07 14:33:27Z twisti $
+ $Id: stacktrace.h 1774 2004-12-20 20:16:57Z jowenn $
*/
void cacao_stacktrace_NormalTrace(void **target);
java_objectarray *cacao_createClassContextArray();
java_objectheader *cacao_currentClassLoader();
+methodinfo* cacao_callingMethod();
#endif /* _STACKTRACE_H */
Authors: Edwin Steiner
- $Id: typecheck.c 1735 2004-12-07 14:33:27Z twisti $
+ $Id: typecheck.c 1774 2004-12-20 20:16:57Z jowenn $
*/
/* XXX We should resolve the method and pass its
* class as implementingclass to is_accessible. */
- if (!is_accessible(mi->flags,mi->class,NULL, myclass,
+ /* JOWENN: FIXME (and on other invokation places of is_accessible too) */
+ if (!is_accessible(mi->flags,mi->class,/*NULL have to check what here should really be*/ mi->class /*dont't crash right now*/, myclass,
(opcode == ICMD_INVOKESTATIC) ? NULL
: &(srcstack->typeinfo)))
panic("Invoking unaccessible method");
- the heap
- additional support functions
- $Id: tables.c 1735 2004-12-07 14:33:27Z twisti $
+ $Id: tables.c 1774 2004-12-20 20:16:57Z jowenn $
*/
char *p = utf_end(c->name) - 1;
char *start = c->name->text;
for (;p > start; --p) {
- if (*p == '.') {
- c->packagename = utf_new(start, p - start);
+ if (*p == '/') {
+ c->packagename = utf_new (start, p - start);
break;
}
}
--- /dev/null
+import java.util.*;
+
+public class sleep_exception extends Thread {
+ public static Random r = new Random();
+
+ public sleep_exception (String name) {
+ super(name);
+ }
+
+ public void run() {
+ for (int i = 0; i < 10; ++i) {
+ System.out.println(getName());
+ try {
+ throw new Exception("Exception in thread");
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ try {
+ sleep((long) (r.nextFloat() * 1000));
+ } catch (Exception e) {
+ e.printStackTrace();
+ }
+ }
+ }
+
+ public static void main(String args[]) {
+ sleep_exception t1 = new sleep_exception("a");
+ sleep_exception t2 = new sleep_exception("b");
+
+ t1.start();
+ t2.start();
+ }
+}