home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Geek Gadgets 1
/
ADE-1.bin
/
ade-dist
/
kaffe-0.5p4-src.tgz
/
tar.out
/
contrib
/
kaffe
/
lib
/
native
/
java.lang
/
Class.c
next >
Wrap
C/C++ Source or Header
|
1996-09-28
|
2KB
|
110 lines
/*
* java.lang.Class.c
*
* Copyright (c) 1996 Systems Architecture Research Centre,
* City University, London, UK.
*
* See the file "license.terms" for information on usage and redistribution
* of this file, and for a DISCLAIMER OF ALL WARRANTIES.
*
* Written by Tim Wilkinson <tim@sarc.city.ac.uk>, February 1996.
*/
#define __jtypes_h
#include <stdio.h>
#include <assert.h>
#include <string.h>
#include "../../kaffevm/gtypes.h"
#include <native.h>
#include "../../kaffevm/access.h"
#include "../../kaffevm/constants.h"
#include "../../kaffevm/object.h"
#include "../../kaffevm/classMethod.h"
#include "defs.h"
extern char* addStringLen(char*, int);
extern struct Hjava_lang_Class* lookupClass(char*);
/*
* Convert string name to class object.
*/
struct Hjava_lang_Class*
java_lang_Class_forName(struct Hjava_lang_Class* this, struct Hjava_lang_String* str)
{
struct Hjava_lang_Class* c;
char* s;
char buf[MAXNAMELEN];
int i;
/* Get string and convert '.' to '/' */
javaString2CString(str, buf, sizeof(buf));
classname2pathname(buf, buf);
c = lookupClass(addStringLen(buf, strlen(buf)));
assert(c != 0);
return (c);
}
/*
* Convert class to string name.
*/
struct Hjava_lang_String*
java_lang_Class_getName(struct Hjava_lang_Class* c)
{
return (makeJavaString(c->name, strlen(c->name)));
}
/*
* Create a new instance of the derived class.
*/
struct Hjava_lang_Object*
java_lang_Class_newInstance(struct Hjava_lang_Class* this)
{
return (execute_java_constructor(0, 0, this, "()V"));
}
/*
* Return super class.
*/
struct Hjava_lang_Class*
java_lang_Class_getSuperclass(struct Hjava_lang_Class* this)
{
return (this->superclass);
}
HArrayOfObject* /* [Ljava.lang.Class; */
java_lang_Class_getInterfaces(struct Hjava_lang_Class* this)
{
object* obj;
struct Hjava_lang_Class** ifaces;
int i;
obj = AllocObjectArray(this->interface_len, this->name);
ifaces = (struct Hjava_lang_Class**)(obj+1);
for (i = 0; i < this->interface_len; i++) {
ifaces[i] = this->interfaces[i];
}
return ((HArrayOfObject*)obj);
}
/*
* Return the class loader which loaded me.
* Not currently supported.
*/
struct Hjava_lang_ClassLoader*
java_lang_Class_getClassLoader(struct Hjava_lang_Class* this)
{
return (0);
}
/*
* Is the class an interface?
*/
long /* bool */
java_lang_Class_isInterface(struct Hjava_lang_Class* this)
{
return ((this->accflags & ACC_INTERFACE) ? 1 : 0);
}