Initial check-in of ElectricalFire, a Java JIT compiler.

git-svn-id: svn://10.0.0.236/trunk@15719 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
fur%netscape.com
1998-12-03 21:10:47 +00:00
parent b0eacc489e
commit 8a43aa3ae0
580 changed files with 152293 additions and 0 deletions

View File

@@ -0,0 +1,45 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#######################################################################
# (1) Include manifest file #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "component" configuration information. #
#######################################################################
include $(DEPTH)/config/config.mk
#######################################################################
# (3) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
#######################################################################
# (4) Execute "component" rules. (OPTIONAL) #
#######################################################################
include $(DEPTH)/config/rules.mk
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

View File

@@ -0,0 +1,45 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#######################################################################
# (1) Include manifest file #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "component" configuration information. #
#######################################################################
include $(DEPTH)/config/config.mk
#######################################################################
# (3) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
#######################################################################
# (4) Execute "component" rules. (OPTIONAL) #
#######################################################################
include $(DEPTH)/config/rules.mk
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

View File

@@ -0,0 +1,23 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
DIRS = nativesrc

View File

@@ -0,0 +1,366 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_io_File.h"
#include "java_lang_String.h"
#include "prio.h"
#include "prprf.h"
#include "JavaString.h"
#include "JavaVM.h"
#include "SysCallsRuntime.h"
extern "C" {
/* Implementation of the native code in java/io/File */
static bool getFileInfo(Java_java_io_File *file, PRFileInfo &info)
{
JavaString *str = (JavaString *) file->path;
if (str == NULL)
sysThrowNullPointerException();
char *filePath = str->convertUtf();
bool ret = (PR_GetFileInfo(filePath, &info) == PR_SUCCESS);
JavaString::freeUtf(filePath);
return ret;
}
/* Given a File object, return its file name. The null-terminated
* string returned by this function must be freed using JavaString::freeUtf()
*/
static char *getFilePath(Java_java_io_File *file)
{
JavaString *str = (JavaString *) file->path;
if (str == NULL)
sysThrowNullPointerException();
char *filePath = str->convertUtf();
return filePath;
}
/*
* Class : java/io/File
* Method : exists0
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_io_File_exists0(Java_java_io_File *file)
{
PRFileInfo info;
return getFileInfo(file, info);
}
/*
* Class : java/io/File
* Method : canWrite0
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_io_File_canWrite0(Java_java_io_File *file)
{
/* Open the file for writing; if it succeeds, we can write to the file. */
char *filePath = getFilePath(file);
PRFileDesc *fd = PR_Open(filePath, PR_WRONLY, 00644);
JavaString::freeUtf(filePath);
if (!fd)
return false;
PR_Close(fd);
return true;
}
/*
* Class : java/io/File
* Method : canRead0
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_io_File_canRead0(Java_java_io_File *file)
{
/* Open the file for reading; if it succeeds, we can write to the file. */
char *filePath = getFilePath(file);
PRFileDesc *fd = PR_Open(filePath, PR_RDONLY, 00644);
JavaString::freeUtf(filePath);
if (!fd)
return false;
PR_Close(fd);
return true;
}
/*
* Class : java/io/File
* Method : isFile0
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_io_File_isFile0(Java_java_io_File *file)
{
PRFileInfo fileInfo;
if (!getFileInfo(file, fileInfo))
return false;
return (fileInfo.type == PR_FILE_FILE);
}
/*
* Class : java/io/File
* Method : isDirectory0
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_io_File_isDirectory0(Java_java_io_File *file)
{
PRFileInfo fileInfo;
if (!getFileInfo(file, fileInfo))
return false;
return (fileInfo.type == PR_FILE_DIRECTORY);
}
/*
* Class : java/io/File
* Method : lastModified0
* Signature : ()J
*/
NS_EXPORT NS_NATIVECALL(int64)
Netscape_Java_java_io_File_lastModified0(Java_java_io_File *)
{
PR_fprintf(PR_STDERR, "Warning: File::lastModified0() not implemented\n");
return 0;
}
/*
* Class : java/io/File
* Method : length0
* Signature : ()J
*/
NS_EXPORT NS_NATIVECALL(int64)
Netscape_Java_java_io_File_length0(Java_java_io_File *file)
{
PRFileInfo fileInfo;
if (!getFileInfo(file, fileInfo))
return 0;
return ((Int64) fileInfo.size);
}
/*
* Class : java/io/File
* Method : mkdir0
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_io_File_mkdir0(Java_java_io_File *file)
{
char *dirName = getFilePath(file);
bool ret = true;
if (PR_MkDir(dirName, 00755) == PR_FAILURE)
ret = false;
JavaString::freeUtf(dirName);
return ret;
}
/*
* Class : java/io/File
* Method : renameTo0
* Signature : (Ljava/io/File;)Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_io_File_renameTo0(Java_java_io_File *from,
Java_java_io_File *to)
{
char *fromName = getFilePath(from);
char *toName = getFilePath(to);
bool ret = (PR_Rename(fromName, toName) == PR_SUCCESS);
JavaString::freeUtf(fromName);
JavaString::freeUtf(toName);
return ret;
}
/*
* Class : java/io/File
* Method : delete0
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_io_File_delete0(Java_java_io_File *file)
{
char *name = getFilePath(file);
bool ret = (PR_Delete(name) == PR_SUCCESS);
JavaString::freeUtf(name);
return ret;
}
/*
* Class : java/io/File
* Method : rmdir0
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_io_File_rmdir0(Java_java_io_File *file)
{
char *name = getFilePath(file);
bool ret = (PR_RmDir(name) == PR_SUCCESS);
JavaString::freeUtf(name);
return ret;
}
/*
* Class : java/io/File
* Method : list0
* Signature : ()[Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_String *)
Netscape_Java_java_io_File_list0(Java_java_io_File *dir)
{
char *name = getFilePath(dir);
PRFileInfo info;
if (!getFileInfo(dir, info))
return 0;
PRDir* d = PR_OpenDir(name);
PRDirEntry* e;
Uint32 count = 0;
while ((e = PR_ReadDir(d, PR_SKIP_BOTH)) != NULL)
count++;
PR_CloseDir(d);
d = PR_OpenDir(name);
JavaArray *arr = (JavaArray *) sysNewObjectArray(&VM::getStandardClass(cString), count);
ArrayOf_Java_java_lang_String *stringArray = (ArrayOf_Java_java_lang_String *) arr;
for (Uint32 i = 0; i < count; i++)
stringArray->elements[i] = (Java_java_lang_String*) JavaString::make(PR_ReadDir(d, PR_SKIP_BOTH)->name);
PR_CloseDir(d);
return stringArray;
}
/*
* Class : java/io/File
* Method : canonPath
* Signature : (Ljava/lang/String;)Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_String *)
Netscape_Java_java_io_File_canonPath(Java_java_io_File *, Java_java_lang_String *)
{
printf("File::canonPath() not yet implemented\n");
return 0;
}
/*
* Class : java/io/File
* Method : isAbsolute
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_io_File_isAbsolute(Java_java_io_File *file)
{
JavaString* jspath = (JavaString*)file->path;
const int16* path = jspath->getStr();
char first = (char) path[0];
// Shouldn't this be done in NSPR ?
#if defined(XP_UNIX)
Class &clazz = const_cast<Class&>(file->getClass());
Field &fld = clazz.getField("pathSeparatorChar");
int16 pathSeparatorChar = fld.getChar(NULL); // pathSeparatorChar is a static field
if (first == pathSeparatorChar)
return 1;
else return 0;
#elif defined(XP_PC)
if (first == '/' || first == '\\')
return 1;
char second = (char) path[1];
if (((first >= 'A' && first <= 'Z') || (first >= 'a' && first <= 'z'))
&& (second == ':'))
return 1;
return 0;
#else
printf("File::isAbsolute() not yet implemented on this platform\n");
#endif
return 0;
}
/*
* Class : java/io/File
* Method : initIDs
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_File_initIDs()
{
/* Currently empty, since all our initialization is done statically (see Mapping.h) */
}
} /* extern "C" */

View File

@@ -0,0 +1,76 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <string.h>
#include "java_io_FileDescriptor.h"
#include "prio.h"
#include "prprf.h"
#include "Mapping.h"
/* This is used as a global file-descriptor mapper */
Mapping fdMapping;
extern "C" {
#ifdef LINUX
//
// This is temporary. I have to find a way to get the static
// initializers to work !!!!
//
// Sorry, Laurent.
//
void _init()
{
fdMapping.init();
#if 0
fdMapping.descs[1] = PR_Open("/tmp/stdout", PR_WRONLY | PR_CREATE_FILE | PR_APPEND, 0644);
fdMapping.descs[2] = fdMapping.descs[1];
#endif
}
#endif
/*
* Class : java/io/FileDescriptor
* Method : sync
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_FileDescriptor_sync(Java_java_io_FileDescriptor *fileD)
{
PRFileDesc *desc = fdMapping.get(fileD->fd);
if (desc) PR_Sync(desc);
}
/*
* Class : java/io/FileDescriptor
* Method : initIDs
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_FileDescriptor_initIDs()
{
}
} /* extern "C" */

View File

@@ -0,0 +1,180 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_io_FileInputStream.h"
#include "java_io_FileDescriptor.h"
#include "prio.h"
#include "prprf.h"
#include "Mapping.h"
#include "ErrorHandling.h"
#include "JavaString.h"
#include "SysCallsRuntime.h"
extern Mapping fdMapping;
extern "C" {
inline PRFileDesc *java_io_FileInputStream_GetDesc(Java_java_io_FileInputStream *str)
{
PRFileDesc *desc = fdMapping.get(str->fd->fd);
if (!desc)
sysThrowNamedException("java/io/IOException");
return desc;
}
inline int64 java_io_FileInputStream_Read(Java_java_io_FileInputStream *str,
char *buf, int32 len)
{
PRFileDesc *desc = java_io_FileInputStream_GetDesc(str);
int nRead = PR_Read(desc, buf, len);
if (nRead == 0)
return -1; /* EOF */
else if (nRead < 0)
sysThrowNamedException("java/io/IOException");
return nRead;
}
/*
* Class : java/io/FileInputStream
* Method : open
* Signature : (Ljava/lang/String;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_FileInputStream_open(Java_java_io_FileInputStream *stream,
Java_java_lang_String *str)
{
char *name = ((JavaString *) str)->convertUtf();
PRFileDesc *desc = PR_Open(name, PR_RDONLY, 0);
JavaString::freeUtf(name);
if (!desc)
sysThrowNamedException("java/io/IOException");
Int32 fd = fdMapping.add(desc);
stream->fd->fd = fd;
}
/*
* Class : java/io/FileInputStream
* Method : read
* Signature : ()I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_io_FileInputStream_read(Java_java_io_FileInputStream *str)
{
char c;
Int32 nRead = (int32) java_io_FileInputStream_Read(str, &c, 1);
assert(nRead == 1);
return (Int32) c;
}
/*
* Class : java/io/FileInputStream
* Method : readBytes
* Signature : ([BII)I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_io_FileInputStream_readBytes(Java_java_io_FileInputStream *str,
ArrayOf_uint8 *arr,
int32 offset,
int32 len)
{
if (offset < 0 || offset >= len || (Uint32)len > (arr->length - offset))
runtimeError(RuntimeError::illegalAccess);
char *startp = (char *) arr->elements + offset;
int32 nRead = (int32) java_io_FileInputStream_Read(str, startp, len);
return nRead;
}
/*
* Class : java/io/FileInputStream
* Method : skip
* Signature : (J)J
*/
NS_EXPORT NS_NATIVECALL(int64)
Netscape_Java_java_io_FileInputStream_skip(Java_java_io_FileInputStream *str,
int64 nBytesToSkip)
{
if (nBytesToSkip < 0)
sysThrowNamedException("java/io/IOException");
else if (nBytesToSkip == 0)
return 0;
char *buf = new char[(int32) nBytesToSkip];
if (!buf)
return 0;
int32 nRead = (int32) java_io_FileInputStream_Read(str, buf, (int32) nBytesToSkip);
return nRead;
}
/*
* Class : java/io/FileInputStream
* Method : available
* Signature : ()I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_io_FileInputStream_available(Java_java_io_FileInputStream *str)
{
PRFileDesc *desc = java_io_FileInputStream_GetDesc(str);
return PR_Available(desc);
}
/*
* Class : java/io/FileInputStream
* Method : close
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_FileInputStream_close(Java_java_io_FileInputStream *str)
{
fdMapping.close(str->fd->fd);
}
/*
* Class : java/io/FileInputStream
* Method : initIDs
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_FileInputStream_initIDs()
{
/* Currently empty, since all our initialization is done statically (see Mapping.h) */
}
} /* extern "C" */

View File

@@ -0,0 +1,157 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_io_FileOutputStream.h"
#include "java_io_FileDescriptor.h"
#include "java_lang_String.h"
#include "prio.h"
#include "prprf.h"
#include "ErrorHandling.h"
#include "Mapping.h"
#include "JavaString.h"
#include "SysCallsRuntime.h"
extern Mapping fdMapping;
extern "C" {
inline PRFileDesc *java_io_FileOutputStream_GetDesc(Java_java_io_FileOutputStream *str)
{
PRFileDesc *desc = fdMapping.get(str->fd->fd);
if (!desc)
runtimeError(RuntimeError::IOError);
return desc;
}
inline int64 java_io_FileOutputStream_Write(Java_java_io_FileOutputStream *str,
char *buf, int32 len)
{
PRFileDesc *desc = java_io_FileOutputStream_GetDesc(str);
int nWritten = PR_Write(desc, buf, len);
if (nWritten < 0)
runtimeError(RuntimeError::IOError);
return nWritten;
}
/*
* Class : java/io/FileOutputStream
* Method : open
* Signature : (Ljava/lang/String;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_FileOutputStream_open(Java_java_io_FileOutputStream *stream,
Java_java_lang_String *string)
{
char *name = ((JavaString *) string)->convertUtf();
PRFileDesc *desc = PR_Open(name, PR_WRONLY | PR_CREATE_FILE, 0);
JavaString::freeUtf(name);
if (!desc)
sysThrowNamedException("java/io/IOException");
int32 fd = fdMapping.add(desc);
stream->fd->fd = fd;
}
/*
* Class : java/io/FileOutputStream
* Method : openAppend
* Signature : (Ljava/lang/String;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_FileOutputStream_openAppend(Java_java_io_FileOutputStream *stream, Java_java_lang_String *string)
{
char *name = ((JavaString *) string)->convertUtf();
PRFileDesc *desc = PR_Open(name, PR_APPEND, 0);
JavaString::freeUtf(name);
if (!desc)
sysThrowNamedException("java/io/IOException");
int32 fd = fdMapping.add(desc);
stream->fd->fd = fd;
}
/*
* Class : java/io/FileOutputStream
* Method : write
* Signature : (I)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_FileOutputStream_write(Java_java_io_FileOutputStream *str,
int32 byte)
{
java_io_FileOutputStream_Write(str, (char *) &byte, 1);
}
/*
* Class : java/io/FileOutputStream
* Method : writeBytes
* Signature : ([BII)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_FileOutputStream_writeBytes(Java_java_io_FileOutputStream *str,
ArrayOf_uint8 *arr,
int32 offset, int32 len)
{
if (offset < 0 || offset >= len || (Uint32)len > (arr->length - offset))
runtimeError(RuntimeError::illegalAccess);
char *startp = (char *) arr->elements + offset;
java_io_FileOutputStream_Write(str, startp, len);
}
/*
* Class : java/io/FileOutputStream
* Method : close
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_FileOutputStream_close(Java_java_io_FileOutputStream *str)
{
fdMapping.close(str->fd->fd);
}
/*
* Class : java/io/FileOutputStream
* Method : initIDs
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_FileOutputStream_initIDs()
{
/* Currently empty, since all our initialization is done statically (see Mapping.h) */
}
} /* extern "C" */

View File

@@ -0,0 +1,45 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#######################################################################
# (1) Include manifest file #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "component" configuration information. #
#######################################################################
include $(DEPTH)/config/config.mk
#######################################################################
# (3) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
#######################################################################
# (4) Execute "component" rules. (OPTIONAL) #
#######################################################################
include $(DEPTH)/config/rules.mk
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

View File

@@ -0,0 +1,87 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#ifndef _FD_MAPPING_H_
#define _FD_MAPPING_H_
#include <string.h>
/* The current JDK Java source uses an int32 to represent a file-descriptor.
* NSPR uses pointers to PRFileDesc's. So we need a mapping from one to the
* other.
*/
struct Mapping {
PRFileDesc **descs;
int32 numDescs;
/* Initialize the mapping mechanism and the values of STDIN, STDOUT
* and STDERR.
*/
Mapping() {init(); }
void init() {
numDescs = 10;
descs = new PRFileDesc * [numDescs];
memset(descs, 0, numDescs * sizeof(PRFileDesc *));
descs[0] = PR_STDIN;
descs[1] = PR_STDOUT;
descs[2] = PR_STDERR;
}
/* Return true if the given fd is valid. */
bool valid(int fd) { return (fd < numDescs && descs[fd] != 0); }
/* Add a new file descriptor and return the corresponding fd */
int add(PRFileDesc *desc) {
int32 i;
for (i = 0; i < numDescs; i++)
if (!descs[i]) {
descs[i] = desc;
return i;
} else if (descs[i] == desc) /* Already added by someone else */
return i;
PRFileDesc **temp = descs;
descs = new PRFileDesc * [numDescs = numDescs+10];
memset(descs, 0, sizeof(PRFileDesc *)*numDescs);
for (int32 j = 0; j < numDescs; j++)
descs[j] = temp[j];
delete [] temp;
descs[i] = desc;
return i;
}
PRFileDesc *get(int32 fd) { assert(fd < numDescs); return descs[fd]; }
void close(int32 fd) {
assert(fd < numDescs);
if (valid(fd))
PR_Close(descs[fd]);
descs[fd] = 0;
}
~Mapping() {
delete [] descs;
}
};
#endif /* _FD_MAPPING_H_ */

View File

@@ -0,0 +1,66 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_io_RandomAccessFile.h"
#include "java_io_FileDescriptor.h"
#include "java_lang_String.h"
#include "prio.h"
#include "prprf.h"
#include "Mapping.h"
#include "JavaString.h"
#include "JavaVM.h"
extern Mapping fdMapping;
extern "C" {
/*
* Class : java/io/RandomAccessFile
* Method : initIDs
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_RandomAccessFile_initIDs()
{
// PR_fprintf(PR_STDERR, "Warning: RandomAccessFile::initIDs() not implemented\n");
}
/*
* Class : java/io/RandomAccessFile
* Method : open
* Signature : (Ljava/lang/String;Z)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_io_RandomAccessFile_open(Java_java_io_RandomAccessFile *raFile, Java_java_lang_String *str, uint32 /* bool */ w)
{
char *name = ((JavaString *) str)->convertUtf();
PRFileDesc *desc = PR_Open(name, (w) ? PR_RDWR|PR_CREATE_FILE : PR_RDONLY, 0);
JavaString::freeUtf(name);
if (!desc)
sysThrowNamedException("java/io/IOException");
Int32 fd = fdMapping.add(desc);
raFile->fd->fd = fd;
}
}

View File

@@ -0,0 +1,36 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../..
MODULE_NAME = Package
CPPSRCS = File.cpp \
FileDescriptor.cpp \
FileInputStream.cpp \
FileOutputStream.cpp \
$(NULL)
HEADER_GEN = java.io.File \
java.io.FileDescriptor \
java.io.FileInputStream \
java.io.FileOutputStream \
$(NULL)

View File

@@ -0,0 +1,45 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#######################################################################
# (1) Include manifest file #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "component" configuration information. #
#######################################################################
include $(DEPTH)/config/config.mk
#######################################################################
# (3) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
#######################################################################
# (4) Execute "component" rules. (OPTIONAL) #
#######################################################################
include $(DEPTH)/config/rules.mk
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

View File

@@ -0,0 +1,25 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
DIRS = nativesrc

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,721 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_Class.h"
#include "java_lang_reflect_Field.h"
#include "java_lang_reflect_Method.h"
#include "java_lang_reflect_Constructor.h"
#include "JavaVM.h"
#include "JavaString.h"
#include "prprf.h"
#include "SysCallsRuntime.h"
#include "StackWalker.h"
enum FieldOrMethodCategory {
fieldOrMethodCategoryPublic=0,
fieldOrMethodCategoryDeclared=1
};
static inline void throwClassVerifyException(VerifyError err)
{
// FIXME Need to be more specific in the exceptions we throw here
switch (err.cause) {
case VerifyError::noClassDefFound:
case VerifyError::badClassFormat:
default:
sysThrowNamedException("java/lang/ClassNotFoundException");
break;
case VerifyError::illegalAccess:
sysThrowNamedException("java/lang/IllegalAccessException");
break;
}
}
static inline void throwClassRuntimeException(RuntimeError err)
{
// FIXME Need to be more specific in the exceptions we throw here
switch (err.cause) {
case RuntimeError::illegalAccess:
sysThrowNamedException("java/lang/IllegalAccessException");
break;
case RuntimeError::nullPointer:
sysThrowNullPointerException();
break;
default:
sysThrowNamedException("java/lang/IllegalArgumentException");
break;
}
}
extern "C" {
/* Some interesting things to remember:
* (1) What is passed to all native methods of java/lang/Class is an instance
* of the VM class Class.
* (2) All native routines here do not check for security restrictions; it is
* assumed that security is dealt with at a higher level.
*/
static inline Type &toType(Java_java_lang_Class &inClass)
{
Type &type = *(Type *) (&inClass);
return type;
}
static inline JavaObject &toObject(Java_java_lang_Object &inObject)
{
return *(Class *)(&inObject);
}
/*
* Class : java/lang/Class
* Method : forName
* Signature : (Ljava/lang/String;)Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_Class_forName(Java_java_lang_String *nameString)
{
if (!nameString)
sysThrowNamedException("java/lang/ClassNotFoundException");
ClassCentral &central = VM::getCentral();
char *name = ((JavaString *) nameString)->convertUtf();
// Replace dots with slashes to obtain the fully qualified name of the class.
// central.addClass() expects a fully qualified class name.
for (char *p = name; *p; p++)
if (*p == '.') *p = '/';
Class *clz;
try {
clz = static_cast<Class *>(central.addClass(name).getThisClass());
} catch(VerifyError err) {
throwClassVerifyException(err);
} catch(RuntimeError err) {
throwClassRuntimeException(err);
}
/* Free the memory we just allocated */
JavaString::freeUtf(name);
return (Java_java_lang_Class *) clz;
}
/*
* Class : java/lang/Class
* Method : newInstance
* Signature : ()Ljava/lang/Object;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Object *)
Netscape_Java_java_lang_Class_newInstance(Java_java_lang_Class *inClass)
{
Type &type = toType(*inClass);
// We can't instantiate primitive types, arrays or interfaces
if (type.typeKind != tkObject)
sysThrowNamedException("java/lang/InstantiationException");
const Class &clazz = asClass(type);
// Check to see if the caller of the class has package access to this class
Frame thisFrame;
Method &callerMethod = thisFrame.getCallingJavaMethod();
ClassOrInterface *callingClass;
callingClass = callerMethod.getDeclaringClass();
bool hasPackageAccess = false;
if (callingClass->package.name == clazz.package.name)
hasPackageAccess = true;
// Check argument type. Make sure that the class that called this
// method is a class that can access the class clazz.
if (!(clazz.getModifiers() & CR_ACC_PUBLIC) && !hasPackageAccess)
sysThrowNamedException("java/lang/IllegalAccessException");
// Make sure that the class is instantiable. The class is
// instantiable if it is not abstract, and has at least one constructor
// that the calling class can access.
if ((clazz.getModifiers() & CR_ACC_ABSTRACT) || clazz.isInterface())
sysThrowNamedException("java/lang/InstantiationException");
const Constructor **constructors;
const Constructor **declaredConstructors;
Int32 nDeclaredConstructors;
// Check that there is at least one constructor that the calling class can call
if (const_cast<Class *>(&clazz)->getConstructors(constructors) == 0 &&
(nDeclaredConstructors =
const_cast<Class *>(&clazz)->getDeclaredConstructors(declaredConstructors)) > 0) {
/* Now go through each of these declared constructors and see if we have
* package access to any of them
* FIXME This is horrendous, too much work. Think about not doing this much
* work everytime
*/
for (Int32 i = 0; i < nDeclaredConstructors; i++)
if (!(declaredConstructors[i]->getModifiers() & CR_METHOD_PRIVATE))
if (hasPackageAccess)
break;
if (i == nDeclaredConstructors)
sysThrowNamedException("java/lang/IllegalAccessException");
}
try {
return (Java_java_lang_Object *) (&const_cast<Class *>(&clazz)->newInstance());
} catch (RuntimeError err) {
throwClassRuntimeException(err);
}
}
/*
* Class : java/lang/Class
* Method : isInstance
* Signature : (Ljava/lang/Object;)Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_lang_Class_isInstance(Java_java_lang_Class *inClass,
Java_java_lang_Object *inObj)
{
Type &type = toType(*inClass);
if (type.isPrimitive())
return (Uint32)false;
if (!inObj)
return false;
const Class &clazz = asClass(type);
return (Uint32) clazz.isInstance(toObject(*inObj));
}
/*
* Class : java/lang/Class
* Method : isAssignableFrom
* Signature : (Ljava/lang/Class;)Z
*/
NS_EXPORT NS_NATIVECALL(uint32) /* bool */
Netscape_Java_java_lang_Class_isAssignableFrom(Java_java_lang_Class * inClass,
Java_java_lang_Class * inToClass)
{
if (!inToClass)
sysThrowNullPointerException();
return toType(*inClass).isAssignableFrom(toType(*inToClass));
}
/*
* Class : java/lang/Class
* Method : isInterface
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_lang_Class_isInterface(Java_java_lang_Class *inClass)
{
Type &type = toType(*inClass);
return type.isInterface();
}
/*
* Class : java/lang/Class
* Method : isArray
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_lang_Class_isArray(Java_java_lang_Class *inClass)
{
Type &type = toType(*inClass);
return type.isArray();
}
/*
* Class : java/lang/Class
* Method : isPrimitive
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_lang_Class_isPrimitive(Java_java_lang_Class *inClass)
{
Type &type = toType(*inClass);
return type.isPrimitive();
}
/*
* Class : java/lang/Class
* Method : getName
* Signature : ()Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_String *)
Netscape_Java_java_lang_Class_getName(Java_java_lang_Class *inClass)
{
Type &type = toType(*inClass);
const char *fullName = type.getName();
JavaString &fullNameStr = VM::intern(fullName);
return (Java_java_lang_String *) &fullNameStr;
}
/*
* Class : java/lang/Class
* Method : getClassLoader
* Signature : ()Ljava/lang/ClassLoader;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_ClassLoader *)
Netscape_Java_java_lang_Class_getClassLoader(Java_java_lang_Class *)
{
#ifdef DEBUG_LOG
PR_fprintf(PR_STDERR, "Netscape_Java_java_lang_Class_getClassLoader() not implemented");
#endif
return 0;
}
/*
* Class : java/lang/Class
* Method : getSuperclass
* Signature : ()Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_Class_getSuperclass(Java_java_lang_Class *inClass)
{
Type &type = toType(*inClass);
const Type *superClass = type.getSuperClass();
return (Java_java_lang_Class *) superClass;
}
/*
* Class : java/lang/Class
* Method : getInterfaces
* Signature : ()[Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_Class *)
Netscape_Java_java_lang_Class_getInterfaces(Java_java_lang_Class *inClass)
{
Type &type = toType(*inClass);
if (isPrimitiveKind(type.typeKind))
sysThrowNamedException("java/lang/IllegalAccessException");
ClassOrInterface &clazz = *static_cast<ClassOrInterface *>(&type);
Interface **interfaces;
Int32 numInterfaces = clazz.getInterfaces(interfaces);
JavaArray *arr = (JavaArray *) sysNewObjectArray(&VM::getStandardClass(cClass), numInterfaces);
ArrayOf_Java_java_lang_Class *clazzArray = (ArrayOf_Java_java_lang_Class *) arr;
for (Int32 i = 0; i < numInterfaces; i++)
clazzArray->elements[i] = (Java_java_lang_Class *) interfaces[i];
return clazzArray;
}
/*
* Class : java/lang/Class
* Method : getComponentType
* Signature : ()Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_Class_getComponentType(Java_java_lang_Class *inClass)
{
Type &type = toType(*inClass);
if (!type.isArray())
return NULL;
const Type &componentType = asArray(type).getComponentType();
return (Java_java_lang_Class *) &componentType;
}
/*
* Class : java/lang/Class
* Method : getModifiers
* Signature : ()I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_Class_getModifiers(Java_java_lang_Class *inClass)
{
Type &type = toType(*inClass);
return type.getModifiers();
}
/*
* Class : java/lang/Class
* Method : getSigners
* Signature : ()[Ljava/lang/Object;
*/
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_Object *)
Netscape_Java_java_lang_Class_getSigners(Java_java_lang_Class *)
{
printf("Netscape_Java_java_lang_Class_getSigners() not implemented");
return 0;
}
/*
* Class : java/lang/Class
* Method : setSigners
* Signature : ([Ljava/lang/Object;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Class_setSigners(Java_java_lang_Class *, ArrayOf_Java_java_lang_Object *)
{
printf("Netscape_Java_java_lang_Class_setSigners() not implemented");
}
/*
* Class : java/lang/Class
* Method : getPrimitiveClass
* Signature : (Ljava/lang/String;)Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_Class_getPrimitiveClass(Java_java_lang_String *nameString)
{
if (!nameString)
return NULL;
char *className = ((JavaString *) nameString)->convertUtf();
const PrimitiveType *clazz = PrimitiveType::getClass(className);
/* Free the memory we just allocated */
JavaString::freeUtf(className);
return (Java_java_lang_Class *)clazz;
}
/*
* Class : java/lang/Class
* Method : getFields0
* Signature : (I)[Ljava/lang/reflect/Field;
*
* fieldCategory tells us what class of fields to return.
* fieldCategory can have the values defined in enum FieldCategory,
* defined above.
*/
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_reflect_Field *)
Netscape_Java_java_lang_Class_getFields0(Java_java_lang_Class *inClass,
int32 category)
{
#if 0
ClassOrInterface &clazz = *(ClassOrInterface *) &toType(*inClass);
const Field **fields;
Int32 numFields;
if (category == fieldOrMethodCategoryPublic)
numFields = clazz.getFields(fields);
else
numFields = clazz.getDeclaredFields(fields);
const Type *classField = &VM::getStandardClass(cField);
JavaArray *arr = (JavaArray *) sysNewObjectArray(classField, numFields);
ArrayOf_Java_java_lang_reflect_Field *fieldArray =
(ArrayOf_Java_java_lang_reflect_Field *) arr;
for (Int32 i = 0; i < numFields; i++)
fieldArray->elements[i] = (Java_java_lang_reflect_Field *) fields[i];
return fieldArray;
#else
bool publik = (category == fieldOrMethodCategoryPublic);
ClassOrInterface &clazz = *(ClassOrInterface *) &toType(*inClass);
Int32 numFields = 0;
if (publik) {
Int32 i;
/* Walk all interfaces that we implement */
Int32 interfaceCount;
Interface **interfaces;
interfaceCount = clazz.getInterfaces(interfaces);
for (i = 0; i < interfaceCount; i++) {
const Field **dummy;
numFields += interfaces[i]->getFields(dummy);
}
/* Walk our instance fields from child to parent */
ClassOrInterface *tmp;
for (tmp = &clazz; tmp; tmp = (ClassOrInterface *) tmp->getSuperClass()) {
const Field **fieldsInThisClass;
Int32 numFieldsInThisClass = tmp->getDeclaredFields(fieldsInThisClass);
for (i = 0; i < numFieldsInThisClass; i++)
if (fieldsInThisClass[i]->getModifiers() & CR_FIELD_PUBLIC)
numFields++;
}
/* Allocate a JavaArray of the correct size */
const Type *classField = &VM::getStandardClass(cField);
JavaArray *arr = (JavaArray *) sysNewObjectArray(classField, numFields);
ArrayOf_Java_java_lang_reflect_Field *fieldArray =
(ArrayOf_Java_java_lang_reflect_Field *) arr;
Int32 index = 0;
/* Walk the fields again, this time copying them into our array */
for (i = 0; i < interfaceCount; i++) {
const Field **interfaceFields;
Int32 numInterfaceFields = interfaces[i]->getFields(interfaceFields);
for (Int32 j = 0; j < numInterfaceFields; j++)
fieldArray->elements[index++] = (Java_java_lang_reflect_Field *) interfaceFields[j];
}
/* Add instance fields, starting with the topmost superclass */
Vector<ClassOrInterface *> vec;
for (tmp = &clazz; tmp; tmp = (ClassOrInterface *)(tmp->getSuperClass()))
vec.append(tmp);
for (Int32 vectorIndex = vec.size(); vectorIndex > 0; vectorIndex--) {
tmp = vec[vectorIndex-1];
const Field **fieldsInThisClass;
Int32 numFieldsInThisClass = tmp->getDeclaredFields(fieldsInThisClass);
for (i = 0; i < numFieldsInThisClass; i++)
if (fieldsInThisClass[i]->getModifiers() & CR_FIELD_PUBLIC)
fieldArray->elements[index++] = (Java_java_lang_reflect_Field *) fieldsInThisClass[i];
}
assert(index == numFields);
return fieldArray;
} else {
const Field **fields;
numFields = clazz.getDeclaredFields(fields);
const Type *classField = &VM::getStandardClass(cField);
JavaArray *arr = (JavaArray *) sysNewObjectArray(classField, numFields);
ArrayOf_Java_java_lang_reflect_Field *fieldArray =
(ArrayOf_Java_java_lang_reflect_Field *) arr;
for (Int32 i = 0; i < numFields; i++)
fieldArray->elements[i] = (Java_java_lang_reflect_Field *) fields[i];
return fieldArray;
}
#endif
}
/*
* Class : java/lang/Class
* Method : getMethods0
* Signature : (I)[Ljava/lang/reflect/Method;
*/
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_reflect_Method *)
Netscape_Java_java_lang_Class_getMethods0(Java_java_lang_Class *inClass,
int32 category)
{
ClassOrInterface &clazz = *(ClassOrInterface *) &toType(*inClass);
const Method **methods;
Int32 numMethods;
if (category == fieldOrMethodCategoryPublic)
numMethods = clazz.getMethods(methods);
else
numMethods = clazz.getDeclaredMethods(methods);
const Type *classMethod = &VM::getStandardClass(cMethod);
JavaArray *arr = (JavaArray *) sysNewObjectArray(classMethod, numMethods);
ArrayOf_Java_java_lang_reflect_Method *methodArray =
(ArrayOf_Java_java_lang_reflect_Method *) arr;
for (Int32 i = 0; i < numMethods; i++)
methodArray->elements[i] = (Java_java_lang_reflect_Method *) methods[i];
return methodArray;
}
/*
* Class : java/lang/Class
* Method : getConstructors0
* Signature : (I)[Ljava/lang/reflect/Constructor;
*/
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_reflect_Constructor *)
Netscape_Java_java_lang_Class_getConstructors0(Java_java_lang_Class *inClass,
int32 category)
{
ClassOrInterface &clazz = *(ClassOrInterface *) &toType(*inClass);
const Constructor **constructors;
Int32 numConstructors;
if (category == fieldOrMethodCategoryPublic)
numConstructors = clazz.getConstructors(constructors);
else
numConstructors = clazz.getDeclaredConstructors(constructors);
const Type *classConstructor = &VM::getStandardClass(cConstructor);
JavaArray *arr = (JavaArray *) sysNewObjectArray(classConstructor, numConstructors);
ArrayOf_Java_java_lang_reflect_Constructor *constructorArray =
(ArrayOf_Java_java_lang_reflect_Constructor *) arr;
for (Int32 i = 0; i < numConstructors; i++)
constructorArray->elements[i] = (Java_java_lang_reflect_Constructor *) constructors[i];
return constructorArray;
}
/*
* Class : java/lang/Class
* Method : getField0
* Signature : (Ljava/lang/String;I)Ljava/lang/reflect/Field;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_reflect_Field *)
Netscape_Java_java_lang_Class_getField0(Java_java_lang_Class *inClass,
Java_java_lang_String *inName,
int32 category)
{
if (!inName || !inClass)
sysThrowNullPointerException();
char *name = ((JavaString *) inName)->convertUtf();
ClassOrInterface &clazz = *(ClassOrInterface *) &toType(*inClass);
const Field *field;
try {
if (category == fieldOrMethodCategoryPublic)
field = &clazz.getField(name);
else
field = &clazz.getDeclaredField(name);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/NoSuchFieldException");
}
JavaString::freeUtf(name);
return (Java_java_lang_reflect_Field *)field;
}
/*
* Class : java/lang/Class
* Method : getMethod0
* Signature : (Ljava/lang/String;[Ljava/lang/Class;I)Ljava/lang/reflect/Method;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_reflect_Method *)
Netscape_Java_java_lang_Class_getMethod0(Java_java_lang_Class *inClass,
Java_java_lang_String *inName,
ArrayOf_Java_java_lang_Class *paramTypes,
int32 category)
{
if (!inName)
sysThrowNullPointerException();
Int32 numParams;
const Type **params;
if (!paramTypes) {
Type *dummy[1];
params = (const Type **) dummy;
numParams = 0;
} else {
params = (const Type **) paramTypes->elements;
numParams = paramTypes->length;
}
ClassOrInterface &clazz = *(ClassOrInterface *) &toType(*inClass);
char *name = ((JavaString *) inName)->convertUtf();
const Method *method;
try {
if (category == fieldOrMethodCategoryPublic)
method = &clazz.getMethod(name, params, numParams);
else
method = &clazz.getDeclaredMethod(name, params, numParams);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/NoSuchMethodException");
}
JavaString::freeUtf(name);
return (Java_java_lang_reflect_Method *) method;
}
/*
* Class : java/lang/Class
* Method : getConstructor0
* Signature : ([Ljava/lang/Class;I)Ljava/lang/reflect/Constructor;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_reflect_Constructor *)
Netscape_Java_java_lang_Class_getConstructor0(Java_java_lang_Class *inClass,
ArrayOf_Java_java_lang_Class *paramTypes,
int32 category)
{
ClassOrInterface &clazz = *(ClassOrInterface *) &toType(*inClass);
const Type **params;
Uint32 nParams;
if (paramTypes == 0) {
params = (const Type **) 0;
nParams = 0;
} else {
params = (const Type **) paramTypes->elements;
nParams = paramTypes->length;
}
Constructor *constructor;
try {
if (category == fieldOrMethodCategoryPublic)
constructor = &clazz.getConstructor(params, nParams);
else
constructor = &clazz.getDeclaredConstructor(params, nParams);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/NoSuchMethodException");
}
return (Java_java_lang_reflect_Constructor *) constructor;
}
} /* extern "C" */

View File

@@ -0,0 +1,150 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_ClassLoader.h"
#include "FieldOrMethod.h"
#include "JavaVM.h"
#include "JavaString.h"
#include "SysCallsRuntime.h"
#include "prio.h"
#include <stdio.h>
extern "C" {
/*
* Class : java/lang/ClassLoader
* Method : init
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void )
Netscape_Java_java_lang_ClassLoader_init(Java_java_lang_ClassLoader *)
{
//printf("Netscape_Java_java_lang_ClassLoader_init() not implemented");
}
NS_EXPORT NS_NATIVECALL(void )
Netscape_Java_java_lang_ClassLoader_initIDs()
{
// printf("Netscape_Java_java_lang_ClassLoader_init() not implemented");
}
/*
* Class : java/lang/ClassLoader
* Method : defineClass0
* Signature : (Ljava/lang/String;[BII)Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_ClassLoader_defineClass0(Java_java_lang_ClassLoader *, Java_java_lang_String *, ArrayOf_uint8 *, int32, int32)
{
printf("Netscape_Java_java_lang_ClassLoader_defineClass0() not implemented");
return 0;
}
/*
* Class : java/lang/ClassLoader
* Method : resolveClass0
* Signature : (Ljava/lang/Class;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_ClassLoader_resolveClass0(Java_java_lang_ClassLoader *, Java_java_lang_Class *)
{
printf("Netscape_Java_java_lang_ClassLoader_resolveClass0() not implemented");
}
/*
* Class : java/lang/ClassLoader
* Method : findSystemClass0
* Signature : (Ljava/lang/String;)Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_ClassLoader_findSystemClass0(Java_java_lang_ClassLoader *, Java_java_lang_String *str)
{
#if 0
Java_java_lang_Class* ret;
try {
char *className = ((JavaString *) str)->convertUtf();
ClassCentral &central = VM::getCentral();
ClassFileSummary &summ = central.addClass(className);
Class *clazz = const_cast<Class *>(static_cast<const Class *>(summ.getThisClass()));
JavaString::freeUtf(className);
assert(clazz);
ret = ((Java_java_lang_Class*)&asClass(*clazz));
} catch (VerifyError e) {
ret = NULL;
}
return ret;
#endif
// fprintf(stdout, "looking for class %s\n", ((JavaString *) str)->convertUtf());
return NULL;
}
/*
* Class : java/lang/ClassLoader
* Method : getSystemResourceAsStream0
* Signature : (Ljava/lang/String;)Ljava/io/InputStream;
*/
NS_EXPORT NS_NATIVECALL(Java_java_io_InputStream *)
Netscape_Java_java_lang_ClassLoader_getSystemResourceAsStream0(Java_java_lang_String *str)
{
if (str == NULL)
sysThrowNullPointerException();
char* fileName = ((JavaString *) str)->convertUtf();
PRFileInfo info;
if (PR_GetFileInfo(fileName, &info) != PR_SUCCESS) {
JavaString::freeUtf(fileName);
return NULL;
}
JavaString::freeUtf(fileName);
ClassCentral &central = VM::getCentral();
ClassFileSummary &summ = central.addClass("java/io/FileInputStream");
Class *clazz = const_cast<Class *>(static_cast<const Class *>(summ.getThisClass()));
const Type* paramType[1];
paramType[0] = (Type *) &VM::getStandardClass(cString);
JavaObject* param[1];
param[0] = (JavaObject *) str;
Constructor& c = clazz->getDeclaredConstructor(paramType, 1);
JavaObject& ret = c.newInstance(param, 1);
return (Java_java_io_InputStream *) &ret;
}
/*
* Class : java/lang/ClassLoader
* Method : getSystemResourceAsName0
* Signature : (Ljava/lang/String;)Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_String *)
Netscape_Java_java_lang_ClassLoader_getSystemResourceAsName0(Java_java_lang_String *)
{
printf("Netscape_Java_java_lang_ClassLoader_getSystemResourceAsName0() not implemented");
return 0;
}
} /* extern "C" */

View File

@@ -0,0 +1,97 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_Compiler.h"
#include <stdio.h>
extern "C" {
/*
* Class : java/lang/Compiler
* Method : initialize
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Compiler_initialize()
{
printf("Netscape_Java_java_lang_Compiler_initialize() not implemented");
}
/*
* Class : java/lang/Compiler
* Method : compileClass
* Signature : (Ljava/lang/Class;)Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_lang_Compiler_compileClass(Java_java_lang_Class *)
{
printf("Netscape_Java_java_lang_Compiler_compileClass() not implemented");
return 0;
}
/*
* Class : java/lang/Compiler
* Method : compileClasses
* Signature : (Ljava/lang/String;)Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_lang_Compiler_compileClasses(Java_java_lang_String *)
{
printf("Netscape_Java_java_lang_Compiler_compileClasses() not implemented");
return 0;
}
/*
* Class : java/lang/Compiler
* Method : command
* Signature : (Ljava/lang/Object;)Ljava/lang/Object;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Object *)
Netscape_Java_java_lang_Compiler_command(Java_java_lang_Object *)
{
printf("Netscape_Java_java_lang_Compiler_command() not implemented");
return 0;
}
/*
* Class : java/lang/Compiler
* Method : enable
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Compiler_enable()
{
printf("Netscape_Java_java_lang_Compiler_enable() not implemented");
}
/*
* Class : java/lang/Compiler
* Method : disable
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Compiler_disable()
{
printf("Netscape_Java_java_lang_Compiler_disable() not implemented");
}
} /* extern "C" */

View File

@@ -0,0 +1,60 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_Double.h"
#include <stdio.h>
extern "C" {
/*
* Class : java/lang/Double
* Method : doubleToLongBits
* Signature : (D)J
*/
NS_EXPORT NS_NATIVECALL(int64)
Netscape_Java_java_lang_Double_doubleToLongBits(float64 d)
{
return *reinterpret_cast<Int64*>(&d);
}
/*
* Class : java/lang/Double
* Method : longBitsToDouble
* Signature : (J)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Double_longBitsToDouble(int64 i)
{
return *reinterpret_cast<Flt64*>(&i);
}
/*
* Class : java/lang/Double
* Method : valueOf0
* Signature : (Ljava/lang/String;)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Double_valueOf0(Java_java_lang_String *)
{
printf("Netscape_Java_java_lang_Double_valueOf0() not implemented");
return 0;
}
} /* extern "C" */

View File

@@ -0,0 +1,46 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_Float.h"
#include <stdio.h>
extern "C" {
/*
* Class : java/lang/Float
* Method : floatToIntBits
* Signature : (F)I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_Float_floatToIntBits(float f)
{
return *reinterpret_cast<Int32*>(&f);
}
/*
* Class : java/lang/Float
* Method : intBitsToFloat
* Signature : (I)F
*/
NS_EXPORT NS_NATIVECALL(float)
Netscape_Java_java_lang_Float_intBitsToFloat(int32 i)
{
return *reinterpret_cast<Flt32*>(&i);
}
} /* extern "C" */

View File

@@ -0,0 +1,45 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#######################################################################
# (1) Include manifest file #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "component" configuration information. #
#######################################################################
include $(DEPTH)/config/config.mk
#######################################################################
# (3) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
#######################################################################
# (4) Execute "component" rules. (OPTIONAL) #
#######################################################################
include $(DEPTH)/config/rules.mk
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

View File

@@ -0,0 +1,214 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_Math.h"
#include <stdio.h>
extern "C" {
/*
* Class : java/lang/Math
* Method : sin
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_sin(float64)
{
printf("Netscape_Java_java_lang_Math_sin() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : cos
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_cos(float64)
{
printf("Netscape_Java_java_lang_Math_cos() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : tan
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_tan(float64)
{
printf("Netscape_Java_java_lang_Math_tan() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : asin
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_asin(float64)
{
printf("Netscape_Java_java_lang_Math_asin() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : acos
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_acos(float64);
/*
* Class : java/lang/Math
* Method : atan
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_atan(float64)
{
printf("Netscape_Java_java_lang_Math_atan() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : exp
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_exp(float64)
{
printf("Netscape_Java_java_lang_Math_exp() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : log
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_log(float64)
{
printf("Netscape_Java_java_lang_Math_log() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : sqrt
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_sqrt(float64)
{
printf("Netscape_Java_java_lang_Math_sqrt() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : IEEEremainder
* Signature : (DD)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_IEEEremainder(float64, float64)
{
printf("Netscape_Java_java_lang_Math_IEEEremainder() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : ceil
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_ceil(float64)
{
printf("Netscape_Java_java_lang_Math_ceil() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : floor
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_floor(float64)
{
printf("Netscape_Java_java_lang_Math_floor() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : rint
* Signature : (D)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_rint(float64)
{
printf("Netscape_Java_java_lang_Math_rint() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : atan2
* Signature : (DD)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_atan2(float64, float64)
{
printf("Netscape_Java_java_lang_Math_atan2() not implemented");
return 0;
}
/*
* Class : java/lang/Math
* Method : pow
* Signature : (DD)D
*/
NS_EXPORT NS_NATIVECALL(float64)
Netscape_Java_java_lang_Math_pow(float64, float64)
{
printf("Netscape_Java_java_lang_Math_pow() not implemented");
return 0;
}
} /* extern "C" */

View File

@@ -0,0 +1,118 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_Object.h"
#include <stdio.h>
#include "Monitor.h"
#include "Exceptions.h"
extern "C" {
static inline JavaObject &toObject(Java_java_lang_Object &inObject)
{
return *(Class *)(&inObject);
}
/*
* Class : java/lang/Object
* Method : getClass
* Signature : ()Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_Object_getClass(Java_java_lang_Object *obj)
{
return (Java_java_lang_Class *) (&toObject(*obj).getType());
}
/*
* Class : java/lang/Object
* Method : hashCode
* Signature : ()I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_Object_hashCode(Java_java_lang_Object *obj)
{
// XXX - This won't work once a relocating GC is implemented
return reinterpret_cast<int32>(obj);
}
/*
* Class : java/lang/Object
* Method : clone
* Signature : ()Ljava/lang/Object;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Object *)
Netscape_Java_java_lang_Object_clone(Java_java_lang_Object *inObj)
{
JavaObject *newObj = ((Class *) toObject(*inObj).getClass().clone(*inObj));
return (Java_java_lang_Object *) (newObj);
}
/*
* Class : java/lang/Object
* Method : notify
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Object_notify(Java_java_lang_Object *o)
{
if (o == NULL) {
sysThrowNamedException("java/lang/NullPointerException");
return;
}
Monitor::notify(*o);
}
/*
* Class : java/lang/Object
* Method : notifyAll
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Object_notifyAll(Java_java_lang_Object *o)
{
if (o == NULL) {
sysThrowNamedException("java/lang/NullPointerException");
return;
}
Monitor::notifyAll(*o);
}
/*
* Class : java/lang/Object
* Method : wait
* Signature : (J)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Object_wait(Java_java_lang_Object *o, int64 l)
{
if (o == NULL) {
sysThrowNamedException("java/lang/NullPointerException");
return;
}
Monitor::wait(*o,l);
}
} /* extern "C" */

View File

@@ -0,0 +1,175 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_Runtime.h"
#include <stdio.h>
#include "Thread.h"
extern "C" {
/*
* Class : java/lang/Runtime
* Method : exitInternal
* Signature : (I)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Runtime_exitInternal(Java_java_lang_Runtime *, int32 code)
{
Thread::exit();
}
/*
* Class : java/lang/Runtime
* Method : runFinalizersOnExit0
* Signature : (Z)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Runtime_runFinalizersOnExit0(uint32 /* bool */)
{
printf("Netscape_Java_java_lang_Runtime_runFinalizersOnExit0() not implemented");
}
/*
* Class : java/lang/Runtime
* Method : execInternal
* Signature : ([Ljava/lang/String;[Ljava/lang/String;)Ljava/lang/Process;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Process *)
Netscape_Java_java_lang_Runtime_execInternal(Java_java_lang_Runtime *, ArrayOf_Java_java_lang_String *, ArrayOf_Java_java_lang_String *)
{
printf("Netscape_Java_java_lang_Runtime_execInternal() not implemented");
return 0;
}
/*
* Class : java/lang/Runtime
* Method : freeMemory
* Signature : ()J
*/
NS_EXPORT NS_NATIVECALL(int64)
Netscape_Java_java_lang_Runtime_freeMemory(Java_java_lang_Runtime *)
{
printf("Netscape_Java_java_lang_Runtime_freeMemory() not implemented");
return 0;
}
/*
* Class : java/lang/Runtime
* Method : totalMemory
* Signature : ()J
*/
NS_EXPORT NS_NATIVECALL(int64)
Netscape_Java_java_lang_Runtime_totalMemory(Java_java_lang_Runtime *)
{
printf("Netscape_Java_java_lang_Runtime_totalMemory() not implemented");
return 0;
}
/*
* Class : java/lang/Runtime
* Method : gc
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Runtime_gc(Java_java_lang_Runtime *)
{
printf("Netscape_Java_java_lang_Runtime_gc() not implemented");
}
/*
* Class : java/lang/Runtime
* Method : runFinalization
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Runtime_runFinalization(Java_java_lang_Runtime *)
{
printf("Netscape_Java_java_lang_Runtime_runFinalization() not implemented");
}
/*
* Class : java/lang/Runtime
* Method : traceInstructions
* Signature : (Z)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Runtime_traceInstructions(Java_java_lang_Runtime *, uint32 /* bool */)
{
printf("Netscape_Java_java_lang_Runtime_traceInstructions() not implemented");
}
/*
* Class : java/lang/Runtime
* Method : traceMethodCalls
* Signature : (Z)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Runtime_traceMethodCalls(Java_java_lang_Runtime *, uint32 /* bool */)
{
printf("Netscape_Java_java_lang_Runtime_traceMethodCalls() not implemented");
}
/*
* Class : java/lang/Runtime
* Method : initializeLinkerInternal
* Signature : ()Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_String *)
Netscape_Java_java_lang_Runtime_initializeLinkerInternal(Java_java_lang_Runtime *)
{
printf("Netscape_Java_java_lang_Runtime_initializeLinkerInternal() not implemented");
return 0;
}
/*
* Class : java/lang/Runtime
* Method : buildLibName
* Signature : (Ljava/lang/String;Ljava/lang/String;)Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_String *)
Netscape_Java_java_lang_Runtime_buildLibName(Java_java_lang_Runtime *, Java_java_lang_String *, Java_java_lang_String *)
{
printf("Netscape_Java_java_lang_Runtime_buildLibName() not implemented");
return 0;
}
/*
* Class : java/lang/Runtime
* Method : loadFileInternal
* Signature : (Ljava/lang/String;)I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_Runtime_loadFileInternal(Java_java_lang_Runtime *, Java_java_lang_String *)
{
printf("Netscape_Java_java_lang_Runtime_loadFileInternal() not implemented");
return 0;
}
} /* extern "C" */

View File

@@ -0,0 +1,88 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_SecurityManager.h"
#include <stdio.h>
extern "C" {
/*
* Class : java/lang/SecurityManager
* Method : getClassContext
* Signature : ()[Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_Class *)
Netscape_Java_java_lang_SecurityManager_getClassContext(Java_java_lang_SecurityManager *)
{
printf("Netscape_Java_java_lang_SecurityManager_getClassContext() not implemented");
return 0;
}
/*
* Class : java/lang/SecurityManager
* Method : currentClassLoader
* Signature : ()Ljava/lang/ClassLoader;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_ClassLoader *)
Netscape_Java_java_lang_SecurityManager_currentClassLoader(Java_java_lang_SecurityManager *)
{
printf("Netscape_Java_java_lang_SecurityManager_currentClassLoader() not implemented");
return 0;
}
/*
* Class : java/lang/SecurityManager
* Method : classDepth
* Signature : (Ljava/lang/String;)I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_SecurityManager_classDepth(Java_java_lang_SecurityManager *, Java_java_lang_String *)
{
printf("Netscape_Java_java_lang_SecurityManager_classDepth() not implemented");
return 0;
}
/*
* Class : java/lang/SecurityManager
* Method : classLoaderDepth
* Signature : ()I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_SecurityManager_classLoaderDepth(Java_java_lang_SecurityManager *)
{
printf("Netscape_Java_java_lang_SecurityManager_classLoaderDepth() not implemented");
return 0;
}
/*
* Class : java/lang/SecurityManager
* Method : currentLoadedClass0
* Signature : ()Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_SecurityManager_currentLoadedClass0(Java_java_lang_SecurityManager *)
{
printf("Netscape_Java_java_lang_SecurityManager_currentLoadedClass0() not implemented");
return 0;
}
} /* extern "C" */

View File

@@ -0,0 +1,40 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_String.h"
#include "JavaVM.h"
extern "C" {
/*
* Class : java/lang/String
* Method : intern
* Signature : ()Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_String *)
Netscape_Java_java_lang_String_intern(Java_java_lang_String *jThis)
{
JavaString& jString = asJavaString(*jThis);
char* CString = jString.convertUtf();
JavaString& internString = VM::intern(CString);
JavaString::freeUtf(CString);
return (Java_java_lang_String *)(&internString);
}
}

View File

@@ -0,0 +1,282 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_System.h"
#include "java_io_InputStream.h"
#include "java_io_PrintStream.h"
#include "java_util_Properties.h"
#include "FieldOrMethod.h"
#include "JavaVM.h"
#include "prprf.h"
#include "prtime.h"
#include "StackWalker.h"
#include "SysCallsRuntime.h"
extern "C" {
inline Field *getField(const char *className, const char *name)
{
ClassCentral &central = VM::getCentral();
ClassFileSummary &summ = central.addClass(className);
Class *clazz = const_cast<Class *>(static_cast<const Class *>(summ.getThisClass()));
Field *field = &clazz->getDeclaredField(name);
return field;
}
inline void setStaticField(const char *name, const char *className, JavaObject &val)
{
Field *field = getField(className, name);
field->set(0, val);
}
/*
* Class : java/lang/System
* Method : setIn0
* Signature : (Ljava/io/InputStream;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_System_setIn0(Java_java_io_InputStream *str)
{
setStaticField("in", "java/lang/System", *str);
}
/*
* Class : java/lang/System
* Method : setOut0
* Signature : (Ljava/io/PrintStream;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_System_setOut0(Java_java_io_PrintStream *str)
{
setStaticField("out", "java/lang/System", *str);
}
/*
* Class : java/lang/System
* Method : setErr0
* Signature : (Ljava/io/PrintStream;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_System_setErr0(Java_java_io_PrintStream *str)
{
setStaticField("err", "java/lang/System", *str);
}
/*
* Class : java/lang/System
* Method : currentTimeMillis
* Signature : ()J
*/
NS_EXPORT NS_NATIVECALL(int64)
Netscape_Java_java_lang_System_currentTimeMillis()
{
PRInt64 thousand, milliseconds;
PRTime now = PR_Now();
LL_I2L(thousand, 1000);
LL_DIV(milliseconds, now, thousand);
return milliseconds;
}
/*
* Class : java/lang/System
* Method : arraycopy
* Signature : (Ljava/lang/Object;ILjava/lang/Object;II)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_System_arraycopy(Java_java_lang_Object *srcObj,
int32 srcPos,
Java_java_lang_Object *destObj,
int32 destPos, int32 len)
{
// ChkNull.
if ((srcObj == 0) || (destObj == 0)) {
sysThrowNullPointerException();
assert("never come back"); // FIX-ME assert(true)
}
// ChkArrayStore.
if ((srcObj->getType().typeKind != tkArray) || (destObj->getType().typeKind != tkArray)) {
sysThrowArrayStoreException();
assert("never come back"); // FIX-ME assert(1)
}
TypeKind tkSource = asArray(srcObj->getType()).componentType.typeKind;
TypeKind tkDest = asArray(destObj->getType()).componentType.typeKind;
if (tkSource != tkDest)
sysThrowArrayStoreException();
JavaArray& srcArray = *reinterpret_cast<JavaArray *>(srcObj);
JavaArray& dstArray = *reinterpret_cast<JavaArray *>(destObj);
// ChkLimit.
if ((len < 0) || (srcPos < 0) || (destPos < 0) || (uint32(len + srcPos) > srcArray.length) ||
(uint32(len + destPos) > dstArray.length)) {
sysThrowArrayIndexOutOfBoundsException();
assert("never come back");
}
// Do the copy.
int offset = arrayEltsOffset(tkSource);
char* srcPtr = ((char *) &srcArray) + offset;
char* destPtr = ((char *) &dstArray) + offset;
int8 shift = getLgTypeKindSize(tkSource);
memmove(&destPtr[destPos << shift], &srcPtr[srcPos << shift], len << shift);
}
/*
* Class : java/lang/System
* Method : getCallerClass
* Signature : ()Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_System_getCallerClass()
{
Frame thisFrame;
Method* callerMethod;
thisFrame.moveToPrevFrame(); // system guard frame
thisFrame.moveToPrevFrame(); // java frame
callerMethod = thisFrame.getMethod();
// FIX-ME should call some RuntimeException here
if (!callerMethod)
{
trespass("Caller was not a Java function!!");
return 0;
}
else
{
ClassOrInterface* potentialClass = callerMethod->getDeclaringClass();
assert(potentialClass); // FIX-ME this might be guaranteed to me non-NULL
return ((Java_java_lang_Class*)&asClass(*potentialClass));
}
}
/*
* Class : java/lang/System
* Method : identityHashCode
* Signature : (Ljava/lang/Object;)I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_System_identityHashCode(Java_java_lang_Object *)
{
#ifdef DEBUG_LOG
PR_fprintf(PR_STDERR, "Warning: System::hashCode() not implemented\n");
#endif
return 0;
}
/*
* Class : java/lang/System
* Method : initProperties
* Signature : (Ljava/util/Properties;)Ljava/util/Properties;
*/
NS_EXPORT NS_NATIVECALL(Java_java_util_Properties *)
Netscape_Java_java_lang_System_initProperties(Java_java_util_Properties *props)
{
// FIXME: should we check the security manager for checkPropertiesAccess ?
const Type* parameterTypesForPropertyPut[2];
parameterTypesForPropertyPut[0] = (Type *) &VM::getStandardClass(cObject);
parameterTypesForPropertyPut[1] = (Type *) &VM::getStandardClass(cObject);
Method& Property_put = const_cast<Class *>(&props->getClass())->getMethod("put", parameterTypesForPropertyPut, 2);
JavaObject* arguments[2];
#define PUTPROP(key,value) { \
arguments[0] = JavaString::make(key); \
arguments[1] = JavaString::make(value); \
Property_put.invoke(props, arguments, 2); \
}
/* java properties */
PUTPROP("java-vm.specification.version", "?.?");
PUTPROP("java-vm.specification.name", "???");
PUTPROP("java-vm.specification.vendor", "???");
PUTPROP("java-vm.version", "?.?");
PUTPROP("java-vm.name", "Electrical Fire");
PUTPROP("java-vm.vendor", "???");
PUTPROP("java.specification.version", "?.?");
PUTPROP("java.specification.name", "???");
PUTPROP("java.specification.vendor", "???");
PUTPROP("java.version", "?");
PUTPROP("java.vendor", "???");
PUTPROP("java.vendor.url", "home.netscape.com");
PUTPROP("java.vendor.url.bug", "home.netscape.com/bugreport.cgi");
PUTPROP("java.class.version", "?.?");
/* Java2D properties */
PUTPROP("java.awt.graphicsenv", "sun.awt.GraphicsEnvironment");
PUTPROP("java.awt.fonts", "you wanna fonts?");
/* os properties */
PUTPROP("os.name", "???");
PUTPROP("os.version", "???");
PUTPROP("os.arch", "???");
/* file system properties */
PUTPROP("file.separator", "/ or \\");
PUTPROP("path.separator", ": or ;");
PUTPROP("line.separator", "\n");
/*
* user.language
* user.region (if user's environmant specify this)
* file.encoding
* file.encoding.pkg
*/
PUTPROP("user.language", "???");
PUTPROP("file.encoding", "???");
PUTPROP("user.region", "???");
PUTPROP("file.encoding.pkg", "sun.io");
/* system */
PUTPROP("java.library.path", "???");
PUTPROP("java.home", "???");
PUTPROP("java.class.path", "\ns\dist\classes");
PUTPROP("user.name", "???");
PUTPROP("user.home", "???");
PUTPROP("user.timezone", "???");
PUTPROP("user.dir", "???");
PUTPROP("java.compiler", "???");
return props;
}
} /* extern "C" */

View File

@@ -0,0 +1,221 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_Thread.h"
#include "Thread.h"
extern "C" {
/*
* Class : java/lang/Thread
* Method : currentThread
* Signature : ()Ljava/lang/Thread;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Thread *)
Netscape_Java_java_lang_Thread_currentThread()
{
return (Java_java_lang_Thread *)Thread::currentThread();
}
/*
* Class : java/lang/Thread
* Method : yield
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Thread_yield()
{
Thread::yield();
}
/*
* Class : java/lang/Thread
* Method : sleep
* Signature : (J)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Thread_sleep(int64 l)
{
Thread::sleep(l);
}
/*
* Class : java/lang/Thread
* Method : start
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Thread_start(Java_java_lang_Thread *t)
{
Thread* thr = (Thread*)static_cast<int32>(t->eetop);
if (thr == NULL) {
//thr = new(*Thread::pool) Thread((JavaObject*)t);
thr = new Thread((JavaObject*)t);
t->eetop = (int64)thr;
}
thr->start();
}
/*
* Class : java/lang/Thread
* Method : isInterrupted
* Signature : (Z)Z
*/
NS_EXPORT NS_NATIVECALL(uint32) /* bool */
Netscape_Java_java_lang_Thread_isInterrupted(Java_java_lang_Thread *t, uint32 f)
{
Thread* thr = (Thread*)static_cast<int32>(t->eetop);
if (thr == NULL) {
//thr = new(*Thread::pool) Thread((JavaObject*)t);
thr = new Thread((JavaObject*)t);
t->eetop = (int64)thr;
}
return thr->isInterrupted(f);
}
/*
* Class : java/lang/Thread
* Method : isAlive
* Signature : ()Z
*/
NS_EXPORT NS_NATIVECALL(uint32) /* bool */
Netscape_Java_java_lang_Thread_isAlive(Java_java_lang_Thread *t)
{
Thread* thr = (Thread*)static_cast<int32>(t->eetop);
if (thr == NULL) {
//thr = new(*Thread::pool) Thread((JavaObject*)t);
thr = new Thread((JavaObject*)t);
t->eetop = (int64)thr;
}
return thr->isAlive();
}
/*
* Class : java/lang/Thread
* Method : countStackFrames
* Signature : ()I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_Thread_countStackFrames(Java_java_lang_Thread *t)
{
Thread* thr = (Thread*)static_cast<int32>(t->eetop);
if (thr == NULL) {
//thr = new(*Thread::pool) Thread((JavaObject*)t);
thr = new Thread((JavaObject*)t);
t->eetop = (int64)thr;
}
return thr->countStackFrames();
}
/*
* Class : java/lang/Thread
* Method : setPriority0
* Signature : (I)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Thread_setPriority0(Java_java_lang_Thread *t, int32 p)
{
Thread* thr = (Thread*)static_cast<int32>(t->eetop);
if (thr == NULL) {
//thr = new(*Thread::pool) Thread((JavaObject*)t);
thr = new Thread((JavaObject*)t);
t->eetop = (int64)thr;
}
thr->setPriority(p);
}
/*
* Class : java/lang/Thread
* Method : stop0
* Signature : (Ljava/lang/Object;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Thread_stop0(Java_java_lang_Thread *t, Java_java_lang_Object *exc)
{
Thread* thr = (Thread*)static_cast<int32>(t->eetop);
if (thr == NULL) {
//thr = new(*Thread::pool) Thread((JavaObject*)t);
thr = new Thread((JavaObject*)t);
t->eetop = (int64)thr;
}
thr->stop((JavaObject*)exc);
}
/*
* Class : java/lang/Thread
* Method : suspend0
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Thread_suspend0(Java_java_lang_Thread *t)
{
Thread* thr = (Thread*)static_cast<int32>(t->eetop);
if (thr == NULL) {
//thr = new(*Thread::pool) Thread((JavaObject*)t);
thr = new Thread((JavaObject*)t);
t->eetop = (int64)thr;
}
thr->suspend();
}
/*
* Class : java/lang/Thread
* Method : resume0
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Thread_resume0(Java_java_lang_Thread *t)
{
Thread* thr = (Thread*)static_cast<int32>(t->eetop);
if (thr == NULL) {
//thr = new(*Thread::pool) Thread((JavaObject*)t);
thr = new Thread((JavaObject*)t);
t->eetop = (int64)thr;
}
thr->resume();
}
/*
* Class : java/lang/Thread
* Method : interrupt0
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Thread_interrupt0(Java_java_lang_Thread *t)
{
Thread* thr = (Thread*)static_cast<int32>(t->eetop);
if (thr == NULL) {
//thr = new(*Thread::pool) Thread((JavaObject*)t);
thr = new Thread((JavaObject*)t);
t->eetop = (int64)thr;
}
thr->interrupt();
}
} /* extern "C" */

View File

@@ -0,0 +1,48 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_Throwable.h"
#include <stdio.h>
extern "C" {
/*
* Class : java/lang/Throwable
* Method : printStackTrace0
* Signature : (Ljava/lang/Object;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_Throwable_printStackTrace0(Java_java_lang_Throwable *, Java_java_lang_Object *)
{
printf("Netscape_Java_java_lang_Throwable_printStackTrace0() not implemented");
}
/*
* Class : java/lang/Throwable
* Method : fillInStackTrace
* Signature : ()Ljava/lang/Throwable;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Throwable *)
Netscape_Java_java_lang_Throwable_fillInStackTrace(Java_java_lang_Throwable *)
{
//printf("Netscape_Java_java_lang_Throwable_fillInStackTrace() not implemented");
return 0;
}
} /* extern "C" */

View File

@@ -0,0 +1,43 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../..
MODULE_NAME = Package
DIRS = reflect
CPPSRCS = Character.cpp \
Class.cpp \
ClassLoader.cpp \
Compiler.cpp \
Double.cpp \
Float.cpp \
Math.cpp \
Object.cpp \
Runtime.cpp \
SecurityManager.cpp \
String.cpp \
System.cpp \
Thread.cpp \
Throwable.cpp \
$(NULL)
HEADER_GEN = java.lang.Object \
$(NULL)

View File

@@ -0,0 +1,509 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_reflect_Array.h"
#include <stdio.h>
#include "SysCallsRuntime.h"
#include "ErrorHandling.h"
static inline JavaArray &toArray(Java_java_lang_Object *obj)
{
if (!obj)
sysThrowNullPointerException();
if (obj->type->typeKind != tkArray)
sysThrowNamedException("java/lang/IllegalArgumentException");
return *(JavaArray *) obj;
}
static inline void checkIndex(JavaArray &array, Int32 index)
{
if (index < 0 || index >= (Int32) array.length)
sysThrowArrayIndexOutOfBoundsException();
}
extern "C" {
/*
* Class : java/lang/reflect/Array
* Method : get
* Signature : (Ljava/lang/Object;I)Ljava/lang/Object;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Object *)
Netscape_Java_java_lang_reflect_Array_get(Java_java_lang_Object *obj, int32 index)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
return (Java_java_lang_Object *) array.get(index);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : getBoolean
* Signature : (Ljava/lang/Object;I)Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_lang_reflect_Array_getBoolean(Java_java_lang_Object *obj,
int32 index)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
return array.getBoolean(index);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : getByte
* Signature : (Ljava/lang/Object;I)B
*/
NS_EXPORT NS_NATIVECALL(uint32 /* byte */)
Netscape_Java_java_lang_reflect_Array_getByte(Java_java_lang_Object *obj,
int32 index)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
return array.getByte(index);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : getChar
* Signature : (Ljava/lang/Object;I)C
*/
NS_EXPORT NS_NATIVECALL(int32 /* char */)
Netscape_Java_java_lang_reflect_Array_getChar(Java_java_lang_Object *obj,
int32 index)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
return array.getChar(index);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : getDouble
* Signature : (Ljava/lang/Object;I)D
*/
NS_EXPORT NS_NATIVECALL(Flt64)
Netscape_Java_java_lang_reflect_Array_getDouble(Java_java_lang_Object *obj,
int32 index)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
return array.getDouble(index);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : getFloat
* Signature : (Ljava/lang/Object;I)F
*/
NS_EXPORT NS_NATIVECALL(Flt32)
Netscape_Java_java_lang_reflect_Array_getFloat(Java_java_lang_Object *obj,
int32 index)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
return array.getFloat(index);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : getInt
* Signature : (Ljava/lang/Object;I)I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_reflect_Array_getInt(Java_java_lang_Object *obj,
int32 index)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
return array.getInt(index);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : getLength
* Signature : (Ljava/lang/Object;)I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_reflect_Array_getLength(Java_java_lang_Object *obj)
{
JavaArray &array = toArray(obj);
return array.length;
}
/*
* Class : java/lang/reflect/Array
* Method : getLong
* Signature : (Ljava/lang/Object;I)J
*/
NS_EXPORT NS_NATIVECALL(int64)
Netscape_Java_java_lang_reflect_Array_getLong(Java_java_lang_Object *obj, int32 index)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
return array.getLong(index);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : getShort
* Signature : (Ljava/lang/Object;I)S
*/
NS_EXPORT NS_NATIVECALL(int32 /* short */)
Netscape_Java_java_lang_reflect_Array_getShort(Java_java_lang_Object *obj, int32 index)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
return array.getShort(index);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : multiNewArray
* Signature : (Ljava/lang/Class;[I)Ljava/lang/Object;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Object *)
Netscape_Java_java_lang_reflect_Array_multiNewArray(Java_java_lang_Class *inClass,
ArrayOf_int32 *dimensions)
{
if (!inClass || !dimensions)
sysThrowNullPointerException();
if (dimensions->length < 0)
sysThrowNamedException("java/lang/NegativeArraySizeException");
else if (dimensions->length >= 255 || dimensions->length == 0)
sysThrowNamedException("java/lang/IllegalArgumentException");
/* We special-case 2D and 3D arrays since we have sysCalls defined for them */
Int32 numDimensions = dimensions->length;
switch (numDimensions) {
case 2:
return (Java_java_lang_Object *) sysNew2DArray(&((Type *) inClass)->getArrayType().getArrayType(),
dimensions->elements[0],
dimensions->elements[1]);
case 3:
return (Java_java_lang_Object *) sysNew3DArray(&((Type *) inClass)->getArrayType().getArrayType().getArrayType(),
dimensions->elements[0],
dimensions->elements[1],
dimensions->elements[2]);
default:
return (Java_java_lang_Object *) sysNewNDArray((const Type *) inClass, dimensions);
}
}
/*
* Class : java/lang/reflect/Array
* Method : newArray
* Signature : (Ljava/lang/Class;I)Ljava/lang/Object;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Object *)
Netscape_Java_java_lang_reflect_Array_newArray(Java_java_lang_Class *inClass,
int32 size)
{
if (!inClass)
sysThrowNullPointerException();
if (size < 0)
sysThrowNamedException("java/lang/NegativeArraySizeException");
const Type *typeOfArray = (const Type *) inClass;
if (typeOfArray->isPrimitive()) {
JavaArray *primitiveArray = (JavaArray *) sysNewPrimitiveArray(typeOfArray->typeKind,
size);
return (Java_java_lang_Object *) primitiveArray;
} else {
JavaArray *objectArray = (JavaArray *) sysNewObjectArray(typeOfArray, size);
return (Java_java_lang_Object *) objectArray;
}
}
/*
* Class : java/lang/reflect/Array
* Method : set
* Signature : (Ljava/lang/Object;ILjava/lang/Object;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Array_set(Java_java_lang_Object *obj, int32 index,
Java_java_lang_Object *value)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
array.set(index, value);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : setBoolean
* Signature : (Ljava/lang/Object;IZ)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Array_setBoolean(Java_java_lang_Object *obj,
int32 index,
uint32 /* bool */ value)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
array.setBoolean(index, (Int8) value);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : setByte
* Signature : (Ljava/lang/Object;IB)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Array_setByte(Java_java_lang_Object *obj,
int32 index,
uint32 /* byte */ value)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
array.setByte(index, (Int8) value);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : setChar
* Signature : (Ljava/lang/Object;IC)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Array_setChar(Java_java_lang_Object *obj,
int32 index,
int32 /* char */ value)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
array.setChar(index, (Int16) value);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : setDouble
* Signature : (Ljava/lang/Object;ID)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Array_setDouble(Java_java_lang_Object *obj,
int32 index,
Flt64 value)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
array.setDouble(index, value);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : setFloat
* Signature : (Ljava/lang/Object;IF)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Array_setFloat(Java_java_lang_Object *obj,
int32 index, Flt32 value)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
array.setFloat(index, value);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : setInt
* Signature : (Ljava/lang/Object;II)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Array_setInt(Java_java_lang_Object *obj,
int32 index,
int32 value)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
array.setInt(index, value);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : setLong
* Signature : (Ljava/lang/Object;IJ)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Array_setLong(Java_java_lang_Object *obj,
int32 index,
int64 value)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
array.setLong(index, value);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
/*
* Class : java/lang/reflect/Array
* Method : setShort
* Signature : (Ljava/lang/Object;IS)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Array_setShort(Java_java_lang_Object *obj, int32 index,
int32 /* short */value)
{
JavaArray &array = toArray(obj);
checkIndex(array, index);
try {
array.setShort(index, (Int16) value);
} catch (RuntimeError) {
sysThrowNamedException("java/lang/IllegalArgumentException");
}
}
}

View File

@@ -0,0 +1,209 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_lang_reflect_Constructor.h"
#include "java_lang_Class.h"
#include "JavaVM.h"
#include "FieldOrMethod.h"
#include "SysCallsRuntime.h"
#include "StackWalker.h"
#include <stdio.h>
// Make sure that the class that called this method can access this field.
// Throw an IllegalAccessException if it can't.
static inline void checkCallingClass(const Method &method)
{
Frame thisFrame;
Method &callerMethod = thisFrame.getCallingJavaMethod();
if (callerMethod.getDeclaringClass() != method.getDeclaringClass()) {
if ((method.getModifiers() & CR_METHOD_PRIVATE))
sysThrowNamedException("java/lang/IllegalAccessException");
else if ((method.getModifiers() & CR_METHOD_PROTECTED)) {
if (!method.getDeclaringClass()->isAssignableFrom(*(const Type *) callerMethod.getDeclaringClass()))
sysThrowNamedException("java/lang/IllegalAccessException");
}
}
}
static void throwConstructorException(RuntimeError err)
{
// FIXME Need to check for illegalAccess, which we currently do not enforce
// Also need to throw an InvocationTargetException
switch (err.cause) {
case RuntimeError::nullPointer:
sysThrowNullPointerException();
break;
case RuntimeError::illegalArgument:
sysThrowNamedException("java/lang/IllegalArgumentException");
break;
case RuntimeError::notInstantiable:
sysThrowNamedException("java/lang/InstantiationException");
break;
default:
trespass("Unknown Runtime Error in throwConstructorException()");
}
}
extern "C" {
/* XXX Routines returning strings will have to be redone once the VM supports
* unicode strings directly
*/
static inline Constructor &toConstructor(Java_java_lang_reflect_Constructor *inConstr)
{
if (!inConstr)
sysThrowNullPointerException();
return *(Constructor *) inConstr;
}
/*
* Class : java/lang/reflect/Constructor
* Method : equals
* Signature : (Ljava/lang/Object;)Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_lang_reflect_Constructor_equals(Java_java_lang_reflect_Constructor *inConstr,
Java_java_lang_Object *inObj)
{
Constructor &constructor = toConstructor(inConstr);
JavaObject *obj = (JavaObject *) inObj;
return obj && constructor.equals(*obj);
}
/*
* Class : java/lang/reflect/Constructor
* Method : getDeclaringClass
* Signature : ()Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_reflect_Constructor_getDeclaringClass(Java_java_lang_reflect_Constructor *inConstr)
{
Constructor &constructor = toConstructor(inConstr);
return ((Java_java_lang_Class *) constructor.getDeclaringClass());
}
/*
* Class : java/lang/reflect/Constructor
* Method : getExceptionTypes
* Signature : ()[Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_Class *)
Netscape_Java_java_lang_reflect_Constructor_getExceptionTypes(Java_java_lang_reflect_Constructor *)
{
printf("Netscape_Java_java_lang_reflect_Constructor_getExceptionTypes() not implemented\n");
return 0;
}
/*
* Class : java/lang/reflect/Constructor
* Method : getModifiers
* Signature : ()I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_reflect_Constructor_getModifiers(Java_java_lang_reflect_Constructor *inConstr)
{
Constructor &constructor = toConstructor(inConstr);
return constructor.getModifiers();
}
/*
* Class : java/lang/reflect/Constructor
* Method : getParameterTypes
* Signature : ()[Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_Class *)
Netscape_Java_java_lang_reflect_Constructor_getParameterTypes(Java_java_lang_reflect_Constructor *inConstr)
{
Constructor &constructor = toConstructor(inConstr);
const Type **params;
Int32 numParams;
numParams = constructor.getParameterTypes(params);
void *arr = sysNewObjectArray(&VM::getStandardClass(cClass), numParams-1);
ArrayOf_Java_java_lang_Class *clazzArray = (ArrayOf_Java_java_lang_Class *) arr;
// The first parameter is always ourselves
for (Int32 i = 1; i < numParams; i++)
clazzArray->elements[i-1] = (Java_java_lang_Class *)params[i];
return clazzArray;
}
/*
* Class : java/lang/reflect/Constructor
* Method : newInstance
* Signature : ([Ljava/lang/Object;)Ljava/lang/Object;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Object *)
Netscape_Java_java_lang_reflect_Constructor_newInstance(Java_java_lang_reflect_Constructor *inConstr,
ArrayOf_Java_java_lang_Object *inParams)
{
Constructor &constructor = toConstructor(inConstr);
checkCallingClass(constructor);
JavaObject **params = (JavaObject **) inParams->elements;
Int32 numParams = (inParams) ? inParams->length : 0;
try {
return (Java_java_lang_Object *) &constructor.newInstance(params, numParams);
} catch (RuntimeError err) {
throwConstructorException(err);
}
}
/*
* Class : java/lang/reflect/Constructor
* Method : toString
* Signature : ()Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_String *)
Netscape_Java_java_lang_reflect_Constructor_toString(Java_java_lang_reflect_Constructor *inConstr)
{
Constructor &constructor = toConstructor(inConstr);
const char *str = constructor.toString();
return ((Java_java_lang_String *) &VM::intern(str));
}
}

View File

@@ -0,0 +1,564 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <stdio.h>
#include "java_lang_reflect_Field.h"
#include "java_lang_Class.h"
#include "JavaVM.h"
#include "SysCallsRuntime.h"
#include "StackWalker.h"
static inline void throwFieldException(RuntimeError err)
{
// FIXME Need to check for illegalAccess, which we currently do not enforce
if (err.cause == RuntimeError::nullPointer)
sysThrowNullPointerException();
else if (err.cause == RuntimeError::illegalArgument)
sysThrowNamedException("java/lang/IllegalArgumentException");
else
trespass("Unknown Runtime Error in throwFieldException()");
}
extern "C" {
/* XXX Routines returning strings will have to be redone once the VM supports
* unicode strings directly
*/
static inline Field &toField(Java_java_lang_reflect_Field *inField)
{
if (!inField)
sysThrowNullPointerException();
return *(Field *) inField;
}
/*
* Class : java/lang/reflect/Field
* Method : equals
* Signature : (Ljava/lang/Object;)Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_lang_reflect_Field_equals(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *inObj)
{
Field &field = toField(inField);
JavaObject *obj = (JavaObject *) inObj;
return obj && field.equals(*obj);
}
// Make sure that the class that called this method can access this field.
// Throw an IllegalAccessException if it can't.
static inline void checkCallingClass(const Field &field)
{
Frame thisFrame;
Method &callerMethod = thisFrame.getCallingJavaMethod();
if (callerMethod.getDeclaringClass() != field.getDeclaringClass()) {
if ((field.getModifiers() & CR_FIELD_PRIVATE))
sysThrowNamedException("java/lang/IllegalAccessException");
else if ((field.getModifiers() & CR_FIELD_PROTECTED)) {
if (!field.getDeclaringClass()->isAssignableFrom(*(const Type *) callerMethod.getDeclaringClass()))
sysThrowNamedException("java/lang/IllegalAccessException");
}
}
}
#if 0
/* Warning this code assumes that the caller was a Java Method */\
thisFrame.moveToPrevFrame(); /* system guard frame */\
thisFrame.moveToPrevFrame(); /* java frame */\
Method *callerMethod = thisFrame.getMethod();\
if (callerMethod->getDeclaringClass() != field.getDeclaringClass()) {\
if ((field.getModifiers() & CR_FIELD_PRIVATE)) \
sysThrowNamedException("java/lang/IllegalAccessException");\
else if ((field.getModifiers() & CR_FIELD_PROTECTED)) {\
if (!field.getDeclaringClass()->isAssignableFrom(*(const Type *) callerMethod->getDeclaringClass()))\
sysThrowNamedException("java/lang/IllegalAccessException");\
}\
}
#endif
/*
* Class : java/lang/reflect/Field
* Method : get
* Signature : (Ljava/lang/Object;)Ljava/lang/Object;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Object *)
Netscape_Java_java_lang_reflect_Field_get(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
return (Java_java_lang_Object *)&field.get((JavaObject *) obj);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : getBoolean
* Signature : (Ljava/lang/Object;)Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_lang_reflect_Field_getBoolean(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
return field.getBoolean((JavaObject *) obj);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : getByte
* Signature : (Ljava/lang/Object;)B
*/
NS_EXPORT NS_NATIVECALL(uint32 /* byte */)
Netscape_Java_java_lang_reflect_Field_getByte(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
return field.getByte((JavaObject *) obj);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : getChar
* Signature : (Ljava/lang/Object;)C
*/
NS_EXPORT NS_NATIVECALL(int32 /* char */)
Netscape_Java_java_lang_reflect_Field_getChar(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
return field.getChar((JavaObject *) obj);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : getDouble
* Signature : (Ljava/lang/Object;)D
*/
NS_EXPORT NS_NATIVECALL(Flt64)
Netscape_Java_java_lang_reflect_Field_getDouble(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
return field.getDouble((JavaObject *) obj);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : getFloat
* Signature : (Ljava/lang/Object;)F
*/
NS_EXPORT NS_NATIVECALL(Flt32)
Netscape_Java_java_lang_reflect_Field_getFloat(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
return field.getFloat((JavaObject *) obj);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : getInt
* Signature : (Ljava/lang/Object;)I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_reflect_Field_getInt(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
return field.getInt((JavaObject *) obj);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : getLong
* Signature : (Ljava/lang/Object;)J
*/
NS_EXPORT NS_NATIVECALL(int64)
Netscape_Java_java_lang_reflect_Field_getLong(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
return field.getLong((JavaObject *) obj);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : getShort
* Signature : (Ljava/lang/Object;)S
*/
NS_EXPORT NS_NATIVECALL(int32 /* short */)
Netscape_Java_java_lang_reflect_Field_getShort(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
return field.getShort((JavaObject *) obj);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : getDeclaringClass
* Signature : ()Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_reflect_Field_getDeclaringClass(Java_java_lang_reflect_Field *inField)
{
Field &field = toField(inField);
return ((Java_java_lang_Class *) field.getDeclaringClass());
}
/*
* Class : java/lang/reflect/Field
* Method : getModifiers
* Signature : ()I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_reflect_Field_getModifiers(Java_java_lang_reflect_Field *inField)
{
Field &field = toField(inField);
return field.getModifiers();
}
/*
* Class : java/lang/reflect/Field
* Method : getName
* Signature : ()Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_String *)
Netscape_Java_java_lang_reflect_Field_getName(Java_java_lang_reflect_Field *inField)
{
Field &field = toField(inField);
const char *str = field.getName();
return ((Java_java_lang_String *) &VM::intern(str));
}
/*
* Class : java/lang/reflect/Field
* Method : set
* Signature : (Ljava/lang/Object;Ljava/lang/Object;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Field_set(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj,
Java_java_lang_Object *value)
{
Field &field = toField(inField);
checkCallingClass(field);
if (value == 0)
sysThrowNullPointerException();
try {
field.set((JavaObject *) obj, *(JavaObject *) value);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : getType
* Signature : ()Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_reflect_Field_getType(Java_java_lang_reflect_Field *inField)
{
Field &field = toField(inField);
return (Java_java_lang_Class *) &field.getType();
}
/*
* Class : java/lang/reflect/Field
* Method : setBoolean
* Signature : (Ljava/lang/Object;Z)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Field_setBoolean(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj,
uint32 /* bool */value)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
field.setBoolean((JavaObject *) obj, (Int8) value);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : setByte
* Signature : (Ljava/lang/Object;B)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Field_setByte(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj,
uint32 /* byte */value)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
field.setByte((JavaObject *) obj, (Uint8) value);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : setChar
* Signature : (Ljava/lang/Object;C)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Field_setChar(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj,
int32 /* char */value)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
field.setChar((JavaObject *) obj, (Int16) value);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : setDouble
* Signature : (Ljava/lang/Object;D)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Field_setDouble(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj,
Flt64 value)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
field.setDouble((JavaObject *) obj, value);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : setFloat
* Signature : (Ljava/lang/Object;F)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Field_setFloat(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj,
Flt32 value)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
field.setFloat((JavaObject *) obj, value);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : setInt
* Signature : (Ljava/lang/Object;I)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Field_setInt(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj,
int32 value)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
field.setInt((JavaObject *) obj, (Int32) value);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : setLong
* Signature : (Ljava/lang/Object;J)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Field_setLong(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj,
int64 value)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
field.setLong((JavaObject *) obj, value);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : setShort
* Signature : (Ljava/lang/Object;S)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_lang_reflect_Field_setShort(Java_java_lang_reflect_Field *inField,
Java_java_lang_Object *obj,
int32 /* short */value)
{
Field &field = toField(inField);
checkCallingClass(field);
try {
field.setShort((JavaObject *) obj, (Int16) value);
} catch (RuntimeError err) {
throwFieldException(err);
}
}
/*
* Class : java/lang/reflect/Field
* Method : toString
* Signature : ()Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_String *)
Netscape_Java_java_lang_reflect_Field_toString(Java_java_lang_reflect_Field *inField)
{
Field &field = toField(inField);
const char *str = field.toString();
return ((Java_java_lang_String *) &VM::intern(str));
}
}

View File

@@ -0,0 +1,45 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#######################################################################
# (1) Include manifest file #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "component" configuration information. #
#######################################################################
include $(DEPTH)/config/config.mk
#######################################################################
# (3) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
#######################################################################
# (4) Execute "component" rules. (OPTIONAL) #
#######################################################################
include $(DEPTH)/config/rules.mk
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

View File

@@ -0,0 +1,246 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include <stdio.h>
#include "java_lang_reflect_Method.h"
#include "java_lang_Class.h"
#include "JavaVM.h"
#include "SysCallsRuntime.h"
#include "StackWalker.h"
static inline void throwMethodException(RuntimeError err)
{
// FIXME Need to check for illegalAccess, which we currently do not enforce
// Also need to throw an InvocationTargetException
if (err.cause == RuntimeError::nullPointer)
sysThrowNullPointerException();
else if (err.cause == RuntimeError::illegalArgument)
sysThrowNamedException("java/lang/IllegalArgumentException");
else
trespass("Unknown Runtime Error in throwMethodException()");
}
// Make sure that the class that called this method can access this field.
// Throw an IllegalAccessException if it can't.
static inline void checkCallingClass(const Method &method)
{
Frame thisFrame;
Method &callerMethod = thisFrame.getCallingJavaMethod();
if (callerMethod.getDeclaringClass() != method.getDeclaringClass()) {
if ((method.getModifiers() & CR_METHOD_PRIVATE))
sysThrowNamedException("java/lang/IllegalAccessException");
else if ((method.getModifiers() & CR_METHOD_PROTECTED)) {
if (!method.getDeclaringClass()->isAssignableFrom(*(const Type *) callerMethod.getDeclaringClass()))
sysThrowNamedException("java/lang/IllegalAccessException");
}
}
}
extern "C" {
/* XXX Routines returning strings will have to be redone once the VM supports
* unicode strings directly
*/
static inline Method &toMethod(Java_java_lang_reflect_Method *inMethod)
{
if (!inMethod)
sysThrowNullPointerException();
return *(Method *) inMethod;
}
/*
* Class : java/lang/reflect/Method
* Method : equals
* Signature : (Ljava/lang/Object;)Z
*/
NS_EXPORT NS_NATIVECALL(uint32 /* bool */)
Netscape_Java_java_lang_reflect_Method_equals(Java_java_lang_reflect_Method *inMethod,
Java_java_lang_Object *inObj)
{
Method &method = toMethod(inMethod);
JavaObject *obj = (JavaObject *) inObj;
return obj && method.equals(*obj);
}
/*
* Class : java/lang/reflect/Method
* Method : getDeclaringClass
* Signature : ()Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_reflect_Method_getDeclaringClass(Java_java_lang_reflect_Method *inMethod)
{
Method &method = toMethod(inMethod);
return ((Java_java_lang_Class *) method.getDeclaringClass());
}
/*
* Class : java/lang/reflect/Method
* Method : getExceptionTypes
* Signature : ()[Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_Class *)
Netscape_Java_java_lang_reflect_Method_getExceptionTypes(Java_java_lang_reflect_Method *)
{
printf("Netscape_Java_java_lang_reflect_Method_getExceptionTypes() not implemented\n");
return 0;
}
/*
* Class : java/lang/reflect/Method
* Method : getModifiers
* Signature : ()I
*/
NS_EXPORT NS_NATIVECALL(int32)
Netscape_Java_java_lang_reflect_Method_getModifiers(Java_java_lang_reflect_Method *inMethod)
{
Method &method = toMethod(inMethod);
return method.getModifiers();
}
/*
* Class : java/lang/reflect/Method
* Method : getName
* Signature : ()Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_String *)
Netscape_Java_java_lang_reflect_Method_getName(Java_java_lang_reflect_Method *inMethod)
{
Method &method = toMethod(inMethod);
const char *name = method.getName();
return ((Java_java_lang_String *) &VM::intern(name));
}
/*
* Class : java/lang/reflect/Method
* Method : getParameterTypes
* Signature : ()[Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_Class *)
Netscape_Java_java_lang_reflect_Method_getParameterTypes(Java_java_lang_reflect_Method *inMethod)
{
Method &method = toMethod(inMethod);
const Type **params;
Int32 numParams;
numParams = method.getParameterTypes(params);
void *arr = sysNewObjectArray(&VM::getStandardClass(cClass), numParams);
ArrayOf_Java_java_lang_Class *clazzArray = (ArrayOf_Java_java_lang_Class *) arr;
for (Int32 i = 0; i < numParams; i++)
clazzArray->elements[i] = (Java_java_lang_Class *) params[i];
return clazzArray;
}
/*
* Class : java/lang/reflect/Method
* Method : getReturnType
* Signature : ()Ljava/lang/Class;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Class *)
Netscape_Java_java_lang_reflect_Method_getReturnType(Java_java_lang_reflect_Method *inMethod)
{
Method &method = toMethod(inMethod);
return ((Java_java_lang_Class *) &method.getReturnType());
}
/*
* Class : java/lang/reflect/Method
* Method : invoke
* Signature : (Ljava/lang/Object;[Ljava/lang/Object;)Ljava/lang/Object;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_Object *)
Netscape_Java_java_lang_reflect_Method_invoke(Java_java_lang_reflect_Method *inMethod,
Java_java_lang_Object *inObj,
ArrayOf_Java_java_lang_Object *inParams)
{
Method &method = toMethod(inMethod);
checkCallingClass(method);
if (!(method.getModifiers() & CR_METHOD_STATIC) && !inObj)
sysThrowNullPointerException();
JavaObject *obj = (JavaObject *) inObj;
JavaObject **params;
Int32 numParams;
if (inParams) {
params = (JavaObject **) inParams->elements;
numParams = inParams->length;
} else {
JavaObject *dummy[1];
// It is permissible for params to be non-null only if
// the method takes no arguments
params = (JavaObject **) dummy;
numParams = 0;
}
try {
return ((Java_java_lang_Object *) method.invoke(obj, params, numParams));
} catch (RuntimeError err) {
throwMethodException(err);
}
}
/*
* Class : java/lang/reflect/Method
* Method : toString
* Signature : ()Ljava/lang/String;
*/
NS_EXPORT NS_NATIVECALL(Java_java_lang_String *)
Netscape_Java_java_lang_reflect_Method_toString(Java_java_lang_reflect_Method *inMethod)
{
Method &method = toMethod(inMethod);
const char *str = method.toString();
return ((Java_java_lang_String *) &VM::intern(str));
}
}

View File

@@ -0,0 +1,51 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../../..
MODULE_NAME = Package
CPPSRCS = Array.cpp \
Constructor.cpp \
Field.cpp \
Method.cpp \
$(NULL)
HEADER_GEN = java.lang.String \
java.lang.Class \
java.lang.ClassLoader \
java.lang.Compiler \
java.lang.Character \
java.lang.Double \
java.lang.Float \
java.lang.Math \
java.lang.Runtime \
java.lang.SecurityManager \
java.lang.System \
java.util.Properties \
java.io.InputStream \
java.io.PrintStream \
java.lang.Thread \
java.lang.Throwable \
java.lang.reflect.Field \
java.lang.reflect.Method \
java.lang.reflect.Constructor \
java.lang.reflect.Array \
$(NULL)

View File

@@ -0,0 +1,22 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../..
DIRS = lang io security

View File

@@ -0,0 +1,45 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#######################################################################
# (1) Include manifest file #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "component" configuration information. #
#######################################################################
include $(DEPTH)/config/config.mk
#######################################################################
# (3) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
#######################################################################
# (4) Execute "component" rules. (OPTIONAL) #
#######################################################################
include $(DEPTH)/config/rules.mk
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

View File

@@ -0,0 +1,23 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../..
DIRS = nativesrc

View File

@@ -0,0 +1,80 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_security_AccessController.h"
#include "prprf.h"
extern "C" {
/*
* Class : java/security/AccessController
* Method : beginPrivileged
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_security_AccessController_beginPrivileged()
{
PR_fprintf(PR_STDERR, "Netscape_Java_java_security_AccessController_beginPrivilege not implemented\n");
}
/*
* Class : java/security/AccessController
* Method : endPrivileged
* Signature : ()V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_security_AccessController_endPrivileged()
{
PR_fprintf(PR_STDERR, "Netscape_Java_java_security_AccessController_endPrivileged not implemented\n");
}
/*
* Class : java/security/AccessController
* Method : getInheritedAccessControlContext
* Signature : ()Ljava/security/AccessControlContext;
*/
NS_EXPORT NS_NATIVECALL(Java_java_security_AccessControlContext *)
Netscape_Java_java_security_AccessController_getInheritedAccessControlContext()
{
PR_fprintf(PR_STDERR, "Netscape_Java_java_security_AccessController_getInheritedAccessControlContext not implemented\n");
return 0;
}
/*
* Class : java/security/AccessController
* Method : getStackAccessControlContext
* Signature : ()Ljava/security/AccessControlContext;
*/
NS_EXPORT NS_NATIVECALL(Java_java_security_AccessControlContext *)
Netscape_Java_java_security_AccessController_getStackAccessControlContext()
{
PR_fprintf(PR_STDERR, "Netscape_Java_java_security_AccessController_getStackAccessControlContext not implemented\n");
return 0;
}
}

View File

@@ -0,0 +1,45 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
#######################################################################
# (1) Include manifest file #
#######################################################################
include manifest.mn
#######################################################################
# (2) Include "component" configuration information. #
#######################################################################
include $(DEPTH)/config/config.mk
#######################################################################
# (3) Include "local" platform-dependent assignments (OPTIONAL). #
#######################################################################
#######################################################################
# (4) Execute "component" rules. (OPTIONAL) #
#######################################################################
include $(DEPTH)/config/rules.mk
#######################################################################
# (7) Execute "local" rules. (OPTIONAL). #
#######################################################################

View File

@@ -0,0 +1,49 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_security_ProtectionDomain.h"
#include "prprf.h"
extern "C" {
/*
* Class : java/security/ProtectionDomain
* Method : getProtectionDomain
* Signature : (Ljava/lang/Class;)Ljava/security/ProtectionDomain;
*/
NS_EXPORT NS_NATIVECALL(Java_java_security_ProtectionDomain *)
Netscape_Java_java_security_ProtectionDomain_getProtectionDomain(Java_java_lang_Class *)
{
PR_fprintf(PR_STDERR, "Netscape_Java_java_security_ProtectionDomain_getProtectionDomain not implemented\n");
return 0;
}
/*
* Class : java/security/ProtectionDomain
* Method : setProtectionDomain
* Signature : (Ljava/lang/Class;Ljava/security/ProtectionDomain;)V
*/
NS_EXPORT NS_NATIVECALL(void)
Netscape_Java_java_security_ProtectionDomain_setProtectionDomain(Java_java_lang_Class *, Java_java_security_ProtectionDomain *)
{
PR_fprintf(PR_STDERR, "Netscape_Java_java_security_ProtectionDomain_setProtectionDomain not implemented\n");
}
}

View File

@@ -0,0 +1,32 @@
#!gmake
#
# The contents of this file are subject to the Netscape Public License
# Version 1.0 (the "NPL"); you may not use this file except in
# compliance with the NPL. You may obtain a copy of the NPL at
# http://www.mozilla.org/NPL/
#
# Software distributed under the NPL is distributed on an "AS IS" basis,
# WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
# for the specific language governing rights and limitations under the
# NPL.
#
# The Initial Developer of this code under the NPL is Netscape
# Communications Corporation. Portions created by Netscape are
# Copyright (C) 1998 Netscape Communications Corporation. All Rights
# Reserved.
DEPTH = ../../../..
MODULE_NAME = Package
CPPSRCS = AccessController.cpp \
ProtectionDomain.cpp \
$(NULL)
HEADER_GEN = java.security.AccessController \
java.security.ProtectionDomain \
$(NULL)

View File

@@ -0,0 +1,37 @@
/* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 2 -*-
*
* The contents of this file are subject to the Netscape Public License
* Version 1.0 (the "NPL"); you may not use this file except in
* compliance with the NPL. You may obtain a copy of the NPL at
* http://www.mozilla.org/NPL/
*
* Software distributed under the NPL is distributed on an "AS IS" basis,
* WITHOUT WARRANTY OF ANY KIND, either express or implied. See the NPL
* for the specific language governing rights and limitations under the
* NPL.
*
* The Initial Developer of this code under the NPL is Netscape
* Communications Corporation. Portions created by Netscape are
* Copyright (C) 1998 Netscape Communications Corporation. All Rights
* Reserved.
*/
#include "java_util_ResourceBundle.h"
#include "prprf.h"
#include "prio.h"
#include "JavaVM.h"
#include "SysCallsRuntime.h"
extern "C" {
NS_EXPORT NS_NATIVECALL(ArrayOf_Java_java_lang_Class *)
Netscape_Java_java_util_ResourceBundle_getClassContext()
{
#ifdef DEBUG_LOG
// PR_fprintf(PR_STDERR, "Warning: ResourceBundle::getClassContext() not implemented\n");
#endif
ArrayOf_Java_java_lang_Class *arr = (ArrayOf_Java_java_lang_Class *) sysNewObjectArray(&VM::getStandardClass(cClass), 3);
return arr;
}
}