diff -r 000000000000 -r c880a8a8803b rt/emul/compact/src/main/java/java/lang/invoke/ProxyClassesDumper.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/rt/emul/compact/src/main/java/java/lang/invoke/ProxyClassesDumper.java Sat Aug 09 11:11:13 2014 +0200 @@ -0,0 +1,147 @@ +/* + * 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. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * 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. + */ +package java.lang.invoke; + +import sun.util.logging.PlatformLogger; + +import java.io.FilePermission; +import java.nio.file.Files; +import java.nio.file.InvalidPathException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.security.AccessController; +import java.security.PrivilegedAction; +import java.util.Objects; +import java.util.concurrent.atomic.AtomicBoolean; + +/** + * Helper class used by InnerClassLambdaMetafactory to log generated classes + * + * @implNote + *
Because this class is called by LambdaMetafactory, make use
+ * of lambda lead to recursive calls cause stack overflow.
+ */
+final class ProxyClassesDumper {
+ private static final char[] HEX = {
+ '0', '1', '2', '3', '4', '5', '6', '7',
+ '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'
+ };
+ private static final char[] BAD_CHARS = {
+ '\\', ':', '*', '?', '"', '<', '>', '|'
+ };
+ private static final String[] REPLACEMENT = {
+ "%5C", "%3A", "%2A", "%3F", "%22", "%3C", "%3E", "%7C"
+ };
+
+ private final Path dumpDir;
+
+ public static ProxyClassesDumper getInstance(String path) {
+ if (null == path) {
+ return null;
+ }
+ try {
+ path = path.trim();
+ final Path dir = Paths.get(path.length() == 0 ? "." : path);
+ AccessController.doPrivileged(new PrivilegedAction