Skip to content

Commit a3ac05a

Browse files
committed
Parse native in Java bytecode as @Native
1 parent 5ada87f commit a3ac05a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

compiler/src/dotty/tools/dotc/core/classfile/ClassfileParser.scala

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -311,9 +311,10 @@ class ClassfileParser(
311311
}
312312

313313
val isVarargs = denot.is(Flags.Method) && (jflags & JAVA_ACC_VARARGS) != 0
314+
val isNative = (jflags & JAVA_ACC_NATIVE) != 0
314315
denot.info = sigToType(sig, isVarargs = isVarargs)
315316
if (isConstructor) normalizeConstructorParams()
316-
denot.info = translateTempPoly(attrCompleter.complete(denot.info, isVarargs))
317+
denot.info = translateTempPoly(attrCompleter.complete(denot.info, isVarargs, isNative))
317318
if (isConstructor) normalizeConstructorInfo()
318319

319320
if (ctx.explicitNulls) denot.info = JavaNullInterop.nullifyMember(denot.symbol, denot.info, isEnum)
@@ -687,7 +688,7 @@ class ClassfileParser(
687688
var exceptions: List[NameOrString] = Nil
688689
var annotations: List[Annotation] = Nil
689690
var namedParams: Map[Int, TermName] = Map.empty
690-
def complete(tp: Type, isVarargs: Boolean = false)(using Context): Type = {
691+
def complete(tp: Type, isVarargs: Boolean = false, isNative: Boolean = false)(using Context): Type = {
691692
val updatedType =
692693
if sig == null then tp
693694
else {
@@ -704,6 +705,8 @@ class ClassfileParser(
704705
else updatedType
705706

706707
annotations.foreach(annot => sym.addAnnotation(annot))
708+
if isNative then
709+
sym.addAnnotation(Annotation(defn.NativeAnnot))
707710

708711
exceptions.foreach { ex =>
709712
val cls = getClassSymbol(ex.name)

0 commit comments

Comments
 (0)