Mercurial > hg > release > icedtea7-forest-2.6 > jdk
changeset 7013:517a47e66573
Merge
author | asaha |
---|---|
date | Fri, 28 Jun 2013 11:39:50 -0700 |
parents | 2cc729dda2f8 (current diff) 3a8f9e7f331f (diff) |
children | b06abd965701 |
files | .hgtags src/windows/classes/java/lang/ProcessImpl.java test/java/lang/Runtime/exec/ExecCommand.java |
diffstat | 11 files changed, 248 insertions(+), 56 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Tue Jun 25 17:20:25 2013 -0700 +++ b/.hgtags Fri Jun 28 11:39:50 2013 -0700 @@ -323,4 +323,5 @@ 2043900095890e676f5ed0f959f470e2138c2a9a jdk7u40-b28 d3186a0676dbc7ab80e00fa67f952b67933d5a35 jdk7u40-b29 60d52db33828bf0355a94be2a82df90c901592f3 jdk7u40-b30 +c2522d149ff6663ed1d3602c88c286cff25a43a7 jdk7u40-b31 55f01444cf58c8004df9a9634c1bd7ff87caa370 jdk7u25-b32
--- a/src/macosx/native/sun/awt/awt.m Tue Jun 25 17:20:25 2013 -0700 +++ b/src/macosx/native/sun/awt/awt.m Fri Jun 28 11:39:50 2013 -0700 @@ -317,8 +317,11 @@ // its finishLaunching has initialized it. // ApplicationDelegate is the support code for com.apple.eawt. [ThreadUtilities performOnMainThreadWaiting:YES block:^(){ - OSXAPP_SetApplicationDelegate([ApplicationDelegate sharedDelegate]); - }]; + id<NSApplicationDelegate> delegate = [ApplicationDelegate sharedDelegate]; + if (delegate != nil) { + OSXAPP_SetApplicationDelegate(delegate); + } + }]; } }
--- a/src/share/classes/sun/reflect/Reflection.java Tue Jun 25 17:20:25 2013 -0700 +++ b/src/share/classes/sun/reflect/Reflection.java Fri Jun 28 11:39:50 2013 -0700 @@ -65,7 +65,7 @@ @Deprecated @CallerSensitive public static Class getCallerClass(int depth) { - return getCallerClass0(depth); + return getCallerClass0(depth+1); } // If the VM enforces getting caller class with @CallerSensitive,
--- a/src/share/native/sun/font/layout/KernTable.cpp Tue Jun 25 17:20:25 2013 -0700 +++ b/src/share/native/sun/font/layout/KernTable.cpp Fri Jun 28 11:39:50 2013 -0700 @@ -96,7 +96,7 @@ * TODO: respect header flags */ KernTable::KernTable(const LETableReference& base, LEErrorCode &success) - : pairs(), pairsSwapped(NULL), fTable(base) + : pairsSwapped(NULL), fTable(base) { if(LE_FAILURE(success) || (fTable.isEmpty())) { #if DEBUG @@ -143,32 +143,36 @@ #endif if(LE_SUCCESS(success) && nPairs>0) { - // pairs is an instance member, and table is on the stack. - // set 'pairs' based on table.getAlias(). This will range check it. + // pairsSwapped is an instance member, and table is on the stack. + // set 'pairsSwapped' based on table.getAlias(). This will range check it. - pairs = LEReferenceToArrayOf<PairInfo>(fTable, // based on overall table - success, - (const PairInfo*)table.getAlias(), // subtable 0 + .. - KERN_SUBTABLE_0_HEADER_SIZE, // .. offset of header size - nPairs); // count - } - if (LE_SUCCESS(success) && pairs.isValid()) { - pairsSwapped = (PairInfo*)(malloc(nPairs*sizeof(PairInfo))); - PairInfo *p = (PairInfo*)pairsSwapped; - for (int i = 0; LE_SUCCESS(success) && i < nPairs; i++, p++) { - memcpy(p, pairs.getAlias(i,success), KERN_PAIRINFO_SIZE); - p->key = SWAPL(p->key); + pairsSwapped = (PairInfo*)(fTable.getFont()->getKernPairs()); + if (pairsSwapped == NULL) { + LEReferenceToArrayOf<PairInfo>pairs = + LEReferenceToArrayOf<PairInfo>(fTable, // based on overall table + success, + (const PairInfo*)table.getAlias(), // subtable 0 + .. + KERN_SUBTABLE_0_HEADER_SIZE, // .. offset of header size + nPairs); // count + if (LE_SUCCESS(success) && pairs.isValid()) { + pairsSwapped = (PairInfo*)(malloc(nPairs*sizeof(PairInfo))); + PairInfo *p = (PairInfo*)pairsSwapped; + for (int i = 0; LE_SUCCESS(success) && i < nPairs; i++, p++) { + memcpy(p, pairs.getAlias(i,success), KERN_PAIRINFO_SIZE); + p->key = SWAPL(p->key); + } + fTable.getFont()->setKernPairs((void*)pairsSwapped); // store it } - fTable.getFont()->setKernPairs((void*)pairsSwapped); // store it + } } #if 0 - fprintf(stderr, "coverage: %0.4x nPairs: %d pairs %p\n", coverage, nPairs, pairs.getAlias()); + fprintf(stderr, "coverage: %0.4x nPairs: %d pairs %p\n", coverage, nPairs, pairsSwapped); fprintf(stderr, " searchRange: %d entrySelector: %d rangeShift: %d\n", searchRange, entrySelector, rangeShift); fprintf(stderr, "[[ ignored font table entries: range %d selector %d shift %d ]]\n", SWAPW(table->searchRange), SWAPW(table->entrySelector), SWAPW(table->rangeShift)); #endif #if DEBUG - fprintf(stderr, "coverage: %0.4x nPairs: %d pairs 0x%x\n", coverage, nPairs, pairs); + fprintf(stderr, "coverage: %0.4x nPairs: %d pairs 0x%x\n", coverage, nPairs, pairsSwapped); fprintf(stderr, " searchRange(pairs): %d entrySelector: %d rangeShift(pairs): %d\n", searchRange, entrySelector, rangeShift); @@ -182,7 +186,7 @@ ids[id] = (char)i; } } - PairInfo *p = pairs; + PairInfo *p = pairsSwapped; for (int i = 0; i < nPairs; ++i, p++) { le_uint32 k = p->key; le_uint16 left = (k >> 16) & 0xffff;
--- a/src/share/native/sun/font/layout/KernTable.h Tue Jun 25 17:20:25 2013 -0700 +++ b/src/share/native/sun/font/layout/KernTable.h Fri Jun 28 11:39:50 2013 -0700 @@ -57,7 +57,6 @@ private: le_uint16 coverage; le_uint16 nPairs; - LEReferenceToArrayOf<PairInfo> pairs; PairInfo *pairsSwapped; const LETableReference &fTable; le_uint16 searchRange;
--- a/src/share/native/sun/font/layout/LayoutEngine.cpp Tue Jun 25 17:20:25 2013 -0700 +++ b/src/share/native/sun/font/layout/LayoutEngine.cpp Fri Jun 28 11:39:50 2013 -0700 @@ -569,7 +569,6 @@ { if(fGlyphStorage!=NULL) { fGlyphStorage->reset(); - fGlyphStorage = NULL; } }
--- a/src/windows/classes/java/lang/ProcessImpl.java Tue Jun 25 17:20:25 2013 -0700 +++ b/src/windows/classes/java/lang/ProcessImpl.java Fri Jun 28 11:39:50 2013 -0700 @@ -169,7 +169,19 @@ return matchList.toArray(new String[matchList.size()]); } - private static String createCommandLine(boolean isCmdFile, + private static final int VERIFICATION_CMD_BAT = 0; + private static final int VERIFICATION_WIN32 = 1; + private static final int VERIFICATION_LEGACY = 2; + private static final char ESCAPE_VERIFICATION[][] = { + // We guarantee the only command file execution for implicit [cmd.exe] run. + // http://technet.microsoft.com/en-us/library/bb490954.aspx + {' ', '\t', '<', '>', '&', '|', '^'}, + + {' ', '\t', '<', '>'}, + {' ', '\t'} + }; + + private static String createCommandLine(int verificationType, final String executablePath, final String cmd[]) { @@ -180,9 +192,8 @@ for (int i = 1; i < cmd.length; ++i) { cmdbuf.append(' '); String s = cmd[i]; - if (needsEscaping(isCmdFile, s)) { - cmdbuf.append('"'); - cmdbuf.append(s); + if (needsEscaping(verificationType, s)) { + cmdbuf.append('"').append(s); // The code protects the [java.exe] and console command line // parser, that interprets the [\"] combination as an escape @@ -196,7 +207,7 @@ // command line parser. The case of the [""] tail escape // sequence could not be realized due to the argument validation // procedure. - if (!isCmdFile && s.endsWith("\\")) { + if ((verificationType != VERIFICATION_CMD_BAT) && s.endsWith("\\")) { cmdbuf.append('\\'); } cmdbuf.append('"'); @@ -207,11 +218,6 @@ return cmdbuf.toString(); } - // We guarantee the only command file execution for implicit [cmd.exe] run. - // http://technet.microsoft.com/en-us/library/bb490954.aspx - private static final char CMD_BAT_ESCAPE[] = {' ', '\t', '<', '>', '&', '|', '^'}; - private static final char WIN32_EXECUTABLE_ESCAPE[] = {' ', '\t', '<', '>'}; - private static boolean isQuoted(boolean noQuotesInside, String arg, String errorMessage) { int lastPos = arg.length() - 1; @@ -234,7 +240,7 @@ return false; } - private static boolean needsEscaping(boolean isCmdFile, String arg) { + private static boolean needsEscaping(int verificationType, String arg) { // Switch off MS heuristic for internal ["]. // Please, use the explicit [cmd.exe] call // if you need the internal ["]. @@ -242,13 +248,12 @@ // For [.exe] or [.com] file the unpaired/internal ["] // in the argument is not a problem. - boolean argIsQuoted = isQuoted(isCmdFile, arg, - "Argument has embedded quote, use the explicit CMD.EXE call."); + boolean argIsQuoted = isQuoted( + (verificationType == VERIFICATION_CMD_BAT), + arg, "Argument has embedded quote, use the explicit CMD.EXE call."); if (!argIsQuoted) { - char testEscape[] = isCmdFile - ? CMD_BAT_ESCAPE - : WIN32_EXECUTABLE_ESCAPE; + char testEscape[] = ESCAPE_VERIFICATION[verificationType]; for (int i = 0; i < testEscape.length; ++i) { if (arg.indexOf(testEscape[i]) >= 0) { return true; @@ -316,6 +321,7 @@ SecurityManager security = System.getSecurityManager(); boolean allowAmbiguousCommands = false; if (security == null) { + allowAmbiguousCommands = true; String value = System.getProperty("jdk.lang.Process.allowAmbiguousCommands"); if (value != null) allowAmbiguousCommands = !"false".equalsIgnoreCase(value); @@ -326,12 +332,13 @@ // Normalize path if possible. String executablePath = new File(cmd[0]).getPath(); - // No worry about internal and unpaired ["] . - if (needsEscaping(false, executablePath) ) + // No worry about internal, unpaired ["], and redirection/piping. + if (needsEscaping(VERIFICATION_LEGACY, executablePath) ) executablePath = quoteString(executablePath); cmdstr = createCommandLine( - false, //legacy mode doesn't worry about extended verification + //legacy mode doesn't worry about extended verification + VERIFICATION_LEGACY, executablePath, cmd); } else { @@ -368,7 +375,9 @@ // [.exe] extension heuristic. cmdstr = createCommandLine( // We need the extended verification procedure for CMD files. - isShellFile(executablePath), + isShellFile(executablePath) + ? VERIFICATION_CMD_BAT + : VERIFICATION_WIN32, quoteString(executablePath), cmd); }
--- a/src/windows/native/sun/windows/awt_Frame.cpp Tue Jun 25 17:20:25 2013 -0700 +++ b/src/windows/native/sun/windows/awt_Frame.cpp Fri Jun 28 11:39:50 2013 -0700 @@ -354,8 +354,10 @@ if (sm_inSynthesizeFocus) break; // pass it up the WindowProc chain if (!sm_suppressFocusAndActivation && IsEmbeddedFrame()) { - AwtWindow::SynthesizeWmActivate(FALSE, GetHWnd(), NULL); - + HWND oppositeToplevelHWnd = AwtComponent::GetTopLevelParentForWindow((HWND)wParam); + if (oppositeToplevelHWnd != AwtComponent::GetFocusedWindow()) { + AwtWindow::SynthesizeWmActivate(FALSE, GetHWnd(), NULL); + } } else if (sm_restoreFocusAndActivation) { if (AwtComponent::GetFocusedWindow() != NULL) { AwtWindow *focusedWindow = (AwtWindow*)GetComponent(AwtComponent::GetFocusedWindow());
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/java/awt/font/TextLayout/KerningLeak.java Fri Jun 28 11:39:50 2013 -0700 @@ -0,0 +1,57 @@ +/* + * 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 8015334 + * @summary Memory leak with kerning. + */ + +import java.awt.Font; +import java.awt.FontMetrics; +import java.awt.font.FontRenderContext; +import java.awt.font.TextAttribute; +import java.awt.font.TextLayout; +import java.util.HashMap; +import java.util.Map; + +public class KerningLeak { + + public static void main(String[] args) { + Map<TextAttribute, Object> textAttributes = new HashMap<>(); + textAttributes.put(TextAttribute.FAMILY, "Sans Serif"); + textAttributes.put(TextAttribute.SIZE, 12); + textAttributes.put(TextAttribute.KERNING, TextAttribute.KERNING_ON); + Font font = Font.getFont(textAttributes); + int totalAdvance = 0; + FontRenderContext frc = new FontRenderContext(null, false, false); + for (int i = 0; i < 500; i++) { + if (i % 10 == 0) System.out.println("Starting iter " + (i+1)); + for (int j = 0; j <1000; j++) { + TextLayout tl = new TextLayout(Integer.toString(j), font, frc); + totalAdvance += tl.getAdvance(); + } + } + System.out.println("done " + totalAdvance); + } +}
--- a/test/java/lang/Runtime/exec/ExecCommand.java Tue Jun 25 17:20:25 2013 -0700 +++ b/test/java/lang/Runtime/exec/ExecCommand.java Fri Jun 28 11:39:50 2013 -0700 @@ -24,15 +24,18 @@ /** * @test - * @bug 8012453 + * @bug 8012453 8016046 * @run main/othervm ExecCommand * @summary workaround for legacy applications with Runtime.getRuntime().exec(String command) */ import java.io.BufferedWriter; import java.io.File; +import java.io.FileNotFoundException; import java.io.FileWriter; import java.io.IOException; +import java.nio.file.FileSystems; +import java.nio.file.Files; import java.security.AccessControlException; public class ExecCommand { @@ -57,16 +60,22 @@ if ( ncmd.equals(".\\Program") || ncmd.equals("\".\\Program") || ncmd.equals(".\\Program Files\\do.cmd") - || ncmd.equals(".\\Program.cmd")) + || ncmd.equals(".\\Program.cmd") + || ncmd.equals("cmd")) { return; } super.checkExec(cmd); } + + @Override public void checkDelete(String file) {} + @Override public void checkRead(String file) {} } // Parameters for the Runtime.exec calls private static final String TEST_RTE_ARG[] = { + "cmd /C dir > dirOut.txt", + "cmd /C dir > \".\\Program Files\\dirOut.txt\"", ".\\Program Files\\do.cmd", "\".\\Program Files\\doNot.cmd\" arg", "\".\\Program Files\\do.cmd\" arg", @@ -83,15 +92,29 @@ // Golden image for results private static final String TEST_RTE_GI[][] = { - //Pure system | Legacy mode | Legacy mode & SM + //Def Legacy mode, Enforced mode, Set Legacy mode, Set Legacy mode & SM + // [cmd /C dir > dirOut.txt] + new String[]{"Success", + "IOException", // [cmd /C dir ">" dirOut.txt] no redirection + "Success", + "IOException"}, //SM - no legacy mode, bad command + + // [cmd /C dir > ".\Program Files\dirOut.txt"] + new String[]{"Success", + "IOException", // [cmd /C dir ">" ".\Program Files\dirOut.txt"] no redirection + "Success", + "IOException"}, //SM - no legacy mode, bad command + // [.\Program File\do.cmd] - new String[]{"IOException", // [.\Program] not found + new String[]{"Success", + "IOException", // [.\Program] not found "Success", "IOException"}, //SM - no legacy mode [.\Program] - OK // [".\Program File\doNot.cmd" arg] new String[]{"Success", "Success", + "Success", "AccessControlException"}, //SM - [".\Program] - OK, // [.\\Program Files\\doNot.cmd] - Fail @@ -99,14 +122,27 @@ // AccessControlException new String[]{"Success", "Success", + "Success", "Success"}, //SM - [".\Program] - OK, // [.\\Program Files\\do.cmd] - OK // compatibility - new String[]{"Success", "Success", "Success"}, //[".\Program.cmd"] - new String[]{"Success", "Success", "Success"} //[.\Program.cmd] + new String[]{"Success", "Success", "Success", "Success"}, //[".\Program.cmd"] + new String[]{"Success", "Success", "Success", "Success"} //[.\Program.cmd] }; + private static void deleteOut(String path) { + try { + Files.delete(FileSystems.getDefault().getPath(path)); + } catch (IOException ex) { + //that is OK + } + } + private static void checkOut(String path) throws FileNotFoundException { + if (Files.notExists(FileSystems.getDefault().getPath(path))) + throw new FileNotFoundException(path); + } + public static void main(String[] _args) throws Exception { if (!System.getProperty("os.name").startsWith("Windows")) { return; @@ -126,20 +162,51 @@ } // action - for (int k = 0; k < 3; ++k) { + for (int k = 0; k < 4; ++k) { switch (k) { + case 0: + // the "jdk.lang.Process.allowAmbiguousCommands" is undefined + // "true" by default with the legacy verification procedure + break; case 1: + System.setProperty("jdk.lang.Process.allowAmbiguousCommands", "false"); + break; + case 2: System.setProperty("jdk.lang.Process.allowAmbiguousCommands", ""); break; - case 2: + case 3: System.setSecurityManager( new SecurityMan() ); break; } for (int i = 0; i < TEST_RTE_ARG.length; ++i) { String outRes; try { + // tear up + switch (i) { + case 0: + // [cmd /C dir > dirOut.txt] + deleteOut(".\\dirOut.txt"); + break; + case 1: + // [cmd /C dir > ".\Program Files\dirOut.txt"] + deleteOut(".\\Program Files\\dirOut.txt"); + break; + } + Process exec = Runtime.getRuntime().exec(TEST_RTE_ARG[i]); exec.waitFor(); + + //exteded check + switch (i) { + case 0: + // [cmd /C dir > dirOut.txt] + checkOut(".\\dirOut.txt"); + break; + case 1: + // [cmd /C dir > ".\Program Files\dirOut.txt"] + checkOut(".\\Program Files\\dirOut.txt"); + break; + } outRes = "Success"; } catch (IOException ioe) { outRes = "IOException: " + ioe.getMessage(); @@ -150,8 +217,8 @@ } if (!outRes.startsWith(TEST_RTE_GI[i][k])) { - throw new Error("Unexpected output! Step" + k + "" + i - + " \nArgument: " + TEST_RTE_ARG[i] + throw new Error("Unexpected output! Step" + k + ":" + i + + "\nArgument: " + TEST_RTE_ARG[i] + "\nExpected: " + TEST_RTE_GI[i][k] + "\n Output: " + outRes); } else {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/test/sun/reflect/GetCallerClass.java Fri Jun 28 11:39:50 2013 -0700 @@ -0,0 +1,51 @@ +/* + * 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 8016814 + * @summary Test sun.reflect.Reflection.getCallerClass(int) + * @compile -XDignore.symbol.file GetCallerClass.java + * @run main GetCallerClass + */ + +public class GetCallerClass { + public static void main(String[] args) throws Exception { + Class<?> c = Temp.test(); + if (c != GetCallerClass.class) { + throw new RuntimeException("Incorrect caller: " + c); + } + } + + @sun.reflect.CallerSensitive + public Class<?> getCallerClass() { + // 0: Reflection 1: getCallerClass 2: Temp.test 3: main + return sun.reflect.Reflection.getCallerClass(3); + } + + static class Temp { + public static Class<?> test() { + return new GetCallerClass().getCallerClass(); + } + } +}