From: Julian D. <do...@us...> - 2016-11-28 16:47:35
|
Martin, That all sounds good. I guess I should have read the code more carefully before commenting; the integration with annotations looks very nice. -- Julian From: Martin Hecker <mar...@ki...> To: wal...@li... Date: 11/28/2016 11:22 AM Subject: Re: [Wala-wala] JSR 308 "Type Annotations" Support On 11/28/2016 04:41 PM, Julian Dolby wrote: > This looks very nice, and I would definitely be in favour of having it as part of WALA core! Great! I will eventually provide a pull-request then - once I've incorporated any suggestions that come up here in this thread. > 1) Maybe we can minimize the space cost of the bytecode index mapping arrays by using the existing mapping. Since that > is an array from instruction index to bytecode offset, we ought to be able to use binary search on that array for a > reverse mapping. Logarithmic time should be fine, given that the bytecode size is limited anyway. That's a great idea, I will look into implementing this and report back! > We can do that if the bytecode order is always sorted; it should be since I think Shrike only ever messes with the order > of bytecodes when JSRs are used, and they are not allowed in newer code anyway. So do you reckon one would use such a "fast" implementation whenever no JSRs are present, and fall back to some slower search when JSRs are present? > 2) It looks from JSR 308 that there is a lot of sharing of formats between the new type annotations and the previous > annotations of Java 7. It would be great if that commonality could be reflected as much as possible in the code of the > AnnotationsReader and the TypeAnnotationReader. > > For instance, the type_annotation structure in JSR308 appears to be an extension of the annotation structure from > previous versions of Java. Currently, this is reflected in TypeAnnotationReader in so far as that Pair<TypeAnnotationAttribute, Integer> TypeAnnotationReader.getTypeAttributeAndSize(int begin) calls the existing method Pair< AnnotationAttribute, Integer> AnnotationsReader.getAttributeAndSize(int begin) in order to parse the part of the type annotation that is shared with "normal" annotations as specified in https://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.7.16 > It might aid ultimate integration into the WALA IR annotation structures, if that could be > reflected somehow in the Shrike structures, that would be great. With regard to the WALA (as opposed to: Shrike) structures, the TypeAnnotation class is composed from the the existing WALA Annotation class like this: public class TypeAnnotation { private final Annotation annotation; ^^^^^^^^^^ private final List<Pair<TypePathKind, Integer>> typePath; private final TypeAnnotationTarget typeAnnotationTarget; private final TargetType targetType; ... } Greetings, Martin [attachment "smime.p7s" deleted by Julian Dolby/Watson/IBM] ------------------------------------------------------------------------------ _______________________________________________ Wala-wala mailing list Wal...@li... https://lists.sourceforge.net/lists/listinfo/wala-wala |