Mercurial > hg > icedtea7-forest > langtools
changeset 2080:bb9d09219d3e icedtea-2.6pre18
Merge jdk7u80-b05
author | andrew |
---|---|
date | Thu, 29 Jan 2015 22:20:25 +0000 |
parents | ddeb14520365 (current diff) 66326158f20b (diff) |
children | 4c600e18a7e4 |
files | .hgtags src/share/classes/com/sun/tools/javac/jvm/ClassReader.java |
diffstat | 26 files changed, 1202 insertions(+), 65 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Thu Jan 22 02:55:38 2015 +0000 +++ b/.hgtags Thu Jan 29 22:20:25 2015 +0000 @@ -492,11 +492,19 @@ 0f809f893588548a3b5c8441e28c9e0a62bc13ef jdk7u65-b18 eae289997f58ef6396dc323c3d5b93a56fb43573 jdk7u65-b19 afc940d62b49059f565f87c83343fa3d28df883b jdk7u65-b32 +772aad4e9681828b8ee193b9ed971cbfe6c7f347 jdk7u80-b00 +6c307a0b7a94e002d8a2532ffd8146d6c53f42d3 jdk7u80-b01 +5bd6f3adf690dc2de8881b6f9f48336db4af7865 jdk7u80-b02 114c4fc53777e4067a26f6510fe72fa770a9253c jdk7u65-b20 8a09cca8f12027ba59df4bb18d49e855c4db4811 jdk7u67-b01 eae289997f58ef6396dc323c3d5b93a56fb43573 jdk7u65-b40 5e4cc118e2d1f7a8eefca5dd7146d46a1b0ca911 jdk7u65-b31 59575d1928f98d1e26ea548ff4d5e2415dfe9b57 jdk7u65-b33 +8a09cca8f12027ba59df4bb18d49e855c4db4811 jdk7u67-b01 +e3b604d29f9177ac0c1344cdb7af8f5ccdc1db42 jdk7u67-b31 +e6bf55d457016764b4dd785b61ae79a125ba869b jdk7u67-b32 +624c54795faaf1a92bc1eb8c369dc18c1704c812 jdk7u67-b33 +18077957a8b802d9ce8724856e8b5f3fcde38b9e jdk7u67-b34 684f0285b699d304d1efff487b550ff2e1679e98 jdk7u66-b00 a927daae851fa81d0470d2b67f52e8156e4d423c jdk7u66-b01 6f229fda19bdabf7a3d1caad9d809dd713cce65d jdk7u66-b09 @@ -538,6 +546,39 @@ cade57461d3b90a59ec62c06d77068b1b73f05b2 jdk7u72-b13 6106b56a874e19e603660a09d506fe8afcde9e14 jdk7u72-b14 7a09f7596c8bb17d3b25b4506dd76425f6efb15e jdk7u72-b30 +de0088aaf97fa861be8c17e97b57139287068c86 jdk7u72-b31 +0138c5f55af0c700882deeac4411fbd9118b4d6e jdk7u75-b00 +7ecfdbf693cfc14d648ebdf2cc87716068569e8d jdk7u75-b01 +688a304d3215af8104336ecce50b7f4edfb88d36 jdk7u75-b02 +105ad2d2417515b2b595c151e2a5d8ae0fe729eb jdk7u75-b03 +bdbe862f8846558c83f8bc15518446ab0495a173 jdk7u75-b04 +1895dc97d832950fe13a16428b797c952c9e4f4a jdk7u75-b05 +5fcea7a0e4f1e3fa52bd6010e685098731966933 jdk7u75-b06 +2e1c7e887c37dd702b2d09a00dacbafd79604e8c jdk7u75-b07 +fe8e75540f0990c6ad9d060c2343ef896cb5bc19 jdk7u75-b08 +512d77cd143798615266314c72c00ee32500661c jdk7u75-b09 +d77d44ecfb980610de2c90446fab13910ed2c8d7 jdk7u75-b10 +b5554ad39fa33c17033931a4ef5564a9b9d88f05 jdk7u75-b11 +6f369f5322618b48225eebcde52ab9dfa552e286 jdk7u75-b12 +7eb2663b7feb537ca765747e7bd0128245812c64 jdk7u75-b13 +059a87205fda11b19d25ace75698a854aa8edbf3 jdk7u75-b30 +591a7e4cabb5c5efc3ec65128181b38b1fa44a96 jdk7u75-b31 +e77dbc24fcdb5c55f414459798e4c65ed75bf570 jdk7u76-b00 +17aaafb2d1ecb6e2dac5e05cb3198703737e623a jdk7u76-b01 +da47e39ce6680458be011936b89f0946b9587042 jdk7u76-b02 +19a2140056ce1bfa3b6b332d168ad1208bfed1ae jdk7u76-b03 +76969bec514e11903a321f556f38c3be4c2320cf jdk7u76-b04 +ae19a85e5b3864b49b123f54b72de93d13722439 jdk7u76-b05 +b981c087098c8c18f5d2632c02a680ef036217c4 jdk7u76-b06 +b09339e2ca2ac75e5ca29e980eac2e7866e463aa jdk7u76-b07 +23a0bb20d74919861201d0d73cd612cabfd8f1f2 jdk7u76-b08 +853bb5d480cab85c9f9f67ff86f8cb95c31e4885 jdk7u76-b09 +11ca0f4b0c56817f6ad302022e6414aa52582f16 jdk7u76-b10 +63c1f23bddcfc45835f224376525ec621ac73a96 jdk7u76-b11 +f0a6f4f62959a43e21d377436e3e60f6431ee5b4 jdk7u76-b12 +d9e79541170f453dda964319f268fdad80dce9d7 jdk7u76-b13 +24f0420bb212b05d572689bae8ec2d232b9ac5a0 jdk7u76-b30 +f260514e9d6fa7d8c9ee96eb7b5496c61f27d830 jdk7u76-b31 772aad4e9681828b8ee193b9ed971cbfe6c7f347 jdk7u80-b00 6c307a0b7a94e002d8a2532ffd8146d6c53f42d3 jdk7u80-b01 3eab691bd9ac5222c11dbabb7b5fbc8463c62df6 icedtea-2.6pre07 @@ -554,3 +595,5 @@ 029dd486cd1a8f6d7684b1633aae41c613055dd2 icedtea-2.6pre15 c802d4cdd4cbfa8116e4f612cf536de32d67221a icedtea-2.6pre16 e1dd8fea9abd3663838008063715b4b7ab5a58a4 icedtea-2.6pre17 +04b56f4312b62d8bdf4eb1159132de8437994d34 jdk7u80-b04 +f40fb76025c798cab4fb0e1966be1bceb8234527 jdk7u80-b05
--- a/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Jan 22 02:55:38 2015 +0000 +++ b/src/share/classes/com/sun/tools/javac/comp/Check.java Thu Jan 29 22:20:25 2015 +0000 @@ -2400,9 +2400,9 @@ } }); for (Scope.Entry e = a.annotationType.type.tsym.members().elems; - e != null; - e = e.sibling) - if (e.sym.kind == MTH) + e != null; + e = e.sibling) + if (e.sym.kind == MTH && e.sym.name != names.clinit) members.add((MethodSymbol) e.sym); // count them off as they're annotated
--- a/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Jan 22 02:55:38 2015 +0000 +++ b/src/share/classes/com/sun/tools/javac/comp/TransTypes.java Thu Jan 29 22:20:25 2015 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, 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 @@ -223,6 +223,12 @@ meth.name, bridgeType, origin); + /* once JDK-6996415 is solved it should be checked if this approach can + * be applied to method addOverrideBridgesIfNeeded + */ + bridge.params = createBridgeParams(impl, bridge, bridgeType); + bridge.attributes_field = impl.attributes_field; + if (!hypothetical) { JCMethodDecl md = make.MethodDef(bridge, null); @@ -257,6 +263,26 @@ overridden.put(bridge, meth); } + private List<VarSymbol> createBridgeParams(MethodSymbol impl, MethodSymbol bridge, + Type bridgeType) { + List<VarSymbol> bridgeParams = null; + if (impl.params != null) { + bridgeParams = List.nil(); + List<VarSymbol> implParams = impl.params; + Type.MethodType mType = (Type.MethodType)bridgeType; + List<Type> argTypes = mType.argtypes; + while (implParams.nonEmpty() && argTypes.nonEmpty()) { + VarSymbol param = new VarSymbol(implParams.head.flags() | SYNTHETIC | PARAMETER, + implParams.head.name, argTypes.head, bridge); + param.attributes_field = implParams.head.attributes_field; + bridgeParams = bridgeParams.append(param); + implParams = implParams.tail; + argTypes = argTypes.tail; + } + } + return bridgeParams; + } + /** Add bridge if given symbol is a non-private, non-static member * of the given class, which is either defined in the class or non-final * inherited, and one of the two following conditions holds:
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Jan 22 02:55:38 2015 +0000 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java Thu Jan 29 22:20:25 2015 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2015, 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 @@ -1541,15 +1541,17 @@ // The method wasn't found: emit a warning and recover JavaFileObject prevSource = log.useSource(requestingOwner.classfile); try { - if (failure == null) { - log.warning("annotation.method.not.found", - container, - name); - } else { - log.warning("annotation.method.not.found.reason", - container, - name, - failure.getDetailValue());//diagnostic, if present + if (lintClassfile) { + if (failure == null) { + log.warning("annotation.method.not.found", + container, + name); + } else { + log.warning("annotation.method.not.found.reason", + container, + name, + failure.getDetailValue()); //diagnostic, if present + } } } finally { log.useSource(prevSource);
--- a/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Thu Jan 22 02:55:38 2015 +0000 +++ b/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Thu Jan 29 22:20:25 2015 +0000 @@ -1012,25 +1012,29 @@ if (code.varBufferSize > 0) { int alenIdx = writeAttr(names.LocalVariableTable); - databuf.appendChar(code.varBufferSize); + databuf.appendChar(code.getLVTSize()); for (int i=0; i<code.varBufferSize; i++) { Code.LocalVar var = code.varBuffer[i]; - - // write variable info - Assert.check(var.start_pc >= 0 - && var.start_pc <= code.cp); - databuf.appendChar(var.start_pc); - Assert.check(var.length >= 0 - && (var.start_pc + var.length) <= code.cp); - databuf.appendChar(var.length); - VarSymbol sym = var.sym; - databuf.appendChar(pool.put(sym.name)); - Type vartype = sym.erasure(types); - if (needsLocalVariableTypeEntry(sym.type)) - nGenericVars++; - databuf.appendChar(pool.put(typeSig(vartype))); - databuf.appendChar(var.reg); + for (Code.LocalVar.Range r: var.aliveRanges) { + // write variable info + if (!(r.start_pc >= 0 && r.start_pc <= code.cp)) { + throw new AssertionError(); + } + databuf.appendChar(r.start_pc); + if (!(r.length >= 0 && (r.start_pc + r.length) <= code.cp)) { + throw new AssertionError(); + } + databuf.appendChar(r.length); + VarSymbol sym = var.sym; + databuf.appendChar(pool.put(sym.name)); + Type vartype = sym.erasure(types); + databuf.appendChar(pool.put(typeSig(vartype))); + databuf.appendChar(var.reg); + if (needsLocalVariableTypeEntry(var.sym.type)) { + nGenericVars++; + } + } } endAttr(alenIdx); acount++; @@ -1046,13 +1050,15 @@ VarSymbol sym = var.sym; if (!needsLocalVariableTypeEntry(sym.type)) continue; - count++; - // write variable info - databuf.appendChar(var.start_pc); - databuf.appendChar(var.length); - databuf.appendChar(pool.put(sym.name)); - databuf.appendChar(pool.put(typeSig(sym.type))); - databuf.appendChar(var.reg); + for (Code.LocalVar.Range r : var.aliveRanges) { + // write variable info + databuf.appendChar(r.start_pc); + databuf.appendChar(r.length); + databuf.appendChar(pool.put(sym.name)); + databuf.appendChar(pool.put(typeSig(sym.type))); + databuf.appendChar(var.reg); + count++; + } } Assert.check(count == nGenericVars); endAttr(alenIdx);
--- a/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Jan 22 02:55:38 2015 +0000 +++ b/src/share/classes/com/sun/tools/javac/jvm/Code.java Thu Jan 29 22:20:25 2015 +0000 @@ -1151,7 +1151,9 @@ public int entryPoint(State state) { int pc = curPc(); alive = true; - this.state = state.dup(); + State newState = state.dup(); + setDefined(newState.defined); + this.state = newState; Assert.check(state.stacksize <= max_stack); if (debugCode) System.err.println("entry point " + state); pendingStackMap = needStackMap; @@ -1164,7 +1166,9 @@ public int entryPoint(State state, Type pushed) { int pc = curPc(); alive = true; - this.state = state.dup(); + State newState = state.dup(); + setDefined(newState.defined); + this.state = newState; Assert.check(state.stacksize <= max_stack); this.state.push(pushed); if (debugCode) System.err.println("entry point " + state); @@ -1452,6 +1456,10 @@ chain.pc + 3 == target && target == cp && !fixedPc) { // If goto the next instruction, the jump is not needed: // compact the code. + if (varDebugInfo) { + adjustAliveRanges(cp, -3); + } + cp = cp - 3; target = target - 3; if (chain.next == null) { @@ -1736,8 +1744,7 @@ sym = sym.clone(sym.owner); sym.type = newtype; LocalVar newlv = lvar[i] = new LocalVar(sym); - // should the following be initialized to cp? - newlv.start_pc = lv.start_pc; + newlv.aliveRanges = lv.aliveRanges; } } } @@ -1825,18 +1832,118 @@ static class LocalVar { final VarSymbol sym; final char reg; - char start_pc = Character.MAX_VALUE; - char length = Character.MAX_VALUE; + + class Range { + char start_pc = Character.MAX_VALUE; + char length = Character.MAX_VALUE; + + Range() {} + + Range(char start) { + this.start_pc = start; + } + + Range(char start, char length) { + this.start_pc = start; + this.length = length; + } + + boolean closed() { + return start_pc != Character.MAX_VALUE && length != Character.MAX_VALUE; + } + + @Override + public String toString() { + int currentStartPC = start_pc; + int currentLength = length; + return "startpc = " + currentStartPC + " length " + currentLength; + } + } + + java.util.List<Range> aliveRanges = new java.util.ArrayList<Range>(); + LocalVar(VarSymbol v) { this.sym = v; this.reg = (char)v.adr; } + public LocalVar dup() { return new LocalVar(sym); } + + Range firstRange() { + return aliveRanges.isEmpty() ? null : aliveRanges.get(0); + } + + Range lastRange() { + return aliveRanges.isEmpty() ? null : aliveRanges.get(aliveRanges.size() - 1); + } + + void removeLastRange() { + Range lastRange = lastRange(); + if (lastRange != null) { + aliveRanges.remove(lastRange); + } + } + + @Override public String toString() { - return "" + sym + " in register " + ((int)reg) + " starts at pc=" + ((int)start_pc) + " length=" + ((int)length); + if (aliveRanges == null) { + return "empty local var"; + } + StringBuilder sb = new StringBuilder().append(sym) + .append(" in register ").append((int)reg).append(" \n"); + for (Range r : aliveRanges) { + sb.append(" starts at pc=").append(Integer.toString(((int)r.start_pc))) + .append(" length=").append(Integer.toString(((int)r.length))) + .append("\n"); + } + return sb.toString(); + } + + public void openRange(char start) { + if (!hasOpenRange()) { + aliveRanges.add(new Range(start)); + } } + + public void closeRange(char length) { + if (isLastRangeInitialized() && length > 0) { + Range range = lastRange(); + if (range != null) { + if (range.length == Character.MAX_VALUE) { + range.length = length; + } + } + } else { + removeLastRange(); + } + } + + public boolean hasOpenRange() { + if (aliveRanges.isEmpty()) { + return false; + } + return lastRange().length == Character.MAX_VALUE; + } + + public boolean isLastRangeInitialized() { + if (aliveRanges.isEmpty()) { + return false; + } + return lastRange().start_pc != Character.MAX_VALUE; + } + + public Range getWidestRange() { + if (aliveRanges.isEmpty()) { + return new Range(); + } else { + Range firstRange = firstRange(); + Range lastRange = lastRange(); + char length = (char)(lastRange.length + (lastRange.start_pc - firstRange.start_pc)); + return new Range(firstRange.start_pc, length); + } + } }; /** Local variables, indexed by register. */ @@ -1858,6 +1965,30 @@ state.defined.excl(adr); } + void adjustAliveRanges(int oldCP, int delta) { + for (LocalVar localVar: lvar) { + if (localVar != null) { + for (LocalVar.Range range: localVar.aliveRanges) { + if (range.closed() && range.start_pc + range.length >= oldCP) { + range.length += delta; + } + } + } + } + } + + /** + * Calculates the size of the LocalVariableTable. + */ + public int getLVTSize() { + int result = varBufferSize; + for (int i = 0; i < varBufferSize; i++) { + LocalVar var = varBuffer[i]; + result += var.aliveRanges.size() - 1; + } + return result; + } + /** Set the current variable defined state. */ public void setDefined(Bits newDefined) { if (alive && newDefined != state.defined) { @@ -1883,8 +2014,7 @@ } else { state.defined.incl(adr); if (cp < Character.MAX_VALUE) { - if (v.start_pc == Character.MAX_VALUE) - v.start_pc = (char)cp; + v.openRange((char)cp); } } } @@ -1894,15 +2024,15 @@ state.defined.excl(adr); if (adr < lvar.length && lvar[adr] != null && - lvar[adr].start_pc != Character.MAX_VALUE) { + lvar[adr].isLastRangeInitialized()) { LocalVar v = lvar[adr]; - char length = (char)(curPc() - v.start_pc); + char length = (char)(curPc()- v.lastRange().start_pc); if (length > 0 && length < Character.MAX_VALUE) { lvar[adr] = v.dup(); - v.length = length; + v.closeRange(length); putVar(v); } else { - v.start_pc = Character.MAX_VALUE; + v.removeLastRange(); } } } @@ -1912,10 +2042,10 @@ LocalVar v = lvar[adr]; if (v != null) { lvar[adr] = null; - if (v.start_pc != Character.MAX_VALUE) { - char length = (char)(curPc() - v.start_pc); + if (v.isLastRangeInitialized()) { + char length = (char)(curPc()- v.lastRange().start_pc); if (length < Character.MAX_VALUE) { - v.length = length; + v.closeRange(length); putVar(v); } }
--- a/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Thu Jan 22 02:55:38 2015 +0000 +++ b/src/share/classes/com/sun/tools/javac/resources/javac_ja.properties Thu Jan 29 22:20:25 2015 +0000 @@ -37,7 +37,7 @@ javac.opt.Xbootclasspath.p=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306B\u4ED8\u52A0\u3059\u308B javac.opt.Xbootclasspath.a=\u30D6\u30FC\u30C8\u30B9\u30C8\u30E9\u30C3\u30D7\u30FB\u30AF\u30E9\u30B9\u30FB\u30D1\u30B9\u306B\u8FFD\u52A0\u3059\u308B javac.opt.endorseddirs=\u63A8\u5968\u898F\u683C\u30D1\u30B9\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B -javac.opt.extdirs=\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u6E08\u307F\u62E1\u5F35\u6A5F\u80FD\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B +javac.opt.extdirs=\u30A4\u30F3\u30B9\u30C8\u30FC\u30EB\u6E08\u62E1\u5F35\u6A5F\u80FD\u306E\u5834\u6240\u3092\u30AA\u30FC\u30D0\u30FC\u30E9\u30A4\u30C9\u3059\u308B javac.opt.processorpath=\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u3092\u691C\u7D22\u3059\u308B\u4F4D\u7F6E\u3092\u6307\u5B9A\u3059\u308B javac.opt.processor=\u5B9F\u884C\u3059\u308B\u6CE8\u91C8\u30D7\u30ED\u30BB\u30C3\u30B5\u306E\u540D\u524D\u3002\u30C7\u30D5\u30A9\u30EB\u30C8\u306E\u691C\u51FA\u51E6\u7406\u3092\u30D0\u30A4\u30D1\u30B9 javac.opt.proc.none.only=\u6CE8\u91C8\u51E6\u7406\u3084\u30B3\u30F3\u30D1\u30A4\u30EB\u3092\u5B9F\u884C\u3059\u308B\u304B\u3069\u3046\u304B\u3092\u5236\u5FA1\u3057\u307E\u3059\u3002
--- a/test/tools/javac/6889255/T6889255.java Thu Jan 22 02:55:38 2015 +0000 +++ b/test/tools/javac/6889255/T6889255.java Thu Jan 29 22:20:25 2015 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, 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 @@ -429,9 +429,9 @@ // -- no Code attribute for the LocalVariableTable attribute if ((v.owner.flags() & Flags.ABSTRACT) != 0) return "arg" + (i - 1); - // bridge methods use xN + // bridge methods use argN. No LVT for them anymore if ((v.owner.flags() & Flags.BRIDGE) != 0) - return "x" + (i - 1); + return "arg" + (i - 1); // The rest of this method assumes the local conventions in the test program Type t = v.type;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/T6695379/AnnotationsAreNotCopiedToBridgeMethodsTest.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,103 @@ +/* + * Copyright (c) 2014, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6695379 + * @summary Copy method annotations and parameter annotations to synthetic + * bridge methods + * @run main AnnotationsAreNotCopiedToBridgeMethodsTest + */ + +import java.lang.annotation.ElementType; +import java.lang.annotation.Target; +import java.io.BufferedInputStream; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +import com.sun.tools.classfile.AccessFlags; +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.Attributes; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.Method; +import com.sun.tools.javac.util.Assert; + +public class AnnotationsAreNotCopiedToBridgeMethodsTest { + + public static void main(String[] args) throws Exception { + new AnnotationsAreNotCopiedToBridgeMethodsTest().run(); + } + + void run() throws Exception { + checkClassFile(Paths.get(System.getProperty("test.classes"), + this.getClass().getSimpleName() + "$CovariantReturnType.class")); + checkClassFile(Paths.get(System.getProperty("test.classes"), + this.getClass().getSimpleName() + + "$CovariantReturnType$VisibilityChange.class")); + } + + void checkClassFile(final Path cfilePath) throws Exception { + ClassFile classFile = ClassFile.read( + new BufferedInputStream(Files.newInputStream(cfilePath))); + for (Method method : classFile.methods) { + if (method.access_flags.is(AccessFlags.ACC_BRIDGE)) { + checkForAttr(method.attributes, + "Annotations hasn't been copied to bridge method", + Attribute.RuntimeVisibleAnnotations, + Attribute.RuntimeVisibleParameterAnnotations); + } + } + } + + void checkForAttr(Attributes attrs, String errorMsg, String... attrNames) { + for (String attrName : attrNames) { + Assert.checkNonNull(attrs.get(attrName), errorMsg); + } + } + + @Target(value = {ElementType.PARAMETER}) + @Retention(RetentionPolicy.RUNTIME) + @interface ParamAnnotation {} + + @Target(value = {ElementType.METHOD}) + @Retention(RetentionPolicy.RUNTIME) + @interface MethodAnnotation {} + + abstract class T<A,B> { + B m(A a){return null;} + } + + class CovariantReturnType extends T<Integer, Integer> { + @MethodAnnotation + Integer m(@ParamAnnotation Integer i) { + return i; + } + + public class VisibilityChange extends CovariantReturnType {} + + } + +}
--- a/test/tools/javac/annotations/6214965/T6214965.java Thu Jan 22 02:55:38 2015 +0000 +++ b/test/tools/javac/annotations/6214965/T6214965.java Thu Jan 29 22:20:25 2015 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, 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 @@ -23,9 +23,10 @@ /** * @test - * @bug 6214965 6365854 + * @bug 6214965 6365854 8068639 * @summary Compiler crash on redefing nested annotation types * @compile CompilerAnnotationTest.java CompilerAnnotationTest2.java * @compile CompilerAnnotationTest2bad.java - * @compile/ref=T6214965.out -XDrawDiagnostics CompilerAnnotationTest2bad.java + * @compile/ref=T6214965.out -XDrawDiagnostics -Xlint:classfile CompilerAnnotationTest2bad.java + * @compile -Werror CompilerAnnotationTest2bad.java */
--- a/test/tools/javac/annotations/6365854/T6365854.java Thu Jan 22 02:55:38 2015 +0000 +++ b/test/tools/javac/annotations/6365854/T6365854.java Thu Jan 29 22:20:25 2015 +0000 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2015, 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 @@ -23,7 +23,7 @@ /** * @test - * @bug 6365854 + * @bug 6365854 8068639 * @summary javac crashes when compiling against an annotated class * @compile TestAnnotation.java TestCore.java * @clean test.annotation.TestAnnotation @@ -33,11 +33,11 @@ * * @compile TestAnnotation.java TestCore.java * @clean test.annotation.TestAnnotation - * @compile/ref=test1.out -XDrawDiagnostics T6365854.java + * @compile/ref=test1.out -XDrawDiagnostics -Xlint:classfile T6365854.java * @run main T6365854 - * @compile/ref=test2.out -XDrawDiagnostics evolve/TestAnnotation.java T6365854.java + * @compile/ref=test2.out -XDrawDiagnostics -Xlint:classfile evolve/TestAnnotation.java T6365854.java * @run main T6365854 - * @compile/ref=test2.out -XDrawDiagnostics T6365854.java + * @compile/ref=test2.out -XDrawDiagnostics -Xlint:classfile T6365854.java * @run main T6365854 */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/clinit/AnnoWithClinit1.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,52 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8013485 + * @summary Annotations that gets a clinit can't be verified for correct elements in a second compilation unit + * @compile AnnoWithClinit1.java + */ + +public @interface AnnoWithClinit1 { + Foo f = new Foo(); + + @AnnoWithClinit1 + static class C {} // this is in the same CU so there wont be a + // <clinit> when the this anno instance is checked + + class Foo {} +} + + +@AnnoWithClinit1 +class BarAnnoClinit1 {} + +@interface AAnnoClinit1 { + Runnable r2 = new Runnable() { public void run() { }}; + String str1(); + String str2withdefault() default "bar"; +} + +@AAnnoClinit1(str1="value") +class TestAnnoClinit1 { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/clinit/AnnoWithClinitFail.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,45 @@ +/* + * Copyright (c) 2013, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8013485 + * @summary Annotations that gets a clinit can't be verified for correct elements in a second compilation unit + * @compile/fail/ref=AnnoWithClinitFail.out -XDrawDiagnostics AnnoWithClinitFail.java + */ + +public @interface AnnoWithClinitFail { + Foo f = new Foo(); + + String foo(); + String bar() default "bar"; + + @AnnoWithClinitFail + static class C {} // this is in the same CU so there wont be a + // <clinit> when the this anno instance is checked + + class Foo {} +} + +@AnnoWithClinitFail +class TestAnnoWithClinitFail { }
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/annotations/clinit/AnnoWithClinitFail.out Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,3 @@ +AnnoWithClinitFail.java:37:5: compiler.err.annotation.missing.default.value: AnnoWithClinitFail, foo +AnnoWithClinitFail.java:44:1: compiler.err.annotation.missing.default.value: AnnoWithClinitFail, foo +2 errors
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/DARanges.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,33 @@ +/* + * Copyright (c) 2014, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ +import java.lang.annotation.*; + +@Target({ElementType.METHOD}) +@interface DARange { + String varName(); + int bytecodeStart(); + int bytecodeLength(); +} + +@Target({ElementType.METHOD}) +@interface DARanges {DARange[] value();}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/LVTHarness.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,290 @@ +/* + * Copyright (c) 2014, 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 8058708 + * @summary The LVT is not generated correctly during some try/catch scenarios + * javac crash while creating LVT entry for a local variable defined in + * an inner block + * @library /tools/javac/lib + * @build JavacTestingAbstractProcessor LVTHarness + * @run main LVTHarness + */ + +import java.io.File; +import java.io.IOException; +import java.lang.annotation.Annotation; +import java.util.Set; +import java.util.Arrays; +import java.util.ArrayList; +import java.util.Collections; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; + +import javax.annotation.processing.RoundEnvironment; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.ToolProvider; + +import com.sun.source.util.JavacTask; +import com.sun.tools.classfile.Attribute; +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.ConstantPool; +import com.sun.tools.classfile.ConstantPoolException; +import com.sun.tools.classfile.Code_attribute; +import com.sun.tools.classfile.ConstantPool.InvalidIndex; +import com.sun.tools.classfile.ConstantPool.UnexpectedEntry; +import com.sun.tools.classfile.Descriptor.InvalidDescriptor; +import com.sun.tools.classfile.LocalVariableTable_attribute; +import com.sun.tools.classfile.Method; + +import static javax.tools.StandardLocation.*; +import static com.sun.tools.classfile.LocalVariableTable_attribute.Entry; +import static javax.tools.JavaFileObject.Kind.SOURCE; + +public class LVTHarness { + + static int nerrors = 0; + + static final JavaCompiler comp = ToolProvider.getSystemJavaCompiler(); + static final StandardJavaFileManager fm = comp.getStandardFileManager(null, null, null); + + public static void main(String[] args) throws Exception { + + String testDir = System.getProperty("test.src"); + fm.setLocation(SOURCE_PATH, Arrays.asList(new File(testDir, "tests"))); + + // Make sure classes are written to scratch dir. + fm.setLocation(CLASS_OUTPUT, Arrays.asList(new File("."))); + + for (JavaFileObject jfo : fm.list(SOURCE_PATH, "", Collections.singleton(SOURCE), true)) { + new LVTHarness(jfo).check(); + } + if (nerrors > 0) { + throw new AssertionError("Errors were found"); + } + } + + + JavaFileObject jfo; + Map<ElementKey, DARanges> aliveRangeMap = new HashMap<ElementKey, DARanges>(); + Set<String> declaredKeys = new HashSet<String>(); + List<ElementKey> seenDARanges = new ArrayList<ElementKey>(); + + protected LVTHarness(JavaFileObject jfo) { + this.jfo = jfo; + } + + protected void check() throws Exception { + + JavacTask ct = (JavacTask) comp.getTask(null, fm, null, Arrays.asList("-g"), + null, Arrays.asList(jfo)); + System.err.println("compiling code " + jfo); + ct.setProcessors(Collections.singleton(new DARangeFinder())); + if (!ct.call()) { + throw new AssertionError("Error during compilation"); + } + + + File javaFile = new File(jfo.getName()); + File classFile = new File(javaFile.getName().replace(".java", ".class")); + checkClassFile(classFile); + + //check all candidates have been used up + for (Map.Entry<ElementKey, DARanges> entry : aliveRangeMap.entrySet()) { + if (!seenDARanges.contains(entry.getKey())) { + error("Redundant @DARanges annotation on method " + + entry.getKey().elem + " with key " + entry.getKey()); + } + } + } + + void checkClassFile(File file) + throws IOException, ConstantPoolException, InvalidDescriptor { + ClassFile classFile = ClassFile.read(file); + ConstantPool constantPool = classFile.constant_pool; + + //lets get all the methods in the class file. + for (Method method : classFile.methods) { + for (ElementKey elementKey: aliveRangeMap.keySet()) { + String methodDesc = method.getName(constantPool) + + method.descriptor.getParameterTypes(constantPool).replace(" ", ""); + if (methodDesc.equals(elementKey.elem.toString())) { + checkMethod(constantPool, method, aliveRangeMap.get(elementKey)); + seenDARanges.add(elementKey); + } + } + } + } + + void checkMethod(ConstantPool constantPool, Method method, DARanges ranges) + throws InvalidIndex, UnexpectedEntry { + Code_attribute code = (Code_attribute) method.attributes.get(Attribute.Code); + LocalVariableTable_attribute lvt = + (LocalVariableTable_attribute) (code.attributes.get(Attribute.LocalVariableTable)); + List<String> infoFromRanges = convertToStringList(ranges); + List<String> infoFromLVT = convertToStringList(constantPool, lvt); + + // infoFromRanges most be contained in infoFromLVT + int i = 0; + int j = 0; + while (i < infoFromRanges.size() && j < infoFromLVT.size()) { + int comparison = infoFromRanges.get(i).compareTo(infoFromLVT.get(j)); + if (comparison == 0) { + i++; j++; + } else if (comparison > 0) { + j++; + } else { + break; + } + } + + if (i < infoFromRanges.size()) { + error(infoFromLVT, infoFromRanges); + } + } + + List<String> convertToStringList(DARanges ranges) { + List<String> result = new ArrayList<String>(); + for (Annotation anno : ranges.value()) { + DARange range = (DARange)anno; + String str = formatLocalVariableData(range.varName(), + range.bytecodeStart(), range.bytecodeLength()); + result.add(str); + } + Collections.sort(result); + return result; + } + + List<String> convertToStringList(ConstantPool constantPool, + LocalVariableTable_attribute lvt) throws InvalidIndex, UnexpectedEntry { + List<String> result = new ArrayList<String>(); + for (Entry entry : lvt.local_variable_table) { + String str = formatLocalVariableData(constantPool.getUTF8Value(entry.name_index), + entry.start_pc, entry.length); + result.add(str); + } + Collections.sort(result); + return result; + } + + String formatLocalVariableData(String varName, int start, int length) { + StringBuilder sb = new StringBuilder() + .append("var name: ").append(varName) + .append(" start: ").append(start) + .append(" length: ").append(length); + return sb.toString(); + } + + protected void error(List<String> infoFromLVT, List<String> infoFromRanges) { + nerrors++; + System.err.printf("Error occurred while checking file: %s\n", jfo.getName()); + System.err.println("The range info from the annotations is"); + printStringListToErrOutput(infoFromRanges); + System.err.println(); + System.err.println("And the range info from the class file is"); + printStringListToErrOutput(infoFromLVT); + System.err.println(); + } + + void printStringListToErrOutput(List<String> list) { + for (String s : list) { + System.err.println("\t" + s); + } + } + + protected void error(String msg) { + nerrors++; + System.err.printf("Error occurred while checking file: %s\nreason: %s\n", + jfo.getName(), msg); + } + + class DARangeFinder extends JavacTestingAbstractProcessor { + + @Override + public boolean process(Set<? extends TypeElement> annotations, + RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) + return true; + + TypeElement aliveRangeAnno = elements.getTypeElement("DARanges"); + + if (!annotations.contains(aliveRangeAnno)) { + error("no @DARanges annotation found in test class"); + } + + for (Element elem: roundEnv.getElementsAnnotatedWith(aliveRangeAnno)) { + Annotation annotation = elem.getAnnotation(DARanges.class); + aliveRangeMap.put(new ElementKey(elem), (DARanges)annotation); + } + return true; + } + } + + class ElementKey { + + String key; + Element elem; + + public ElementKey(Element elem) { + this.elem = elem; + this.key = computeKey(elem); + } + + @Override + public boolean equals(Object obj) { + if (obj instanceof ElementKey) { + ElementKey other = (ElementKey)obj; + return other.key.equals(key); + } + return false; + } + + @Override + public int hashCode() { + return key.hashCode(); + } + + String computeKey(Element e) { + StringBuilder buf = new StringBuilder(); + while (e != null) { + buf.append(e.toString()); + e = e.getEnclosingElement(); + } + buf.append(jfo.getName()); + return buf.toString(); + } + + @Override + public String toString() { + return "Key{" + key + "}"; + } + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/tests/TestCaseConditional.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,15 @@ +public class TestCaseConditional { + @DARanges({ + @DARange(varName="o", bytecodeStart=5, bytecodeLength=33), + @DARange(varName="oo", bytecodeStart=23, bytecodeLength=15) + }) + void m(String[] args) { + Boolean o; + Boolean oo = ((o = Boolean.TRUE).booleanValue()) ? + o = Boolean.TRUE : + Boolean.FALSE; + oo.hashCode(); + o = Boolean.FALSE; + o.hashCode(); + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/tests/TestCaseDoLoop.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,15 @@ +public class TestCaseDoLoop { + + @DARanges({ + @DARange(varName="o", bytecodeStart=3, bytecodeLength=15), + @DARange(varName="args", bytecodeStart=0, bytecodeLength=18) + }) + void m(String[] args) { + Object o; + do { + o = ""; + o.hashCode(); + } while (args[0] != null); + o = ""; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/tests/TestCaseFor.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,29 @@ +public class TestCaseFor { + + @DARanges({ + @DARange(varName="o", bytecodeStart=10, bytecodeLength=11), + @DARange(varName="o", bytecodeStart=24, bytecodeLength=1) + }) + void m1(String[] args) { + Object o; + for (int i = 0; i < 5; i++) { + o = ""; + o.hashCode(); + } + o = ""; + } + + @DARanges({ + @DARange(varName="o", bytecodeStart=10, bytecodeLength=11), + @DARange(varName="o", bytecodeStart=24, bytecodeLength=1) + }) + void m2(String[] args) { + Object o; + for (int i = 0; i < 5; i++) { + o = ""; + o.hashCode(); + continue; + } + o = ""; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/tests/TestCaseForEach.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,15 @@ +public class TestCaseForEach { + + @DARanges({ + @DARange(varName="o", bytecodeStart=25, bytecodeLength=11), + @DARange(varName="o", bytecodeStart=39, bytecodeLength=1) + }) + void m(String[] args) { + Object o; + for (String s : args) { + o = ""; + o.hashCode(); + } + o = ""; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/tests/TestCaseIf.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,84 @@ +public class TestCaseIf { + @DARanges({ + @DARange(varName="o", bytecodeStart=9, bytecodeLength=5), + @DARange(varName="o", bytecodeStart=17, bytecodeLength=1) + }) + void m0(String[] args) { + Object o; + if (args[0] != null) { + o = ""; + o.hashCode(); + } + o = ""; + } + + @DARanges({ + @DARange(varName="o", bytecodeStart=10, bytecodeLength=5), + @DARange(varName="o", bytecodeStart=18, bytecodeLength=1) + }) + void m1() { + Object o; + int i = 5; + if (i == 5) { + o = ""; + o.hashCode(); + } + o = ""; + } + + @DARanges({ + @DARange(varName="o", bytecodeStart=10, bytecodeLength=5), + @DARange(varName="o", bytecodeStart=18, bytecodeLength=1) + }) + void m2() { + Object o; + int i = 5; + if (!(i == 5)) { + o = ""; + o.hashCode(); + } + o = ""; + } + + @DARanges({ + @DARange(varName="o", bytecodeStart=15, bytecodeLength=5), + @DARange(varName="o", bytecodeStart=23, bytecodeLength=1) + }) + void m3(String[] args) { + Object o; + if (args[0] != null && args[1] != null) { + o = ""; + o.hashCode(); + } + o = ""; + } + + @DARanges({ + @DARange(varName="o", bytecodeStart=15, bytecodeLength=5), + @DARange(varName="o", bytecodeStart=23, bytecodeLength=1) + }) + void m4(String[] args) { + Object o; + if (args[0] != null || args[1] != null) { + o = ""; + o.hashCode(); + } + o = ""; + } + + @DARanges({ + @DARange(varName="finalLocal", bytecodeStart=11, bytecodeLength=6), + @DARange(varName="used", bytecodeStart=13, bytecodeLength=4) + }) + void m5(Object o) { + if (o != null) { + Object notUsed; + Object used; + if (o != null) { + final Object finalLocal = null; + used = null; + if (o == null) {} + } + } + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/tests/TestCaseIfElse.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,69 @@ +public class TestCaseIfElse { + + @DARanges({ + @DARange(varName="o", bytecodeStart=9, bytecodeLength=8), + @DARange(varName="o", bytecodeStart=20, bytecodeLength=9) + }) + void m0(String[] args) { + Object o; + if (args[0] != null) { + o = "then"; + o.hashCode(); + } else { + o = "else"; + o.hashCode(); + } + o = "finish"; + } + + @DARanges({ + @DARange(varName="o", bytecodeStart=10, bytecodeLength=8), + @DARange(varName="o", bytecodeStart=21, bytecodeLength=9) + }) + void m1() { + Object o; + int i = 5; + if (i == 5) { + o = "then"; + o.hashCode(); + } else { + o = "else"; + o.hashCode(); + } + o = "finish"; + } + + @DARanges({ + @DARange(varName="o", bytecodeStart=10, bytecodeLength=8), + @DARange(varName="o", bytecodeStart=21, bytecodeLength=9) + }) + void m2() { + Object o; + int i = 5; + if (i != 5) { + o = "then"; + o.hashCode(); + } else { + o = "else"; + o.hashCode(); + } + o = "finish"; + } + + @DARanges({ + @DARange(varName="o", bytecodeStart=11, bytecodeLength=3), + @DARange(varName="o", bytecodeStart=17, bytecodeLength=2) + }) + Object m3(boolean cond1, boolean cond2) { + Object o; + if (cond1) { + if (cond2) { + o = "then"; + } else { + o = "else"; + return null; + } + } + return null; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/tests/TestCaseLocalInInnerBlock.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,20 @@ +public class TestCaseLocalInInnerBlock { + + @DARanges({ + @DARange(varName="fm", bytecodeStart=23, bytecodeLength=10), + @DARange(varName="newWidth", bytecodeStart=2, bytecodeLength=33), + @DARange(varName="tc", bytecodeStart=5, bytecodeLength=30) + }) + int m() { + int newWidth = 0; + String tc = "b"; + if (tc != null) { + String fm; + if (tc.trim() != null) { + } else if ((fm = "b") != null) { + newWidth += fm.length(); + } + } + return newWidth; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/tests/TestCaseSwitch.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,86 @@ +public class TestCaseSwitch { + + @DARanges({ + @DARange(varName="o", bytecodeStart=31, bytecodeLength=16), + @DARange(varName="o", bytecodeStart=50, bytecodeLength=15), + @DARange(varName="o", bytecodeStart=68, bytecodeLength=1), + @DARange(varName="oo", bytecodeStart=39, bytecodeLength=8), + @DARange(varName="uu", bytecodeStart=59, bytecodeLength=6) + }) + void m1(String[] args) { + Object o; + switch (args.length) { + case 0: + o = "0"; + o.hashCode(); + Object oo = "oo"; + oo.hashCode(); + break; + case 1: + o = "1"; + o.hashCode(); + Object uu = "uu"; + uu.hashCode(); + break; + } + o = "return"; + } + + @DARanges({ + @DARange(varName="o", bytecodeStart=35, bytecodeLength=8), + @DARange(varName="o", bytecodeStart=46, bytecodeLength=8), + @DARange(varName="o", bytecodeStart=78, bytecodeLength=5), + @DARange(varName="o", bytecodeStart=86, bytecodeLength=1), + @DARange(varName="oo", bytecodeStart=56, bytecodeLength=16) + }) + void m3(int i) { + Object o; + switch (i) { + case 0: + o = "0"; + o.hashCode(); + break; + case 1: + o = "1"; + o.hashCode(); + break; + case 2: + int oo = i; + if (oo > 1) { + System.out.println("greater"); + } + break; + case 3: + int uu = i; + default: + o = "default"; + o.hashCode(); + } + o = "finish"; + } + + @DARanges({ + @DARange(varName="oCache", bytecodeStart=30, bytecodeLength=6), + @DARange(varName="cache", bytecodeStart=41, bytecodeLength=3), + @DARange(varName="cache", bytecodeStart=54, bytecodeLength=2), + @DARange(varName="service", bytecodeStart=39, bytecodeLength=5) + }) + public Object m(int i) { + Object cache; + switch (i) { + case 0: + Object oCache = null; + if (oCache != null) { + return oCache; + } + case 1: + Object service = null; + cache = null; + break; + default: + throw new AssertionError(""); + } + return cache; + } + +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/tests/TestCaseTry.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,55 @@ +public class TestCaseTry { + + @DARanges({ + @DARange(varName="o", bytecodeStart=3, bytecodeLength=8), + @DARange(varName="o", bytecodeStart=15, bytecodeLength=1) + }) + void m0(String[] args) { + Object o; + try { + o = ""; + o.hashCode(); + } catch (RuntimeException e) {} + o = ""; + } + + @DARanges({ + @DARange(varName="o", bytecodeStart=3, bytecodeLength=16), + @DARange(varName="o", bytecodeStart=23, bytecodeLength=8), + @DARange(varName="o", bytecodeStart=35, bytecodeLength=11) + }) + void m1() { + Object o; + try { + o = ""; + o.hashCode(); + } catch (RuntimeException e) { + } + finally { + o = "finally"; + o.hashCode(); + } + o = ""; + } + + @DARanges({ + @DARange(varName="o", bytecodeStart=3, bytecodeLength=16), + @DARange(varName="o", bytecodeStart=23, bytecodeLength=16), + @DARange(varName="o", bytecodeStart=43, bytecodeLength=11) + }) + void m2() { + Object o; + try { + o = ""; + o.hashCode(); + } catch (RuntimeException e) { + o = "catch"; + o.hashCode(); + } + finally { + o = "finally"; + o.hashCode(); + } + o = ""; + } +}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/tools/javac/flow/tests/TestCaseWhile.java Thu Jan 29 22:20:25 2015 +0000 @@ -0,0 +1,15 @@ +public class TestCaseWhile { + + @DARanges({ + @DARange(varName="o", bytecodeStart=9, bytecodeLength=8), + @DARange(varName="o", bytecodeStart=20, bytecodeLength=1) + }) + void m(String[] args) { + Object o; + while (args[0] != null) { + o = ""; + o.hashCode(); + } + o = ""; + } +}