30 import javax.lang.model.type.TypeKind; |
30 import javax.lang.model.type.TypeKind; |
31 import javax.tools.JavaFileObject; |
31 import javax.tools.JavaFileObject; |
32 |
32 |
33 import com.sun.tools.javac.code.Attribute.Array; |
33 import com.sun.tools.javac.code.Attribute.Array; |
34 import com.sun.tools.javac.code.Attribute.TypeCompound; |
34 import com.sun.tools.javac.code.Attribute.TypeCompound; |
|
35 import com.sun.tools.javac.code.Symbol.ClassSymbol; |
35 import com.sun.tools.javac.code.Symbol.TypeSymbol; |
36 import com.sun.tools.javac.code.Symbol.TypeSymbol; |
36 import com.sun.tools.javac.code.Type.ArrayType; |
37 import com.sun.tools.javac.code.Type.ArrayType; |
37 import com.sun.tools.javac.code.Type.CapturedType; |
38 import com.sun.tools.javac.code.Type.CapturedType; |
38 import com.sun.tools.javac.code.Type.ClassType; |
39 import com.sun.tools.javac.code.Type.ClassType; |
39 import com.sun.tools.javac.code.Type.ErrorType; |
40 import com.sun.tools.javac.code.Type.ErrorType; |
386 if (sym.getKind() == ElementKind.PARAMETER || |
387 if (sym.getKind() == ElementKind.PARAMETER || |
387 sym.getKind() == ElementKind.LOCAL_VARIABLE || |
388 sym.getKind() == ElementKind.LOCAL_VARIABLE || |
388 sym.getKind() == ElementKind.RESOURCE_VARIABLE || |
389 sym.getKind() == ElementKind.RESOURCE_VARIABLE || |
389 sym.getKind() == ElementKind.EXCEPTION_PARAMETER) { |
390 sym.getKind() == ElementKind.EXCEPTION_PARAMETER) { |
390 // Make sure all type annotations from the symbol are also |
391 // Make sure all type annotations from the symbol are also |
391 // on the owner. |
392 // on the owner. If the owner is an initializer block, propagate |
392 sym.owner.appendUniqueTypeAttributes(sym.getRawTypeAttributes()); |
393 // to the type. |
|
394 final long ownerFlags = sym.owner.flags(); |
|
395 if ((ownerFlags & Flags.BLOCK) != 0) { |
|
396 // Store init and clinit type annotations with the ClassSymbol |
|
397 // to allow output in Gen.normalizeDefs. |
|
398 ClassSymbol cs = (ClassSymbol) sym.owner.owner; |
|
399 if ((ownerFlags & Flags.STATIC) != 0) { |
|
400 cs.appendClassInitTypeAttributes(typeAnnotations); |
|
401 } else { |
|
402 cs.appendInitTypeAttributes(typeAnnotations); |
|
403 } |
|
404 } else { |
|
405 sym.owner.appendUniqueTypeAttributes(sym.getRawTypeAttributes()); |
|
406 } |
393 } |
407 } |
394 } |
408 } |
395 |
409 |
396 // This method has a similar purpose as |
410 // This method has a similar purpose as |
397 // {@link com.sun.tools.javac.parser.JavacParser.insertAnnotationsToMostInner(JCExpression, List<JCTypeAnnotation>, boolean)} |
411 // {@link com.sun.tools.javac.parser.JavacParser.insertAnnotationsToMostInner(JCExpression, List<JCTypeAnnotation>, boolean)} |