mirror of
https://github.com/corda/corda.git
synced 2025-01-01 02:36:44 +00:00
various fixes to get Eclipse 3.6 working
* add libnet.so and libnio.so to built-in libraries for openjdk-src build * implement sun.misc.Unsafe.park/unpark * implement JVM_SetClassSigners/JVM_GetClassSigners * etc.
This commit is contained in:
parent
459f4d5194
commit
e68dfe1e89
11
makefile
11
makefile
@ -81,12 +81,12 @@ ifneq ($(openjdk),)
|
||||
ifneq ($(openjdk-src),)
|
||||
include openjdk-src.mk
|
||||
options := $(options)-openjdk-src
|
||||
classpath-objects = $(openjdk-objects)
|
||||
classpath-objects = $(openjdk-objects) $(openjdk-local-objects)
|
||||
classpath-cflags = -DAVIAN_OPENJDK_SRC -DBOOT_JAVAHOME
|
||||
openjdk-jar-dep = $(build)/openjdk-jar.dep
|
||||
classpath-jar-dep = $(openjdk-jar-dep)
|
||||
javahome = $(embed-prefix)/javahomeJar
|
||||
javahome-files = lib/zi
|
||||
javahome-files = lib/zi lib/currency.data
|
||||
ifeq ($(platform),windows)
|
||||
javahome-files += lib/tzmappings
|
||||
endif
|
||||
@ -819,6 +819,13 @@ $(openjdk-objects): $(build)/openjdk/%.o: $(openjdk-src)/%.c \
|
||||
$(cc) -fPIC $(openjdk-extra-cflags) $(openjdk-cflags) \
|
||||
$(optimization-cflags) -w -c $(<) $(call output,$(@))
|
||||
|
||||
$(openjdk-local-objects): $(build)/openjdk/%.o: $(src)/openjdk/%.c \
|
||||
$(openjdk-headers-dep)
|
||||
@echo "compiling $(@)"
|
||||
@mkdir -p $(dir $(@))
|
||||
$(cc) -fPIC $(openjdk-extra-cflags) $(openjdk-cflags) \
|
||||
$(optimization-cflags) -w -c $(<) $(call output,$(@))
|
||||
|
||||
$(openjdk-headers-dep):
|
||||
@echo "generating openjdk headers"
|
||||
@mkdir -p $(dir $(@))
|
||||
|
@ -32,6 +32,10 @@ openjdk-sources = \
|
||||
$(openjdk-src)/share/native/java/lang/Thread.c \
|
||||
$(openjdk-src)/share/native/java/lang/Throwable.c \
|
||||
$(wildcard $(openjdk-src)/share/native/java/lang/fdlibm/src/*.c) \
|
||||
$(openjdk-src)/share/native/java/net/DatagramPacket.c \
|
||||
$(openjdk-src)/share/native/java/net/InetAddress.c \
|
||||
$(openjdk-src)/share/native/java/net/Inet4Address.c \
|
||||
$(openjdk-src)/share/native/java/net/Inet6Address.c \
|
||||
$(openjdk-src)/share/native/java/nio/Bits.c \
|
||||
$(openjdk-src)/share/native/java/security/AccessController.c \
|
||||
$(openjdk-src)/share/native/java/sql/DriverManager.c \
|
||||
@ -70,6 +74,7 @@ openjdk-headers-classes = \
|
||||
java.lang.Compiler \
|
||||
java.lang.Double \
|
||||
java.lang.Float \
|
||||
java.lang.Integer \
|
||||
java.lang.Object \
|
||||
java.lang.Package \
|
||||
java.lang.Runtime \
|
||||
@ -83,6 +88,20 @@ openjdk-headers-classes = \
|
||||
java.lang.ref.Finalizer \
|
||||
java.lang.reflect.Array \
|
||||
java.lang.reflect.Proxy \
|
||||
java.net.InetAddress \
|
||||
java.net.Inet4Address \
|
||||
java.net.Inet6Address \
|
||||
java.net.DatagramPacket \
|
||||
java.net.SocketOptions \
|
||||
java.net.InetAddressImplFactory \
|
||||
java.net.Inet4AddressImpl \
|
||||
java.net.Inet6AddressImpl \
|
||||
java.net.NetworkInterface \
|
||||
java.net.PlainSocketImpl \
|
||||
java.net.PlainDatagramSocketImpl \
|
||||
java.net.SocketInputStream \
|
||||
java.net.SocketOutputStream \
|
||||
java.nio.MappedByteBuffer \
|
||||
java.security.AccessController \
|
||||
java.util.ResourceBundle \
|
||||
java.util.TimeZone \
|
||||
@ -101,6 +120,21 @@ openjdk-headers-classes = \
|
||||
sun.misc.VM \
|
||||
sun.misc.VMSupport \
|
||||
sun.misc.Version \
|
||||
sun.net.spi.DefaultProxySelector \
|
||||
sun.nio.ch.FileKey \
|
||||
sun.nio.ch.FileChannelImpl \
|
||||
sun.nio.ch.FileDispatcher \
|
||||
sun.nio.ch.DatagramChannelImpl \
|
||||
sun.nio.ch.DatagramDispatcher \
|
||||
sun.nio.ch.IOStatus \
|
||||
sun.nio.ch.IOUtil \
|
||||
sun.nio.ch.Net \
|
||||
sun.nio.ch.ServerSocketChannelImpl \
|
||||
sun.nio.ch.SocketChannelImpl \
|
||||
sun.nio.ch.EPollArrayWrapper \
|
||||
sun.nio.ch.PollArrayWrapper \
|
||||
sun.nio.ch.InheritedChannel \
|
||||
sun.nio.ch.NativeThread \
|
||||
sun.reflect.ConstantPool \
|
||||
sun.reflect.NativeConstructorAccessorImpl \
|
||||
sun.reflect.NativeMethodAccessorImpl \
|
||||
@ -116,7 +150,9 @@ openjdk-cflags = \
|
||||
"-I$(openjdk-src)/share/native/java/io" \
|
||||
"-I$(openjdk-src)/share/native/java/lang" \
|
||||
"-I$(openjdk-src)/share/native/java/lang/fdlibm/include" \
|
||||
"-I$(openjdk-src)/share/native/java/net" \
|
||||
"-I$(openjdk-src)/share/native/java/util/zip" \
|
||||
"-I$(openjdk-src)/share/native/sun/nio/ch" \
|
||||
"-I$(openjdk-src)/share/javavm/include" \
|
||||
-D_LITTLE_ENDIAN \
|
||||
-DARCHPROPNAME=\"x86\" \
|
||||
@ -147,6 +183,10 @@ ifeq ($(platform),windows)
|
||||
$(openjdk-src)/windows/native/java/io/WinNTFileSystem_md.c \
|
||||
$(openjdk-src)/windows/native/java/lang/java_props_md.c \
|
||||
$(openjdk-src)/windows/native/java/lang/ProcessEnvironment_md.c \
|
||||
$(openjdk-src)/windows/native/java/net/InetAddressImplFactory.c \
|
||||
$(openjdk-src)/windows/native/java/net/Inet4AddressImpl.c \
|
||||
$(openjdk-src)/windows/native/java/net/Inet6AddressImpl.c \
|
||||
$(openjdk-src)/windows/native/java/net/NetworkInterface.c \
|
||||
$(openjdk-src)/windows/native/java/util/WindowsPreferences.c \
|
||||
$(openjdk-src)/windows/native/java/util/logging.c \
|
||||
$(openjdk-src)/windows/native/java/util/TimeZone_md.c \
|
||||
@ -158,6 +198,7 @@ ifeq ($(platform),windows)
|
||||
openjdk-cflags += "-I$(openjdk-src)/windows/javavm/export" \
|
||||
"-I$(openjdk-src)/windows/native/common" \
|
||||
"-I$(openjdk-src)/windows/native/java/io" \
|
||||
"-I$(openjdk-src)/windows/native/java/net" \
|
||||
"-I$(openjdk-src)/windows/native/java/util" \
|
||||
"-I$(openjdk-src)/windows/javavm/include" \
|
||||
"-I$(root)/win32/include" \
|
||||
@ -178,9 +219,36 @@ else
|
||||
$(openjdk-src)/solaris/native/java/lang/java_props_md.c \
|
||||
$(openjdk-src)/solaris/native/java/lang/ProcessEnvironment_md.c \
|
||||
$(openjdk-src)/solaris/native/java/lang/UNIXProcess_md.c \
|
||||
$(openjdk-src)/solaris/native/java/net/net_util_md.c \
|
||||
$(openjdk-src)/solaris/native/java/net/linux_close.c \
|
||||
$(openjdk-src)/solaris/native/java/net/InetAddressImplFactory.c \
|
||||
$(openjdk-src)/solaris/native/java/net/Inet4AddressImpl.c \
|
||||
$(openjdk-src)/solaris/native/java/net/Inet6AddressImpl.c \
|
||||
$(openjdk-src)/solaris/native/java/net/NetworkInterface.c \
|
||||
$(openjdk-src)/solaris/native/java/net/PlainSocketImpl.c \
|
||||
$(openjdk-src)/solaris/native/java/net/PlainDatagramSocketImpl.c \
|
||||
$(openjdk-src)/solaris/native/java/net/SocketInputStream.c \
|
||||
$(openjdk-src)/solaris/native/java/net/SocketOutputStream.c \
|
||||
$(openjdk-src)/solaris/native/java/nio/MappedByteBuffer.c \
|
||||
$(openjdk-src)/solaris/native/java/util/FileSystemPreferences.c \
|
||||
$(openjdk-src)/solaris/native/java/util/logging.c \
|
||||
$(openjdk-src)/solaris/native/java/util/TimeZone_md.c
|
||||
$(openjdk-src)/solaris/native/java/util/TimeZone_md.c \
|
||||
$(openjdk-src)/solaris/native/sun/net/dns/ResolverConfigurationImpl.c \
|
||||
$(openjdk-src)/solaris/native/sun/net/spi/DefaultProxySelector.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/DatagramChannelImpl.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/DatagramDispatcher.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/FileChannelImpl.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/FileDispatcher.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/FileKey.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/IOUtil.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/Net.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/SocketChannelImpl.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/SocketDispatcher.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/EPollArrayWrapper.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/PollArrayWrapper.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/InheritedChannel.c \
|
||||
$(openjdk-src)/solaris/native/sun/nio/ch/NativeThread.c \
|
||||
|
||||
openjdk-headers-classes += \
|
||||
java.io.UnixFileSystem
|
||||
@ -188,13 +256,20 @@ else
|
||||
openjdk-cflags += "-I$(openjdk-src)/solaris/javavm/export" \
|
||||
"-I$(openjdk-src)/solaris/native/common" \
|
||||
"-I$(openjdk-src)/solaris/native/java/io" \
|
||||
"-I$(openjdk-src)/solaris/native/java/net" \
|
||||
"-I$(openjdk-src)/solaris/native/java/util" \
|
||||
"-I$(openjdk-src)/solaris/javavm/include"
|
||||
endif
|
||||
|
||||
openjdk-local-sources = \
|
||||
$(src)/openjdk/my_net_util.c
|
||||
|
||||
c-objects = $(foreach x,$(1),$(patsubst $(2)/%.c,$(3)/%.o,$(x)))
|
||||
|
||||
openjdk-objects = \
|
||||
$(call c-objects,$(openjdk-sources),$(openjdk-src),$(build)/openjdk)
|
||||
|
||||
openjdk-local-objects = \
|
||||
$(call c-objects,$(openjdk-local-sources),$(src)/openjdk,$(build)/openjdk)
|
||||
|
||||
openjdk-headers-dep = $(build)/openjdk/headers.dep
|
||||
|
@ -64,6 +64,7 @@ typedef int socklen_t;
|
||||
# include <fcntl.h>
|
||||
# include <errno.h>
|
||||
# include <sched.h>
|
||||
# include <dlfcn.h>
|
||||
|
||||
# define OPEN open
|
||||
# define CLOSE close
|
||||
@ -244,6 +245,22 @@ class MyClasspath : public Classpath {
|
||||
sb.append(SO_SUFFIX);
|
||||
sb.append('\0');
|
||||
|
||||
this->netLibrary = sb.pointer;
|
||||
sb.append(this->libraryPath);
|
||||
sb.append("/");
|
||||
sb.append(SO_PREFIX);
|
||||
sb.append("net");
|
||||
sb.append(SO_SUFFIX);
|
||||
sb.append('\0');
|
||||
|
||||
this->nioLibrary = sb.pointer;
|
||||
sb.append(this->libraryPath);
|
||||
sb.append("/");
|
||||
sb.append(SO_PREFIX);
|
||||
sb.append("nio");
|
||||
sb.append(SO_SUFFIX);
|
||||
sb.append('\0');
|
||||
|
||||
this->tzMappings = sb.pointer;
|
||||
sb.append(javaHome);
|
||||
sb.append("/lib/tzmappings");
|
||||
@ -414,6 +431,8 @@ class MyClasspath : public Classpath {
|
||||
const char* classpath;
|
||||
const char* libraryPath;
|
||||
const char* zipLibrary;
|
||||
const char* netLibrary;
|
||||
const char* nioLibrary;
|
||||
const char* tzMappings;
|
||||
const char* embedPrefix;
|
||||
unsigned tzMappingsLength;
|
||||
@ -561,7 +580,10 @@ getFileAttributes
|
||||
stringChars(t, path, RUNTIME_ARRAY_BODY(p));
|
||||
replace('\\', '/', RUNTIME_ARRAY_BODY(p));
|
||||
|
||||
if (pathEqual(cp->zipLibrary, RUNTIME_ARRAY_BODY(p))) {
|
||||
if (pathEqual(cp->zipLibrary, RUNTIME_ARRAY_BODY(p))
|
||||
or pathEqual(cp->netLibrary, RUNTIME_ARRAY_BODY(p))
|
||||
or pathEqual(cp->nioLibrary, RUNTIME_ARRAY_BODY(p)))
|
||||
{
|
||||
return Exists | Regular;
|
||||
} else {
|
||||
EmbeddedFile ef(cp, RUNTIME_ARRAY_BODY(p), stringLength(t, path));
|
||||
@ -1665,6 +1687,41 @@ Avian_sun_misc_Unsafe_ensureClassInitialized
|
||||
initClass(t, jclassVmClass(t, reinterpret_cast<object>(arguments[1])));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Avian_sun_misc_Unsafe_unpark
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
object thread = reinterpret_cast<object>(arguments[1]);
|
||||
|
||||
monitorAcquire(t, local::interruptLock(t, thread));
|
||||
threadUnparked(t, thread) = true;
|
||||
monitorNotify(t, local::interruptLock(t, thread));
|
||||
monitorRelease(t, local::interruptLock(t, thread));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
Avian_sun_misc_Unsafe_park
|
||||
(Thread* t, object, uintptr_t* arguments)
|
||||
{
|
||||
bool absolute = arguments[1];
|
||||
int64_t time; memcpy(&time, arguments + 2, 8);
|
||||
|
||||
if (absolute) {
|
||||
time -= t->m->system->now();
|
||||
}
|
||||
|
||||
if (time <= 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
monitorAcquire(t, local::interruptLock(t, t->javaThread));
|
||||
while (not (threadUnparked(t, t->javaThread)
|
||||
or monitorWait(t, local::interruptLock(t, t->javaThread), time)))
|
||||
{ }
|
||||
threadUnparked(t, t->javaThread) = false;
|
||||
monitorRelease(t, local::interruptLock(t, t->javaThread));
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
EXPORT(JVM_GetInterfaceVersion)()
|
||||
{
|
||||
@ -1879,7 +1936,13 @@ EXPORT(JVM_MaxMemory)()
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
EXPORT(JVM_ActiveProcessorCount)(void) { abort(); }
|
||||
EXPORT(JVM_ActiveProcessorCount)()
|
||||
{
|
||||
return 1;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jint JNICALL
|
||||
net_JNI_OnLoad(JavaVM*, void*);
|
||||
|
||||
extern "C" JNIEXPORT void* JNICALL
|
||||
EXPORT(JVM_LoadLibrary)(const char* path)
|
||||
@ -1892,9 +1955,18 @@ EXPORT(JVM_LoadLibrary)(const char* path)
|
||||
#ifdef AVIAN_OPENJDK_SRC
|
||||
if (local::pathEqual
|
||||
(static_cast<local::MyClasspath*>(t->m->classpath)->zipLibrary,
|
||||
RUNTIME_ARRAY_BODY(p))
|
||||
or local::pathEqual
|
||||
(static_cast<local::MyClasspath*>(t->m->classpath)->nioLibrary,
|
||||
RUNTIME_ARRAY_BODY(p)))
|
||||
{
|
||||
return t->m->libraries;
|
||||
} else if (local::pathEqual
|
||||
(static_cast<local::MyClasspath*>(t->m->classpath)->netLibrary,
|
||||
RUNTIME_ARRAY_BODY(p)))
|
||||
{
|
||||
net_JNI_OnLoad(t->m, 0);
|
||||
return t->m->libraries;
|
||||
}
|
||||
#endif // AVIAN_OPENJDK_SRC
|
||||
|
||||
@ -1915,6 +1987,10 @@ EXPORT(JVM_FindLibraryEntry)(void* library, const char* name)
|
||||
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
if (library == 0) {
|
||||
library = t->m->libraries;
|
||||
}
|
||||
|
||||
return static_cast<System::Library*>(library)->resolve(name);
|
||||
}
|
||||
|
||||
@ -2411,10 +2487,25 @@ EXPORT(JVM_IsInterface)(Thread* t, jclass c)
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jobjectArray JNICALL
|
||||
EXPORT(JVM_GetClassSigners)(Thread*, jclass) { abort(); }
|
||||
EXPORT(JVM_GetClassSigners)(Thread* t, jclass c)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
object runtimeData = getClassRuntimeDataIfExists(t, jclassVmClass(t, *c));
|
||||
|
||||
return runtimeData ? makeLocalReference
|
||||
(t, classRuntimeDataSigners(t, runtimeData)) : 0;
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT void JNICALL
|
||||
EXPORT(JVM_SetClassSigners)(Thread*, jclass, jobjectArray) { abort(); }
|
||||
EXPORT(JVM_SetClassSigners)(Thread* t, jclass c, jobjectArray signers)
|
||||
{
|
||||
ENTER(t, Thread::ActiveState);
|
||||
|
||||
object runtimeData = getClassRuntimeData(t, jclassVmClass(t, *c));
|
||||
|
||||
set(t, runtimeData, ClassRuntimeDataSigners, *signers);
|
||||
}
|
||||
|
||||
extern "C" JNIEXPORT jobject JNICALL
|
||||
EXPORT(JVM_GetProtectionDomain)(Thread* t, jclass)
|
||||
|
@ -2625,7 +2625,7 @@ throw_(MyThread* t, object o)
|
||||
(t, Machine::NullPointerExceptionType);
|
||||
}
|
||||
|
||||
// printTrace(t, t->exception);
|
||||
// printTrace(t, t->exception);
|
||||
|
||||
unwind(t);
|
||||
}
|
||||
@ -7178,7 +7178,7 @@ class SegFaultHandler: public System::SignalHandler {
|
||||
t->exception = root(t, Machine::NullPointerException);
|
||||
}
|
||||
|
||||
printTrace(t, t->exception);
|
||||
// printTrace(t, t->exception);
|
||||
|
||||
object continuation;
|
||||
findUnwindTarget(t, ip, base, stack, &continuation);
|
||||
|
@ -222,7 +222,7 @@ class DataRegion: public System::Region {
|
||||
}
|
||||
|
||||
virtual void dispose() {
|
||||
allocator->free(this, sizeof(*this));
|
||||
allocator->free(this, sizeof(*this) + length_);
|
||||
}
|
||||
|
||||
System* s;
|
||||
|
@ -1882,9 +1882,6 @@ resolveObjectArrayClass(Thread* t, object loader, object elementClass)
|
||||
void
|
||||
removeMonitor(Thread* t, object o)
|
||||
{
|
||||
expect(t, t->state == Thread::ExclusiveState
|
||||
or t->state == Thread::ExitState);
|
||||
|
||||
unsigned hash;
|
||||
if (DebugMonitors) {
|
||||
hash = objectHash(t, o);
|
||||
@ -1893,8 +1890,6 @@ removeMonitor(Thread* t, object o)
|
||||
object m = hashMapRemove
|
||||
(t, root(t, Machine::MonitorMap), o, objectHash, objectEqual);
|
||||
|
||||
expect(t, m);
|
||||
|
||||
if (DebugMonitors) {
|
||||
fprintf(stderr, "dispose monitor %p for object %x\n", m, hash);
|
||||
}
|
||||
|
@ -3061,6 +3061,17 @@ resolveMethod(Thread* t, object method, unsigned index)
|
||||
object
|
||||
vectorAppend(Thread*, object, object);
|
||||
|
||||
inline object
|
||||
getClassRuntimeDataIfExists(Thread* t, object c)
|
||||
{
|
||||
if (classRuntimeDataIndex(t, c)) {
|
||||
return vectorBody(t, root(t, Machine::ClassRuntimeDataTable),
|
||||
classRuntimeDataIndex(t, c) - 1);
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
inline object
|
||||
getClassRuntimeData(Thread* t, object c)
|
||||
{
|
||||
@ -3070,7 +3081,7 @@ getClassRuntimeData(Thread* t, object c)
|
||||
ACQUIRE(t, t->m->classLock);
|
||||
|
||||
if (classRuntimeDataIndex(t, c) == 0) {
|
||||
object runtimeData = makeClassRuntimeData(t, 0, 0, 0);
|
||||
object runtimeData = makeClassRuntimeData(t, 0, 0, 0, 0);
|
||||
|
||||
setRoot(t, Machine::ClassRuntimeDataTable, vectorAppend
|
||||
(t, root(t, Machine::ClassRuntimeDataTable), runtimeData));
|
||||
|
@ -40,7 +40,8 @@
|
||||
(type classRuntimeData
|
||||
(object arrayClass)
|
||||
(object jclass)
|
||||
(object pool))
|
||||
(object pool)
|
||||
(object signers))
|
||||
|
||||
(type methodRuntimeData
|
||||
(object native))
|
||||
@ -187,6 +188,7 @@
|
||||
(require object sleepLock)
|
||||
(require object interruptLock)
|
||||
(require uint8_t interrupted)
|
||||
(require uint8_t unparked)
|
||||
(alias peer uint64_t eetop))
|
||||
|
||||
(type threadGroup java/lang/ThreadGroup)
|
||||
|
Loading…
Reference in New Issue
Block a user