File tree Expand file tree Collapse file tree 2 files changed +13
-3
lines changed
src/dotty/tools/dotc/core/classfile Expand file tree Collapse file tree 2 files changed +13
-3
lines changed Original file line number Diff line number Diff line change @@ -276,6 +276,8 @@ class ClassfileParser(
276276 val sym = denot.symbol
277277 val isEnum = (jflags & JAVA_ACC_ENUM ) != 0
278278 val isNative = (jflags & JAVA_ACC_NATIVE ) != 0
279+ val isTransient = (jflags & JAVA_ACC_TRANSIENT ) != 0
280+ val isVolatile = (jflags & JAVA_ACC_VOLATILE ) != 0
279281 val isConstructor = name eq nme.CONSTRUCTOR
280282
281283 /** Strip leading outer param from constructor and trailing access tag for
@@ -315,9 +317,11 @@ class ClassfileParser(
315317 denot.info = sigToType(sig, isVarargs = isVarargs)
316318 if (isConstructor) normalizeConstructorParams()
317319 if isNative then
318- attrCompleter.annotations ::= Annotation .deferredSymAndTree(defn.NativeAnnot ) {
319- New (defn.NativeAnnot .typeRef, Nil )
320- }
320+ attrCompleter.annotations ::= Annotation .deferredSymAndTree(defn.NativeAnnot )(New (defn.NativeAnnot .typeRef, Nil ))
321+ if isTransient then
322+ attrCompleter.annotations ::= Annotation .deferredSymAndTree(defn.TransientAnnot )(New (defn.TransientAnnot .typeRef, Nil ))
323+ if isVolatile then
324+ attrCompleter.annotations ::= Annotation .deferredSymAndTree(defn.VolatileAnnot )(New (defn.VolatileAnnot .typeRef, Nil ))
321325 denot.info = translateTempPoly(attrCompleter.complete(denot.info, isVarargs))
322326 if (isConstructor) normalizeConstructorInfo()
323327
Original file line number Diff line number Diff line change @@ -89,3 +89,9 @@ class AnnotationsTest:
8989 s " A missing annotation while parsing a Java class should be silently ignored but: ${ctx.reporter.summary}" )
9090 }
9191 }
92+
93+ @ Test def hasNativeAnnot : Unit =
94+ inCompilerContext(TestConfiguration .basicClasspath) {
95+ val term : TermSymbol = requiredClass(" java.lang.invoke.MethodHandle" ).requiredMethod(" invokeExact" )
96+ assert(term.hasAnnotation(defn.NativeAnnot ), i " ${term.annotations}" )
97+ }
You can’t perform that action at this time.
0 commit comments