Skip to content

Commit

Permalink
Parse native in Java bytecode as @Native
Browse files Browse the repository at this point in the history
  • Loading branch information
dwijnand committed Oct 22, 2022
1 parent 5ada87f commit a3ac05a
Showing 1 changed file with 5 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,10 @@ class ClassfileParser(
}

val isVarargs = denot.is(Flags.Method) && (jflags & JAVA_ACC_VARARGS) != 0
val isNative = (jflags & JAVA_ACC_NATIVE) != 0
denot.info = sigToType(sig, isVarargs = isVarargs)
if (isConstructor) normalizeConstructorParams()
denot.info = translateTempPoly(attrCompleter.complete(denot.info, isVarargs))
denot.info = translateTempPoly(attrCompleter.complete(denot.info, isVarargs, isNative))
if (isConstructor) normalizeConstructorInfo()

if (ctx.explicitNulls) denot.info = JavaNullInterop.nullifyMember(denot.symbol, denot.info, isEnum)
Expand Down Expand Up @@ -687,7 +688,7 @@ class ClassfileParser(
var exceptions: List[NameOrString] = Nil
var annotations: List[Annotation] = Nil
var namedParams: Map[Int, TermName] = Map.empty
def complete(tp: Type, isVarargs: Boolean = false)(using Context): Type = {
def complete(tp: Type, isVarargs: Boolean = false, isNative: Boolean = false)(using Context): Type = {
val updatedType =
if sig == null then tp
else {
Expand All @@ -704,6 +705,8 @@ class ClassfileParser(
else updatedType

annotations.foreach(annot => sym.addAnnotation(annot))
if isNative then
sym.addAnnotation(Annotation(defn.NativeAnnot))

exceptions.foreach { ex =>
val cls = getClassSymbol(ex.name)
Expand Down

0 comments on commit a3ac05a

Please sign in to comment.