diff -r 88502b1cf76f -r 7799a51dbe30 src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java --- a/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Mon Sep 09 11:43:16 2019 -0400 +++ b/src/jdk.compiler/share/classes/com/sun/tools/javac/code/TypeAnnotations.java Wed Nov 27 09:00:01 2019 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2019, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -390,22 +390,26 @@ sym.getKind() == ElementKind.LOCAL_VARIABLE || sym.getKind() == ElementKind.RESOURCE_VARIABLE || sym.getKind() == ElementKind.EXCEPTION_PARAMETER) { - // Make sure all type annotations from the symbol are also - // on the owner. If the owner is an initializer block, propagate - // to the type. - final long ownerFlags = sym.owner.flags(); - if ((ownerFlags & Flags.BLOCK) != 0) { - // Store init and clinit type annotations with the ClassSymbol - // to allow output in Gen.normalizeDefs. - ClassSymbol cs = (ClassSymbol) sym.owner.owner; - if ((ownerFlags & Flags.STATIC) != 0) { - cs.appendClassInitTypeAttributes(typeAnnotations); - } else { - cs.appendInitTypeAttributes(typeAnnotations); - } + appendTypeAnnotationsToOwner(sym, typeAnnotations); + } + } + + private void appendTypeAnnotationsToOwner(Symbol sym, List typeAnnotations) { + // Make sure all type annotations from the symbol are also + // on the owner. If the owner is an initializer block, propagate + // to the type. + final long ownerFlags = sym.owner.flags(); + if ((ownerFlags & Flags.BLOCK) != 0) { + // Store init and clinit type annotations with the ClassSymbol + // to allow output in Gen.normalizeDefs. + ClassSymbol cs = (ClassSymbol) sym.owner.owner; + if ((ownerFlags & Flags.STATIC) != 0) { + cs.appendClassInitTypeAttributes(typeAnnotations); } else { - sym.owner.appendUniqueTypeAttributes(sym.getRawTypeAttributes()); + cs.appendInitTypeAttributes(typeAnnotations); } + } else { + sym.owner.appendUniqueTypeAttributes(typeAnnotations); } } @@ -943,10 +947,11 @@ " within frame " + frame); } + case BINDING_PATTERN: case VARIABLE: - VarSymbol v = ((JCVariableDecl)frame).sym; + VarSymbol v = frame.hasTag(Tag.BINDINGPATTERN) ? ((JCBindingPattern) frame).symbol : ((JCVariableDecl) frame).sym; if (v.getKind() != ElementKind.FIELD) { - v.owner.appendUniqueTypeAttributes(v.getRawTypeAttributes()); + appendTypeAnnotationsToOwner(v, v.getRawTypeAttributes()); } switch (v.getKind()) { case LOCAL_VARIABLE: