Bug 28203 - annotation inheritance is incorrect
Summary: annotation inheritance is incorrect
Status: RESOLVED FIXED
Alias: None
Product: classpath
Classification: Unclassified
Component: classpath (show other bugs)
Version: 0.92
: P3 normal
Target Milestone: 0.93
Assignee: Tom Tromey
URL:
Keywords:
Depends on:
Blocks:
 
Reported: 2006-06-29 17:33 UTC by Tom Tromey
Modified: 2006-11-29 23:12 UTC (History)
1 user (show)

See Also:
Host:
Target:
Build:
Known to work:
Known to fail:
Last reconfirmed: 2006-10-18 06:35:19


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Tom Tromey 2006-06-29 17:33:12 UTC
Currently Class.getAnnotations implements annotation inheritance incorrectly.
There are 3 problems:

1. Only @Inherited annotations should be inherited
2. Annotations are only inherited from superclasses, not interfaces
3. An annotation should not be inherited if an annotation of the
   same type is already present on the class.
Comment 1 Tom Tromey 2006-07-07 21:25:48 UTC
Also, in AnnotationInvocationHandler, if the 'val' being returned
is an array, I think it should be cloned.
Comment 2 Jeroen Frijters 2006-07-08 08:52:44 UTC
Agreed.
Comment 3 Tom Tromey 2006-10-18 06:35:19 UTC
Working on a patch.

I fixed the cloning problem in libgcj; I'll push
the patch upstream soon.
Comment 4 Tom Tromey 2006-10-18 19:56:49 UTC
Subject: Bug 28203

Author: tromey
Date: Wed Oct 18 19:56:40 2006
New Revision: 117861

URL: http://gcc.gnu.org/viewcvs?root=gcc&view=rev&rev=117861
Log:
	PR classpath/28203:
	* java/lang/Class.java (getAnnotations): Rewrote.
	* java/lang/reflect/Method.java (METHOD_MODIFIERS): Now
	package-private.
	* java/lang/reflect/Field.java (FIELD_MODIFIERS): Now
	package-private.
	* gcj/field.h (_Jv_FIELD_CONSTANT_VALUE): Removed.
	* defineclass.cc (handleConstantValueAttribute): Added found_value
	argument.  Don't use _Jv_FIELD_CONSTANT_VALUE.
	(read_one_field_attribute): Updated.
	(read_fields): Likewise.
	(handleField): Mask with FIELD_MODIFIERS, not ALL_FLAGS.
	(handleMethod): Mask with METHOD_MODIFIERS, not ALL_FLAGS.

Modified:
    branches/gcj-eclipse/libjava/ChangeLog
    branches/gcj-eclipse/libjava/classpath/lib/java/lang/Class.class
    branches/gcj-eclipse/libjava/classpath/lib/java/lang/reflect/Field.class
    branches/gcj-eclipse/libjava/classpath/lib/java/lang/reflect/Method.class
    branches/gcj-eclipse/libjava/defineclass.cc
    branches/gcj-eclipse/libjava/gcj/field.h
    branches/gcj-eclipse/libjava/java/lang/Class.java
    branches/gcj-eclipse/libjava/java/lang/reflect/Field.h
    branches/gcj-eclipse/libjava/java/lang/reflect/Field.java
    branches/gcj-eclipse/libjava/java/lang/reflect/Method.h
    branches/gcj-eclipse/libjava/java/lang/reflect/Method.java

Comment 5 cvs-commit@developer.classpath.org 2006-11-29 23:10:58 UTC
Subject: Bug 28203

CVSROOT:	/cvsroot/classpath
Module name:	classpath
Branch:		generics-branch
Changes by:	Tom Tromey <tromey>	06/11/29 23:10:31

Modified files:
	.              : ChangeLog 
	java/lang      : Class.java 

Log message:
		PR classpath/28203:
		* java/lang/Class.java (getAnnotations): Rewrote.

CVSWeb URLs:
http://cvs.savannah.gnu.org/viewcvs/classpath/ChangeLog?cvsroot=classpath&only_with_tag=generics-branch&r1=1.2386.2.343&r2=1.2386.2.344
http://cvs.savannah.gnu.org/viewcvs/classpath/java/lang/Class.java?cvsroot=classpath&only_with_tag=generics-branch&r1=1.22.2.25&r2=1.22.2.26



Comment 6 Tom Tromey 2006-11-29 23:12:00 UTC
I checked in a fix for annotation inheritance.
The other fix is pending introduction of Method.getDefaultValue, see
the classpath patch list.