Skip to content

Commit

Permalink
add support for the RuntimeVisibleParameterAnnotations attribute
Browse files Browse the repository at this point in the history
  • Loading branch information
dicej committed May 1, 2013
1 parent b1840a2 commit 529c7a1
Show file tree
Hide file tree
Showing 3 changed files with 34 additions and 9 deletions.
1 change: 1 addition & 0 deletions classpath/avian/MethodAddendum.java
Expand Up @@ -13,4 +13,5 @@
public class MethodAddendum extends Addendum {
public Object exceptionTable;
public Object annotationDefault;
public Object parameterAnnotationTable;
}
20 changes: 16 additions & 4 deletions src/classpath-openjdk.cpp
Expand Up @@ -2261,6 +2261,7 @@ makeJmethod(Thread* t, object vmMethod, int index)

object signature;
object annotationTable;
object parameterAnnotationTable;
object annotationDefault;
object addendum = methodAddendum(t, vmMethod);
if (addendum) {
Expand All @@ -2274,18 +2275,23 @@ makeJmethod(Thread* t, object vmMethod, int index)

annotationTable = addendumAnnotationTable(t, addendum);

parameterAnnotationTable = methodAddendumParameterAnnotationTable
(t, addendum);

annotationDefault = methodAddendumAnnotationDefault(t, addendum);
} else {
signature = 0;
annotationTable = 0;
parameterAnnotationTable = 0;
annotationDefault = 0;
}

PROTECT(t, signature);
PROTECT(t, annotationTable);
PROTECT(t, parameterAnnotationTable);
PROTECT(t, annotationDefault);

if (annotationTable or annotationDefault) {
if (annotationTable or parameterAnnotationTable or annotationDefault) {
object runtimeData = getClassRuntimeData(t, methodClass(t, vmMethod));

set(t, runtimeData, ClassRuntimeDataPool,
Expand All @@ -2309,7 +2315,7 @@ makeJmethod(Thread* t, object vmMethod, int index)
return makeJmethod
(t, true, 0, jclass, index, name, returnType, parameterTypes,
exceptionTypes, methodFlags(t, vmMethod), signature, 0, annotationTable,
0, annotationDefault, 0, 0, 0);
parameterAnnotationTable, annotationDefault, 0, 0, 0);
}

object
Expand All @@ -2331,6 +2337,7 @@ makeJconstructor(Thread* t, object vmMethod, int index)

object signature;
object annotationTable;
object parameterAnnotationTable;
object addendum = methodAddendum(t, vmMethod);
if (addendum) {
signature = addendumSignature(t, addendum);
Expand All @@ -2342,15 +2349,19 @@ makeJconstructor(Thread* t, object vmMethod, int index)
}

annotationTable = addendumAnnotationTable(t, addendum);
parameterAnnotationTable = methodAddendumParameterAnnotationTable
(t, addendum);
} else {
signature = 0;
annotationTable = 0;
parameterAnnotationTable = 0;
}

PROTECT(t, signature);
PROTECT(t, annotationTable);
PROTECT(t, parameterAnnotationTable);

if (annotationTable) {
if (annotationTable or parameterAnnotationTable) {
object runtimeData = getClassRuntimeData(t, methodClass(t, vmMethod));

set(t, runtimeData, ClassRuntimeDataPool,
Expand All @@ -2373,7 +2384,8 @@ makeJconstructor(Thread* t, object vmMethod, int index)

return makeJconstructor
(t, true, 0, jclass, index, parameterTypes, exceptionTypes, methodFlags
(t, vmMethod), signature, 0, annotationTable, 0, 0, 0, 0);
(t, vmMethod), signature, 0, annotationTable, parameterAnnotationTable,
0, 0, 0);
}

object
Expand Down
22 changes: 17 additions & 5 deletions src/machine.cpp
Expand Up @@ -2009,7 +2009,7 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
&byteArrayBody(t, attributeName, 0)) == 0)
{
if (addendum == 0) {
addendum = makeMethodAddendum(t, pool, 0, 0, 0, 0);
addendum = makeMethodAddendum(t, pool, 0, 0, 0, 0, 0);
}
unsigned exceptionCount = s.read2();
object body = makeShortArray(t, exceptionCount);
Expand All @@ -2022,7 +2022,7 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
&byteArrayBody(t, attributeName, 0)) == 0)
{
if (addendum == 0) {
addendum = makeMethodAddendum(t, pool, 0, 0, 0, 0);
addendum = makeMethodAddendum(t, pool, 0, 0, 0, 0, 0);
}

object body = makeByteArray(t, length);
Expand All @@ -2034,7 +2034,7 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
&byteArrayBody(t, attributeName, 0)) == 0)
{
if (addendum == 0) {
addendum = makeMethodAddendum(t, pool, 0, 0, 0, 0);
addendum = makeMethodAddendum(t, pool, 0, 0, 0, 0, 0);
}

set(t, addendum, AddendumSignature,
Expand All @@ -2044,14 +2044,27 @@ parseMethodTable(Thread* t, Stream& s, object class_, object pool)
&byteArrayBody(t, attributeName, 0)) == 0)
{
if (addendum == 0) {
addendum = makeMethodAddendum(t, pool, 0, 0, 0, 0);
addendum = makeMethodAddendum(t, pool, 0, 0, 0, 0, 0);
}

object body = makeByteArray(t, length);
s.read(reinterpret_cast<uint8_t*>(&byteArrayBody(t, body, 0)),
length);

set(t, addendum, AddendumAnnotationTable, body);
} else if (vm::strcmp(reinterpret_cast<const int8_t*>
("RuntimeVisibleParameterAnnotations"),
&byteArrayBody(t, attributeName, 0)) == 0)
{
if (addendum == 0) {
addendum = makeMethodAddendum(t, pool, 0, 0, 0, 0, 0);
}

object body = makeByteArray(t, length);
s.read(reinterpret_cast<uint8_t*>(&byteArrayBody(t, body, 0)),
length);

set(t, addendum, MethodAddendumParameterAnnotationTable, body);
} else {
s.skip(length);
}
Expand Down Expand Up @@ -5243,7 +5256,6 @@ threadIsInterrupted(Thread* t, object thread, bool clear)
threadInterrupted(t, thread) = false;
}
monitorRelease(t, interruptLock(t, thread));

return v;
}

Expand Down

0 comments on commit 529c7a1

Please sign in to comment.