File tree 2 files changed +15
-0
lines changed
src/dotty/tools/dotc/core/classfile
2 files changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -275,6 +275,9 @@ class ClassfileParser(
275
275
def complete (denot : SymDenotation )(using Context ): Unit = {
276
276
val sym = denot.symbol
277
277
val isEnum = (jflags & JAVA_ACC_ENUM ) != 0
278
+ val isNative = (jflags & JAVA_ACC_NATIVE ) != 0
279
+ val isTransient = (jflags & JAVA_ACC_TRANSIENT ) != 0
280
+ val isVolatile = (jflags & JAVA_ACC_VOLATILE ) != 0
278
281
val isConstructor = name eq nme.CONSTRUCTOR
279
282
280
283
/** Strip leading outer param from constructor and trailing access tag for
@@ -313,6 +316,12 @@ class ClassfileParser(
313
316
val isVarargs = denot.is(Flags .Method ) && (jflags & JAVA_ACC_VARARGS ) != 0
314
317
denot.info = sigToType(sig, isVarargs = isVarargs)
315
318
if (isConstructor) normalizeConstructorParams()
319
+ if isNative then
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 ))
316
325
denot.info = translateTempPoly(attrCompleter.complete(denot.info, isVarargs))
317
326
if (isConstructor) normalizeConstructorInfo()
318
327
Original file line number Diff line number Diff line change @@ -89,3 +89,9 @@ class AnnotationsTest:
89
89
s " A missing annotation while parsing a Java class should be silently ignored but: ${ctx.reporter.summary}" )
90
90
}
91
91
}
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