1 /* |
1 /* |
2 * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. |
2 * Copyright (c) 1999, 2012, Oracle and/or its affiliates. All rights reserved. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
3 * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. |
4 * |
4 * |
5 * This code is free software; you can redistribute it and/or modify it |
5 * This code is free software; you can redistribute it and/or modify it |
6 * under the terms of the GNU General Public License version 2 only, as |
6 * under the terms of the GNU General Public License version 2 only, as |
7 * published by the Free Software Foundation. Oracle designates this |
7 * published by the Free Software Foundation. Oracle designates this |
198 (owner.flags() & INTERFACE) != 0 && kind != MTH; |
198 (owner.flags() & INTERFACE) != 0 && kind != MTH; |
199 } |
199 } |
200 |
200 |
201 public boolean isInterface() { |
201 public boolean isInterface() { |
202 return (flags() & INTERFACE) != 0; |
202 return (flags() & INTERFACE) != 0; |
203 } |
|
204 |
|
205 /** Recognize if this symbol was marked @PolymorphicSignature in the source. */ |
|
206 public boolean isPolymorphicSignatureGeneric() { |
|
207 return (flags() & (POLYMORPHIC_SIGNATURE | HYPOTHETICAL)) == POLYMORPHIC_SIGNATURE; |
|
208 } |
|
209 |
|
210 /** Recognize if this symbol was split from a @PolymorphicSignature symbol in the source. */ |
|
211 public boolean isPolymorphicSignatureInstance() { |
|
212 return (flags() & (POLYMORPHIC_SIGNATURE | HYPOTHETICAL)) == (POLYMORPHIC_SIGNATURE | HYPOTHETICAL); |
|
213 } |
203 } |
214 |
204 |
215 /** Is this symbol declared (directly or indirectly) local |
205 /** Is this symbol declared (directly or indirectly) local |
216 * to a method or variable initializer? |
206 * to a method or variable initializer? |
217 * Also includes fields of inner classes which are in |
207 * Also includes fields of inner classes which are in |
1314 public boolean isStaticOrInstanceInit() { |
1304 public boolean isStaticOrInstanceInit() { |
1315 return getKind() == ElementKind.STATIC_INIT || |
1305 return getKind() == ElementKind.STATIC_INIT || |
1316 getKind() == ElementKind.INSTANCE_INIT; |
1306 getKind() == ElementKind.INSTANCE_INIT; |
1317 } |
1307 } |
1318 |
1308 |
|
1309 /** |
|
1310 * A polymorphic signature method (JLS SE 7, 8.4.1) is a method that |
|
1311 * (i) is declared in the java.lang.invoke.MethodHandle class, (ii) takes |
|
1312 * a single variable arity parameter (iii) whose declared type is Object[], |
|
1313 * (iv) has a return type of Object and (v) is native. |
|
1314 */ |
|
1315 public boolean isSignaturePolymorphic(Types types) { |
|
1316 List<Type> argtypes = type.getParameterTypes(); |
|
1317 Type firstElemType = argtypes.nonEmpty() ? |
|
1318 types.elemtype(argtypes.head) : |
|
1319 null; |
|
1320 return owner == types.syms.methodHandleType.tsym && |
|
1321 argtypes.length() == 1 && |
|
1322 firstElemType != null && |
|
1323 types.isSameType(firstElemType, types.syms.objectType) && |
|
1324 types.isSameType(type.getReturnType(), types.syms.objectType) && |
|
1325 (flags() & NATIVE) != 0; |
|
1326 } |
|
1327 |
1319 public Attribute getDefaultValue() { |
1328 public Attribute getDefaultValue() { |
1320 return defaultValue; |
1329 return defaultValue; |
1321 } |
1330 } |
1322 |
1331 |
1323 public List<VarSymbol> getParameters() { |
1332 public List<VarSymbol> getParameters() { |