File tree 2 files changed +26
-5
lines changed
compiler/src/dotty/tools/backend/jvm
2 files changed +26
-5
lines changed Original file line number Diff line number Diff line change @@ -200,16 +200,21 @@ class BTypesFromSymbols[I <: BackendInterface](val int: I) extends BTypes {
200
200
201
201
val finalFlag = sym.getsJavaFinalFlag
202
202
203
- // Primitives are "abstract final" to prohibit instantiation
204
- // without having to provide any implementations, but that is an
205
- // illegal combination of modifiers at the bytecode level so
206
- // suppress final if abstract if present.
207
203
import asm .Opcodes ._
208
204
GenBCodeOps .mkFlags(
209
205
if (privateFlag) ACC_PRIVATE else ACC_PUBLIC ,
210
206
if (sym.isDeferred || sym.hasAbstractFlag) ACC_ABSTRACT else 0 ,
211
207
if (sym.isInterface) ACC_INTERFACE else 0 ,
212
- if (finalFlag && ! sym.hasAbstractFlag) ACC_FINAL else 0 ,
208
+
209
+ if (finalFlag &&
210
+ // Primitives are "abstract final" to prohibit instantiation
211
+ // without having to provide any implementations, but that is an
212
+ // illegal combination of modifiers at the bytecode level so
213
+ // suppress final if abstract if present.
214
+ ! sym.hasAbstractFlag &&
215
+ // Mixin forwarders are bridges and can be final, but final bridges confuse some frameworks
216
+ ! sym.isBridge)
217
+ ACC_FINAL else 0 ,
213
218
if (sym.isStaticMember) ACC_STATIC else 0 ,
214
219
if (sym.isBridge) ACC_BRIDGE | ACC_SYNTHETIC else 0 ,
215
220
if (sym.isArtifact) ACC_SYNTHETIC else 0 ,
Original file line number Diff line number Diff line change
1
+ import java .lang .reflect .Modifier
2
+
3
+ trait HaveFinalMethod {
4
+ final def finalMethod : String = " final"
5
+ }
6
+
7
+ class Child extends HaveFinalMethod
8
+
9
+ object Test {
10
+ def main (args : Array [String ]): Unit = {
11
+ val meth = classOf [Child ].getMethod(" finalMethod" )
12
+ assert(meth.isBridge)
13
+ val mods = meth.getModifiers
14
+ assert(! Modifier .isFinal(mods))
15
+ }
16
+ }
You can’t perform that action at this time.
0 commit comments