mirror of
https://github.com/corda/corda.git
synced 2025-01-07 13:38:47 +00:00
only return declared interfaces from Class.getInterfaces
The result of Class.getInterfaces should not include interfaces declared to be implemented/extended by superclasses/superinterfaces, only those declared by the class itself. This is important because it influences how java.io.ObjectStreamClass calculates serial version IDs.
This commit is contained in:
parent
56e832d3e8
commit
9fe41b2afc
@ -10,4 +10,6 @@
|
|||||||
|
|
||||||
package avian;
|
package avian;
|
||||||
|
|
||||||
public class ClassAddendum extends Addendum { }
|
public class ClassAddendum extends Addendum {
|
||||||
|
public Object[] interfaceTable;
|
||||||
|
}
|
||||||
|
@ -3553,29 +3553,28 @@ jvmGetClassInterfaces(Thread* t, uintptr_t* arguments)
|
|||||||
{
|
{
|
||||||
jclass c = reinterpret_cast<jclass>(arguments[0]);
|
jclass c = reinterpret_cast<jclass>(arguments[0]);
|
||||||
|
|
||||||
object table = classInterfaceTable(t, jclassVmClass(t, *c));
|
object addendum = classAddendum(t, jclassVmClass(t, *c));
|
||||||
|
if (addendum) {
|
||||||
|
object table = classAddendumInterfaceTable(t, addendum);
|
||||||
if (table) {
|
if (table) {
|
||||||
PROTECT(t, table);
|
PROTECT(t, table);
|
||||||
|
|
||||||
unsigned stride =
|
object array = makeObjectArray(t, arrayLength(t, table));
|
||||||
(classFlags(t, jclassVmClass(t, *c)) & ACC_INTERFACE) == 0 ? 2 : 1;
|
|
||||||
|
|
||||||
object array = makeObjectArray
|
|
||||||
(t, type(t, Machine::JclassType), arrayLength(t, table) / stride);
|
|
||||||
PROTECT(t, array);
|
PROTECT(t, array);
|
||||||
|
|
||||||
for (unsigned i = 0; i < objectArrayLength(t, array); ++i) {
|
for (unsigned i = 0; i < arrayLength(t, table); ++i) {
|
||||||
object interface = getJClass(t, arrayBody(t, table, i * stride));
|
object c = getJClass(t, arrayBody(t, table, i));
|
||||||
set(t, array, ArrayBody + (i * BytesPerWord), interface);
|
set(t, array, ArrayBody + (i * BytesPerWord), c);
|
||||||
}
|
}
|
||||||
|
|
||||||
return reinterpret_cast<uint64_t>(makeLocalReference(t, array));
|
return reinterpret_cast<uint64_t>(makeLocalReference(t, array));
|
||||||
} else {
|
}
|
||||||
|
}
|
||||||
|
|
||||||
return reinterpret_cast<uint64_t>
|
return reinterpret_cast<uint64_t>
|
||||||
(makeLocalReference
|
(makeLocalReference
|
||||||
(t, makeObjectArray(t, type(t, Machine::JclassType), 0)));
|
(t, makeObjectArray(t, type(t, Machine::JclassType), 0)));
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
extern "C" JNIEXPORT jobjectArray JNICALL
|
extern "C" JNIEXPORT jobjectArray JNICALL
|
||||||
EXPORT(JVM_GetClassInterfaces)(Thread* t, jclass c)
|
EXPORT(JVM_GetClassInterfaces)(Thread* t, jclass c)
|
||||||
|
@ -986,6 +986,17 @@ parseInterfaceTable(Thread* t, Stream& s, object class_, object pool,
|
|||||||
}
|
}
|
||||||
|
|
||||||
unsigned count = s.read2();
|
unsigned count = s.read2();
|
||||||
|
object table = 0;
|
||||||
|
PROTECT(t, table);
|
||||||
|
|
||||||
|
if (count) {
|
||||||
|
table = makeArray(t, count);
|
||||||
|
if (classAddendum(t, class_) == 0) {
|
||||||
|
object addendum = makeClassAddendum(t, pool, 0, 0, table);
|
||||||
|
set(t, class_, ClassAddendum, addendum);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
for (unsigned i = 0; i < count; ++i) {
|
for (unsigned i = 0; i < count; ++i) {
|
||||||
object name = referenceName(t, singletonObject(t, pool, s.read2() - 1));
|
object name = referenceName(t, singletonObject(t, pool, s.read2() - 1));
|
||||||
PROTECT(t, name);
|
PROTECT(t, name);
|
||||||
@ -995,6 +1006,8 @@ parseInterfaceTable(Thread* t, Stream& s, object class_, object pool,
|
|||||||
|
|
||||||
PROTECT(t, interface);
|
PROTECT(t, interface);
|
||||||
|
|
||||||
|
set(t, table, ArrayBody + (i * BytesPerWord), interface);
|
||||||
|
|
||||||
hashMapInsertMaybe(t, map, name, interface, byteArrayHash, byteArrayEqual);
|
hashMapInsertMaybe(t, map, name, interface, byteArrayHash, byteArrayEqual);
|
||||||
|
|
||||||
addInterfaces(t, interface, map);
|
addInterfaces(t, interface, map);
|
||||||
@ -1696,7 +1709,7 @@ parseAttributeTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
PROTECT(t, class_);
|
PROTECT(t, class_);
|
||||||
PROTECT(t, pool);
|
PROTECT(t, pool);
|
||||||
|
|
||||||
object addendum = 0;
|
object addendum = classAddendum(t, class_);
|
||||||
PROTECT(t, addendum);
|
PROTECT(t, addendum);
|
||||||
|
|
||||||
unsigned attributeCount = s.read2();
|
unsigned attributeCount = s.read2();
|
||||||
@ -1712,7 +1725,7 @@ parseAttributeTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
&byteArrayBody(t, name, 0)) == 0)
|
&byteArrayBody(t, name, 0)) == 0)
|
||||||
{
|
{
|
||||||
if (addendum == 0) {
|
if (addendum == 0) {
|
||||||
addendum = makeClassAddendum(t, pool, 0, 0);
|
addendum = makeClassAddendum(t, pool, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
set(t, addendum, AddendumSignature,
|
set(t, addendum, AddendumSignature,
|
||||||
@ -1722,7 +1735,7 @@ parseAttributeTable(Thread* t, Stream& s, object class_, object pool)
|
|||||||
&byteArrayBody(t, name, 0)) == 0)
|
&byteArrayBody(t, name, 0)) == 0)
|
||||||
{
|
{
|
||||||
if (addendum == 0) {
|
if (addendum == 0) {
|
||||||
addendum = makeClassAddendum(t, pool, 0, 0);
|
addendum = makeClassAddendum(t, pool, 0, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
object body = makeByteArray(t, length);
|
object body = makeByteArray(t, length);
|
||||||
|
Loading…
Reference in New Issue
Block a user