equal
deleted
inserted
replaced
66 private Log log; |
66 private Log log; |
67 private Symtab syms; |
67 private Symtab syms; |
68 private TreeMaker make; |
68 private TreeMaker make; |
69 private Enter enter; |
69 private Enter enter; |
70 private boolean allowEnums; |
70 private boolean allowEnums; |
71 private boolean allowInterfaceBridges; |
|
72 private Types types; |
71 private Types types; |
73 private final Resolve resolve; |
72 private final Resolve resolve; |
74 |
73 |
75 /** |
74 /** |
76 * Flag to indicate whether or not to generate bridge methods. |
75 * Flag to indicate whether or not to generate bridge methods. |
90 enter = Enter.instance(context); |
89 enter = Enter.instance(context); |
91 overridden = new HashMap<MethodSymbol,MethodSymbol>(); |
90 overridden = new HashMap<MethodSymbol,MethodSymbol>(); |
92 Source source = Source.instance(context); |
91 Source source = Source.instance(context); |
93 allowEnums = source.allowEnums(); |
92 allowEnums = source.allowEnums(); |
94 addBridges = source.addBridges(); |
93 addBridges = source.addBridges(); |
95 allowInterfaceBridges = source.allowDefaultMethods(); |
|
96 types = Types.instance(context); |
94 types = Types.instance(context); |
97 make = TreeMaker.instance(context); |
95 make = TreeMaker.instance(context); |
98 resolve = Resolve.instance(context); |
96 resolve = Resolve.instance(context); |
99 } |
97 } |
100 |
98 |
252 Type origType = types.memberType(origin.type, meth); |
250 Type origType = types.memberType(origin.type, meth); |
253 Type origErasure = erasure(origType); |
251 Type origErasure = erasure(origType); |
254 |
252 |
255 // Create a bridge method symbol and a bridge definition without a body. |
253 // Create a bridge method symbol and a bridge definition without a body. |
256 Type bridgeType = meth.erasure(types); |
254 Type bridgeType = meth.erasure(types); |
257 long flags = impl.flags() & AccessFlags | SYNTHETIC | BRIDGE | |
255 long flags = impl.flags() & AccessFlags | SYNTHETIC | BRIDGE; |
258 (origin.isInterface() ? DEFAULT : 0); |
|
259 if (hypothetical) flags |= HYPOTHETICAL; |
256 if (hypothetical) flags |= HYPOTHETICAL; |
260 MethodSymbol bridge = new MethodSymbol(flags, |
257 MethodSymbol bridge = new MethodSymbol(flags, |
261 meth.name, |
258 meth.name, |
262 bridgeType, |
259 bridgeType, |
263 origin); |
260 origin); |
388 meth, meth.location(origin.type, types)); |
385 meth, meth.location(origin.type, types)); |
389 } |
386 } |
390 } |
387 } |
391 } |
388 } |
392 // where |
389 // where |
393 private Filter<Symbol> overrideBridgeFilter = new Filter<Symbol>() { |
390 Filter<Symbol> overrideBridgeFilter = new Filter<Symbol>() { |
394 public boolean accepts(Symbol s) { |
391 public boolean accepts(Symbol s) { |
395 return (s.flags() & (SYNTHETIC | OVERRIDE_BRIDGE)) != SYNTHETIC; |
392 return (s.flags() & (SYNTHETIC | OVERRIDE_BRIDGE)) != SYNTHETIC; |
396 } |
393 } |
397 }; |
394 }; |
398 |
|
399 /** |
395 /** |
400 * @param method The symbol for which a bridge might have to be added |
396 * @param method The symbol for which a bridge might have to be added |
401 * @param impl The implementation of method |
397 * @param impl The implementation of method |
402 * @param dest The type in which the bridge would go |
398 * @param dest The type in which the bridge would go |
403 */ |
399 */ |
1001 make.at(tree.pos); |
997 make.at(tree.pos); |
1002 if (addBridges) { |
998 if (addBridges) { |
1003 ListBuffer<JCTree> bridges = new ListBuffer<JCTree>(); |
999 ListBuffer<JCTree> bridges = new ListBuffer<JCTree>(); |
1004 if (false) //see CR: 6996415 |
1000 if (false) //see CR: 6996415 |
1005 bridges.appendList(addOverrideBridgesIfNeeded(tree, c)); |
1001 bridges.appendList(addOverrideBridgesIfNeeded(tree, c)); |
1006 if (allowInterfaceBridges || (tree.sym.flags() & INTERFACE) == 0) { |
1002 if ((tree.sym.flags() & INTERFACE) == 0) |
1007 addBridges(tree.pos(), c, bridges); |
1003 addBridges(tree.pos(), tree.sym, bridges); |
1008 } |
|
1009 tree.defs = bridges.toList().prependList(tree.defs); |
1004 tree.defs = bridges.toList().prependList(tree.defs); |
1010 } |
1005 } |
1011 tree.type = erasure(tree.type); |
1006 tree.type = erasure(tree.type); |
1012 } finally { |
1007 } finally { |
1013 make = savedMake; |
1008 make = savedMake; |