fix build for recent versions of OpenJDK 7

As of the latest code from the jdk7u-dev Mercurial repository,
java.lang.String no longer has offset or length fields.  Instead, the
content fits exactly into the backing char array, so offset is
implicitly zero and length is the length of the array.  The VM
previously relied on those fields being present, whereas this commit
handles the case where they are not.

In addition, I've made some changes to openjdk-src.mk to ensure that
we can build against both a stock OpenJDK 7 and an IcedTea-patched
version.
This commit is contained in:
Joel Dice 2012-06-11 23:30:22 +00:00
parent 165986841e
commit fa8ba2afc8
4 changed files with 53 additions and 16 deletions

View File

@ -239,8 +239,7 @@ ifeq ($(platform),windows)
-Ds6_bytes=_s6_bytes
else
openjdk-sources += \
$(openjdk-src)/solaris/native/common/jdk_util_md.c \
$(openjdk-src)/solaris/native/common/jni_util_md.c \
$(shell find $(openjdk-src)/solaris/native/common -name '*.c') \
$(openjdk-src)/solaris/native/java/io/canonicalize_md.c \
$(openjdk-src)/solaris/native/java/io/Console_md.c \
$(openjdk-src)/solaris/native/java/io/FileDescriptor_md.c \
@ -305,9 +304,6 @@ else
ifeq ($(platform),linux)
openjdk-sources += \
$(openjdk-src)/solaris/native/java/net/linux_close.c \
$(openjdk-src)/solaris/native/common/deps/syscalls_fp.c \
$(openjdk-src)/solaris/native/common/deps/gconf2/gconf_fp.c \
$(openjdk-src)/solaris/native/common/deps/glib2/gio_fp.c \
$(openjdk-src)/solaris/native/sun/nio/ch/EPollArrayWrapper.c
openjdk-headers-classes += \
@ -316,6 +312,8 @@ else
openjdk-cflags += \
"-I$(openjdk-src)/solaris/native/common/deps/glib2" \
"-I$(openjdk-src)/solaris/native/common/deps/gconf2" \
"-I$(openjdk-src)/solaris/native/common/deps/fontconfig2" \
"-I$(openjdk-src)/solaris/native/common/deps/gtk2" \
$(shell pkg-config --cflags glib-2.0) \
$(shell pkg-config --cflags gconf-2.0)
endif
@ -341,12 +339,13 @@ openjdk-local-sources += \
$(src)/openjdk/my_net_util.c \
$(src)/openjdk/my_management.c
c-objects = $(foreach x,$(1),$(patsubst $(2)/%.c,$(3)/%-openjdk.o,$(x)))
openjdk-c-objects = \
$(foreach x,$(1),$(patsubst $(2)/%.c,$(3)/%-openjdk.o,$(x)))
openjdk-objects = \
$(call c-objects,$(openjdk-sources),$(openjdk-src),$(build)/openjdk)
$(call openjdk-c-objects,$(openjdk-sources),$(openjdk-src),$(build)/openjdk)
openjdk-local-objects = \
$(call c-objects,$(openjdk-local-sources),$(src)/openjdk,$(build)/openjdk)
$(call openjdk-c-objects,$(openjdk-local-sources),$(src)/openjdk,$(build)/openjdk)
openjdk-headers-dep = $(build)/openjdk/headers.dep

View File

@ -562,6 +562,14 @@ class MyClasspath : public Classpath {
expect(t, loadLibrary(t, libraryPath, "java", true, true));
#endif // not AVIAN_OPENJDK_SRC
{ object assertionLock = resolveField
(t, type(t, Machine::ClassLoaderType), "assertionLock",
"Ljava/lang/Object;");
set(t, root(t, Machine::BootLoader), fieldOffset(t, assertionLock),
root(t, Machine::BootLoader));
}
{ object class_ = resolveClass
(t, root(t, Machine::BootLoader), "java/util/Properties", true,
Machine::NoClassDefFoundErrorType);
@ -594,14 +602,6 @@ class MyClasspath : public Classpath {
root(t, Machine::BootLoader));
}
{ object assertionLock = resolveField
(t, type(t, Machine::ClassLoaderType), "assertionLock",
"Ljava/lang/Object;");
set(t, root(t, Machine::BootLoader), fieldOffset(t, assertionLock),
root(t, Machine::BootLoader));
}
{ object scl = resolveField
(t, type(t, Machine::ClassLoaderType), "scl",
"Ljava/lang/ClassLoader;");

View File

@ -2233,6 +2233,39 @@ makeByteArray(Thread* t, const char* format, ...);
object
makeString(Thread* t, const char* format, ...);
#ifndef HAVE_StringOffset
inline unsigned
stringLength(Thread* t, object string)
{
return arrayLength(t, stringData(t, string));
}
inline unsigned
stringOffset(Thread*, object)
{
return 0;
}
inline object
makeString(Thread* t, object data, unsigned offset, unsigned length, unsigned)
{
if (offset == 0 and length == arrayLength(t, data)) {
return makeString(t, data, 0, 0);
} else {
PROTECT(t, data);
object array = makeCharArray(t, length);
memcpy(&charArrayBody(t, array, 0), &charArrayBody(t, data, offset),
length * 2);
return makeString(t, array, 0, 0);
}
}
#endif // not HAVE_StringOffset
int
stringUTFLength(Thread* t, object string, unsigned start, unsigned length);

View File

@ -1384,6 +1384,11 @@ writeAccessor(Output* out, Object* member, Object* offset, bool unsafe = false)
out->write(" = ");
writeOffset(out, offset);
out->write(";\n\n");
out->write("#define HAVE_");
out->write(capitalize(local::typeName(memberOwner(member))));
out->write(capitalize(memberName(member)));
out->write(" 1\n\n");
}
out->write("inline ");