Merge
This commit is contained in:
commit
404c4add66
@ -176,7 +176,6 @@ $(eval $(call SetupDemo,FullThreadDump,management,,FullThreadDump,,,README*))
|
|||||||
$(eval $(call SetupDemo,JTop,management,,JTop,,,README*))
|
$(eval $(call SetupDemo,JTop,management,,JTop,,,README*))
|
||||||
$(eval $(call SetupDemo,MemoryMonitor,management,,MemoryMonitor,,,README*))
|
$(eval $(call SetupDemo,MemoryMonitor,management,,MemoryMonitor,,,README*))
|
||||||
$(eval $(call SetupDemo,VerboseGC,management,,VerboseGC,,,README*))
|
$(eval $(call SetupDemo,VerboseGC,management,,VerboseGC,,,README*))
|
||||||
$(eval $(call SetupDemo,zipfs,nio,,,,,README* *.java,,,,Main-Class: \n))
|
|
||||||
|
|
||||||
ifndef OPENJDK
|
ifndef OPENJDK
|
||||||
$(eval $(call SetupDemo,Laffy,jfc,,,,closed/,*))
|
$(eval $(call SetupDemo,Laffy,jfc,,,,closed/,*))
|
||||||
|
@ -158,15 +158,6 @@ COPY_FILES += $(CURSORS_TARGET_FILES)
|
|||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
CONTENT_TYPES_SRC = $(JDK_TOPDIR)/src/$(OPENJDK_TARGET_OS_API_DIR)/lib
|
|
||||||
|
|
||||||
$(LIBDIR)/content-types.properties: $(CONTENT_TYPES_SRC)/content-types.properties
|
|
||||||
$(call install-file)
|
|
||||||
|
|
||||||
COPY_FILES += $(LIBDIR)/content-types.properties
|
|
||||||
|
|
||||||
##########################################################################################
|
|
||||||
|
|
||||||
CALENDARS_SRC := $(JDK_TOPDIR)/src/share/lib
|
CALENDARS_SRC := $(JDK_TOPDIR)/src/share/lib
|
||||||
|
|
||||||
$(LIBDIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties
|
$(LIBDIR)/calendars.properties: $(CALENDARS_SRC)/calendars.properties
|
||||||
|
@ -26,7 +26,7 @@
|
|||||||
# Copy icu and _dict files used by the text break iterator
|
# Copy icu and _dict files used by the text break iterator
|
||||||
|
|
||||||
COPY_PATTERNS := .icu _dict .dat _options .js aliasmap .spp .wav .css \
|
COPY_PATTERNS := .icu _dict .dat _options .js aliasmap .spp .wav .css \
|
||||||
.png .gif .xml .dtd .txt oqlhelp.html
|
.png .gif .xml .dtd .txt oqlhelp.html content-types.properties
|
||||||
|
|
||||||
# These directories should not be copied at all
|
# These directories should not be copied at all
|
||||||
EXCLUDES += \
|
EXCLUDES += \
|
||||||
|
@ -160,11 +160,13 @@ RT_JAR_EXCLUDES += \
|
|||||||
javax/swing/JWindowBeanInfo.class \
|
javax/swing/JWindowBeanInfo.class \
|
||||||
javax/swing/SwingBeanInfoBase.class \
|
javax/swing/SwingBeanInfoBase.class \
|
||||||
javax/swing/text/JTextComponentBeanInfo.class \
|
javax/swing/text/JTextComponentBeanInfo.class \
|
||||||
|
jdk/nio/zipfs \
|
||||||
META-INF/services/com.sun.jdi.connect.Connector \
|
META-INF/services/com.sun.jdi.connect.Connector \
|
||||||
META-INF/services/com.sun.jdi.connect.spi.TransportService \
|
META-INF/services/com.sun.jdi.connect.spi.TransportService \
|
||||||
META-INF/services/com.sun.tools.attach.spi.AttachProvider \
|
META-INF/services/com.sun.tools.attach.spi.AttachProvider \
|
||||||
META-INF/services/com.sun.tools.xjc.Plugin \
|
META-INF/services/com.sun.tools.xjc.Plugin \
|
||||||
META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor \
|
META-INF/services/sun.net.spi.nameservice.NameServiceDescriptor \
|
||||||
|
META-INF/services/java.nio.file.spi.FileSystemProvider \
|
||||||
org/relaxng/datatype \
|
org/relaxng/datatype \
|
||||||
sun/awt/HKSCS.class \
|
sun/awt/HKSCS.class \
|
||||||
sun/awt/motif/X11GB2312.class \
|
sun/awt/motif/X11GB2312.class \
|
||||||
@ -356,6 +358,16 @@ $(eval $(call SetupArchive,BUILD_CHARSETS_JAR, , \
|
|||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
|
$(eval $(call SetupArchive,BUILD_ZIPFS_JAR, , \
|
||||||
|
SRCS := $(JDK_OUTPUTDIR)/classes, \
|
||||||
|
INCLUDES := jdk/nio/zipfs, \
|
||||||
|
EXTRA_FILES := META-INF/services/java.nio.file.spi.FileSystemProvider, \
|
||||||
|
JAR := $(IMAGES_OUTPUTDIR)/lib/ext/zipfs.jar, \
|
||||||
|
SKIP_METAINF := true, \
|
||||||
|
CHECK_COMPRESS_JAR := true))
|
||||||
|
|
||||||
|
##########################################################################################
|
||||||
|
|
||||||
ifndef OPENJDK
|
ifndef OPENJDK
|
||||||
ifeq ($(ENABLE_JFR), true)
|
ifeq ($(ENABLE_JFR), true)
|
||||||
$(eval $(call SetupArchive,BUILD_JFR_JAR, , \
|
$(eval $(call SetupArchive,BUILD_JFR_JAR, , \
|
||||||
@ -660,11 +672,6 @@ $(IMAGES_OUTPUTDIR)/lib/management-agent.jar: $(JDK_TOPDIR)/src/share/classes/su
|
|||||||
|
|
||||||
##########################################################################################
|
##########################################################################################
|
||||||
|
|
||||||
$(IMAGES_OUTPUTDIR)/lib/ext/zipfs.jar: $(JDK_OUTPUTDIR)/demo/nio/zipfs/zipfs.jar
|
|
||||||
$(install-file)
|
|
||||||
|
|
||||||
##########################################################################################
|
|
||||||
|
|
||||||
# This file is imported from hotspot in Import.gmk. Copying it into images/lib so that
|
# This file is imported from hotspot in Import.gmk. Copying it into images/lib so that
|
||||||
# all jars can be found in one place when creating images in Images.gmk. It needs to be
|
# all jars can be found in one place when creating images in Images.gmk. It needs to be
|
||||||
# done here so that clean targets can be simple and accurate.
|
# done here so that clean targets can be simple and accurate.
|
||||||
|
@ -1079,7 +1079,7 @@ JDWP "Java(tm) Debug Wire Protocol"
|
|||||||
(Command InvokeMethod=3
|
(Command InvokeMethod=3
|
||||||
"Invokes a static method. "
|
"Invokes a static method. "
|
||||||
"The method must be member of the class type "
|
"The method must be member of the class type "
|
||||||
"or one of its superclasses, superinterfaces, or implemented interfaces. "
|
"or one of its superclasses. "
|
||||||
"Access control is not enforced; for example, private "
|
"Access control is not enforced; for example, private "
|
||||||
"methods can be invoked."
|
"methods can be invoked."
|
||||||
"<p>"
|
"<p>"
|
||||||
|
@ -56,7 +56,6 @@ PROFILE_1_JRE_LIB_FILES := \
|
|||||||
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \
|
$(OPENJDK_TARGET_CPU_LEGACY_LIB)/server/Xusage.txt \
|
||||||
calendars.properties \
|
calendars.properties \
|
||||||
classlist \
|
classlist \
|
||||||
content-types.properties \
|
|
||||||
currency.data \
|
currency.data \
|
||||||
ext/localedata.jar \
|
ext/localedata.jar \
|
||||||
ext/meta-index \
|
ext/meta-index \
|
||||||
|
@ -27,6 +27,8 @@ package sun.font;
|
|||||||
|
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
@ -38,6 +40,7 @@ import javax.swing.plaf.FontUIResource;
|
|||||||
|
|
||||||
import sun.awt.FontConfiguration;
|
import sun.awt.FontConfiguration;
|
||||||
import sun.awt.HeadlessToolkit;
|
import sun.awt.HeadlessToolkit;
|
||||||
|
import sun.misc.ThreadGroupUtils;
|
||||||
import sun.lwawt.macosx.*;
|
import sun.lwawt.macosx.*;
|
||||||
|
|
||||||
public class CFontManager extends SunFontManager {
|
public class CFontManager extends SunFontManager {
|
||||||
@ -215,24 +218,19 @@ public class CFontManager extends SunFontManager {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
java.security.AccessController.doPrivileged(
|
AccessController.doPrivileged(
|
||||||
new java.security.PrivilegedAction<Object>() {
|
(PrivilegedAction<Void>) () -> {
|
||||||
public Object run() {
|
/* The thread must be a member of a thread group
|
||||||
/* The thread must be a member of a thread group
|
* which will not get GCed before VM exit.
|
||||||
* which will not get GCed before VM exit.
|
* Make its parent the top-level thread group.
|
||||||
* Make its parent the top-level thread group.
|
*/
|
||||||
*/
|
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||||
ThreadGroup tg =
|
fileCloser = new Thread(rootTG, fileCloserRunnable);
|
||||||
Thread.currentThread().getThreadGroup();
|
fileCloser.setContextClassLoader(null);
|
||||||
for (ThreadGroup tgn = tg;
|
Runtime.getRuntime().addShutdownHook(fileCloser);
|
||||||
tgn != null;
|
return null;
|
||||||
tg = tgn, tgn = tg.getParent());
|
}
|
||||||
fileCloser = new Thread(tg, fileCloserRunnable);
|
);
|
||||||
fileCloser.setContextClassLoader(null);
|
|
||||||
Runtime.getRuntime().addShutdownHook(fileCloser);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -35,6 +35,7 @@ import java.util.*;
|
|||||||
|
|
||||||
import sun.awt.*;
|
import sun.awt.*;
|
||||||
import sun.print.*;
|
import sun.print.*;
|
||||||
|
import sun.misc.ThreadGroupUtils;
|
||||||
|
|
||||||
import static sun.lwawt.LWWindowPeer.PeerType;
|
import static sun.lwawt.LWWindowPeer.PeerType;
|
||||||
|
|
||||||
@ -70,30 +71,17 @@ public abstract class LWToolkit extends SunToolkit implements Runnable {
|
|||||||
protected final void init() {
|
protected final void init() {
|
||||||
AWTAutoShutdown.notifyToolkitThreadBusy();
|
AWTAutoShutdown.notifyToolkitThreadBusy();
|
||||||
|
|
||||||
ThreadGroup mainTG = AccessController.doPrivileged(
|
ThreadGroup rootTG = AccessController.doPrivileged(
|
||||||
new PrivilegedAction<ThreadGroup>() {
|
(PrivilegedAction<ThreadGroup>) ThreadGroupUtils::getRootThreadGroup);
|
||||||
public ThreadGroup run() {
|
|
||||||
ThreadGroup currentTG = Thread.currentThread().getThreadGroup();
|
|
||||||
ThreadGroup parentTG = currentTG.getParent();
|
|
||||||
while (parentTG != null) {
|
|
||||||
currentTG = parentTG;
|
|
||||||
parentTG = currentTG.getParent();
|
|
||||||
}
|
|
||||||
return currentTG;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
|
|
||||||
Runtime.getRuntime().addShutdownHook(
|
Runtime.getRuntime().addShutdownHook(
|
||||||
new Thread(mainTG, new Runnable() {
|
new Thread(rootTG, () -> {
|
||||||
public void run() {
|
shutdown();
|
||||||
shutdown();
|
waitForRunState(STATE_CLEANUP);
|
||||||
waitForRunState(STATE_CLEANUP);
|
|
||||||
}
|
|
||||||
})
|
})
|
||||||
);
|
);
|
||||||
|
|
||||||
Thread toolkitThread = new Thread(mainTG, this, "AWT-LW");
|
Thread toolkitThread = new Thread(rootTG, this, "AWT-LW");
|
||||||
toolkitThread.setDaemon(true);
|
toolkitThread.setDaemon(true);
|
||||||
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
|
toolkitThread.setPriority(Thread.NORM_PRIORITY + 1);
|
||||||
toolkitThread.start();
|
toolkitThread.start();
|
||||||
|
@ -58,7 +58,7 @@ final class CClipboard extends SunClipboard {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
protected void setContentsNative(Transferable contents) {
|
protected void setContentsNative(Transferable contents) {
|
||||||
|
FlavorTable flavorMap = getDefaultFlavorTable();
|
||||||
// Don't use delayed Clipboard rendering for the Transferable's data.
|
// Don't use delayed Clipboard rendering for the Transferable's data.
|
||||||
// If we did that, we would call Transferable.getTransferData on
|
// If we did that, we would call Transferable.getTransferData on
|
||||||
// the Toolkit thread, which is a security hole.
|
// the Toolkit thread, which is a security hole.
|
||||||
|
@ -483,8 +483,12 @@ public final class LWCToolkit extends LWToolkit {
|
|||||||
private static final String APPKIT_THREAD_NAME = "AppKit Thread";
|
private static final String APPKIT_THREAD_NAME = "AppKit Thread";
|
||||||
|
|
||||||
// Intended to be called from the LWCToolkit.m only.
|
// Intended to be called from the LWCToolkit.m only.
|
||||||
private static void installToolkitThreadNameInJava() {
|
private static void installToolkitThreadInJava() {
|
||||||
Thread.currentThread().setName(APPKIT_THREAD_NAME);
|
Thread.currentThread().setName(APPKIT_THREAD_NAME);
|
||||||
|
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||||
|
Thread.currentThread().setContextClassLoader(null);
|
||||||
|
return null;
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
@ -1,276 +0,0 @@
|
|||||||
#sun.net.www MIME content-types table
|
|
||||||
#
|
|
||||||
# Property fields:
|
|
||||||
#
|
|
||||||
# <description> ::= 'description' '=' <descriptive string>
|
|
||||||
# <extensions> ::= 'file_extensions' '=' <comma-delimited list, include '.'>
|
|
||||||
# <image> ::= 'icon' '=' <filename of icon image>
|
|
||||||
# <action> ::= 'browser' | 'application' | 'save' | 'unknown'
|
|
||||||
# <application> ::= 'application' '=' <command line template>
|
|
||||||
#
|
|
||||||
|
|
||||||
#
|
|
||||||
# The "we don't know anything about this data" type(s).
|
|
||||||
# Used internally to mark unrecognized types.
|
|
||||||
#
|
|
||||||
content/unknown: description=Unknown Content
|
|
||||||
unknown/unknown: description=Unknown Data Type
|
|
||||||
|
|
||||||
#
|
|
||||||
# The template we should use for temporary files when launching an application
|
|
||||||
# to view a document of given type.
|
|
||||||
#
|
|
||||||
temp.file.template: /tmp/%s
|
|
||||||
|
|
||||||
#
|
|
||||||
# The "real" types.
|
|
||||||
#
|
|
||||||
application/octet-stream: \
|
|
||||||
description=Generic Binary Stream;\
|
|
||||||
file_extensions=.saveme,.dump,.hqx,.arc,.o,.a,.bin,.exe,.z,.gz
|
|
||||||
|
|
||||||
application/oda: \
|
|
||||||
description=ODA Document;\
|
|
||||||
file_extensions=.oda
|
|
||||||
|
|
||||||
application/pdf: \
|
|
||||||
description=Adobe PDF Format;\
|
|
||||||
file_extensions=.pdf
|
|
||||||
|
|
||||||
application/postscript: \
|
|
||||||
description=Postscript File;\
|
|
||||||
file_extensions=.eps,.ai,.ps;\
|
|
||||||
icon=ps;\
|
|
||||||
action=application;\
|
|
||||||
application=imagetool %s
|
|
||||||
|
|
||||||
application/x-dvi: \
|
|
||||||
description=TeX DVI File;\
|
|
||||||
file_extensions=.dvi;\
|
|
||||||
action=application;\
|
|
||||||
application=xdvi %s
|
|
||||||
|
|
||||||
application/x-hdf: \
|
|
||||||
description=Hierarchical Data Format;\
|
|
||||||
file_extensions=.hdf;\
|
|
||||||
action=save
|
|
||||||
|
|
||||||
application/x-latex: \
|
|
||||||
description=LaTeX Source;\
|
|
||||||
file_extensions=.latex
|
|
||||||
|
|
||||||
application/x-netcdf: \
|
|
||||||
description=Unidata netCDF Data Format;\
|
|
||||||
file_extensions=.nc,.cdf;\
|
|
||||||
action=save
|
|
||||||
|
|
||||||
application/x-tex: \
|
|
||||||
description=TeX Source;\
|
|
||||||
file_extensions=.tex
|
|
||||||
|
|
||||||
application/x-texinfo: \
|
|
||||||
description=Gnu Texinfo;\
|
|
||||||
file_extensions=.texinfo,.texi
|
|
||||||
|
|
||||||
application/x-troff: \
|
|
||||||
description=Troff Source;\
|
|
||||||
file_extensions=.t,.tr,.roff;\
|
|
||||||
action=application;\
|
|
||||||
application=xterm -title troff -e sh -c \"nroff %s | col | more -w\"
|
|
||||||
|
|
||||||
application/x-troff-man: \
|
|
||||||
description=Troff Manpage Source;\
|
|
||||||
file_extensions=.man;\
|
|
||||||
action=application;\
|
|
||||||
application=xterm -title troff -e sh -c \"nroff -man %s | col | more -w\"
|
|
||||||
|
|
||||||
application/x-troff-me: \
|
|
||||||
description=Troff ME Macros;\
|
|
||||||
file_extensions=.me;\
|
|
||||||
action=application;\
|
|
||||||
application=xterm -title troff -e sh -c \"nroff -me %s | col | more -w\"
|
|
||||||
|
|
||||||
application/x-troff-ms: \
|
|
||||||
description=Troff MS Macros;\
|
|
||||||
file_extensions=.ms;\
|
|
||||||
action=application;\
|
|
||||||
application=xterm -title troff -e sh -c \"nroff -ms %s | col | more -w\"
|
|
||||||
|
|
||||||
application/x-wais-source: \
|
|
||||||
description=Wais Source;\
|
|
||||||
file_extensions=.src,.wsrc
|
|
||||||
|
|
||||||
application/zip: \
|
|
||||||
description=Zip File;\
|
|
||||||
file_extensions=.zip;\
|
|
||||||
icon=zip;\
|
|
||||||
action=save
|
|
||||||
|
|
||||||
application/x-bcpio: \
|
|
||||||
description=Old Binary CPIO Archive;\
|
|
||||||
file_extensions=.bcpio; action=save
|
|
||||||
|
|
||||||
application/x-cpio: \
|
|
||||||
description=Unix CPIO Archive;\
|
|
||||||
file_extensions=.cpio; action=save
|
|
||||||
|
|
||||||
application/x-gtar: \
|
|
||||||
description=Gnu Tar Archive;\
|
|
||||||
file_extensions=.gtar;\
|
|
||||||
icon=tar;\
|
|
||||||
action=save
|
|
||||||
|
|
||||||
application/x-shar: \
|
|
||||||
description=Shell Archive;\
|
|
||||||
file_extensions=.sh,.shar;\
|
|
||||||
action=save
|
|
||||||
|
|
||||||
application/x-sv4cpio: \
|
|
||||||
description=SVR4 CPIO Archive;\
|
|
||||||
file_extensions=.sv4cpio; action=save
|
|
||||||
|
|
||||||
application/x-sv4crc: \
|
|
||||||
description=SVR4 CPIO with CRC;\
|
|
||||||
file_extensions=.sv4crc; action=save
|
|
||||||
|
|
||||||
application/x-tar: \
|
|
||||||
description=Tar Archive;\
|
|
||||||
file_extensions=.tar;\
|
|
||||||
icon=tar;\
|
|
||||||
action=save
|
|
||||||
|
|
||||||
application/x-ustar: \
|
|
||||||
description=US Tar Archive;\
|
|
||||||
file_extensions=.ustar;\
|
|
||||||
action=save
|
|
||||||
|
|
||||||
audio/basic: \
|
|
||||||
description=Basic Audio;\
|
|
||||||
file_extensions=.snd,.au;\
|
|
||||||
icon=audio;\
|
|
||||||
action=application;\
|
|
||||||
application=audiotool %s
|
|
||||||
|
|
||||||
audio/x-aiff: \
|
|
||||||
description=Audio Interchange Format File;\
|
|
||||||
file_extensions=.aifc,.aif,.aiff;\
|
|
||||||
icon=aiff
|
|
||||||
|
|
||||||
audio/x-wav: \
|
|
||||||
description=Wav Audio;\
|
|
||||||
file_extensions=.wav;\
|
|
||||||
icon=wav
|
|
||||||
|
|
||||||
image/gif: \
|
|
||||||
description=GIF Image;\
|
|
||||||
file_extensions=.gif;\
|
|
||||||
icon=gif;\
|
|
||||||
action=browser
|
|
||||||
|
|
||||||
image/ief: \
|
|
||||||
description=Image Exchange Format;\
|
|
||||||
file_extensions=.ief
|
|
||||||
|
|
||||||
image/jpeg: \
|
|
||||||
description=JPEG Image;\
|
|
||||||
file_extensions=.jfif,.jfif-tbnl,.jpe,.jpg,.jpeg;\
|
|
||||||
icon=jpeg;\
|
|
||||||
action=browser;\
|
|
||||||
application=imagetool %s
|
|
||||||
|
|
||||||
image/tiff: \
|
|
||||||
description=TIFF Image;\
|
|
||||||
file_extensions=.tif,.tiff;\
|
|
||||||
icon=tiff
|
|
||||||
|
|
||||||
image/vnd.fpx: \
|
|
||||||
description=FlashPix Image;\
|
|
||||||
file_extensions=.fpx,.fpix
|
|
||||||
|
|
||||||
image/x-cmu-rast: \
|
|
||||||
description=CMU Raster Image;\
|
|
||||||
file_extensions=.ras
|
|
||||||
|
|
||||||
image/x-portable-anymap: \
|
|
||||||
description=PBM Anymap Format;\
|
|
||||||
file_extensions=.pnm
|
|
||||||
|
|
||||||
image/x-portable-bitmap: \
|
|
||||||
description=PBM Bitmap Format;\
|
|
||||||
file_extensions=.pbm
|
|
||||||
|
|
||||||
image/x-portable-graymap: \
|
|
||||||
description=PBM Graymap Format;\
|
|
||||||
file_extensions=.pgm
|
|
||||||
|
|
||||||
image/x-portable-pixmap: \
|
|
||||||
description=PBM Pixmap Format;\
|
|
||||||
file_extensions=.ppm
|
|
||||||
|
|
||||||
image/x-rgb: \
|
|
||||||
description=RGB Image;\
|
|
||||||
file_extensions=.rgb
|
|
||||||
|
|
||||||
image/x-xbitmap: \
|
|
||||||
description=X Bitmap Image;\
|
|
||||||
file_extensions=.xbm,.xpm
|
|
||||||
|
|
||||||
image/x-xwindowdump: \
|
|
||||||
description=X Window Dump Image;\
|
|
||||||
file_extensions=.xwd
|
|
||||||
|
|
||||||
image/png: \
|
|
||||||
description=PNG Image;\
|
|
||||||
file_extensions=.png;\
|
|
||||||
icon=png;\
|
|
||||||
action=browser
|
|
||||||
|
|
||||||
text/html: \
|
|
||||||
description=HTML Document;\
|
|
||||||
file_extensions=.htm,.html;\
|
|
||||||
icon=html
|
|
||||||
|
|
||||||
text/plain: \
|
|
||||||
description=Plain Text;\
|
|
||||||
file_extensions=.text,.c,.cc,.c++,.h,.pl,.txt,.java,.el;\
|
|
||||||
icon=text;\
|
|
||||||
action=browser
|
|
||||||
|
|
||||||
text/tab-separated-values: \
|
|
||||||
description=Tab Separated Values Text;\
|
|
||||||
file_extensions=.tsv
|
|
||||||
|
|
||||||
text/x-setext: \
|
|
||||||
description=Structure Enhanced Text;\
|
|
||||||
file_extensions=.etx
|
|
||||||
|
|
||||||
video/mpeg: \
|
|
||||||
description=MPEG Video Clip;\
|
|
||||||
file_extensions=.mpg,.mpe,.mpeg;\
|
|
||||||
icon=mpeg;\
|
|
||||||
action=application;\
|
|
||||||
application=mpeg_play %s
|
|
||||||
|
|
||||||
video/quicktime: \
|
|
||||||
description=QuickTime Video Clip;\
|
|
||||||
file_extensions=.mov,.qt
|
|
||||||
|
|
||||||
application/x-troff-msvideo: \
|
|
||||||
description=AVI Video;\
|
|
||||||
file_extensions=.avi;\
|
|
||||||
icon=avi
|
|
||||||
|
|
||||||
video/x-sgi-movie: \
|
|
||||||
description=SGI Movie;\
|
|
||||||
file_extensions=.movie,.mv
|
|
||||||
|
|
||||||
message/rfc822: \
|
|
||||||
description=Internet Email Message;\
|
|
||||||
file_extensions=.mime
|
|
||||||
|
|
||||||
application/xml: \
|
|
||||||
description=XML document;\
|
|
||||||
file_extensions=.xml
|
|
||||||
|
|
||||||
|
|
||||||
|
|
@ -233,15 +233,16 @@ JNIEXPORT void JNICALL
|
|||||||
Java_sun_lwawt_macosx_LWCToolkit_initIDs
|
Java_sun_lwawt_macosx_LWCToolkit_initIDs
|
||||||
(JNIEnv *env, jclass klass) {
|
(JNIEnv *env, jclass klass) {
|
||||||
// set thread names
|
// set thread names
|
||||||
dispatch_async(dispatch_get_main_queue(), ^(void){
|
if (![ThreadUtilities isAWTEmbedded]) {
|
||||||
[[NSThread currentThread] setName:@"AppKit Thread"];
|
dispatch_async(dispatch_get_main_queue(), ^(void){
|
||||||
|
[[NSThread currentThread] setName:@"AppKit Thread"];
|
||||||
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
JNIEnv *env = [ThreadUtilities getJNIEnv];
|
||||||
static JNF_CLASS_CACHE(jc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
|
static JNF_CLASS_CACHE(jc_LWCToolkit, "sun/lwawt/macosx/LWCToolkit");
|
||||||
static JNF_STATIC_MEMBER_CACHE(jsm_installToolkitThreadNameInJava, jc_LWCToolkit, "installToolkitThreadNameInJava", "()V");
|
static JNF_STATIC_MEMBER_CACHE(jsm_installToolkitThreadInJava, jc_LWCToolkit, "installToolkitThreadInJava", "()V");
|
||||||
JNFCallStaticVoidMethod(env, jsm_installToolkitThreadNameInJava);
|
JNFCallStaticVoidMethod(env, jsm_installToolkitThreadInJava);
|
||||||
});
|
});
|
||||||
|
}
|
||||||
|
|
||||||
gNumberOfButtons = sun_lwawt_macosx_LWCToolkit_BUTTONS;
|
gNumberOfButtons = sun_lwawt_macosx_LWCToolkit_BUTTONS;
|
||||||
|
|
||||||
jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
|
jclass inputEventClazz = (*env)->FindClass(env, "java/awt/event/InputEvent");
|
||||||
|
@ -363,6 +363,7 @@ AWT_ASSERT_APPKIT_THREAD;
|
|||||||
// AppKit Application.
|
// AppKit Application.
|
||||||
NSApplication *app = [NSApplicationAWT sharedApplication];
|
NSApplication *app = [NSApplicationAWT sharedApplication];
|
||||||
isEmbedded = ![NSApp isKindOfClass:[NSApplicationAWT class]];
|
isEmbedded = ![NSApp isKindOfClass:[NSApplicationAWT class]];
|
||||||
|
[ThreadUtilities setAWTEmbedded:isEmbedded];
|
||||||
|
|
||||||
if (!isEmbedded) {
|
if (!isEmbedded) {
|
||||||
// Install run loop observers and set the AppKit Java thread name
|
// Install run loop observers and set the AppKit Java thread name
|
||||||
@ -433,6 +434,14 @@ JNF_COCOA_ENTER(env);
|
|||||||
if (isSWTInWebStart(env)) {
|
if (isSWTInWebStart(env)) {
|
||||||
forceEmbeddedMode = YES;
|
forceEmbeddedMode = YES;
|
||||||
}
|
}
|
||||||
|
JNIEnv* env = [ThreadUtilities getJNIEnvUncached];
|
||||||
|
jclass jc_ThreadGroupUtils = (*env)->FindClass(env, "sun/misc/ThreadGroupUtils");
|
||||||
|
jmethodID sjm_getRootThreadGroup = (*env)->GetStaticMethodID(env, jc_ThreadGroupUtils, "getRootThreadGroup", "()Ljava/lang/ThreadGroup;");
|
||||||
|
jobject rootThreadGroup = (*env)->CallStaticObjectMethod(env, jc_ThreadGroupUtils, sjm_getRootThreadGroup);
|
||||||
|
[ThreadUtilities setAppkitThreadGroup:(*env)->NewGlobalRef(env, rootThreadGroup)];
|
||||||
|
// The current thread was attached in getJNIEnvUnchached.
|
||||||
|
// Detach it back. It will be reattached later if needed with a proper TG
|
||||||
|
[ThreadUtilities detachCurrentThread];
|
||||||
|
|
||||||
BOOL headless = isHeadless(env);
|
BOOL headless = isHeadless(env);
|
||||||
|
|
||||||
|
@ -127,6 +127,10 @@ __attribute__((visibility("default")))
|
|||||||
|
|
||||||
+ (JNIEnv*)getJNIEnv;
|
+ (JNIEnv*)getJNIEnv;
|
||||||
+ (JNIEnv*)getJNIEnvUncached;
|
+ (JNIEnv*)getJNIEnvUncached;
|
||||||
|
+ (void)detachCurrentThread;
|
||||||
|
+ (void)setAppkitThreadGroup:(jobject)group;
|
||||||
|
+ (void)setAWTEmbedded:(BOOL)embedded;
|
||||||
|
+ (BOOL)isAWTEmbedded;
|
||||||
|
|
||||||
//Wrappers for the corresponding JNFRunLoop methods with a check for main thread
|
//Wrappers for the corresponding JNFRunLoop methods with a check for main thread
|
||||||
+ (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block;
|
+ (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block;
|
||||||
|
@ -33,23 +33,45 @@
|
|||||||
// The following must be named "jvm", as there are extern references to it in AWT
|
// The following must be named "jvm", as there are extern references to it in AWT
|
||||||
JavaVM *jvm = NULL;
|
JavaVM *jvm = NULL;
|
||||||
static JNIEnv *appKitEnv = NULL;
|
static JNIEnv *appKitEnv = NULL;
|
||||||
|
static jobject appkitThreadGroup = NULL;
|
||||||
|
static BOOL awtEmbedded = NO;
|
||||||
|
|
||||||
|
inline void attachCurrentThread(void** env) {
|
||||||
|
if ([NSThread isMainThread]) {
|
||||||
|
JavaVMAttachArgs args;
|
||||||
|
args.version = JNI_VERSION_1_4;
|
||||||
|
args.name = "AppKit Thread";
|
||||||
|
args.group = appkitThreadGroup;
|
||||||
|
(*jvm)->AttachCurrentThreadAsDaemon(jvm, env, &args);
|
||||||
|
} else {
|
||||||
|
(*jvm)->AttachCurrentThreadAsDaemon(jvm, env, NULL);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
@implementation ThreadUtilities
|
@implementation ThreadUtilities
|
||||||
|
|
||||||
+ (JNIEnv*)getJNIEnv {
|
+ (JNIEnv*)getJNIEnv {
|
||||||
AWT_ASSERT_APPKIT_THREAD;
|
AWT_ASSERT_APPKIT_THREAD;
|
||||||
if (appKitEnv == NULL) {
|
if (appKitEnv == NULL) {
|
||||||
(*jvm)->AttachCurrentThreadAsDaemon(jvm, (void **)&appKitEnv, NULL);
|
attachCurrentThread((void **)&appKitEnv);
|
||||||
}
|
}
|
||||||
return appKitEnv;
|
return appKitEnv;
|
||||||
}
|
}
|
||||||
|
|
||||||
+ (JNIEnv*)getJNIEnvUncached {
|
+ (JNIEnv*)getJNIEnvUncached {
|
||||||
JNIEnv *env = NULL;
|
JNIEnv *env = NULL;
|
||||||
(*jvm)->AttachCurrentThreadAsDaemon(jvm, (void **)&env, nil);
|
attachCurrentThread((void **)&env);
|
||||||
return env;
|
return env;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (void)detachCurrentThread {
|
||||||
|
(*jvm)->DetachCurrentThread(jvm);
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (void)setAppkitThreadGroup:(jobject)group {
|
||||||
|
appkitThreadGroup = group;
|
||||||
|
}
|
||||||
|
|
||||||
+ (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block {
|
+ (void)performOnMainThreadWaiting:(BOOL)wait block:(void (^)())block {
|
||||||
if ([NSThread isMainThread] && wait == YES) {
|
if ([NSThread isMainThread] && wait == YES) {
|
||||||
block();
|
block();
|
||||||
@ -66,6 +88,14 @@ AWT_ASSERT_APPKIT_THREAD;
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
+ (void)setAWTEmbedded:(BOOL)embedded {
|
||||||
|
awtEmbedded = embedded;
|
||||||
|
}
|
||||||
|
|
||||||
|
+ (BOOL)isAWTEmbedded {
|
||||||
|
return awtEmbedded;
|
||||||
|
}
|
||||||
|
|
||||||
@end
|
@end
|
||||||
|
|
||||||
|
|
||||||
|
@ -35,6 +35,8 @@ import javax.security.auth.Subject;
|
|||||||
import javax.management.remote.SubjectDelegationPermission;
|
import javax.management.remote.SubjectDelegationPermission;
|
||||||
|
|
||||||
import com.sun.jmx.remote.util.CacheMap;
|
import com.sun.jmx.remote.util.CacheMap;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.Collection;
|
||||||
|
|
||||||
public class SubjectDelegator {
|
public class SubjectDelegator {
|
||||||
private static final int PRINCIPALS_CACHE_SIZE = 10;
|
private static final int PRINCIPALS_CACHE_SIZE = 10;
|
||||||
@ -53,11 +55,14 @@ public class SubjectDelegator {
|
|||||||
boolean removeCallerContext)
|
boolean removeCallerContext)
|
||||||
throws SecurityException {
|
throws SecurityException {
|
||||||
|
|
||||||
|
if (System.getSecurityManager() != null && authenticatedACC == null) {
|
||||||
|
throw new SecurityException("Illegal AccessControlContext: null");
|
||||||
|
}
|
||||||
if (principalsCache == null || accCache == null) {
|
if (principalsCache == null || accCache == null) {
|
||||||
principalsCache =
|
principalsCache =
|
||||||
new CacheMap<Subject, Principal[]>(PRINCIPALS_CACHE_SIZE);
|
new CacheMap<>(PRINCIPALS_CACHE_SIZE);
|
||||||
accCache =
|
accCache =
|
||||||
new CacheMap<Subject, AccessControlContext>(ACC_CACHE_SIZE);
|
new CacheMap<>(ACC_CACHE_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Retrieve the principals for the given
|
// Retrieve the principals for the given
|
||||||
@ -101,14 +106,15 @@ public class SubjectDelegator {
|
|||||||
// principal in the delegated subject
|
// principal in the delegated subject
|
||||||
//
|
//
|
||||||
final Principal[] dp = delegatedPrincipals;
|
final Principal[] dp = delegatedPrincipals;
|
||||||
|
final Collection<Permission> permissions = new ArrayList<>(dp.length);
|
||||||
|
for(Principal p : dp) {
|
||||||
|
final String pname = p.getClass().getName() + "." + p.getName();
|
||||||
|
permissions.add(new SubjectDelegationPermission(pname));
|
||||||
|
}
|
||||||
PrivilegedAction<Void> action =
|
PrivilegedAction<Void> action =
|
||||||
new PrivilegedAction<Void>() {
|
new PrivilegedAction<Void>() {
|
||||||
public Void run() {
|
public Void run() {
|
||||||
for (int i = 0 ; i < dp.length ; i++) {
|
for (Permission sdp : permissions) {
|
||||||
final String pname =
|
|
||||||
dp[i].getClass().getName() + "." + dp[i].getName();
|
|
||||||
Permission sdp =
|
|
||||||
new SubjectDelegationPermission(pname);
|
|
||||||
AccessController.checkPermission(sdp);
|
AccessController.checkPermission(sdp);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
|
@ -30,13 +30,14 @@ import java.net.DatagramSocket;
|
|||||||
import java.net.DatagramPacket;
|
import java.net.DatagramPacket;
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.Socket;
|
import java.net.Socket;
|
||||||
|
import java.security.SecureRandom;
|
||||||
import javax.naming.*;
|
import javax.naming.*;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Set;
|
|
||||||
import java.util.HashSet;
|
import sun.security.jca.JCAUtil;
|
||||||
|
|
||||||
// Some of this code began life as part of sun.javaos.net.DnsClient
|
// Some of this code began life as part of sun.javaos.net.DnsClient
|
||||||
// originally by sritchie@eng 1/96. It was first hacked up for JNDI
|
// originally by sritchie@eng 1/96. It was first hacked up for JNDI
|
||||||
@ -77,6 +78,8 @@ public class DnsClient {
|
|||||||
};
|
};
|
||||||
|
|
||||||
private static final int DEFAULT_PORT = 53;
|
private static final int DEFAULT_PORT = 53;
|
||||||
|
private static final int TRANSACTION_ID_BOUND = 0x10000;
|
||||||
|
private static final SecureRandom random = JCAUtil.getSecureRandom();
|
||||||
private InetAddress[] servers;
|
private InetAddress[] servers;
|
||||||
private int[] serverPorts;
|
private int[] serverPorts;
|
||||||
private int timeout; // initial timeout on UDP queries in ms
|
private int timeout; // initial timeout on UDP queries in ms
|
||||||
@ -85,7 +88,7 @@ public class DnsClient {
|
|||||||
private DatagramSocket udpSocket;
|
private DatagramSocket udpSocket;
|
||||||
|
|
||||||
// Requests sent
|
// Requests sent
|
||||||
private Set<Integer> reqs;
|
private Map<Integer, ResourceRecord> reqs;
|
||||||
|
|
||||||
// Responses received
|
// Responses received
|
||||||
private Map<Integer, byte[]> resps;
|
private Map<Integer, byte[]> resps;
|
||||||
@ -134,7 +137,8 @@ public class DnsClient {
|
|||||||
throw ne;
|
throw ne;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
reqs = Collections.synchronizedSet(new HashSet<Integer>());
|
reqs = Collections.synchronizedMap(
|
||||||
|
new HashMap<Integer, ResourceRecord>());
|
||||||
resps = Collections.synchronizedMap(new HashMap<Integer, byte[]>());
|
resps = Collections.synchronizedMap(new HashMap<Integer, byte[]>());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -153,10 +157,6 @@ public class DnsClient {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
private int ident = 0; // used to set the msg ID field
|
|
||||||
private Object identLock = new Object();
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* If recursion is true, recursion is requested on the query.
|
* If recursion is true, recursion is requested on the query.
|
||||||
* If auth is true, only authoritative responses are accepted; other
|
* If auth is true, only authoritative responses are accepted; other
|
||||||
@ -167,15 +167,19 @@ public class DnsClient {
|
|||||||
throws NamingException {
|
throws NamingException {
|
||||||
|
|
||||||
int xid;
|
int xid;
|
||||||
synchronized (identLock) {
|
Packet pkt;
|
||||||
ident = 0xFFFF & (ident + 1);
|
ResourceRecord collision;
|
||||||
xid = ident;
|
|
||||||
}
|
|
||||||
|
|
||||||
// enqueue the outstanding request
|
do {
|
||||||
reqs.add(xid);
|
// Generate a random transaction ID
|
||||||
|
xid = random.nextInt(TRANSACTION_ID_BOUND);
|
||||||
|
pkt = makeQueryPacket(fqdn, xid, qclass, qtype, recursion);
|
||||||
|
|
||||||
Packet pkt = makeQueryPacket(fqdn, xid, qclass, qtype, recursion);
|
// enqueue the outstanding request
|
||||||
|
collision = reqs.putIfAbsent(xid, new ResourceRecord(pkt.getData(),
|
||||||
|
pkt.length(), Header.HEADER_SIZE, true, false));
|
||||||
|
|
||||||
|
} while (collision != null);
|
||||||
|
|
||||||
Exception caughtException = null;
|
Exception caughtException = null;
|
||||||
boolean[] doNotRetry = new boolean[servers.length];
|
boolean[] doNotRetry = new boolean[servers.length];
|
||||||
@ -305,11 +309,8 @@ public class DnsClient {
|
|||||||
ResourceRecords queryZone(DnsName zone, int qclass, boolean recursion)
|
ResourceRecords queryZone(DnsName zone, int qclass, boolean recursion)
|
||||||
throws NamingException {
|
throws NamingException {
|
||||||
|
|
||||||
int xid;
|
int xid = random.nextInt(TRANSACTION_ID_BOUND);
|
||||||
synchronized (identLock) {
|
|
||||||
ident = 0xFFFF & (ident + 1);
|
|
||||||
xid = ident;
|
|
||||||
}
|
|
||||||
Packet pkt = makeQueryPacket(zone, xid, qclass,
|
Packet pkt = makeQueryPacket(zone, xid, qclass,
|
||||||
ResourceRecord.QTYPE_AXFR, recursion);
|
ResourceRecord.QTYPE_AXFR, recursion);
|
||||||
Exception caughtException = null;
|
Exception caughtException = null;
|
||||||
@ -390,6 +391,7 @@ public class DnsClient {
|
|||||||
DatagramPacket opkt = new DatagramPacket(
|
DatagramPacket opkt = new DatagramPacket(
|
||||||
pkt.getData(), pkt.length(), server, port);
|
pkt.getData(), pkt.length(), server, port);
|
||||||
DatagramPacket ipkt = new DatagramPacket(new byte[8000], 8000);
|
DatagramPacket ipkt = new DatagramPacket(new byte[8000], 8000);
|
||||||
|
// Packets may only be sent to or received from this server address
|
||||||
udpSocket.connect(server, port);
|
udpSocket.connect(server, port);
|
||||||
int pktTimeout = (timeout * (1 << retry));
|
int pktTimeout = (timeout * (1 << retry));
|
||||||
try {
|
try {
|
||||||
@ -542,6 +544,9 @@ public class DnsClient {
|
|||||||
* Checks the header of an incoming DNS response.
|
* Checks the header of an incoming DNS response.
|
||||||
* Returns true if it matches the given xid and throws a naming
|
* Returns true if it matches the given xid and throws a naming
|
||||||
* exception, if appropriate, based on the response code.
|
* exception, if appropriate, based on the response code.
|
||||||
|
*
|
||||||
|
* Also checks that the domain name, type and class in the response
|
||||||
|
* match those in the original query.
|
||||||
*/
|
*/
|
||||||
private boolean isMatchResponse(byte[] pkt, int xid)
|
private boolean isMatchResponse(byte[] pkt, int xid)
|
||||||
throws NamingException {
|
throws NamingException {
|
||||||
@ -551,7 +556,7 @@ public class DnsClient {
|
|||||||
throw new CommunicationException("DNS error: expecting response");
|
throw new CommunicationException("DNS error: expecting response");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!reqs.contains(xid)) { // already received, ignore the response
|
if (!reqs.containsKey(xid)) { // already received, ignore the response
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -560,14 +565,47 @@ public class DnsClient {
|
|||||||
if (debug) {
|
if (debug) {
|
||||||
dprint("XID MATCH:" + xid);
|
dprint("XID MATCH:" + xid);
|
||||||
}
|
}
|
||||||
|
|
||||||
checkResponseCode(hdr);
|
checkResponseCode(hdr);
|
||||||
// remove the response for the xid if received by some other thread.
|
if (!hdr.query && hdr.numQuestions == 1) {
|
||||||
synchronized (queuesLock) {
|
|
||||||
resps.remove(xid);
|
ResourceRecord rr = new ResourceRecord(pkt, pkt.length,
|
||||||
reqs.remove(xid);
|
Header.HEADER_SIZE, true, false);
|
||||||
|
|
||||||
|
// Retrieve the original query
|
||||||
|
ResourceRecord query = reqs.get(xid);
|
||||||
|
int qtype = query.getType();
|
||||||
|
int qclass = query.getRrclass();
|
||||||
|
DnsName qname = query.getName();
|
||||||
|
|
||||||
|
// Check that the type/class/name in the query section of the
|
||||||
|
// response match those in the original query
|
||||||
|
if ((qtype == ResourceRecord.QTYPE_STAR ||
|
||||||
|
qtype == rr.getType()) &&
|
||||||
|
(qclass == ResourceRecord.QCLASS_STAR ||
|
||||||
|
qclass == rr.getRrclass()) &&
|
||||||
|
qname.equals(rr.getName())) {
|
||||||
|
|
||||||
|
if (debug) {
|
||||||
|
dprint("MATCH NAME:" + qname + " QTYPE:" + qtype +
|
||||||
|
" QCLASS:" + qclass);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Remove the response for the xid if received by some other
|
||||||
|
// thread.
|
||||||
|
synchronized (queuesLock) {
|
||||||
|
resps.remove(xid);
|
||||||
|
reqs.remove(xid);
|
||||||
|
}
|
||||||
|
return true;
|
||||||
|
|
||||||
|
} else {
|
||||||
|
if (debug) {
|
||||||
|
dprint("NO-MATCH NAME:" + qname + " QTYPE:" + qtype +
|
||||||
|
" QCLASS:" + qclass);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
return true;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
//
|
//
|
||||||
@ -576,7 +614,7 @@ public class DnsClient {
|
|||||||
// enqueue only the first response, responses for retries are ignored.
|
// enqueue only the first response, responses for retries are ignored.
|
||||||
//
|
//
|
||||||
synchronized (queuesLock) {
|
synchronized (queuesLock) {
|
||||||
if (reqs.contains(hdr.xid)) { // enqueue only the first response
|
if (reqs.containsKey(hdr.xid)) { // enqueue only the first response
|
||||||
resps.put(hdr.xid, pkt);
|
resps.put(hdr.xid, pkt);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,6 +25,10 @@
|
|||||||
|
|
||||||
package com.sun.jndi.ldap;
|
package com.sun.jndi.ldap;
|
||||||
|
|
||||||
|
import java.security.AccessControlContext;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedActionException;
|
||||||
|
import java.security.PrivilegedExceptionAction;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import javax.naming.*;
|
import javax.naming.*;
|
||||||
import javax.naming.directory.*;
|
import javax.naming.directory.*;
|
||||||
@ -36,6 +40,8 @@ import com.sun.jndi.toolkit.ctx.Continuation;
|
|||||||
final class LdapBindingEnumeration
|
final class LdapBindingEnumeration
|
||||||
extends AbstractLdapNamingEnumeration<Binding> {
|
extends AbstractLdapNamingEnumeration<Binding> {
|
||||||
|
|
||||||
|
private final AccessControlContext acc = AccessController.getContext();
|
||||||
|
|
||||||
LdapBindingEnumeration(LdapCtx homeCtx, LdapResult answer, Name remain,
|
LdapBindingEnumeration(LdapCtx homeCtx, LdapResult answer, Name remain,
|
||||||
Continuation cont) throws NamingException
|
Continuation cont) throws NamingException
|
||||||
{
|
{
|
||||||
@ -52,7 +58,16 @@ final class LdapBindingEnumeration
|
|||||||
|
|
||||||
if (attrs.get(Obj.JAVA_ATTRIBUTES[Obj.CLASSNAME]) != null) {
|
if (attrs.get(Obj.JAVA_ATTRIBUTES[Obj.CLASSNAME]) != null) {
|
||||||
// serialized object or object reference
|
// serialized object or object reference
|
||||||
obj = Obj.decodeObject(attrs);
|
try {
|
||||||
|
obj = AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
||||||
|
@Override
|
||||||
|
public Object run() throws NamingException {
|
||||||
|
return Obj.decodeObject(attrs);
|
||||||
|
}
|
||||||
|
}, acc);
|
||||||
|
} catch (PrivilegedActionException e) {
|
||||||
|
throw (NamingException)e.getException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
// DirContext object
|
// DirContext object
|
||||||
|
@ -25,6 +25,10 @@
|
|||||||
|
|
||||||
package com.sun.jndi.ldap;
|
package com.sun.jndi.ldap;
|
||||||
|
|
||||||
|
import java.security.AccessControlContext;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedActionException;
|
||||||
|
import java.security.PrivilegedExceptionAction;
|
||||||
import java.util.Vector;
|
import java.util.Vector;
|
||||||
import javax.naming.*;
|
import javax.naming.*;
|
||||||
import javax.naming.directory.*;
|
import javax.naming.directory.*;
|
||||||
@ -40,6 +44,8 @@ final class LdapSearchEnumeration
|
|||||||
private Name startName; // prefix of names of search results
|
private Name startName; // prefix of names of search results
|
||||||
private LdapCtx.SearchArgs searchArgs = null;
|
private LdapCtx.SearchArgs searchArgs = null;
|
||||||
|
|
||||||
|
private final AccessControlContext acc = AccessController.getContext();
|
||||||
|
|
||||||
LdapSearchEnumeration(LdapCtx homeCtx, LdapResult search_results,
|
LdapSearchEnumeration(LdapCtx homeCtx, LdapResult search_results,
|
||||||
String starter, LdapCtx.SearchArgs args, Continuation cont)
|
String starter, LdapCtx.SearchArgs args, Continuation cont)
|
||||||
throws NamingException {
|
throws NamingException {
|
||||||
@ -112,8 +118,16 @@ final class LdapSearchEnumeration
|
|||||||
if (attrs.get(Obj.JAVA_ATTRIBUTES[Obj.CLASSNAME]) != null) {
|
if (attrs.get(Obj.JAVA_ATTRIBUTES[Obj.CLASSNAME]) != null) {
|
||||||
// Entry contains Java-object attributes (ser/ref object)
|
// Entry contains Java-object attributes (ser/ref object)
|
||||||
// serialized object or object reference
|
// serialized object or object reference
|
||||||
obj = Obj.decodeObject(attrs);
|
try {
|
||||||
|
obj = AccessController.doPrivileged(new PrivilegedExceptionAction<Object>() {
|
||||||
|
@Override
|
||||||
|
public Object run() throws NamingException {
|
||||||
|
return Obj.decodeObject(attrs);
|
||||||
|
}
|
||||||
|
}, acc);
|
||||||
|
} catch (PrivilegedActionException e) {
|
||||||
|
throw (NamingException)e.getException();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if (obj == null) {
|
if (obj == null) {
|
||||||
obj = new LdapCtx(homeCtx, dn);
|
obj = new LdapCtx(homeCtx, dn);
|
||||||
|
@ -25,27 +25,33 @@
|
|||||||
|
|
||||||
package com.sun.media.sound;
|
package com.sun.media.sound;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Properties;
|
import java.util.Properties;
|
||||||
|
|
||||||
import javax.sound.midi.Receiver;
|
import javax.sound.midi.Receiver;
|
||||||
import javax.sound.midi.Sequencer;
|
import javax.sound.midi.Sequencer;
|
||||||
import javax.sound.midi.Synthesizer;
|
import javax.sound.midi.Synthesizer;
|
||||||
import javax.sound.midi.Transmitter;
|
import javax.sound.midi.Transmitter;
|
||||||
|
import javax.sound.midi.spi.MidiDeviceProvider;
|
||||||
|
import javax.sound.midi.spi.MidiFileReader;
|
||||||
|
import javax.sound.midi.spi.MidiFileWriter;
|
||||||
|
import javax.sound.midi.spi.SoundbankReader;
|
||||||
import javax.sound.sampled.Clip;
|
import javax.sound.sampled.Clip;
|
||||||
import javax.sound.sampled.Port;
|
import javax.sound.sampled.Port;
|
||||||
import javax.sound.sampled.SourceDataLine;
|
import javax.sound.sampled.SourceDataLine;
|
||||||
import javax.sound.sampled.TargetDataLine;
|
import javax.sound.sampled.TargetDataLine;
|
||||||
|
import javax.sound.sampled.spi.AudioFileReader;
|
||||||
|
import javax.sound.sampled.spi.AudioFileWriter;
|
||||||
|
import javax.sound.sampled.spi.FormatConversionProvider;
|
||||||
|
import javax.sound.sampled.spi.MixerProvider;
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* JDK13Services uses the Service class in JDK 1.3
|
* JDK13Services uses the Service class in JDK 1.3 to discover a list of service
|
||||||
* to discover a list of service providers installed
|
* providers installed in the system.
|
||||||
* in the system.
|
* <p>
|
||||||
*
|
|
||||||
* This class is public because it is called from javax.sound.midi.MidiSystem
|
* This class is public because it is called from javax.sound.midi.MidiSystem
|
||||||
* and javax.sound.sampled.AudioSystem. The alternative would be to make
|
* and javax.sound.sampled.AudioSystem. The alternative would be to make
|
||||||
* JSSecurityManager public, which is considered worse.
|
* JSSecurityManager public, which is considered worse.
|
||||||
@ -54,80 +60,55 @@ import javax.sound.sampled.TargetDataLine;
|
|||||||
*/
|
*/
|
||||||
public final class JDK13Services {
|
public final class JDK13Services {
|
||||||
|
|
||||||
/** The default for the length of the period to hold the cache.
|
/**
|
||||||
This value is given in milliseconds. It is equivalent to
|
* Filename of the properties file for default provider properties. This
|
||||||
1 minute.
|
* file is searched in the subdirectory "lib" of the JRE directory (this
|
||||||
*/
|
* behaviour is hardcoded).
|
||||||
private static final long DEFAULT_CACHING_PERIOD = 60000;
|
*/
|
||||||
|
|
||||||
/** Filename of the properties file for default provider properties.
|
|
||||||
This file is searched in the subdirectory "lib" of the JRE directory
|
|
||||||
(this behaviour is hardcoded).
|
|
||||||
*/
|
|
||||||
private static final String PROPERTIES_FILENAME = "sound.properties";
|
private static final String PROPERTIES_FILENAME = "sound.properties";
|
||||||
|
|
||||||
/** Cache for the providers.
|
/**
|
||||||
Class objects of the provider type (MixerProvider, MidiDeviceProvider
|
* Properties loaded from the properties file for default provider
|
||||||
...) are used as keys. The values are instances of ProviderCache.
|
* properties.
|
||||||
*/
|
*/
|
||||||
private static final Map providersCacheMap = new HashMap();
|
|
||||||
|
|
||||||
|
|
||||||
/** The length of the period to hold the cache.
|
|
||||||
This value is given in milliseconds.
|
|
||||||
*/
|
|
||||||
private static long cachingPeriod = DEFAULT_CACHING_PERIOD;
|
|
||||||
|
|
||||||
/** Properties loaded from the properties file for default provider
|
|
||||||
properties.
|
|
||||||
*/
|
|
||||||
private static Properties properties;
|
private static Properties properties;
|
||||||
|
|
||||||
|
/**
|
||||||
/** Private, no-args constructor to ensure against instantiation.
|
* Private, no-args constructor to ensure against instantiation.
|
||||||
*/
|
*/
|
||||||
private JDK13Services() {
|
private JDK13Services() {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
/** Set the period provider lists are cached.
|
* Obtains a List containing installed instances of the providers for the
|
||||||
This method is only intended for testing.
|
* requested service. The returned List is immutable.
|
||||||
|
*
|
||||||
|
* @param serviceClass The type of providers requested. This should be one
|
||||||
|
* of AudioFileReader.class, AudioFileWriter.class,
|
||||||
|
* FormatConversionProvider.class, MixerProvider.class,
|
||||||
|
* MidiDeviceProvider.class, MidiFileReader.class,
|
||||||
|
* MidiFileWriter.class or SoundbankReader.class.
|
||||||
|
*
|
||||||
|
* @return A List of providers of the requested type. This List is
|
||||||
|
* immutable.
|
||||||
*/
|
*/
|
||||||
public static void setCachingPeriod(int seconds) {
|
public static List<?> getProviders(final Class<?> serviceClass) {
|
||||||
cachingPeriod = seconds * 1000L;
|
final List<?> providers;
|
||||||
}
|
if (!MixerProvider.class.equals(serviceClass)
|
||||||
|
&& !FormatConversionProvider.class.equals(serviceClass)
|
||||||
|
&& !AudioFileReader.class.equals(serviceClass)
|
||||||
/** Obtains a List containing installed instances of the
|
&& !AudioFileWriter.class.equals(serviceClass)
|
||||||
providers for the requested service.
|
&& !MidiDeviceProvider.class.equals(serviceClass)
|
||||||
The List of providers is cached for the period of time given by
|
&& !SoundbankReader.class.equals(serviceClass)
|
||||||
{@link #cachingPeriod cachingPeriod}. During this period, the same
|
&& !MidiFileWriter.class.equals(serviceClass)
|
||||||
List instance is returned for the same type of provider. After this
|
&& !MidiFileReader.class.equals(serviceClass)) {
|
||||||
period, a new instance is constructed and returned. The returned
|
providers = new ArrayList<>(0);
|
||||||
List is immutable.
|
} else {
|
||||||
@param serviceClass The type of providers requested. This should be one
|
providers = JSSecurityManager.getProviders(serviceClass);
|
||||||
of AudioFileReader.class, AudioFileWriter.class,
|
|
||||||
FormatConversionProvider.class, MixerProvider.class,
|
|
||||||
MidiDeviceProvider.class, MidiFileReader.class, MidiFileWriter.class or
|
|
||||||
SoundbankReader.class.
|
|
||||||
@return A List of providers of the requested type. This List is
|
|
||||||
immutable.
|
|
||||||
*/
|
|
||||||
public static synchronized List getProviders(Class serviceClass) {
|
|
||||||
ProviderCache cache = (ProviderCache) providersCacheMap.get(serviceClass);
|
|
||||||
if (cache == null) {
|
|
||||||
cache = new ProviderCache();
|
|
||||||
providersCacheMap.put(serviceClass, cache);
|
|
||||||
}
|
}
|
||||||
if (cache.providers == null ||
|
return Collections.unmodifiableList(providers);
|
||||||
System.currentTimeMillis() > cache.lastUpdate + cachingPeriod) {
|
|
||||||
cache.providers = Collections.unmodifiableList(JSSecurityManager.getProviders(serviceClass));
|
|
||||||
cache.lastUpdate = System.currentTimeMillis();
|
|
||||||
}
|
|
||||||
return cache.providers;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/** Obtain the provider class name part of a default provider property.
|
/** Obtain the provider class name part of a default provider property.
|
||||||
@param typeClass The type of the default provider property. This
|
@param typeClass The type of the default provider property. This
|
||||||
should be one of Receiver.class, Transmitter.class, Sequencer.class,
|
should be one of Receiver.class, Transmitter.class, Sequencer.class,
|
||||||
@ -219,14 +200,4 @@ public final class JDK13Services {
|
|||||||
}
|
}
|
||||||
return properties;
|
return properties;
|
||||||
}
|
}
|
||||||
|
|
||||||
// INNER CLASSES
|
|
||||||
|
|
||||||
private static class ProviderCache {
|
|
||||||
// System time of the last update in milliseconds.
|
|
||||||
public long lastUpdate;
|
|
||||||
|
|
||||||
// The providers.
|
|
||||||
public List providers;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -185,8 +185,8 @@ final class JSSecurityManager {
|
|||||||
return thread;
|
return thread;
|
||||||
}
|
}
|
||||||
|
|
||||||
static <T> List<T> getProviders(final Class<T> providerClass) {
|
static synchronized <T> List<T> getProviders(final Class<T> providerClass) {
|
||||||
List<T> p = new ArrayList<>();
|
List<T> p = new ArrayList<>(7);
|
||||||
// ServiceLoader creates "lazy" iterator instance, but it ensures that
|
// ServiceLoader creates "lazy" iterator instance, but it ensures that
|
||||||
// next/hasNext run with permissions that are restricted by whatever
|
// next/hasNext run with permissions that are restricted by whatever
|
||||||
// creates the ServiceLoader instance, so it requires to be called from
|
// creates the ServiceLoader instance, so it requires to be called from
|
||||||
|
@ -37,6 +37,7 @@ import javax.sql.rowset.spi.*;
|
|||||||
import javax.sql.rowset.serial.*;
|
import javax.sql.rowset.serial.*;
|
||||||
import com.sun.rowset.internal.*;
|
import com.sun.rowset.internal.*;
|
||||||
import com.sun.rowset.providers.*;
|
import com.sun.rowset.providers.*;
|
||||||
|
import sun.reflect.misc.ReflectUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The standard implementation of the <code>CachedRowSet</code> interface.
|
* The standard implementation of the <code>CachedRowSet</code> interface.
|
||||||
@ -2959,13 +2960,9 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
|
|||||||
// create new instance of the class
|
// create new instance of the class
|
||||||
SQLData obj = null;
|
SQLData obj = null;
|
||||||
try {
|
try {
|
||||||
obj = (SQLData)c.newInstance();
|
obj = (SQLData) ReflectUtil.newInstance(c);
|
||||||
} catch (java.lang.InstantiationException ex) {
|
} catch(Exception ex) {
|
||||||
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
|
throw new SQLException("Unable to Instantiate: ", ex);
|
||||||
ex.getMessage()));
|
|
||||||
} catch (java.lang.IllegalAccessException ex) {
|
|
||||||
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
|
|
||||||
ex.getMessage()));
|
|
||||||
}
|
}
|
||||||
// get the attributes from the struct
|
// get the attributes from the struct
|
||||||
Object attribs[] = s.getAttributes(map);
|
Object attribs[] = s.getAttributes(map);
|
||||||
@ -5710,13 +5707,9 @@ public class CachedRowSetImpl extends BaseRowSet implements RowSet, RowSetIntern
|
|||||||
// create new instance of the class
|
// create new instance of the class
|
||||||
SQLData obj = null;
|
SQLData obj = null;
|
||||||
try {
|
try {
|
||||||
obj = (SQLData)c.newInstance();
|
obj = (SQLData) ReflectUtil.newInstance(c);
|
||||||
} catch (java.lang.InstantiationException ex) {
|
} catch(Exception ex) {
|
||||||
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
|
throw new SQLException("Unable to Instantiate: ", ex);
|
||||||
ex.getMessage()));
|
|
||||||
} catch (java.lang.IllegalAccessException ex) {
|
|
||||||
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
|
|
||||||
ex.getMessage()));
|
|
||||||
}
|
}
|
||||||
// get the attributes from the struct
|
// get the attributes from the struct
|
||||||
Object attribs[] = s.getAttributes(map);
|
Object attribs[] = s.getAttributes(map);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2003, 2012, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -29,6 +29,7 @@ import java.sql.*;
|
|||||||
import javax.sql.*;
|
import javax.sql.*;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
|
import sun.reflect.misc.ReflectUtil;
|
||||||
|
|
||||||
import com.sun.rowset.*;
|
import com.sun.rowset.*;
|
||||||
import java.text.MessageFormat;
|
import java.text.MessageFormat;
|
||||||
@ -572,13 +573,9 @@ public class CachedRowSetWriter implements TransactionalWriter, Serializable {
|
|||||||
// create new instance of the class
|
// create new instance of the class
|
||||||
SQLData obj = null;
|
SQLData obj = null;
|
||||||
try {
|
try {
|
||||||
obj = (SQLData)c.newInstance();
|
obj = (SQLData)ReflectUtil.newInstance(c);
|
||||||
} catch (java.lang.InstantiationException ex) {
|
} catch (Exception ex) {
|
||||||
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
|
throw new SQLException("Unable to Instantiate: ", ex);
|
||||||
ex.getMessage()));
|
|
||||||
} catch (java.lang.IllegalAccessException ex) {
|
|
||||||
throw new SQLException(MessageFormat.format(resBundle.handleGetObject("cachedrowsetimpl.unableins").toString(),
|
|
||||||
ex.getMessage()));
|
|
||||||
}
|
}
|
||||||
// get the attributes from the struct
|
// get the attributes from the struct
|
||||||
Object attribs[] = s.getAttributes(map);
|
Object attribs[] = s.getAttributes(map);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -1061,11 +1061,11 @@ public class EventQueue {
|
|||||||
t.setContextClassLoader(classLoader);
|
t.setContextClassLoader(classLoader);
|
||||||
t.setPriority(Thread.NORM_PRIORITY + 1);
|
t.setPriority(Thread.NORM_PRIORITY + 1);
|
||||||
t.setDaemon(false);
|
t.setDaemon(false);
|
||||||
|
AWTAutoShutdown.getInstance().notifyThreadBusy(t);
|
||||||
return t;
|
return t;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
AWTAutoShutdown.getInstance().notifyThreadBusy(dispatchThread);
|
|
||||||
dispatchThread.start();
|
dispatchThread.start();
|
||||||
}
|
}
|
||||||
} finally {
|
} finally {
|
||||||
|
@ -46,6 +46,7 @@ import java.util.Map;
|
|||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.WeakHashMap;
|
import java.util.WeakHashMap;
|
||||||
|
|
||||||
|
import sun.awt.AppContext;
|
||||||
import sun.awt.datatransfer.DataTransferer;
|
import sun.awt.datatransfer.DataTransferer;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -65,10 +66,7 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
|
|||||||
*/
|
*/
|
||||||
private static String JavaMIME = "JAVA_DATAFLAVOR:";
|
private static String JavaMIME = "JAVA_DATAFLAVOR:";
|
||||||
|
|
||||||
/**
|
private static final Object FLAVOR_MAP_KEY = new Object();
|
||||||
* System singleton which maps a thread's ClassLoader to a SystemFlavorMap.
|
|
||||||
*/
|
|
||||||
private static final WeakHashMap<ClassLoader, FlavorMap> flavorMaps = new WeakHashMap<>();
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Copied from java.util.Properties.
|
* Copied from java.util.Properties.
|
||||||
@ -183,22 +181,12 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
|
|||||||
* @return the default FlavorMap for this thread's ClassLoader
|
* @return the default FlavorMap for this thread's ClassLoader
|
||||||
*/
|
*/
|
||||||
public static FlavorMap getDefaultFlavorMap() {
|
public static FlavorMap getDefaultFlavorMap() {
|
||||||
ClassLoader contextClassLoader =
|
AppContext context = AppContext.getAppContext();
|
||||||
Thread.currentThread().getContextClassLoader();
|
FlavorMap fm = (FlavorMap) context.get(FLAVOR_MAP_KEY);
|
||||||
if (contextClassLoader == null) {
|
if (fm == null) {
|
||||||
contextClassLoader = ClassLoader.getSystemClassLoader();
|
fm = new SystemFlavorMap();
|
||||||
|
context.put(FLAVOR_MAP_KEY, fm);
|
||||||
}
|
}
|
||||||
|
|
||||||
FlavorMap fm;
|
|
||||||
|
|
||||||
synchronized(flavorMaps) {
|
|
||||||
fm = flavorMaps.get(contextClassLoader);
|
|
||||||
if (fm == null) {
|
|
||||||
fm = new SystemFlavorMap();
|
|
||||||
flavorMaps.put(contextClassLoader, fm);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
return fm;
|
return fm;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -239,26 +227,11 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
BufferedReader flavormapURL =
|
String url =
|
||||||
java.security.AccessController.doPrivileged(
|
java.security.AccessController.doPrivileged(
|
||||||
new java.security.PrivilegedAction<BufferedReader>() {
|
new java.security.PrivilegedAction<String>() {
|
||||||
public BufferedReader run() {
|
public String run() {
|
||||||
String url = Toolkit.getProperty("AWT.DnD.flavorMapFileURL", null);
|
return Toolkit.getProperty("AWT.DnD.flavorMapFileURL", null);
|
||||||
|
|
||||||
if (url == null) {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
try {
|
|
||||||
return new BufferedReader
|
|
||||||
(new InputStreamReader
|
|
||||||
(new URL(url).openStream(), "ISO-8859-1"));
|
|
||||||
} catch (MalformedURLException e) {
|
|
||||||
System.err.println("MalformedURLException:" + e + " while reading AWT.DnD.flavorMapFileURL:" + url);
|
|
||||||
} catch (IOException e) {
|
|
||||||
System.err.println("IOException:" + e + " while reading AWT.DnD.flavorMapFileURL:" + url);
|
|
||||||
}
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -270,6 +243,19 @@ public final class SystemFlavorMap implements FlavorMap, FlavorTable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BufferedReader flavormapURL = null;
|
||||||
|
if (url != null) {
|
||||||
|
try {
|
||||||
|
flavormapURL = new BufferedReader(new InputStreamReader(new URL(url).openStream(), "ISO-8859-1"));
|
||||||
|
} catch (MalformedURLException e) {
|
||||||
|
System.err.println("MalformedURLException:" + e + " while reading AWT.DnD.flavorMapFileURL:" + url);
|
||||||
|
} catch (IOException e) {
|
||||||
|
System.err.println("IOException:" + e + " while reading AWT.DnD.flavorMapFileURL:" + url);
|
||||||
|
} catch (SecurityException e) {
|
||||||
|
// ignored
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (flavormapURL != null) {
|
if (flavormapURL != null) {
|
||||||
try {
|
try {
|
||||||
parseAndStoreReader(flavormapURL);
|
parseAndStoreReader(flavormapURL);
|
||||||
|
@ -366,6 +366,8 @@ class Thread implements Runnable {
|
|||||||
throw new NullPointerException("name cannot be null");
|
throw new NullPointerException("name cannot be null");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
this.name = name.toCharArray();
|
||||||
|
|
||||||
Thread parent = currentThread();
|
Thread parent = currentThread();
|
||||||
SecurityManager security = System.getSecurityManager();
|
SecurityManager security = System.getSecurityManager();
|
||||||
if (g == null) {
|
if (g == null) {
|
||||||
@ -402,7 +404,6 @@ class Thread implements Runnable {
|
|||||||
this.group = g;
|
this.group = g;
|
||||||
this.daemon = parent.isDaemon();
|
this.daemon = parent.isDaemon();
|
||||||
this.priority = parent.getPriority();
|
this.priority = parent.getPriority();
|
||||||
this.name = name.toCharArray();
|
|
||||||
if (security == null || isCCLOverridden(parent.getClass()))
|
if (security == null || isCCLOverridden(parent.getClass()))
|
||||||
this.contextClassLoader = parent.getContextClassLoader();
|
this.contextClassLoader = parent.getContextClassLoader();
|
||||||
else
|
else
|
||||||
|
@ -140,7 +140,7 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
* Return the {@link SpeciesData} instance representing this BMH species. All subclasses must provide a
|
* Return the {@link SpeciesData} instance representing this BMH species. All subclasses must provide a
|
||||||
* static field containing this value, and they must accordingly implement this method.
|
* static field containing this value, and they must accordingly implement this method.
|
||||||
*/
|
*/
|
||||||
protected abstract SpeciesData speciesData();
|
/*non-public*/ abstract SpeciesData speciesData();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
final Object internalProperties() {
|
final Object internalProperties() {
|
||||||
@ -156,7 +156,7 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
return Arrays.asList(boundValues);
|
return Arrays.asList(boundValues);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final Object arg(int i) {
|
/*non-public*/ final Object arg(int i) {
|
||||||
try {
|
try {
|
||||||
switch (speciesData().fieldType(i)) {
|
switch (speciesData().fieldType(i)) {
|
||||||
case 'L': return argL(i);
|
case 'L': return argL(i);
|
||||||
@ -170,22 +170,22 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
}
|
}
|
||||||
throw new InternalError("unexpected type: " + speciesData().types+"."+i);
|
throw new InternalError("unexpected type: " + speciesData().types+"."+i);
|
||||||
}
|
}
|
||||||
public final Object argL(int i) throws Throwable { return speciesData().getters[i].invokeBasic(this); }
|
/*non-public*/ final Object argL(int i) throws Throwable { return speciesData().getters[i].invokeBasic(this); }
|
||||||
public final int argI(int i) throws Throwable { return (int) speciesData().getters[i].invokeBasic(this); }
|
/*non-public*/ final int argI(int i) throws Throwable { return (int) speciesData().getters[i].invokeBasic(this); }
|
||||||
public final float argF(int i) throws Throwable { return (float) speciesData().getters[i].invokeBasic(this); }
|
/*non-public*/ final float argF(int i) throws Throwable { return (float) speciesData().getters[i].invokeBasic(this); }
|
||||||
public final double argD(int i) throws Throwable { return (double) speciesData().getters[i].invokeBasic(this); }
|
/*non-public*/ final double argD(int i) throws Throwable { return (double) speciesData().getters[i].invokeBasic(this); }
|
||||||
public final long argJ(int i) throws Throwable { return (long) speciesData().getters[i].invokeBasic(this); }
|
/*non-public*/ final long argJ(int i) throws Throwable { return (long) speciesData().getters[i].invokeBasic(this); }
|
||||||
|
|
||||||
//
|
//
|
||||||
// cloning API
|
// cloning API
|
||||||
//
|
//
|
||||||
|
|
||||||
public abstract BoundMethodHandle clone(MethodType mt, LambdaForm lf) throws Throwable;
|
/*non-public*/ abstract BoundMethodHandle clone(MethodType mt, LambdaForm lf) throws Throwable;
|
||||||
public abstract BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) throws Throwable;
|
/*non-public*/ abstract BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) throws Throwable;
|
||||||
public abstract BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) throws Throwable;
|
/*non-public*/ abstract BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) throws Throwable;
|
||||||
public abstract BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) throws Throwable;
|
/*non-public*/ abstract BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) throws Throwable;
|
||||||
public abstract BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) throws Throwable;
|
/*non-public*/ abstract BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) throws Throwable;
|
||||||
public abstract BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable;
|
/*non-public*/ abstract BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable;
|
||||||
|
|
||||||
// The following is a grossly irregular hack:
|
// The following is a grossly irregular hack:
|
||||||
@Override MethodHandle reinvokerTarget() {
|
@Override MethodHandle reinvokerTarget() {
|
||||||
@ -203,39 +203,39 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
private // make it private to force users to access the enclosing class first
|
private // make it private to force users to access the enclosing class first
|
||||||
static final class Species_L extends BoundMethodHandle {
|
static final class Species_L extends BoundMethodHandle {
|
||||||
final Object argL0;
|
final Object argL0;
|
||||||
public Species_L(MethodType mt, LambdaForm lf, Object argL0) {
|
/*non-public*/ Species_L(MethodType mt, LambdaForm lf, Object argL0) {
|
||||||
super(mt, lf);
|
super(mt, lf);
|
||||||
this.argL0 = argL0;
|
this.argL0 = argL0;
|
||||||
}
|
}
|
||||||
// The following is a grossly irregular hack:
|
// The following is a grossly irregular hack:
|
||||||
@Override MethodHandle reinvokerTarget() { return (MethodHandle) argL0; }
|
@Override MethodHandle reinvokerTarget() { return (MethodHandle) argL0; }
|
||||||
@Override
|
@Override
|
||||||
public SpeciesData speciesData() {
|
/*non-public*/ SpeciesData speciesData() {
|
||||||
return SPECIES_DATA;
|
return SPECIES_DATA;
|
||||||
}
|
}
|
||||||
public static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("L", Species_L.class);
|
/*non-public*/ static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("L", Species_L.class);
|
||||||
@Override
|
@Override
|
||||||
public final BoundMethodHandle clone(MethodType mt, LambdaForm lf) throws Throwable {
|
/*non-public*/ final BoundMethodHandle clone(MethodType mt, LambdaForm lf) throws Throwable {
|
||||||
return new Species_L(mt, lf, argL0);
|
return new Species_L(mt, lf, argL0);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public final BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) throws Throwable {
|
/*non-public*/ final BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) throws Throwable {
|
||||||
return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_L).constructor[0].invokeBasic(mt, lf, argL0, narg);
|
return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_L).constructor[0].invokeBasic(mt, lf, argL0, narg);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) throws Throwable {
|
/*non-public*/ final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) throws Throwable {
|
||||||
return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_I).constructor[0].invokeBasic(mt, lf, argL0, narg);
|
return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_I).constructor[0].invokeBasic(mt, lf, argL0, narg);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) throws Throwable {
|
/*non-public*/ final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) throws Throwable {
|
||||||
return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_J).constructor[0].invokeBasic(mt, lf, argL0, narg);
|
return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_J).constructor[0].invokeBasic(mt, lf, argL0, narg);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) throws Throwable {
|
/*non-public*/ final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) throws Throwable {
|
||||||
return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_F).constructor[0].invokeBasic(mt, lf, argL0, narg);
|
return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_F).constructor[0].invokeBasic(mt, lf, argL0, narg);
|
||||||
}
|
}
|
||||||
@Override
|
@Override
|
||||||
public final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable {
|
/*non-public*/ final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) throws Throwable {
|
||||||
return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_D).constructor[0].invokeBasic(mt, lf, argL0, narg);
|
return (BoundMethodHandle) SPECIES_DATA.extendWithIndex(INDEX_D).constructor[0].invokeBasic(mt, lf, argL0, narg);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -338,10 +338,10 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
final MethodHandle[] getters;
|
final MethodHandle[] getters;
|
||||||
final SpeciesData[] extensions;
|
final SpeciesData[] extensions;
|
||||||
|
|
||||||
public int fieldCount() {
|
/*non-public*/ int fieldCount() {
|
||||||
return types.length();
|
return types.length();
|
||||||
}
|
}
|
||||||
public char fieldType(int i) {
|
/*non-public*/ char fieldType(int i) {
|
||||||
return types.charAt(i);
|
return types.charAt(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -551,30 +551,30 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
* final Object argL0;
|
* final Object argL0;
|
||||||
* final Object argL1;
|
* final Object argL1;
|
||||||
* final int argI2;
|
* final int argI2;
|
||||||
* public Species_LLI(MethodType mt, LambdaForm lf, Object argL0, Object argL1, int argI2) {
|
* Species_LLI(MethodType mt, LambdaForm lf, Object argL0, Object argL1, int argI2) {
|
||||||
* super(mt, lf);
|
* super(mt, lf);
|
||||||
* this.argL0 = argL0;
|
* this.argL0 = argL0;
|
||||||
* this.argL1 = argL1;
|
* this.argL1 = argL1;
|
||||||
* this.argI2 = argI2;
|
* this.argI2 = argI2;
|
||||||
* }
|
* }
|
||||||
* public final SpeciesData speciesData() { return SPECIES_DATA; }
|
* final SpeciesData speciesData() { return SPECIES_DATA; }
|
||||||
* public static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("LLI", Species_LLI.class);
|
* static final SpeciesData SPECIES_DATA = SpeciesData.getForClass("LLI", Species_LLI.class);
|
||||||
* public final BoundMethodHandle clone(MethodType mt, LambdaForm lf) {
|
* final BoundMethodHandle clone(MethodType mt, LambdaForm lf) {
|
||||||
* return SPECIES_DATA.constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2);
|
* return SPECIES_DATA.constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2);
|
||||||
* }
|
* }
|
||||||
* public final BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) {
|
* final BoundMethodHandle cloneExtendL(MethodType mt, LambdaForm lf, Object narg) {
|
||||||
* return SPECIES_DATA.extendWithIndex(INDEX_L).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
|
* return SPECIES_DATA.extendWithIndex(INDEX_L).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
|
||||||
* }
|
* }
|
||||||
* public final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) {
|
* final BoundMethodHandle cloneExtendI(MethodType mt, LambdaForm lf, int narg) {
|
||||||
* return SPECIES_DATA.extendWithIndex(INDEX_I).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
|
* return SPECIES_DATA.extendWithIndex(INDEX_I).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
|
||||||
* }
|
* }
|
||||||
* public final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) {
|
* final BoundMethodHandle cloneExtendJ(MethodType mt, LambdaForm lf, long narg) {
|
||||||
* return SPECIES_DATA.extendWithIndex(INDEX_J).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
|
* return SPECIES_DATA.extendWithIndex(INDEX_J).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
|
||||||
* }
|
* }
|
||||||
* public final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) {
|
* final BoundMethodHandle cloneExtendF(MethodType mt, LambdaForm lf, float narg) {
|
||||||
* return SPECIES_DATA.extendWithIndex(INDEX_F).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
|
* return SPECIES_DATA.extendWithIndex(INDEX_F).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
|
||||||
* }
|
* }
|
||||||
* public final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) {
|
* final BoundMethodHandle cloneExtendD(MethodType mt, LambdaForm lf, double narg) {
|
||||||
* return SPECIES_DATA.extendWithIndex(INDEX_D).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
|
* return SPECIES_DATA.extendWithIndex(INDEX_D).constructor[0].invokeBasic(mt, lf, argL0, argL1, argI2, narg);
|
||||||
* }
|
* }
|
||||||
* }
|
* }
|
||||||
@ -588,11 +588,12 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
|
|
||||||
final String className = SPECIES_PREFIX_PATH + types;
|
final String className = SPECIES_PREFIX_PATH + types;
|
||||||
final String sourceFile = SPECIES_PREFIX_NAME + types;
|
final String sourceFile = SPECIES_PREFIX_NAME + types;
|
||||||
cw.visit(V1_6, ACC_PUBLIC + ACC_FINAL + ACC_SUPER, className, null, BMH, null);
|
final int NOT_ACC_PUBLIC = 0; // not ACC_PUBLIC
|
||||||
|
cw.visit(V1_6, NOT_ACC_PUBLIC + ACC_FINAL + ACC_SUPER, className, null, BMH, null);
|
||||||
cw.visitSource(sourceFile, null);
|
cw.visitSource(sourceFile, null);
|
||||||
|
|
||||||
// emit static types and SPECIES_DATA fields
|
// emit static types and SPECIES_DATA fields
|
||||||
cw.visitField(ACC_PUBLIC + ACC_STATIC, "SPECIES_DATA", SPECIES_DATA_SIG, null, null).visitEnd();
|
cw.visitField(NOT_ACC_PUBLIC + ACC_STATIC, "SPECIES_DATA", SPECIES_DATA_SIG, null, null).visitEnd();
|
||||||
|
|
||||||
// emit bound argument fields
|
// emit bound argument fields
|
||||||
for (int i = 0; i < types.length(); ++i) {
|
for (int i = 0; i < types.length(); ++i) {
|
||||||
@ -605,7 +606,7 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
MethodVisitor mv;
|
MethodVisitor mv;
|
||||||
|
|
||||||
// emit constructor
|
// emit constructor
|
||||||
mv = cw.visitMethod(ACC_PUBLIC, "<init>", makeSignature(types, true), null, null);
|
mv = cw.visitMethod(NOT_ACC_PUBLIC, "<init>", makeSignature(types, true), null, null);
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
mv.visitVarInsn(ALOAD, 0);
|
mv.visitVarInsn(ALOAD, 0);
|
||||||
mv.visitVarInsn(ALOAD, 1);
|
mv.visitVarInsn(ALOAD, 1);
|
||||||
@ -629,7 +630,7 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
|
|
||||||
// emit implementation of reinvokerTarget()
|
// emit implementation of reinvokerTarget()
|
||||||
mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "reinvokerTarget", "()" + MH_SIG, null, null);
|
mv = cw.visitMethod(NOT_ACC_PUBLIC + ACC_FINAL, "reinvokerTarget", "()" + MH_SIG, null, null);
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
mv.visitVarInsn(ALOAD, 0);
|
mv.visitVarInsn(ALOAD, 0);
|
||||||
mv.visitFieldInsn(GETFIELD, className, "argL0", JLO_SIG);
|
mv.visitFieldInsn(GETFIELD, className, "argL0", JLO_SIG);
|
||||||
@ -639,7 +640,7 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
|
|
||||||
// emit implementation of speciesData()
|
// emit implementation of speciesData()
|
||||||
mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "speciesData", MYSPECIES_DATA_SIG, null, null);
|
mv = cw.visitMethod(NOT_ACC_PUBLIC + ACC_FINAL, "speciesData", MYSPECIES_DATA_SIG, null, null);
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
mv.visitFieldInsn(GETSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG);
|
mv.visitFieldInsn(GETSTATIC, className, "SPECIES_DATA", SPECIES_DATA_SIG);
|
||||||
mv.visitInsn(ARETURN);
|
mv.visitInsn(ARETURN);
|
||||||
@ -647,7 +648,7 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
mv.visitEnd();
|
mv.visitEnd();
|
||||||
|
|
||||||
// emit clone()
|
// emit clone()
|
||||||
mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "clone", makeSignature("", false), null, E_THROWABLE);
|
mv = cw.visitMethod(NOT_ACC_PUBLIC + ACC_FINAL, "clone", makeSignature("", false), null, E_THROWABLE);
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
// return speciesData().constructor[0].invokeBasic(mt, lf, argL0, ...)
|
// return speciesData().constructor[0].invokeBasic(mt, lf, argL0, ...)
|
||||||
// obtain constructor
|
// obtain constructor
|
||||||
@ -670,7 +671,7 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
// for each type, emit cloneExtendT()
|
// for each type, emit cloneExtendT()
|
||||||
for (Class<?> c : TYPES) {
|
for (Class<?> c : TYPES) {
|
||||||
char t = Wrapper.basicTypeChar(c);
|
char t = Wrapper.basicTypeChar(c);
|
||||||
mv = cw.visitMethod(ACC_PUBLIC + ACC_FINAL, "cloneExtend" + t, makeSignature(String.valueOf(t), false), null, E_THROWABLE);
|
mv = cw.visitMethod(NOT_ACC_PUBLIC + ACC_FINAL, "cloneExtend" + t, makeSignature(String.valueOf(t), false), null, E_THROWABLE);
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
// return SPECIES_DATA.extendWithIndex(extensionIndex(t)).constructor[0].invokeBasic(mt, lf, argL0, ..., narg)
|
// return SPECIES_DATA.extendWithIndex(extensionIndex(t)).constructor[0].invokeBasic(mt, lf, argL0, ..., narg)
|
||||||
// obtain constructor
|
// obtain constructor
|
||||||
@ -697,7 +698,7 @@ import jdk.internal.org.objectweb.asm.Type;
|
|||||||
}
|
}
|
||||||
|
|
||||||
// emit class initializer
|
// emit class initializer
|
||||||
mv = cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "<clinit>", VOID_SIG, null, null);
|
mv = cw.visitMethod(NOT_ACC_PUBLIC | ACC_STATIC, "<clinit>", VOID_SIG, null, null);
|
||||||
mv.visitCode();
|
mv.visitCode();
|
||||||
mv.visitLdcInsn(types);
|
mv.visitLdcInsn(types);
|
||||||
mv.visitLdcInsn(Type.getObjectType(className));
|
mv.visitLdcInsn(Type.getObjectType(className));
|
||||||
|
@ -272,8 +272,9 @@ class InvokerBytecodeGenerator {
|
|||||||
* Set up class file generation.
|
* Set up class file generation.
|
||||||
*/
|
*/
|
||||||
private void classFilePrologue() {
|
private void classFilePrologue() {
|
||||||
|
final int NOT_ACC_PUBLIC = 0; // not ACC_PUBLIC
|
||||||
cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
|
cw = new ClassWriter(ClassWriter.COMPUTE_MAXS + ClassWriter.COMPUTE_FRAMES);
|
||||||
cw.visit(Opcodes.V1_8, Opcodes.ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, className, null, superName, null);
|
cw.visit(Opcodes.V1_8, NOT_ACC_PUBLIC + Opcodes.ACC_FINAL + Opcodes.ACC_SUPER, className, null, superName, null);
|
||||||
cw.visitSource(sourceFile, null);
|
cw.visitSource(sourceFile, null);
|
||||||
|
|
||||||
String invokerDesc = invokerType.toMethodDescriptorString();
|
String invokerDesc = invokerType.toMethodDescriptorString();
|
||||||
|
@ -2070,6 +2070,7 @@ assert((int)twice.invokeExact(21) == 42);
|
|||||||
*/
|
*/
|
||||||
public static
|
public static
|
||||||
MethodHandle permuteArguments(MethodHandle target, MethodType newType, int... reorder) {
|
MethodHandle permuteArguments(MethodHandle target, MethodType newType, int... reorder) {
|
||||||
|
reorder = reorder.clone();
|
||||||
checkReorder(reorder, newType, target.type());
|
checkReorder(reorder, newType, target.type());
|
||||||
return target.permuteArguments(newType, reorder);
|
return target.permuteArguments(newType, reorder);
|
||||||
}
|
}
|
||||||
@ -2264,6 +2265,7 @@ assertEquals("yz", (String) d0.invokeExact(123, "x", "y", "z"));
|
|||||||
throw newIllegalArgumentException("no argument type to remove");
|
throw newIllegalArgumentException("no argument type to remove");
|
||||||
ArrayList<Class<?>> ptypes = new ArrayList<>(oldType.parameterList());
|
ArrayList<Class<?>> ptypes = new ArrayList<>(oldType.parameterList());
|
||||||
ptypes.addAll(pos, valueTypes);
|
ptypes.addAll(pos, valueTypes);
|
||||||
|
if (ptypes.size() != inargs) throw newIllegalArgumentException("valueTypes");
|
||||||
MethodType newType = MethodType.methodType(oldType.returnType(), ptypes);
|
MethodType newType = MethodType.methodType(oldType.returnType(), ptypes);
|
||||||
return target.dropArguments(newType, pos, dropped);
|
return target.dropArguments(newType, pos, dropped);
|
||||||
}
|
}
|
||||||
|
@ -38,7 +38,6 @@ import java.io.Reader;
|
|||||||
import java.io.UncheckedIOException;
|
import java.io.UncheckedIOException;
|
||||||
import java.io.Writer;
|
import java.io.Writer;
|
||||||
import java.nio.channels.Channels;
|
import java.nio.channels.Channels;
|
||||||
import java.nio.channels.FileChannel;
|
|
||||||
import java.nio.channels.SeekableByteChannel;
|
import java.nio.channels.SeekableByteChannel;
|
||||||
import java.nio.charset.Charset;
|
import java.nio.charset.Charset;
|
||||||
import java.nio.charset.CharsetDecoder;
|
import java.nio.charset.CharsetDecoder;
|
||||||
@ -739,7 +738,7 @@ public final class Files {
|
|||||||
// don't have permission to get absolute path
|
// don't have permission to get absolute path
|
||||||
se = x;
|
se = x;
|
||||||
}
|
}
|
||||||
// find a decendent that exists
|
// find a descendant that exists
|
||||||
Path parent = dir.getParent();
|
Path parent = dir.getParent();
|
||||||
while (parent != null) {
|
while (parent != null) {
|
||||||
try {
|
try {
|
||||||
@ -1400,7 +1399,7 @@ public final class Files {
|
|||||||
return target;
|
return target;
|
||||||
}
|
}
|
||||||
|
|
||||||
// -- Miscellenous --
|
// -- Miscellaneous --
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reads the target of a symbolic link <i>(optional operation)</i>.
|
* Reads the target of a symbolic link <i>(optional operation)</i>.
|
||||||
@ -1535,7 +1534,7 @@ public final class Files {
|
|||||||
private static class FileTypeDetectors{
|
private static class FileTypeDetectors{
|
||||||
static final FileTypeDetector defaultFileTypeDetector =
|
static final FileTypeDetector defaultFileTypeDetector =
|
||||||
createDefaultFileTypeDetector();
|
createDefaultFileTypeDetector();
|
||||||
static final List<FileTypeDetector> installeDetectors =
|
static final List<FileTypeDetector> installedDetectors =
|
||||||
loadInstalledDetectors();
|
loadInstalledDetectors();
|
||||||
|
|
||||||
// creates the default file type detector
|
// creates the default file type detector
|
||||||
@ -1614,7 +1613,7 @@ public final class Files {
|
|||||||
throws IOException
|
throws IOException
|
||||||
{
|
{
|
||||||
// try installed file type detectors
|
// try installed file type detectors
|
||||||
for (FileTypeDetector detector: FileTypeDetectors.installeDetectors) {
|
for (FileTypeDetector detector: FileTypeDetectors.installedDetectors) {
|
||||||
String result = detector.probeContentType(path);
|
String result = detector.probeContentType(path);
|
||||||
if (result != null)
|
if (result != null)
|
||||||
return result;
|
return result;
|
||||||
@ -1922,7 +1921,7 @@ public final class Files {
|
|||||||
* </tr>
|
* </tr>
|
||||||
* <tr>
|
* <tr>
|
||||||
* <td> {@code "posix:permissions,owner,size"} </td>
|
* <td> {@code "posix:permissions,owner,size"} </td>
|
||||||
* <td> Reads the POSX file permissions, owner, and file size. </td>
|
* <td> Reads the POSIX file permissions, owner, and file size. </td>
|
||||||
* </tr>
|
* </tr>
|
||||||
* </table>
|
* </table>
|
||||||
* </blockquote>
|
* </blockquote>
|
||||||
@ -2448,7 +2447,7 @@ public final class Files {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used by isReadbale, isWritable, isExecutable to test access to a file.
|
* Used by isReadable, isWritable, isExecutable to test access to a file.
|
||||||
*/
|
*/
|
||||||
private static boolean isAccessible(Path path, AccessMode... modes) {
|
private static boolean isAccessible(Path path, AccessMode... modes) {
|
||||||
try {
|
try {
|
||||||
|
@ -81,7 +81,7 @@ public abstract class FileSystemProvider {
|
|||||||
// installed providers
|
// installed providers
|
||||||
private static volatile List<FileSystemProvider> installedProviders;
|
private static volatile List<FileSystemProvider> installedProviders;
|
||||||
|
|
||||||
// used to avoid recursive loading of instaled providers
|
// used to avoid recursive loading of installed providers
|
||||||
private static boolean loadingProviders = false;
|
private static boolean loadingProviders = false;
|
||||||
|
|
||||||
private static Void checkPermission() {
|
private static Void checkPermission() {
|
||||||
|
@ -1332,7 +1332,7 @@ public abstract class Provider extends Properties {
|
|||||||
addEngine("SSLContext", false, null);
|
addEngine("SSLContext", false, null);
|
||||||
addEngine("TrustManagerFactory", false, null);
|
addEngine("TrustManagerFactory", false, null);
|
||||||
// JGSS
|
// JGSS
|
||||||
addEngine("GssApiMechanism", true, "sun.security.jgss.GSSCaller");
|
addEngine("GssApiMechanism", false, null);
|
||||||
// SASL
|
// SASL
|
||||||
addEngine("SaslClientFactory", false, null);
|
addEngine("SaslClientFactory", false, null);
|
||||||
addEngine("SaslServerFactory", false, null);
|
addEngine("SaslServerFactory", false, null);
|
||||||
|
@ -382,7 +382,7 @@ public final class ServiceLoader<S>
|
|||||||
return p;
|
return p;
|
||||||
} catch (Throwable x) {
|
} catch (Throwable x) {
|
||||||
fail(service,
|
fail(service,
|
||||||
"Provider " + cn + " could not be instantiated: " + x,
|
"Provider " + cn + " could not be instantiated",
|
||||||
x);
|
x);
|
||||||
}
|
}
|
||||||
throw new Error(); // This cannot happen
|
throw new Error(); // This cannot happen
|
||||||
|
@ -676,6 +676,8 @@ class JarVerifier {
|
|||||||
} else {
|
} else {
|
||||||
matchUnsigned = true;
|
matchUnsigned = true;
|
||||||
}
|
}
|
||||||
|
} else {
|
||||||
|
matchUnsigned = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -778,23 +780,7 @@ class JarVerifier {
|
|||||||
|
|
||||||
// true if file is part of the signature mechanism itself
|
// true if file is part of the signature mechanism itself
|
||||||
static boolean isSigningRelated(String name) {
|
static boolean isSigningRelated(String name) {
|
||||||
name = name.toUpperCase(Locale.ENGLISH);
|
return SignatureFileVerifier.isSigningRelated(name);
|
||||||
if (!name.startsWith("META-INF/")) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
name = name.substring(9);
|
|
||||||
if (name.indexOf('/') != -1) {
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
if (name.endsWith(".DSA")
|
|
||||||
|| name.endsWith(".RSA")
|
|
||||||
|| name.endsWith(".SF")
|
|
||||||
|| name.endsWith(".EC")
|
|
||||||
|| name.startsWith("SIG-")
|
|
||||||
|| name.equals("MANIFEST.MF")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private Enumeration<String> unsignedEntryNames(JarFile jar) {
|
private Enumeration<String> unsignedEntryNames(JarFile jar) {
|
||||||
|
@ -464,7 +464,7 @@ public class LogManager {
|
|||||||
Logger result = getLogger(name);
|
Logger result = getLogger(name);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
// only allocate the new logger once
|
// only allocate the new logger once
|
||||||
Logger newLogger = new Logger(name, resourceBundleName, caller, this);
|
Logger newLogger = new Logger(name, resourceBundleName, caller, this, false);
|
||||||
do {
|
do {
|
||||||
if (addLogger(newLogger)) {
|
if (addLogger(newLogger)) {
|
||||||
// We successfully added the new Logger that we
|
// We successfully added the new Logger that we
|
||||||
@ -511,13 +511,13 @@ public class LogManager {
|
|||||||
} while (logger == null);
|
} while (logger == null);
|
||||||
|
|
||||||
// LogManager will set the sysLogger's handlers via LogManager.addLogger method.
|
// LogManager will set the sysLogger's handlers via LogManager.addLogger method.
|
||||||
if (logger != sysLogger && sysLogger.getHandlers().length == 0) {
|
if (logger != sysLogger && sysLogger.accessCheckedHandlers().length == 0) {
|
||||||
// if logger already exists but handlers not set
|
// if logger already exists but handlers not set
|
||||||
final Logger l = logger;
|
final Logger l = logger;
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
AccessController.doPrivileged(new PrivilegedAction<Void>() {
|
||||||
@Override
|
@Override
|
||||||
public Void run() {
|
public Void run() {
|
||||||
for (Handler hdl : l.getHandlers()) {
|
for (Handler hdl : l.accessCheckedHandlers()) {
|
||||||
sysLogger.addHandler(hdl);
|
sysLogger.addHandler(hdl);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
@ -835,7 +835,7 @@ public class LogManager {
|
|||||||
Logger result = findLogger(name);
|
Logger result = findLogger(name);
|
||||||
if (result == null) {
|
if (result == null) {
|
||||||
// only allocate the new system logger once
|
// only allocate the new system logger once
|
||||||
Logger newLogger = new Logger(name, resourceBundleName, null, getOwner());
|
Logger newLogger = new Logger(name, resourceBundleName, null, getOwner(), true);
|
||||||
do {
|
do {
|
||||||
if (addLocalLogger(newLogger)) {
|
if (addLocalLogger(newLogger)) {
|
||||||
// We successfully added the new Logger that we
|
// We successfully added the new Logger that we
|
||||||
@ -1527,7 +1527,7 @@ public class LogManager {
|
|||||||
// We do not call the protected Logger two args constructor here,
|
// We do not call the protected Logger two args constructor here,
|
||||||
// to avoid calling LogManager.getLogManager() from within the
|
// to avoid calling LogManager.getLogManager() from within the
|
||||||
// RootLogger constructor.
|
// RootLogger constructor.
|
||||||
super("", null, null, LogManager.this);
|
super("", null, null, LogManager.this, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -1550,9 +1550,9 @@ public class LogManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Handler[] getHandlers() {
|
Handler[] accessCheckedHandlers() {
|
||||||
initializeGlobalHandlers();
|
initializeGlobalHandlers();
|
||||||
return super.getHandlers();
|
return super.accessCheckedHandlers();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -277,6 +277,7 @@ public class Logger {
|
|||||||
private volatile Level levelObject;
|
private volatile Level levelObject;
|
||||||
private volatile int levelValue; // current effective level value
|
private volatile int levelValue; // current effective level value
|
||||||
private WeakReference<ClassLoader> callersClassLoaderRef;
|
private WeakReference<ClassLoader> callersClassLoaderRef;
|
||||||
|
private final boolean isSystemLogger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* GLOBAL_LOGGER_NAME is a name for the global logger.
|
* GLOBAL_LOGGER_NAME is a name for the global logger.
|
||||||
@ -370,11 +371,12 @@ public class Logger {
|
|||||||
* no corresponding resource can be found.
|
* no corresponding resource can be found.
|
||||||
*/
|
*/
|
||||||
protected Logger(String name, String resourceBundleName) {
|
protected Logger(String name, String resourceBundleName) {
|
||||||
this(name, resourceBundleName, null, LogManager.getLogManager());
|
this(name, resourceBundleName, null, LogManager.getLogManager(), false);
|
||||||
}
|
}
|
||||||
|
|
||||||
Logger(String name, String resourceBundleName, Class<?> caller, LogManager manager) {
|
Logger(String name, String resourceBundleName, Class<?> caller, LogManager manager, boolean isSystemLogger) {
|
||||||
this.manager = manager;
|
this.manager = manager;
|
||||||
|
this.isSystemLogger = isSystemLogger;
|
||||||
setupResourceInfo(resourceBundleName, caller);
|
setupResourceInfo(resourceBundleName, caller);
|
||||||
this.name = name;
|
this.name = name;
|
||||||
levelValue = Level.INFO.intValue();
|
levelValue = Level.INFO.intValue();
|
||||||
@ -401,6 +403,7 @@ public class Logger {
|
|||||||
private Logger(String name) {
|
private Logger(String name) {
|
||||||
// The manager field is not initialized here.
|
// The manager field is not initialized here.
|
||||||
this.name = name;
|
this.name = name;
|
||||||
|
this.isSystemLogger = true;
|
||||||
levelValue = Level.INFO.intValue();
|
levelValue = Level.INFO.intValue();
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -635,7 +638,7 @@ public class Logger {
|
|||||||
// cleanup some Loggers that have been GC'ed
|
// cleanup some Loggers that have been GC'ed
|
||||||
manager.drainLoggerRefQueueBounded();
|
manager.drainLoggerRefQueueBounded();
|
||||||
Logger result = new Logger(null, resourceBundleName,
|
Logger result = new Logger(null, resourceBundleName,
|
||||||
Reflection.getCallerClass(), manager);
|
Reflection.getCallerClass(), manager, false);
|
||||||
result.anonymous = true;
|
result.anonymous = true;
|
||||||
Logger root = manager.getLogger("");
|
Logger root = manager.getLogger("");
|
||||||
result.doSetParent(root);
|
result.doSetParent(root);
|
||||||
@ -727,15 +730,23 @@ public class Logger {
|
|||||||
|
|
||||||
Logger logger = this;
|
Logger logger = this;
|
||||||
while (logger != null) {
|
while (logger != null) {
|
||||||
for (Handler handler : logger.getHandlers()) {
|
final Handler[] loggerHandlers = isSystemLogger
|
||||||
|
? logger.accessCheckedHandlers()
|
||||||
|
: logger.getHandlers();
|
||||||
|
|
||||||
|
for (Handler handler : loggerHandlers) {
|
||||||
handler.publish(record);
|
handler.publish(record);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!logger.getUseParentHandlers()) {
|
final boolean useParentHdls = isSystemLogger
|
||||||
|
? logger.useParentHandlers
|
||||||
|
: logger.getUseParentHandlers();
|
||||||
|
|
||||||
|
if (!useParentHdls) {
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
logger = logger.getParent();
|
logger = isSystemLogger ? logger.parent : logger.getParent();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1762,6 +1773,12 @@ public class Logger {
|
|||||||
* @return an array of all registered Handlers
|
* @return an array of all registered Handlers
|
||||||
*/
|
*/
|
||||||
public Handler[] getHandlers() {
|
public Handler[] getHandlers() {
|
||||||
|
return accessCheckedHandlers();
|
||||||
|
}
|
||||||
|
|
||||||
|
// This method should ideally be marked final - but unfortunately
|
||||||
|
// it needs to be overridden by LogManager.RootLogger
|
||||||
|
Handler[] accessCheckedHandlers() {
|
||||||
return handlers.toArray(emptyHandlers);
|
return handlers.toArray(emptyHandlers);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2149,12 +2166,14 @@ public class Logger {
|
|||||||
if (trb.userBundle != null) {
|
if (trb.userBundle != null) {
|
||||||
return trb;
|
return trb;
|
||||||
}
|
}
|
||||||
final String rbName = target.getResourceBundleName();
|
final String rbName = isSystemLogger
|
||||||
|
? trb.resourceBundleName
|
||||||
|
: target.getResourceBundleName();
|
||||||
if (rbName != null) {
|
if (rbName != null) {
|
||||||
return LoggerBundle.get(rbName,
|
return LoggerBundle.get(rbName,
|
||||||
findResourceBundle(rbName, true));
|
findResourceBundle(rbName, true));
|
||||||
}
|
}
|
||||||
target = target.getParent();
|
target = isSystemLogger ? target.parent : target.getParent();
|
||||||
}
|
}
|
||||||
return NO_RESOURCE_BUNDLE;
|
return NO_RESOURCE_BUNDLE;
|
||||||
}
|
}
|
||||||
|
@ -81,23 +81,28 @@ public class ScriptEngineManager {
|
|||||||
nameAssociations = new HashMap<String, ScriptEngineFactory>();
|
nameAssociations = new HashMap<String, ScriptEngineFactory>();
|
||||||
extensionAssociations = new HashMap<String, ScriptEngineFactory>();
|
extensionAssociations = new HashMap<String, ScriptEngineFactory>();
|
||||||
mimeTypeAssociations = new HashMap<String, ScriptEngineFactory>();
|
mimeTypeAssociations = new HashMap<String, ScriptEngineFactory>();
|
||||||
AccessController.doPrivileged(new PrivilegedAction<Object>() {
|
initEngines(loader);
|
||||||
public Object run() {
|
}
|
||||||
initEngines(loader);
|
|
||||||
return null;
|
private ServiceLoader<ScriptEngineFactory> getServiceLoader(final ClassLoader loader) {
|
||||||
}
|
if (loader != null) {
|
||||||
});
|
return ServiceLoader.load(ScriptEngineFactory.class, loader);
|
||||||
|
} else {
|
||||||
|
return ServiceLoader.loadInstalled(ScriptEngineFactory.class);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void initEngines(final ClassLoader loader) {
|
private void initEngines(final ClassLoader loader) {
|
||||||
Iterator<ScriptEngineFactory> itr = null;
|
Iterator<ScriptEngineFactory> itr = null;
|
||||||
try {
|
try {
|
||||||
ServiceLoader<ScriptEngineFactory> sl;
|
ServiceLoader<ScriptEngineFactory> sl = AccessController.doPrivileged(
|
||||||
if (loader != null) {
|
new PrivilegedAction<ServiceLoader<ScriptEngineFactory>>() {
|
||||||
sl = ServiceLoader.load(ScriptEngineFactory.class, loader);
|
@Override
|
||||||
} else {
|
public ServiceLoader<ScriptEngineFactory> run() {
|
||||||
sl = ServiceLoader.loadInstalled(ScriptEngineFactory.class);
|
return getServiceLoader(loader);
|
||||||
}
|
}
|
||||||
|
});
|
||||||
|
|
||||||
itr = sl.iterator();
|
itr = sl.iterator();
|
||||||
} catch (ServiceConfigurationError err) {
|
} catch (ServiceConfigurationError err) {
|
||||||
System.err.println("Can't find ScriptEngineFactory providers: " +
|
System.err.println("Can't find ScriptEngineFactory providers: " +
|
||||||
|
@ -959,14 +959,30 @@ public final class Subject implements java.io.Serializable {
|
|||||||
/**
|
/**
|
||||||
* Reads this object from a stream (i.e., deserializes it)
|
* Reads this object from a stream (i.e., deserializes it)
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private void readObject(java.io.ObjectInputStream s)
|
private void readObject(java.io.ObjectInputStream s)
|
||||||
throws java.io.IOException, ClassNotFoundException {
|
throws java.io.IOException, ClassNotFoundException {
|
||||||
|
|
||||||
s.defaultReadObject();
|
ObjectInputStream.GetField gf = s.readFields();
|
||||||
|
|
||||||
|
readOnly = gf.get("readOnly", false);
|
||||||
|
|
||||||
|
Set<Principal> inputPrincs = (Set<Principal>)gf.get("principals", null);
|
||||||
|
|
||||||
// Rewrap the principals into a SecureSet
|
// Rewrap the principals into a SecureSet
|
||||||
principals = Collections.synchronizedSet(new SecureSet<Principal>
|
if (inputPrincs == null) {
|
||||||
(this, PRINCIPAL_SET, principals));
|
throw new NullPointerException
|
||||||
|
(ResourcesMgr.getString("invalid.null.input.s."));
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
principals = Collections.synchronizedSet(new SecureSet<Principal>
|
||||||
|
(this, PRINCIPAL_SET, inputPrincs));
|
||||||
|
} catch (NullPointerException npe) {
|
||||||
|
// Sometimes people deserialize the principals set only.
|
||||||
|
// Subject is not accessible, so just don't fail.
|
||||||
|
principals = Collections.synchronizedSet
|
||||||
|
(new SecureSet<Principal>(this, PRINCIPAL_SET));
|
||||||
|
}
|
||||||
|
|
||||||
// The Credential {@code Set} is not serialized, but we do not
|
// The Credential {@code Set} is not serialized, but we do not
|
||||||
// want the default deserialization routine to set it to null.
|
// want the default deserialization routine to set it to null.
|
||||||
|
@ -28,8 +28,11 @@ package javax.sql.rowset;
|
|||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
import java.sql.SQLException;
|
import java.sql.SQLException;
|
||||||
|
import java.util.PropertyPermission;
|
||||||
import java.util.ServiceConfigurationError;
|
import java.util.ServiceConfigurationError;
|
||||||
import java.util.ServiceLoader;
|
import java.util.ServiceLoader;
|
||||||
|
import javax.sql.rowset.spi.SyncFactoryException;
|
||||||
|
import sun.reflect.misc.ReflectUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A factory API that enables applications to obtain a
|
* A factory API that enables applications to obtain a
|
||||||
@ -129,15 +132,11 @@ public class RowSetProvider {
|
|||||||
factoryClassName = getSystemProperty(ROWSET_FACTORY_NAME);
|
factoryClassName = getSystemProperty(ROWSET_FACTORY_NAME);
|
||||||
if (factoryClassName != null) {
|
if (factoryClassName != null) {
|
||||||
trace("Found system property, value=" + factoryClassName);
|
trace("Found system property, value=" + factoryClassName);
|
||||||
factory = (RowSetFactory) getFactoryClass(factoryClassName, null, true).newInstance();
|
factory = (RowSetFactory) ReflectUtil.newInstance(getFactoryClass(factoryClassName, null, true));
|
||||||
}
|
}
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (Exception e) {
|
||||||
throw new SQLException(
|
throw new SQLException( "RowSetFactory: " + factoryClassName +
|
||||||
"RowSetFactory: " + factoryClassName + " not found", e);
|
" could not be instantiated: ", e);
|
||||||
} catch (Exception e) {
|
|
||||||
throw new SQLException(
|
|
||||||
"RowSetFactory: " + factoryClassName + " could not be instantiated: " + e,
|
|
||||||
e);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check to see if we found the RowSetFactory via a System property
|
// Check to see if we found the RowSetFactory via a System property
|
||||||
@ -182,6 +181,16 @@ public class RowSetProvider {
|
|||||||
throws SQLException {
|
throws SQLException {
|
||||||
|
|
||||||
trace("***In newInstance()");
|
trace("***In newInstance()");
|
||||||
|
|
||||||
|
if(factoryClassName == null) {
|
||||||
|
throw new SQLException("Error: factoryClassName cannot be null");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
ReflectUtil.checkPackageAccess(factoryClassName);
|
||||||
|
} catch (java.security.AccessControlException e) {
|
||||||
|
throw new SQLException("Access Exception",e);
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
Class<?> providerClass = getFactoryClass(factoryClassName, cl, false);
|
Class<?> providerClass = getFactoryClass(factoryClassName, cl, false);
|
||||||
RowSetFactory instance = (RowSetFactory) providerClass.newInstance();
|
RowSetFactory instance = (RowSetFactory) providerClass.newInstance();
|
||||||
@ -291,8 +300,9 @@ public class RowSetProvider {
|
|||||||
public String run() {
|
public String run() {
|
||||||
return System.getProperty(propName);
|
return System.getProperty(propName);
|
||||||
}
|
}
|
||||||
});
|
}, null, new PropertyPermission(propName, "read"));
|
||||||
} catch (SecurityException se) {
|
} catch (SecurityException se) {
|
||||||
|
trace("error getting " + propName + ": "+ se);
|
||||||
if (debug) {
|
if (debug) {
|
||||||
se.printStackTrace();
|
se.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@ -27,6 +27,7 @@ package javax.sql.rowset.serial;
|
|||||||
import java.sql.*;
|
import java.sql.*;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
import sun.reflect.misc.ReflectUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* An input stream used for custom mapping user-defined types (UDTs).
|
* An input stream used for custom mapping user-defined types (UDTs).
|
||||||
@ -476,13 +477,9 @@ public class SQLInputImpl implements SQLInput {
|
|||||||
// create new instance of the class
|
// create new instance of the class
|
||||||
SQLData obj = null;
|
SQLData obj = null;
|
||||||
try {
|
try {
|
||||||
obj = (SQLData)c.newInstance();
|
obj = (SQLData)ReflectUtil.newInstance(c);
|
||||||
} catch (java.lang.InstantiationException ex) {
|
} catch (Exception ex) {
|
||||||
throw new SQLException("Unable to instantiate: " +
|
throw new SQLException("Unable to Instantiate: ", ex);
|
||||||
ex.getMessage());
|
|
||||||
} catch (java.lang.IllegalAccessException ex) {
|
|
||||||
throw new SQLException("Unable to instantiate: " +
|
|
||||||
ex.getMessage());
|
|
||||||
}
|
}
|
||||||
// get the attributes from the struct
|
// get the attributes from the struct
|
||||||
Object attribs[] = s.getAttributes(map);
|
Object attribs[] = s.getAttributes(map);
|
||||||
|
@ -37,8 +37,11 @@ import java.io.IOException;
|
|||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
import java.security.PrivilegedAction;
|
import java.security.PrivilegedAction;
|
||||||
|
import java.security.PrivilegedActionException;
|
||||||
|
import java.security.PrivilegedExceptionAction;
|
||||||
|
|
||||||
import javax.naming.*;
|
import javax.naming.*;
|
||||||
|
import sun.reflect.misc.ReflectUtil;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Service Provider Interface (SPI) mechanism that generates <code>SyncProvider</code>
|
* The Service Provider Interface (SPI) mechanism that generates <code>SyncProvider</code>
|
||||||
@ -329,7 +332,7 @@ public class SyncFactory {
|
|||||||
// Local implementation class names and keys from Properties
|
// Local implementation class names and keys from Properties
|
||||||
// file, translate names into Class objects using Class.forName
|
// file, translate names into Class objects using Class.forName
|
||||||
// and store mappings
|
// and store mappings
|
||||||
Properties properties = new Properties();
|
final Properties properties = new Properties();
|
||||||
|
|
||||||
if (implementations == null) {
|
if (implementations == null) {
|
||||||
implementations = new Hashtable<>();
|
implementations = new Hashtable<>();
|
||||||
@ -356,10 +359,11 @@ public class SyncFactory {
|
|||||||
public String run() {
|
public String run() {
|
||||||
return System.getProperty("rowset.properties");
|
return System.getProperty("rowset.properties");
|
||||||
}
|
}
|
||||||
}, null, new PropertyPermission("rowset.properties","read"));
|
}, null, new PropertyPermission("rowset.properties", "read"));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
System.out.println("errorget rowset.properties: " + ex);
|
||||||
strRowsetProperties = null;
|
strRowsetProperties = null;
|
||||||
}
|
};
|
||||||
|
|
||||||
if (strRowsetProperties != null) {
|
if (strRowsetProperties != null) {
|
||||||
// Load user's implementation of SyncProvider
|
// Load user's implementation of SyncProvider
|
||||||
@ -380,14 +384,27 @@ public class SyncFactory {
|
|||||||
|
|
||||||
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
ClassLoader cl = Thread.currentThread().getContextClassLoader();
|
||||||
|
|
||||||
try (InputStream stream =
|
try {
|
||||||
(cl == null) ? ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES)
|
AccessController.doPrivileged((PrivilegedExceptionAction<Void>) () -> {
|
||||||
: cl.getResourceAsStream(ROWSET_PROPERTIES)) {
|
try (InputStream stream = (cl == null) ?
|
||||||
if (stream == null) {
|
ClassLoader.getSystemResourceAsStream(ROWSET_PROPERTIES)
|
||||||
throw new SyncFactoryException(
|
: cl.getResourceAsStream(ROWSET_PROPERTIES)) {
|
||||||
"Resource " + ROWSET_PROPERTIES + " not found");
|
if (stream == null) {
|
||||||
|
throw new SyncFactoryException("Resource " + ROWSET_PROPERTIES + " not found");
|
||||||
|
}
|
||||||
|
properties.load(stream);
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
});
|
||||||
|
} catch (PrivilegedActionException ex) {
|
||||||
|
Throwable e = ex.getException();
|
||||||
|
if (e instanceof SyncFactoryException) {
|
||||||
|
throw (SyncFactoryException) e;
|
||||||
|
} else {
|
||||||
|
SyncFactoryException sfe = new SyncFactoryException();
|
||||||
|
sfe.initCause(ex.getException());
|
||||||
|
throw sfe;
|
||||||
}
|
}
|
||||||
properties.load(stream);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
parseProperties(properties);
|
parseProperties(properties);
|
||||||
@ -411,7 +428,7 @@ public class SyncFactory {
|
|||||||
public String run() {
|
public String run() {
|
||||||
return System.getProperty(ROWSET_SYNC_PROVIDER);
|
return System.getProperty(ROWSET_SYNC_PROVIDER);
|
||||||
}
|
}
|
||||||
}, null, new PropertyPermission(ROWSET_SYNC_PROVIDER,"read"));
|
}, null, new PropertyPermission(ROWSET_SYNC_PROVIDER, "read"));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
providerImpls = null;
|
providerImpls = null;
|
||||||
}
|
}
|
||||||
@ -547,6 +564,14 @@ public class SyncFactory {
|
|||||||
return new com.sun.rowset.providers.RIOptimisticProvider();
|
return new com.sun.rowset.providers.RIOptimisticProvider();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
ReflectUtil.checkPackageAccess(providerID);
|
||||||
|
} catch (java.security.AccessControlException e) {
|
||||||
|
SyncFactoryException sfe = new SyncFactoryException();
|
||||||
|
sfe.initCause(e);
|
||||||
|
throw sfe;
|
||||||
|
}
|
||||||
|
|
||||||
// Attempt to invoke classname from registered SyncProvider list
|
// Attempt to invoke classname from registered SyncProvider list
|
||||||
Class<?> c = null;
|
Class<?> c = null;
|
||||||
try {
|
try {
|
||||||
@ -555,7 +580,7 @@ public class SyncFactory {
|
|||||||
/**
|
/**
|
||||||
* The SyncProvider implementation of the user will be in
|
* The SyncProvider implementation of the user will be in
|
||||||
* the classpath. We need to find the ClassLoader which loads
|
* the classpath. We need to find the ClassLoader which loads
|
||||||
* this SyncFactory and try to laod the SyncProvider class from
|
* this SyncFactory and try to load the SyncProvider class from
|
||||||
* there.
|
* there.
|
||||||
**/
|
**/
|
||||||
c = Class.forName(providerID, true, cl);
|
c = Class.forName(providerID, true, cl);
|
||||||
|
@ -0,0 +1,83 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (c) 2007, 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. 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 jdk.nio.zipfs;
|
||||||
|
|
||||||
|
import java.nio.file.*;
|
||||||
|
import java.nio.file.spi.*;
|
||||||
|
import java.nio.file.attribute.*;
|
||||||
|
import java.nio.file.spi.FileSystemProvider;
|
||||||
|
|
||||||
|
import java.net.URI;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.net.URISyntaxException;
|
||||||
|
import java.nio.channels.FileChannel;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Set;
|
||||||
|
|
||||||
|
class JarFileSystemProvider extends ZipFileSystemProvider
|
||||||
|
{
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getScheme() {
|
||||||
|
return "jar";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Path uriToPath(URI uri) {
|
||||||
|
String scheme = uri.getScheme();
|
||||||
|
if ((scheme == null) || !scheme.equalsIgnoreCase(getScheme())) {
|
||||||
|
throw new IllegalArgumentException("URI scheme is not '" + getScheme() + "'");
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
String uristr = uri.toString();
|
||||||
|
int end = uristr.indexOf("!/");
|
||||||
|
uristr = uristr.substring(4, (end == -1) ? uristr.length() : end);
|
||||||
|
uri = new URI(uristr);
|
||||||
|
return Paths.get(new URI("file", uri.getHost(), uri.getPath(), null))
|
||||||
|
.toAbsolutePath();
|
||||||
|
} catch (URISyntaxException e) {
|
||||||
|
throw new AssertionError(e); //never thrown
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Path getPath(URI uri) {
|
||||||
|
FileSystem fs = getFileSystem(uri);
|
||||||
|
String path = uri.getFragment();
|
||||||
|
if (path == null) {
|
||||||
|
String uristr = uri.toString();
|
||||||
|
int off = uristr.indexOf("!/");
|
||||||
|
if (off != -1)
|
||||||
|
path = uristr.substring(off + 2);
|
||||||
|
}
|
||||||
|
if (path != null)
|
||||||
|
return fs.getPath(path);
|
||||||
|
throw new IllegalArgumentException("URI: "
|
||||||
|
+ uri
|
||||||
|
+ " does not contain path fragment ex. jar:///c:/foo.zip!/BAR");
|
||||||
|
}
|
||||||
|
}
|
@ -0,0 +1,2 @@
|
|||||||
|
jdk.nio.zipfs.ZipFileSystemProvider
|
||||||
|
|
@ -1,44 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2011, 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* modification, are permitted provided that the following conditions
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
* are met:
|
* 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.
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* 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).
|
||||||
*
|
*
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
* You should have received a copy of the GNU General Public License version
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* - Neither the name of Oracle nor the names of its
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
* contributors may be used to endorse or promote products derived
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* from this software without specific prior written permission.
|
* questions.
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package jdk.nio.zipfs;
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
import java.nio.ByteBuffer;
|
import java.nio.ByteBuffer;
|
||||||
import java.nio.CharBuffer;
|
import java.nio.CharBuffer;
|
@ -1,45 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2012, 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* modification, are permitted provided that the following conditions
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
* are met:
|
* 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.
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* 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).
|
||||||
*
|
*
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
* You should have received a copy of the GNU General Public License version
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* - Neither the name of Oracle nor the names of its
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
* contributors may be used to endorse or promote products derived
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* from this software without specific prior written permission.
|
* questions.
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package jdk.nio.zipfs;
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
@ -1,44 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2011, 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* modification, are permitted provided that the following conditions
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
* are met:
|
* 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.
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* 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).
|
||||||
*
|
*
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
* You should have received a copy of the GNU General Public License version
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* - Neither the name of Oracle nor the names of its
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
* contributors may be used to endorse or promote products derived
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* from this software without specific prior written permission.
|
* questions.
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package jdk.nio.zipfs;
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
import java.nio.file.DirectoryStream;
|
import java.nio.file.DirectoryStream;
|
||||||
import java.nio.file.ClosedDirectoryStreamException;
|
import java.nio.file.ClosedDirectoryStreamException;
|
||||||
@ -53,7 +38,7 @@ import java.io.IOException;
|
|||||||
* @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
|
* @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ZipDirectoryStream implements DirectoryStream<Path> {
|
class ZipDirectoryStream implements DirectoryStream<Path> {
|
||||||
|
|
||||||
private final ZipFileSystem zipfs;
|
private final ZipFileSystem zipfs;
|
||||||
private final byte[] path;
|
private final byte[] path;
|
@ -1,45 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2011, 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* modification, are permitted provided that the following conditions
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
* are met:
|
* 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.
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* 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).
|
||||||
*
|
*
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
* You should have received a copy of the GNU General Public License version
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* - Neither the name of Oracle nor the names of its
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
* contributors may be used to endorse or promote products derived
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* from this software without specific prior written permission.
|
* questions.
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package jdk.nio.zipfs;
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
import java.nio.file.attribute.*;
|
import java.nio.file.attribute.*;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@ -50,7 +34,7 @@ import java.util.Map;
|
|||||||
* @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
|
* @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ZipFileAttributeView implements BasicFileAttributeView
|
class ZipFileAttributeView implements BasicFileAttributeView
|
||||||
{
|
{
|
||||||
private static enum AttrID {
|
private static enum AttrID {
|
||||||
size,
|
size,
|
@ -1,59 +1,42 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2011, 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* modification, are permitted provided that the following conditions
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
* are met:
|
* 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.
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* 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).
|
||||||
*
|
*
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
* You should have received a copy of the GNU General Public License version
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* - Neither the name of Oracle nor the names of its
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
* contributors may be used to endorse or promote products derived
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* from this software without specific prior written permission.
|
* questions.
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package jdk.nio.zipfs;
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
import java.nio.file.attribute.BasicFileAttributes;
|
import java.nio.file.attribute.BasicFileAttributes;
|
||||||
import java.nio.file.attribute.FileTime;
|
import java.nio.file.attribute.FileTime;
|
||||||
import java.util.Arrays;
|
import java.util.Arrays;
|
||||||
import java.util.Formatter;
|
import java.util.Formatter;
|
||||||
import static com.sun.nio.zipfs.ZipUtils.*;
|
import static jdk.nio.zipfs.ZipUtils.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
* @author Xueming Shen, Rajendra Gutupalli,Jaya Hangal
|
* @author Xueming Shen, Rajendra Gutupalli,Jaya Hangal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ZipFileAttributes implements BasicFileAttributes
|
class ZipFileAttributes implements BasicFileAttributes
|
||||||
|
|
||||||
{
|
{
|
||||||
private final ZipFileSystem.Entry e;
|
private final ZipFileSystem.Entry e;
|
||||||
|
|
@ -1,44 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2012, 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* modification, are permitted provided that the following conditions
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
* are met:
|
* 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.
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* 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).
|
||||||
*
|
*
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
* You should have received a copy of the GNU General Public License version
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* - Neither the name of Oracle nor the names of its
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
* contributors may be used to endorse or promote products derived
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* from this software without specific prior written permission.
|
* questions.
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package jdk.nio.zipfs;
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
@ -56,7 +41,7 @@ import java.util.Formatter;
|
|||||||
* @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
|
* @author Xueming Shen, Rajendra Gutupalli, Jaya Hangal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ZipFileStore extends FileStore {
|
class ZipFileStore extends FileStore {
|
||||||
|
|
||||||
private final ZipFileSystem zfs;
|
private final ZipFileSystem zfs;
|
||||||
|
|
@ -1,44 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2013, 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* modification, are permitted provided that the following conditions
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
* are met:
|
* 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.
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* 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).
|
||||||
*
|
*
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
* You should have received a copy of the GNU General Public License version
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* - Neither the name of Oracle nor the names of its
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
* contributors may be used to endorse or promote products derived
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* from this software without specific prior written permission.
|
* questions.
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package jdk.nio.zipfs;
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
import java.io.BufferedOutputStream;
|
import java.io.BufferedOutputStream;
|
||||||
import java.io.ByteArrayInputStream;
|
import java.io.ByteArrayInputStream;
|
||||||
@ -54,6 +39,8 @@ import java.nio.channels.*;
|
|||||||
import java.nio.file.*;
|
import java.nio.file.*;
|
||||||
import java.nio.file.attribute.*;
|
import java.nio.file.attribute.*;
|
||||||
import java.nio.file.spi.*;
|
import java.nio.file.spi.*;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.locks.ReadWriteLock;
|
import java.util.concurrent.locks.ReadWriteLock;
|
||||||
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
import java.util.concurrent.locks.ReentrantReadWriteLock;
|
||||||
@ -66,8 +53,8 @@ import java.util.zip.DeflaterOutputStream;
|
|||||||
import java.util.zip.ZipException;
|
import java.util.zip.ZipException;
|
||||||
import java.util.zip.ZipError;
|
import java.util.zip.ZipError;
|
||||||
import static java.lang.Boolean.*;
|
import static java.lang.Boolean.*;
|
||||||
import static com.sun.nio.zipfs.ZipConstants.*;
|
import static jdk.nio.zipfs.ZipConstants.*;
|
||||||
import static com.sun.nio.zipfs.ZipUtils.*;
|
import static jdk.nio.zipfs.ZipUtils.*;
|
||||||
import static java.nio.file.StandardOpenOption.*;
|
import static java.nio.file.StandardOpenOption.*;
|
||||||
import static java.nio.file.StandardCopyOption.*;
|
import static java.nio.file.StandardCopyOption.*;
|
||||||
|
|
||||||
@ -77,7 +64,7 @@ import static java.nio.file.StandardCopyOption.*;
|
|||||||
* @author Xueming Shen
|
* @author Xueming Shen
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ZipFileSystem extends FileSystem {
|
class ZipFileSystem extends FileSystem {
|
||||||
|
|
||||||
private final ZipFileSystemProvider provider;
|
private final ZipFileSystemProvider provider;
|
||||||
private final ZipPath defaultdir;
|
private final ZipPath defaultdir;
|
||||||
@ -91,8 +78,9 @@ public class ZipFileSystem extends FileSystem {
|
|||||||
private final boolean useTempFile; // use a temp file for newOS, default
|
private final boolean useTempFile; // use a temp file for newOS, default
|
||||||
// is to use BAOS for better performance
|
// is to use BAOS for better performance
|
||||||
private final boolean createNew; // create a new zip if not exists
|
private final boolean createNew; // create a new zip if not exists
|
||||||
private static final boolean isWindows =
|
private static final boolean isWindows = AccessController.doPrivileged(
|
||||||
System.getProperty("os.name").startsWith("Windows");
|
(PrivilegedAction<Boolean>) () -> System.getProperty("os.name")
|
||||||
|
.startsWith("Windows"));
|
||||||
|
|
||||||
ZipFileSystem(ZipFileSystemProvider provider,
|
ZipFileSystem(ZipFileSystemProvider provider,
|
||||||
Path zfpath,
|
Path zfpath,
|
@ -1,44 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2012, 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* modification, are permitted provided that the following conditions
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
* are met:
|
* 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.
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* 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).
|
||||||
*
|
*
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
* You should have received a copy of the GNU General Public License version
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* - Neither the name of Oracle nor the names of its
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
* contributors may be used to endorse or promote products derived
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* from this software without specific prior written permission.
|
* questions.
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package jdk.nio.zipfs;
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.nio.channels.*;
|
import java.nio.channels.*;
|
@ -1,50 +1,35 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2013, 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* modification, are permitted provided that the following conditions
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
* are met:
|
* 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.
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* 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).
|
||||||
*
|
*
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
* You should have received a copy of the GNU General Public License version
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* - Neither the name of Oracle nor the names of its
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
* contributors may be used to endorse or promote products derived
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* from this software without specific prior written permission.
|
* questions.
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package jdk.nio.zipfs;
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
import java.nio.file.Paths;
|
import java.nio.file.Paths;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import static com.sun.nio.zipfs.ZipConstants.*;
|
import static jdk.nio.zipfs.ZipConstants.*;
|
||||||
import static com.sun.nio.zipfs.ZipUtils.*;
|
import static jdk.nio.zipfs.ZipUtils.*;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Print all loc and cen headers of the ZIP file
|
* Print all loc and cen headers of the ZIP file
|
@ -1,44 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2011, 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* modification, are permitted provided that the following conditions
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
* are met:
|
* 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.
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* 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).
|
||||||
*
|
*
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
* You should have received a copy of the GNU General Public License version
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* - Neither the name of Oracle nor the names of its
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
* contributors may be used to endorse or promote products derived
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* from this software without specific prior written permission.
|
* questions.
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package jdk.nio.zipfs;
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.net.URI;
|
import java.net.URI;
|
||||||
@ -56,7 +41,7 @@ import static java.nio.file.StandardCopyOption.*;
|
|||||||
* @author Xueming Shen, Rajendra Gutupalli,Jaya Hangal
|
* @author Xueming Shen, Rajendra Gutupalli,Jaya Hangal
|
||||||
*/
|
*/
|
||||||
|
|
||||||
public class ZipPath implements Path {
|
class ZipPath implements Path {
|
||||||
|
|
||||||
private final ZipFileSystem zfs;
|
private final ZipFileSystem zfs;
|
||||||
private final byte[] path;
|
private final byte[] path;
|
@ -1,44 +1,29 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2009, 2011, 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.
|
||||||
*
|
*
|
||||||
* Redistribution and use in source and binary forms, with or without
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
* modification, are permitted provided that the following conditions
|
* under the terms of the GNU General Public License version 2 only, as
|
||||||
* are met:
|
* 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.
|
||||||
*
|
*
|
||||||
* - Redistributions of source code must retain the above copyright
|
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||||
* notice, this list of conditions and the following disclaimer.
|
* 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).
|
||||||
*
|
*
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
* You should have received a copy of the GNU General Public License version
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||||
* documentation and/or other materials provided with the distribution.
|
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||||
*
|
*
|
||||||
* - Neither the name of Oracle nor the names of its
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||||
* contributors may be used to endorse or promote products derived
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
* from this software without specific prior written permission.
|
* questions.
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
package jdk.nio.zipfs;
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
@ -27,13 +27,15 @@ package sun.awt;
|
|||||||
|
|
||||||
import java.awt.AWTEvent;
|
import java.awt.AWTEvent;
|
||||||
|
|
||||||
import java.util.Collections;
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.IdentityHashMap;
|
import java.util.IdentityHashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
|
|
||||||
import sun.util.logging.PlatformLogger;
|
import sun.util.logging.PlatformLogger;
|
||||||
|
import sun.misc.ThreadGroupUtils;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This class is to let AWT shutdown automatically when a user is done
|
* This class is to let AWT shutdown automatically when a user is done
|
||||||
@ -215,7 +217,10 @@ public final class AWTAutoShutdown implements Runnable {
|
|||||||
synchronized (activationLock) {
|
synchronized (activationLock) {
|
||||||
synchronized (mainLock) {
|
synchronized (mainLock) {
|
||||||
if (!isReadyToShutdown() && blockerThread == null) {
|
if (!isReadyToShutdown() && blockerThread == null) {
|
||||||
activateBlockerThread();
|
AccessController.doPrivileged((PrivilegedAction<Void>) () -> {
|
||||||
|
activateBlockerThread();
|
||||||
|
return null;
|
||||||
|
});
|
||||||
} else {
|
} else {
|
||||||
mainLock.notifyAll();
|
mainLock.notifyAll();
|
||||||
timeoutPassed = false;
|
timeoutPassed = false;
|
||||||
@ -331,9 +336,12 @@ public final class AWTAutoShutdown implements Runnable {
|
|||||||
/**
|
/**
|
||||||
* Creates and starts a new blocker thread. Doesn't return until
|
* Creates and starts a new blocker thread. Doesn't return until
|
||||||
* the new blocker thread starts.
|
* the new blocker thread starts.
|
||||||
|
*
|
||||||
|
* Must be called with {@link sun.security.util.SecurityConstants#MODIFY_THREADGROUP_PERMISSION}
|
||||||
*/
|
*/
|
||||||
private void activateBlockerThread() {
|
private void activateBlockerThread() {
|
||||||
Thread thread = new Thread(this, "AWT-Shutdown");
|
Thread thread = new Thread(ThreadGroupUtils.getRootThreadGroup(), this, "AWT-Shutdown");
|
||||||
|
thread.setContextClassLoader(null);
|
||||||
thread.setDaemon(false);
|
thread.setDaemon(false);
|
||||||
blockerThread = thread;
|
blockerThread = thread;
|
||||||
thread.start();
|
thread.start();
|
||||||
|
@ -40,6 +40,7 @@ import java.io.File;
|
|||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.io.InputStream;
|
import java.io.InputStream;
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
import java.util.concurrent.locks.Condition;
|
import java.util.concurrent.locks.Condition;
|
||||||
|
@ -85,7 +85,7 @@ public class ClipboardTransferable implements Transferable {
|
|||||||
// read it.
|
// read it.
|
||||||
Map<Long, Object> cached_data = new HashMap<>(formats.length, 1.0f);
|
Map<Long, Object> cached_data = new HashMap<>(formats.length, 1.0f);
|
||||||
DataTransferer.getInstance()
|
DataTransferer.getInstance()
|
||||||
.getFlavorsForFormats(formats, SunClipboard.flavorMap)
|
.getFlavorsForFormats(formats, SunClipboard.getDefaultFlavorTable())
|
||||||
.entrySet()
|
.entrySet()
|
||||||
.forEach(entry -> fetchOneFlavor(clipboard, entry.getKey(), entry.getValue(), cached_data));
|
.forEach(entry -> fetchOneFlavor(clipboard, entry.getKey(), entry.getValue(), cached_data));
|
||||||
flavors = DataTransferer.setToSortedDataFlavorArray(flavorsToData.keySet());
|
flavors = DataTransferer.setToSortedDataFlavorArray(flavorsToData.keySet());
|
||||||
|
@ -63,9 +63,6 @@ import sun.awt.SunToolkit;
|
|||||||
public abstract class SunClipboard extends Clipboard
|
public abstract class SunClipboard extends Clipboard
|
||||||
implements PropertyChangeListener {
|
implements PropertyChangeListener {
|
||||||
|
|
||||||
public static final FlavorTable flavorMap =
|
|
||||||
(FlavorTable)SystemFlavorMap.getDefaultFlavorMap();
|
|
||||||
|
|
||||||
private AppContext contentsContext = null;
|
private AppContext contentsContext = null;
|
||||||
|
|
||||||
private final Object CLIPBOARD_FLAVOR_LISTENER_KEY;
|
private final Object CLIPBOARD_FLAVOR_LISTENER_KEY;
|
||||||
@ -167,7 +164,7 @@ public abstract class SunClipboard extends Clipboard
|
|||||||
long[] formats = getClipboardFormatsOpenClose();
|
long[] formats = getClipboardFormatsOpenClose();
|
||||||
|
|
||||||
return DataTransferer.getInstance().
|
return DataTransferer.getInstance().
|
||||||
getFlavorsForFormatsAsArray(formats, flavorMap);
|
getFlavorsForFormatsAsArray(formats, getDefaultFlavorTable());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -213,7 +210,7 @@ public abstract class SunClipboard extends Clipboard
|
|||||||
|
|
||||||
long[] formats = getClipboardFormats();
|
long[] formats = getClipboardFormats();
|
||||||
Long lFormat = DataTransferer.getInstance().
|
Long lFormat = DataTransferer.getInstance().
|
||||||
getFlavorsForFormats(formats, flavorMap).get(flavor);
|
getFlavorsForFormats(formats, getDefaultFlavorTable()).get(flavor);
|
||||||
|
|
||||||
if (lFormat == null) {
|
if (lFormat == null) {
|
||||||
throw new UnsupportedFlavorException(flavor);
|
throw new UnsupportedFlavorException(flavor);
|
||||||
@ -344,7 +341,7 @@ public abstract class SunClipboard extends Clipboard
|
|||||||
private static Set formatArrayAsDataFlavorSet(long[] formats) {
|
private static Set formatArrayAsDataFlavorSet(long[] formats) {
|
||||||
return (formats == null) ? null :
|
return (formats == null) ? null :
|
||||||
DataTransferer.getInstance().
|
DataTransferer.getInstance().
|
||||||
getFlavorsForFormatsAsSet(formats, flavorMap);
|
getFlavorsForFormatsAsSet(formats, getDefaultFlavorTable());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -447,4 +444,8 @@ public abstract class SunClipboard extends Clipboard
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static FlavorTable getDefaultFlavorTable() {
|
||||||
|
return (FlavorTable) SystemFlavorMap.getDefaultFlavorMap();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,12 +27,15 @@ package sun.font;
|
|||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.concurrent.Semaphore;
|
import java.util.concurrent.Semaphore;
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import sun.awt.AppContext;
|
import sun.awt.AppContext;
|
||||||
|
import sun.misc.ThreadGroupUtils;
|
||||||
|
|
||||||
public class CreatedFontTracker {
|
public class CreatedFontTracker {
|
||||||
|
|
||||||
@ -112,28 +115,18 @@ public class CreatedFontTracker {
|
|||||||
static void init() {
|
static void init() {
|
||||||
if (t == null) {
|
if (t == null) {
|
||||||
// Add a shutdown hook to remove the temp file.
|
// Add a shutdown hook to remove the temp file.
|
||||||
java.security.AccessController.doPrivileged(
|
AccessController.doPrivileged(
|
||||||
new java.security.PrivilegedAction<Object>() {
|
(PrivilegedAction<Void>) () -> {
|
||||||
public Object run() {
|
/* The thread must be a member of a thread group
|
||||||
/* The thread must be a member of a thread group
|
* which will not get GCed before VM exit.
|
||||||
* which will not get GCed before VM exit.
|
* Make its parent the top-level thread group.
|
||||||
* Make its parent the top-level thread group.
|
*/
|
||||||
*/
|
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||||
ThreadGroup tg =
|
t = new Thread(rootTG, TempFileDeletionHook::runHooks);
|
||||||
Thread.currentThread().getThreadGroup();
|
t.setContextClassLoader(null);
|
||||||
for (ThreadGroup tgn = tg;
|
Runtime.getRuntime().addShutdownHook(t);
|
||||||
tgn != null;
|
return null;
|
||||||
tg = tgn, tgn = tg.getParent());
|
});
|
||||||
t = new Thread(tg, new Runnable() {
|
|
||||||
public void run() {
|
|
||||||
runHooks();
|
|
||||||
}
|
|
||||||
});
|
|
||||||
t.setContextClassLoader(null);
|
|
||||||
Runtime.getRuntime().addShutdownHook(t);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -52,6 +52,7 @@ import javax.swing.plaf.FontUIResource;
|
|||||||
import sun.awt.AppContext;
|
import sun.awt.AppContext;
|
||||||
import sun.awt.FontConfiguration;
|
import sun.awt.FontConfiguration;
|
||||||
import sun.awt.SunToolkit;
|
import sun.awt.SunToolkit;
|
||||||
|
import sun.misc.ThreadGroupUtils;
|
||||||
import sun.java2d.FontSupport;
|
import sun.java2d.FontSupport;
|
||||||
import sun.util.logging.PlatformLogger;
|
import sun.util.logging.PlatformLogger;
|
||||||
|
|
||||||
@ -2527,24 +2528,18 @@ public abstract class SunFontManager implements FontSupport, FontManagerForSGE {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
java.security.AccessController.doPrivileged(
|
AccessController.doPrivileged(
|
||||||
new java.security.PrivilegedAction<Object>() {
|
(PrivilegedAction<Void>) () -> {
|
||||||
public Object run() {
|
/* The thread must be a member of a thread group
|
||||||
/* The thread must be a member of a thread group
|
* which will not get GCed before VM exit.
|
||||||
* which will not get GCed before VM exit.
|
* Make its parent the top-level thread group.
|
||||||
* Make its parent the top-level thread group.
|
*/
|
||||||
*/
|
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||||
ThreadGroup tg =
|
fileCloser = new Thread(rootTG, fileCloserRunnable);
|
||||||
Thread.currentThread().getThreadGroup();
|
fileCloser.setContextClassLoader(null);
|
||||||
for (ThreadGroup tgn = tg;
|
Runtime.getRuntime().addShutdownHook(fileCloser);
|
||||||
tgn != null;
|
return null;
|
||||||
tg = tgn, tgn = tg.getParent());
|
});
|
||||||
fileCloser = new Thread(tg, fileCloserRunnable);
|
|
||||||
fileCloser.setContextClassLoader(null);
|
|
||||||
Runtime.getRuntime().addShutdownHook(fileCloser);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -25,10 +25,14 @@
|
|||||||
|
|
||||||
package sun.java2d;
|
package sun.java2d;
|
||||||
|
|
||||||
|
import sun.misc.ThreadGroupUtils;
|
||||||
|
|
||||||
import java.lang.ref.Reference;
|
import java.lang.ref.Reference;
|
||||||
import java.lang.ref.ReferenceQueue;
|
import java.lang.ref.ReferenceQueue;
|
||||||
import java.lang.ref.PhantomReference;
|
import java.lang.ref.PhantomReference;
|
||||||
import java.lang.ref.WeakReference;
|
import java.lang.ref.WeakReference;
|
||||||
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Hashtable;
|
import java.util.Hashtable;
|
||||||
|
|
||||||
@ -77,27 +81,21 @@ public class Disposer implements Runnable {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
disposerInstance = new Disposer();
|
disposerInstance = new Disposer();
|
||||||
java.security.AccessController.doPrivileged(
|
AccessController.doPrivileged(
|
||||||
new java.security.PrivilegedAction<Object>() {
|
(PrivilegedAction<Void>) () -> {
|
||||||
public Object run() {
|
/* The thread must be a member of a thread group
|
||||||
/* The thread must be a member of a thread group
|
* which will not get GCed before VM exit.
|
||||||
* which will not get GCed before VM exit.
|
* Make its parent the top-level thread group.
|
||||||
* Make its parent the top-level thread group.
|
*/
|
||||||
*/
|
ThreadGroup rootTG = ThreadGroupUtils.getRootThreadGroup();
|
||||||
ThreadGroup tg = Thread.currentThread().getThreadGroup();
|
Thread t = new Thread(rootTG, disposerInstance, "Java2D Disposer");
|
||||||
for (ThreadGroup tgn = tg;
|
t.setContextClassLoader(null);
|
||||||
tgn != null;
|
t.setDaemon(true);
|
||||||
tg = tgn, tgn = tg.getParent());
|
t.setPriority(Thread.MAX_PRIORITY);
|
||||||
Thread t =
|
t.start();
|
||||||
new Thread(tg, disposerInstance, "Java2D Disposer");
|
return null;
|
||||||
t.setContextClassLoader(null);
|
}
|
||||||
t.setDaemon(true);
|
);
|
||||||
t.setPriority(Thread.MAX_PRIORITY);
|
|
||||||
t.start();
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -25,6 +25,7 @@
|
|||||||
|
|
||||||
package sun.java2d.opengl;
|
package sun.java2d.opengl;
|
||||||
|
|
||||||
|
import sun.misc.ThreadGroupUtils;
|
||||||
import sun.java2d.pipe.RenderBuffer;
|
import sun.java2d.pipe.RenderBuffer;
|
||||||
import sun.java2d.pipe.RenderQueue;
|
import sun.java2d.pipe.RenderQueue;
|
||||||
import static sun.java2d.pipe.BufferedOpCodes.*;
|
import static sun.java2d.pipe.BufferedOpCodes.*;
|
||||||
@ -47,14 +48,8 @@ public class OGLRenderQueue extends RenderQueue {
|
|||||||
* The thread must be a member of a thread group
|
* The thread must be a member of a thread group
|
||||||
* which will not get GCed before VM exit.
|
* which will not get GCed before VM exit.
|
||||||
*/
|
*/
|
||||||
flusher = AccessController.doPrivileged(new PrivilegedAction<QueueFlusher>() {
|
flusher = AccessController.doPrivileged((PrivilegedAction<QueueFlusher>) () -> {
|
||||||
public QueueFlusher run() {
|
return new QueueFlusher(ThreadGroupUtils.getRootThreadGroup());
|
||||||
ThreadGroup rootThreadGroup = Thread.currentThread().getThreadGroup();
|
|
||||||
while (rootThreadGroup.getParent() != null) {
|
|
||||||
rootThreadGroup = rootThreadGroup.getParent();
|
|
||||||
}
|
|
||||||
return new QueueFlusher(rootThreadGroup);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
121
jdk/src/share/classes/sun/misc/InnocuousThread.java
Normal file
121
jdk/src/share/classes/sun/misc/InnocuousThread.java
Normal file
@ -0,0 +1,121 @@
|
|||||||
|
/*
|
||||||
|
* 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 GNUNSAFE 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 WITHOUNSAFET
|
||||||
|
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||||
|
* FITNESS FOR A PARTICUNSAFELAR PUNSAFERPOSE. See the GNUNSAFE 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 GNUNSAFE 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 UNSAFESA.
|
||||||
|
*
|
||||||
|
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 UNSAFESA
|
||||||
|
* or visit www.oracle.com if you need additional information or have any
|
||||||
|
* questions.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package sun.misc;
|
||||||
|
|
||||||
|
import java.security.AccessControlContext;
|
||||||
|
import java.security.ProtectionDomain;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A thread that has no permissions, is not a member of any user-defined
|
||||||
|
* ThreadGroup and supports the ability to erase ThreadLocals.
|
||||||
|
*
|
||||||
|
* @implNote Based on the implementation of InnocuousForkJoinWorkerThread.
|
||||||
|
*/
|
||||||
|
public final class InnocuousThread extends Thread {
|
||||||
|
private static final Unsafe UNSAFE;
|
||||||
|
private static final ThreadGroup THREADGROUP;
|
||||||
|
private static final AccessControlContext ACC;
|
||||||
|
private static final long THREADLOCALS;
|
||||||
|
private static final long INHERITABLETHREADLOCALS;
|
||||||
|
private static final long INHERITEDACCESSCONTROLCONTEXT;
|
||||||
|
|
||||||
|
public InnocuousThread(Runnable target) {
|
||||||
|
super(THREADGROUP, target, "anInnocuousThread");
|
||||||
|
UNSAFE.putOrderedObject(this, INHERITEDACCESSCONTROLCONTEXT, ACC);
|
||||||
|
eraseThreadLocals();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public ClassLoader getContextClassLoader() {
|
||||||
|
// always report system class loader
|
||||||
|
return ClassLoader.getSystemClassLoader();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setUncaughtExceptionHandler(UncaughtExceptionHandler x) {
|
||||||
|
// silently fail
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setContextClassLoader(ClassLoader cl) {
|
||||||
|
throw new SecurityException("setContextClassLoader");
|
||||||
|
}
|
||||||
|
|
||||||
|
// ensure run method is run only once
|
||||||
|
private volatile boolean hasRun;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void run() {
|
||||||
|
if (Thread.currentThread() == this && !hasRun) {
|
||||||
|
hasRun = true;
|
||||||
|
super.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Drops all thread locals (and inherited thread locals).
|
||||||
|
*/
|
||||||
|
public void eraseThreadLocals() {
|
||||||
|
UNSAFE.putObject(this, THREADLOCALS, null);
|
||||||
|
UNSAFE.putObject(this, INHERITABLETHREADLOCALS, null);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Use Unsafe to access Thread group and ThreadGroup parent fields
|
||||||
|
static {
|
||||||
|
try {
|
||||||
|
ACC = new AccessControlContext(new ProtectionDomain[] {
|
||||||
|
new ProtectionDomain(null, null)
|
||||||
|
});
|
||||||
|
|
||||||
|
// Find and use topmost ThreadGroup as parent of new group
|
||||||
|
UNSAFE = Unsafe.getUnsafe();
|
||||||
|
Class<?> tk = Thread.class;
|
||||||
|
Class<?> gk = ThreadGroup.class;
|
||||||
|
|
||||||
|
THREADLOCALS = UNSAFE.objectFieldOffset
|
||||||
|
(tk.getDeclaredField("threadLocals"));
|
||||||
|
INHERITABLETHREADLOCALS = UNSAFE.objectFieldOffset
|
||||||
|
(tk.getDeclaredField("inheritableThreadLocals"));
|
||||||
|
INHERITEDACCESSCONTROLCONTEXT = UNSAFE.objectFieldOffset
|
||||||
|
(tk.getDeclaredField("inheritedAccessControlContext"));
|
||||||
|
|
||||||
|
long tg = UNSAFE.objectFieldOffset(tk.getDeclaredField("group"));
|
||||||
|
long gp = UNSAFE.objectFieldOffset(gk.getDeclaredField("parent"));
|
||||||
|
ThreadGroup group = (ThreadGroup)
|
||||||
|
UNSAFE.getObject(Thread.currentThread(), tg);
|
||||||
|
|
||||||
|
while (group != null) {
|
||||||
|
ThreadGroup parent = (ThreadGroup)UNSAFE.getObject(group, gp);
|
||||||
|
if (parent == null)
|
||||||
|
break;
|
||||||
|
group = parent;
|
||||||
|
}
|
||||||
|
THREADGROUP = new ThreadGroup(group, "InnocuousThreadGroup");
|
||||||
|
} catch (Exception e) {
|
||||||
|
throw new Error(e);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
55
jdk/src/share/classes/sun/misc/ThreadGroupUtils.java
Normal file
55
jdk/src/share/classes/sun/misc/ThreadGroupUtils.java
Normal file
@ -0,0 +1,55 @@
|
|||||||
|
/*
|
||||||
|
* 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. 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 sun.misc;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* A utility class needed to access the root {@code ThreadGroup}
|
||||||
|
*
|
||||||
|
* The class should not depend on any others, because it' called from JNI_OnLoad of the AWT
|
||||||
|
* native library. Triggering class loading could could lead to a deadlock.
|
||||||
|
*/
|
||||||
|
public final class ThreadGroupUtils {
|
||||||
|
|
||||||
|
private ThreadGroupUtils() {
|
||||||
|
// Avoid instantiation
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Returns a root thread group.
|
||||||
|
* Should be called with {@link sun.security.util.SecurityConstants#MODIFY_THREADGROUP_PERMISSION}
|
||||||
|
*
|
||||||
|
* @return a root {@code ThreadGroup}
|
||||||
|
*/
|
||||||
|
public static ThreadGroup getRootThreadGroup() {
|
||||||
|
ThreadGroup currentTG = Thread.currentThread().getThreadGroup();
|
||||||
|
ThreadGroup parentTG = currentTG.getParent();
|
||||||
|
while (parentTG != null) {
|
||||||
|
currentTG = parentTG;
|
||||||
|
parentTG = currentTG.getParent();
|
||||||
|
}
|
||||||
|
return currentTG;
|
||||||
|
}
|
||||||
|
}
|
@ -225,39 +225,28 @@ public class MimeTable implements FileNameMap {
|
|||||||
public synchronized void load() {
|
public synchronized void load() {
|
||||||
Properties entries = new Properties();
|
Properties entries = new Properties();
|
||||||
File file = null;
|
File file = null;
|
||||||
try {
|
InputStream in;
|
||||||
InputStream is;
|
|
||||||
// First try to load the user-specific table, if it exists
|
|
||||||
String userTablePath =
|
|
||||||
System.getProperty("content.types.user.table");
|
|
||||||
if (userTablePath != null) {
|
|
||||||
file = new File(userTablePath);
|
|
||||||
if (!file.exists()) {
|
|
||||||
// No user-table, try to load the default built-in table.
|
|
||||||
file = new File(System.getProperty("java.home") +
|
|
||||||
File.separator +
|
|
||||||
"lib" +
|
|
||||||
File.separator +
|
|
||||||
"content-types.properties");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
// No user table, try to load the default built-in table.
|
|
||||||
file = new File(System.getProperty("java.home") +
|
|
||||||
File.separator +
|
|
||||||
"lib" +
|
|
||||||
File.separator +
|
|
||||||
"content-types.properties");
|
|
||||||
}
|
|
||||||
|
|
||||||
is = new BufferedInputStream(new FileInputStream(file));
|
// First try to load the user-specific table, if it exists
|
||||||
entries.load(is);
|
String userTablePath = System.getProperty("content.types.user.table");
|
||||||
is.close();
|
if (userTablePath != null && (file = new File(userTablePath)).exists()) {
|
||||||
|
try {
|
||||||
|
in = new FileInputStream(file);
|
||||||
|
} catch (FileNotFoundException e) {
|
||||||
|
System.err.println("Warning: " + file.getPath()
|
||||||
|
+ " mime table not found.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
in = MimeTable.class.getResourceAsStream("content-types.properties");
|
||||||
|
if (in == null)
|
||||||
|
throw new InternalError("default mime table not found");
|
||||||
}
|
}
|
||||||
catch (IOException e) {
|
|
||||||
System.err.println("Warning: default mime table not found: " +
|
try (BufferedInputStream bin = new BufferedInputStream(in)) {
|
||||||
file.getPath());
|
entries.load(bin);
|
||||||
return;
|
} catch (IOException e) {
|
||||||
|
System.err.println("Warning: " + e.getMessage());
|
||||||
}
|
}
|
||||||
parse(entries);
|
parse(entries);
|
||||||
}
|
}
|
||||||
@ -380,18 +369,6 @@ public class MimeTable implements FileNameMap {
|
|||||||
return MimeEntry.UNKNOWN;
|
return MimeEntry.UNKNOWN;
|
||||||
}
|
}
|
||||||
|
|
||||||
public synchronized boolean save(String filename) {
|
|
||||||
if (filename == null) {
|
|
||||||
filename = System.getProperty("user.home" +
|
|
||||||
File.separator +
|
|
||||||
"lib" +
|
|
||||||
File.separator +
|
|
||||||
"content-types.properties");
|
|
||||||
}
|
|
||||||
|
|
||||||
return saveAsProperties(new File(filename));
|
|
||||||
}
|
|
||||||
|
|
||||||
public Properties getAsProperties() {
|
public Properties getAsProperties() {
|
||||||
Properties properties = new Properties();
|
Properties properties = new Properties();
|
||||||
Enumeration<MimeEntry> e = elements();
|
Enumeration<MimeEntry> e = elements();
|
||||||
|
@ -130,6 +130,18 @@ class Invoker {
|
|||||||
|
|
||||||
// clear interrupt
|
// clear interrupt
|
||||||
Thread.interrupted();
|
Thread.interrupted();
|
||||||
|
|
||||||
|
// clear thread locals when in default thread pool
|
||||||
|
if (System.getSecurityManager() != null) {
|
||||||
|
Thread me = Thread.currentThread();
|
||||||
|
if (me instanceof sun.misc.InnocuousThread) {
|
||||||
|
GroupAndInvokeCount thisGroupAndInvokeCount = myGroupAndInvokeCount.get();
|
||||||
|
((sun.misc.InnocuousThread)me).eraseThreadLocals();
|
||||||
|
if (thisGroupAndInvokeCount != null) {
|
||||||
|
myGroupAndInvokeCount.set(thisGroupAndInvokeCount);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -27,6 +27,7 @@ package sun.nio.ch;
|
|||||||
|
|
||||||
import java.util.concurrent.*;
|
import java.util.concurrent.*;
|
||||||
import java.security.AccessController;
|
import java.security.AccessController;
|
||||||
|
import java.security.PrivilegedAction;
|
||||||
import sun.security.action.GetPropertyAction;
|
import sun.security.action.GetPropertyAction;
|
||||||
import sun.security.action.GetIntegerAction;
|
import sun.security.action.GetIntegerAction;
|
||||||
|
|
||||||
@ -39,14 +40,6 @@ public class ThreadPool {
|
|||||||
"java.nio.channels.DefaultThreadPool.threadFactory";
|
"java.nio.channels.DefaultThreadPool.threadFactory";
|
||||||
private static final String DEFAULT_THREAD_POOL_INITIAL_SIZE =
|
private static final String DEFAULT_THREAD_POOL_INITIAL_SIZE =
|
||||||
"java.nio.channels.DefaultThreadPool.initialSize";
|
"java.nio.channels.DefaultThreadPool.initialSize";
|
||||||
private static final ThreadFactory defaultThreadFactory = new ThreadFactory() {
|
|
||||||
@Override
|
|
||||||
public Thread newThread(Runnable r) {
|
|
||||||
Thread t = new Thread(r);
|
|
||||||
t.setDaemon(true);
|
|
||||||
return t;
|
|
||||||
}
|
|
||||||
};
|
|
||||||
|
|
||||||
private final ExecutorService executor;
|
private final ExecutorService executor;
|
||||||
|
|
||||||
@ -79,7 +72,22 @@ public class ThreadPool {
|
|||||||
}
|
}
|
||||||
|
|
||||||
static ThreadFactory defaultThreadFactory() {
|
static ThreadFactory defaultThreadFactory() {
|
||||||
return defaultThreadFactory;
|
if (System.getSecurityManager() == null) {
|
||||||
|
return (Runnable r) -> {
|
||||||
|
Thread t = new Thread(r);
|
||||||
|
t.setDaemon(true);
|
||||||
|
return t;
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
return (Runnable r) -> {
|
||||||
|
PrivilegedAction<Thread> action = () -> {
|
||||||
|
Thread t = new sun.misc.InnocuousThread(r);
|
||||||
|
t.setDaemon(true);
|
||||||
|
return t;
|
||||||
|
};
|
||||||
|
return AccessController.doPrivileged(action);
|
||||||
|
};
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static class DefaultThreadPoolHolder {
|
private static class DefaultThreadPoolHolder {
|
||||||
@ -100,7 +108,7 @@ public class ThreadPool {
|
|||||||
// default to thread factory that creates daemon threads
|
// default to thread factory that creates daemon threads
|
||||||
ThreadFactory threadFactory = getDefaultThreadPoolThreadFactory();
|
ThreadFactory threadFactory = getDefaultThreadPoolThreadFactory();
|
||||||
if (threadFactory == null)
|
if (threadFactory == null)
|
||||||
threadFactory = defaultThreadFactory;
|
threadFactory = defaultThreadFactory();
|
||||||
// create thread pool
|
// create thread pool
|
||||||
ExecutorService executor = Executors.newCachedThreadPool(threadFactory);
|
ExecutorService executor = Executors.newCachedThreadPool(threadFactory);
|
||||||
return new ThreadPool(executor, false, initialSize);
|
return new ThreadPool(executor, false, initialSize);
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 1996, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -179,8 +179,8 @@ abstract class SeedGenerator {
|
|||||||
md.update(p.getProperty(s).getBytes());
|
md.update(p.getProperty(s).getBytes());
|
||||||
}
|
}
|
||||||
|
|
||||||
md.update
|
// Include network adapter names (and a Mac address)
|
||||||
(InetAddress.getLocalHost().toString().getBytes());
|
addNetworkAdapterInfo(md);
|
||||||
|
|
||||||
// The temporary dir
|
// The temporary dir
|
||||||
File f = new File(p.getProperty("java.io.tmpdir"));
|
File f = new File(p.getProperty("java.io.tmpdir"));
|
||||||
@ -221,6 +221,31 @@ abstract class SeedGenerator {
|
|||||||
return md.digest();
|
return md.digest();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Include network adapter names and, if available, a Mac address
|
||||||
|
*
|
||||||
|
* See also java.util.concurrent.ThreadLocalRandom.initialSeed()
|
||||||
|
*/
|
||||||
|
private static void addNetworkAdapterInfo(MessageDigest md) {
|
||||||
|
|
||||||
|
try {
|
||||||
|
Enumeration<NetworkInterface> ifcs =
|
||||||
|
NetworkInterface.getNetworkInterfaces();
|
||||||
|
while (ifcs.hasMoreElements()) {
|
||||||
|
NetworkInterface ifc = ifcs.nextElement();
|
||||||
|
md.update(ifc.toString().getBytes());
|
||||||
|
if (!ifc.isVirtual()) { // skip fake addresses
|
||||||
|
byte[] bs = ifc.getHardwareAddress();
|
||||||
|
if (bs != null) {
|
||||||
|
md.update(bs);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} catch (Exception ignore) {
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Helper function to convert a long into a byte array (least significant
|
* Helper function to convert a long into a byte array (least significant
|
||||||
* byte first).
|
* byte first).
|
||||||
|
@ -75,7 +75,7 @@ final public class AlgorithmChecker extends PKIXCertPathChecker {
|
|||||||
private PublicKey prevPubKey;
|
private PublicKey prevPubKey;
|
||||||
|
|
||||||
private final static Set<CryptoPrimitive> SIGNATURE_PRIMITIVE_SET =
|
private final static Set<CryptoPrimitive> SIGNATURE_PRIMITIVE_SET =
|
||||||
EnumSet.of(CryptoPrimitive.SIGNATURE);
|
Collections.unmodifiableSet(EnumSet.of(CryptoPrimitive.SIGNATURE));
|
||||||
|
|
||||||
private final static DisabledAlgorithmConstraints
|
private final static DisabledAlgorithmConstraints
|
||||||
certPathDefaultConstraints = new DisabledAlgorithmConstraints(
|
certPathDefaultConstraints = new DisabledAlgorithmConstraints(
|
||||||
|
@ -25,11 +25,9 @@
|
|||||||
|
|
||||||
package sun.security.rsa;
|
package sun.security.rsa;
|
||||||
|
|
||||||
import java.math.BigInteger;
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
import java.security.*;
|
import java.security.*;
|
||||||
import java.security.interfaces.*;
|
|
||||||
import java.security.spec.*;
|
import java.security.spec.*;
|
||||||
|
|
||||||
import javax.crypto.BadPaddingException;
|
import javax.crypto.BadPaddingException;
|
||||||
@ -41,21 +39,41 @@ import sun.security.jca.JCAUtil;
|
|||||||
/**
|
/**
|
||||||
* RSA padding and unpadding.
|
* RSA padding and unpadding.
|
||||||
*
|
*
|
||||||
* Format of PKCS#1 v1.5 padding is:
|
* The various PKCS#1 versions can be found in the EMC/RSA Labs
|
||||||
|
* web site, which is currently:
|
||||||
|
*
|
||||||
|
* http://www.emc.com/emc-plus/rsa-labs/index.htm
|
||||||
|
*
|
||||||
|
* or in the IETF RFCs derived from the above PKCS#1 standards.
|
||||||
|
*
|
||||||
|
* RFC 2313: v1.5
|
||||||
|
* RFC 2437: v2.0
|
||||||
|
* RFC 3447: v2.1
|
||||||
|
*
|
||||||
|
* The format of PKCS#1 v1.5 padding is:
|
||||||
|
*
|
||||||
* 0x00 | BT | PS...PS | 0x00 | data...data
|
* 0x00 | BT | PS...PS | 0x00 | data...data
|
||||||
|
*
|
||||||
* where BT is the blocktype (1 or 2). The length of the entire string
|
* where BT is the blocktype (1 or 2). The length of the entire string
|
||||||
* must be the same as the size of the modulus (i.e. 128 byte for a 1024 bit
|
* must be the same as the size of the modulus (i.e. 128 byte for a 1024 bit
|
||||||
* key). Per spec, the padding string must be at least 8 bytes long. That
|
* key). Per spec, the padding string must be at least 8 bytes long. That
|
||||||
* leaves up to (length of key in bytes) - 11 bytes for the data.
|
* leaves up to (length of key in bytes) - 11 bytes for the data.
|
||||||
*
|
*
|
||||||
* OAEP padding is a bit more complicated and has a number of options.
|
* OAEP padding was introduced in PKCS#1 v2.0 and is a bit more complicated
|
||||||
* We support:
|
* and has a number of options. We support:
|
||||||
|
*
|
||||||
* . arbitrary hash functions ('Hash' in the specification), MessageDigest
|
* . arbitrary hash functions ('Hash' in the specification), MessageDigest
|
||||||
* implementation must be available
|
* implementation must be available
|
||||||
* . MGF1 as the mask generation function
|
* . MGF1 as the mask generation function
|
||||||
* . the empty string as the default value for label L and whatever
|
* . the empty string as the default value for label L and whatever
|
||||||
* specified in javax.crypto.spec.OAEPParameterSpec
|
* specified in javax.crypto.spec.OAEPParameterSpec
|
||||||
*
|
*
|
||||||
|
* The algorithms (representations) are forwards-compatible: that is,
|
||||||
|
* the algorithm described in previous releases are in later releases.
|
||||||
|
* However, additional comments/checks/clarifications were added to the
|
||||||
|
* later versions based on real-world experience (e.g. stricter v1.5
|
||||||
|
* format checking.)
|
||||||
|
*
|
||||||
* Note: RSA keys should be at least 512 bits long
|
* Note: RSA keys should be at least 512 bits long
|
||||||
*
|
*
|
||||||
* @since 1.5
|
* @since 1.5
|
||||||
@ -156,7 +174,8 @@ public final class RSAPadding {
|
|||||||
throw new InvalidAlgorithmParameterException
|
throw new InvalidAlgorithmParameterException
|
||||||
("Unsupported MGF algo: " + mgfName);
|
("Unsupported MGF algo: " + mgfName);
|
||||||
}
|
}
|
||||||
mgfMdName = ((MGF1ParameterSpec)spec.getMGFParameters()).getDigestAlgorithm();
|
mgfMdName = ((MGF1ParameterSpec)spec.getMGFParameters())
|
||||||
|
.getDigestAlgorithm();
|
||||||
PSource pSrc = spec.getPSource();
|
PSource pSrc = spec.getPSource();
|
||||||
String pSrcAlgo = pSrc.getAlgorithm();
|
String pSrcAlgo = pSrc.getAlgorithm();
|
||||||
if (!pSrcAlgo.equalsIgnoreCase("PSpecified")) {
|
if (!pSrcAlgo.equalsIgnoreCase("PSpecified")) {
|
||||||
@ -198,7 +217,7 @@ public final class RSAPadding {
|
|||||||
*/
|
*/
|
||||||
private static byte[] getInitialHash(MessageDigest md,
|
private static byte[] getInitialHash(MessageDigest md,
|
||||||
byte[] digestInput) {
|
byte[] digestInput) {
|
||||||
byte[] result = null;
|
byte[] result;
|
||||||
if ((digestInput == null) || (digestInput.length == 0)) {
|
if ((digestInput == null) || (digestInput.length == 0)) {
|
||||||
String digestName = md.getAlgorithm();
|
String digestName = md.getAlgorithm();
|
||||||
result = emptyHashes.get(digestName);
|
result = emptyHashes.get(digestName);
|
||||||
@ -213,8 +232,8 @@ public final class RSAPadding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Return the maximum size of the plaintext data that can be processed using
|
* Return the maximum size of the plaintext data that can be processed
|
||||||
* this object.
|
* using this object.
|
||||||
*/
|
*/
|
||||||
public int getMaxDataSize() {
|
public int getMaxDataSize() {
|
||||||
return maxDataSize;
|
return maxDataSize;
|
||||||
@ -262,7 +281,7 @@ public final class RSAPadding {
|
|||||||
*/
|
*/
|
||||||
public byte[] unpad(byte[] padded) throws BadPaddingException {
|
public byte[] unpad(byte[] padded) throws BadPaddingException {
|
||||||
if (padded.length != paddedSize) {
|
if (padded.length != paddedSize) {
|
||||||
throw new BadPaddingException("Padded length must be " + paddedSize);
|
throw new BadPaddingException("Decryption error");
|
||||||
}
|
}
|
||||||
switch (type) {
|
switch (type) {
|
||||||
case PAD_NONE:
|
case PAD_NONE:
|
||||||
@ -282,7 +301,8 @@ public final class RSAPadding {
|
|||||||
*/
|
*/
|
||||||
private byte[] padV15(byte[] data) throws BadPaddingException {
|
private byte[] padV15(byte[] data) throws BadPaddingException {
|
||||||
byte[] padded = new byte[paddedSize];
|
byte[] padded = new byte[paddedSize];
|
||||||
System.arraycopy(data, 0, padded, paddedSize - data.length, data.length);
|
System.arraycopy(data, 0, padded, paddedSize - data.length,
|
||||||
|
data.length);
|
||||||
int psSize = paddedSize - 3 - data.length;
|
int psSize = paddedSize - 3 - data.length;
|
||||||
int k = 0;
|
int k = 0;
|
||||||
padded[k++] = 0;
|
padded[k++] = 0;
|
||||||
@ -317,55 +337,53 @@ public final class RSAPadding {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* PKCS#1 v1.5 unpadding (blocktype 1 and 2).
|
* PKCS#1 v1.5 unpadding (blocktype 1 (signature) and 2 (encryption)).
|
||||||
*
|
*
|
||||||
* Note that we want to make it a constant-time operation
|
* Note that we want to make it a constant-time operation
|
||||||
*/
|
*/
|
||||||
private byte[] unpadV15(byte[] padded) throws BadPaddingException {
|
private byte[] unpadV15(byte[] padded) throws BadPaddingException {
|
||||||
int k = 0;
|
int k = 0;
|
||||||
BadPaddingException bpe = null;
|
boolean bp = false;
|
||||||
|
|
||||||
if (padded[k++] != 0) {
|
if (padded[k++] != 0) {
|
||||||
bpe = new BadPaddingException("Data must start with zero");
|
bp = true;
|
||||||
}
|
}
|
||||||
if (padded[k++] != type && bpe == null) {
|
if (padded[k++] != type) {
|
||||||
bpe = new BadPaddingException("Blocktype mismatch: " + padded[1]);
|
bp = true;
|
||||||
}
|
}
|
||||||
int p = 0;
|
int p = 0;
|
||||||
while (k < padded.length) {
|
while (k < padded.length) {
|
||||||
int b = padded[k++] & 0xff;
|
int b = padded[k++] & 0xff;
|
||||||
if (b == 0 && p == 0) {
|
if ((b == 0) && (p == 0)) {
|
||||||
p = k;
|
p = k;
|
||||||
}
|
}
|
||||||
if (k == padded.length && p == 0 && bpe == null) {
|
if ((k == padded.length) && (p == 0)) {
|
||||||
bpe = new BadPaddingException("Padding string not terminated");
|
bp = true;
|
||||||
}
|
}
|
||||||
if ((type == PAD_BLOCKTYPE_1) && (b != 0xff) &&
|
if ((type == PAD_BLOCKTYPE_1) && (b != 0xff) &&
|
||||||
p == 0 && bpe == null) {
|
(p == 0)) {
|
||||||
bpe = new BadPaddingException("Padding byte not 0xff: " + b);
|
bp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
int n = padded.length - p;
|
int n = padded.length - p;
|
||||||
if (n > maxDataSize && bpe == null) {
|
if (n > maxDataSize) {
|
||||||
bpe = new BadPaddingException("Padding string too short");
|
bp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// copy useless padding array for a constant-time method
|
// copy useless padding array for a constant-time method
|
||||||
//
|
|
||||||
// Is it necessary?
|
|
||||||
byte[] padding = new byte[p];
|
byte[] padding = new byte[p];
|
||||||
System.arraycopy(padded, 0, padding, 0, p);
|
System.arraycopy(padded, 0, padding, 0, p);
|
||||||
|
|
||||||
byte[] data = new byte[n];
|
byte[] data = new byte[n];
|
||||||
System.arraycopy(padded, p, data, 0, n);
|
System.arraycopy(padded, p, data, 0, n);
|
||||||
|
|
||||||
if (bpe == null) {
|
BadPaddingException bpe = new BadPaddingException("Decryption error");
|
||||||
bpe = new BadPaddingException("Unused exception");
|
|
||||||
} else {
|
|
||||||
throw bpe;
|
|
||||||
}
|
|
||||||
|
|
||||||
return data;
|
if (bp) {
|
||||||
|
throw bpe;
|
||||||
|
} else {
|
||||||
|
return data;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -424,10 +442,11 @@ public final class RSAPadding {
|
|||||||
*/
|
*/
|
||||||
private byte[] unpadOAEP(byte[] padded) throws BadPaddingException {
|
private byte[] unpadOAEP(byte[] padded) throws BadPaddingException {
|
||||||
byte[] EM = padded;
|
byte[] EM = padded;
|
||||||
|
boolean bp = false;
|
||||||
int hLen = lHash.length;
|
int hLen = lHash.length;
|
||||||
|
|
||||||
if (EM[0] != 0) {
|
if (EM[0] != 0) {
|
||||||
throw new BadPaddingException("Data must start with zero");
|
bp = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
int seedStart = 1;
|
int seedStart = 1;
|
||||||
@ -442,29 +461,48 @@ public final class RSAPadding {
|
|||||||
// verify lHash == lHash'
|
// verify lHash == lHash'
|
||||||
for (int i = 0; i < hLen; i++) {
|
for (int i = 0; i < hLen; i++) {
|
||||||
if (lHash[i] != EM[dbStart + i]) {
|
if (lHash[i] != EM[dbStart + i]) {
|
||||||
throw new BadPaddingException("lHash mismatch");
|
bp = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// skip over padding (0x00 bytes)
|
int padStart = dbStart + hLen;
|
||||||
int i = dbStart + hLen;
|
int onePos = -1;
|
||||||
while (EM[i] == 0) {
|
|
||||||
i++;
|
for (int i = padStart; i < EM.length; i++) {
|
||||||
if (i >= EM.length) {
|
int value = EM[i];
|
||||||
throw new BadPaddingException("Padding string not terminated");
|
if (onePos == -1) {
|
||||||
|
if (value == 0x00) {
|
||||||
|
// continue;
|
||||||
|
} else if (value == 0x01) {
|
||||||
|
onePos = i;
|
||||||
|
} else { // Anything other than {0,1} is bad.
|
||||||
|
bp = true;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (EM[i++] != 1) {
|
// We either ran off the rails or found something other than 0/1.
|
||||||
throw new BadPaddingException
|
if (onePos == -1) {
|
||||||
("Padding string not terminated by 0x01 byte");
|
bp = true;
|
||||||
|
onePos = EM.length - 1; // Don't inadvertently return any data.
|
||||||
}
|
}
|
||||||
|
|
||||||
int mLen = EM.length - i;
|
int mStart = onePos + 1;
|
||||||
byte[] m = new byte[mLen];
|
|
||||||
System.arraycopy(EM, i, m, 0, mLen);
|
|
||||||
|
|
||||||
return m;
|
// copy useless padding array for a constant-time method
|
||||||
|
byte [] tmp = new byte[mStart - padStart];
|
||||||
|
System.arraycopy(EM, padStart, tmp, 0, tmp.length);
|
||||||
|
|
||||||
|
byte [] m = new byte[EM.length - mStart];
|
||||||
|
System.arraycopy(EM, mStart, m, 0, m.length);
|
||||||
|
|
||||||
|
BadPaddingException bpe = new BadPaddingException("Decryption error");
|
||||||
|
|
||||||
|
if (bp) {
|
||||||
|
throw bpe;
|
||||||
|
} else {
|
||||||
|
return m;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -499,5 +537,4 @@ public final class RSAPadding {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -68,7 +68,7 @@ final class SignatureAndHashAlgorithm {
|
|||||||
|
|
||||||
// performance optimization
|
// performance optimization
|
||||||
private final static Set<CryptoPrimitive> SIGNATURE_PRIMITIVE_SET =
|
private final static Set<CryptoPrimitive> SIGNATURE_PRIMITIVE_SET =
|
||||||
EnumSet.of(CryptoPrimitive.SIGNATURE);
|
Collections.unmodifiableSet(EnumSet.of(CryptoPrimitive.SIGNATURE));
|
||||||
|
|
||||||
// supported pairs of signature and hash algorithm
|
// supported pairs of signature and hash algorithm
|
||||||
private final static Map<Integer, SignatureAndHashAlgorithm> supportedMap;
|
private final static Map<Integer, SignatureAndHashAlgorithm> supportedMap;
|
||||||
|
@ -90,9 +90,6 @@ public class Main {
|
|||||||
|
|
||||||
private static final String META_INF = "META-INF/";
|
private static final String META_INF = "META-INF/";
|
||||||
|
|
||||||
// prefix for new signature-related files in META-INF directory
|
|
||||||
private static final String SIG_PREFIX = META_INF + "SIG-";
|
|
||||||
|
|
||||||
private static final Class<?>[] PARAM_STRING = { String.class };
|
private static final Class<?>[] PARAM_STRING = { String.class };
|
||||||
|
|
||||||
private static final String NONE = "NONE";
|
private static final String NONE = "NONE";
|
||||||
@ -1522,22 +1519,7 @@ public class Main {
|
|||||||
* . META-INF/*.EC
|
* . META-INF/*.EC
|
||||||
*/
|
*/
|
||||||
private boolean signatureRelated(String name) {
|
private boolean signatureRelated(String name) {
|
||||||
String ucName = name.toUpperCase(Locale.ENGLISH);
|
return SignatureFileVerifier.isSigningRelated(name);
|
||||||
if (ucName.equals(JarFile.MANIFEST_NAME) ||
|
|
||||||
ucName.equals(META_INF) ||
|
|
||||||
(ucName.startsWith(SIG_PREFIX) &&
|
|
||||||
ucName.indexOf("/") == ucName.lastIndexOf("/"))) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (ucName.startsWith(META_INF) &&
|
|
||||||
SignatureFileVerifier.isBlockOrSF(ucName)) {
|
|
||||||
// .SF/.DSA/.RSA/.EC files in META-INF subdirs
|
|
||||||
// are not considered signature-related
|
|
||||||
return (ucName.indexOf("/") == ucName.lastIndexOf("/"));
|
|
||||||
}
|
|
||||||
|
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
Map<CodeSigner,String> cacheForSignerInfo = new IdentityHashMap<>();
|
Map<CodeSigner,String> cacheForSignerInfo = new IdentityHashMap<>();
|
||||||
|
@ -152,6 +152,52 @@ public class SignatureFileVerifier {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Yet another utility method used by JarVerifier and JarSigner
|
||||||
|
* to determine what files are signature related, which includes
|
||||||
|
* the MANIFEST, SF files, known signature block files, and other
|
||||||
|
* unknown signature related files (those starting with SIG- with
|
||||||
|
* an optional [A-Z0-9]{1,3} extension right inside META-INF).
|
||||||
|
*
|
||||||
|
* @param s file name
|
||||||
|
* @return true if the input file name is signature related
|
||||||
|
*/
|
||||||
|
public static boolean isSigningRelated(String name) {
|
||||||
|
name = name.toUpperCase(Locale.ENGLISH);
|
||||||
|
if (!name.startsWith("META-INF/")) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
name = name.substring(9);
|
||||||
|
if (name.indexOf('/') != -1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
if (isBlockOrSF(name) || name.equals("MANIFEST.MF")) {
|
||||||
|
return true;
|
||||||
|
} else if (name.startsWith("SIG-")) {
|
||||||
|
// check filename extension
|
||||||
|
// see http://docs.oracle.com/javase/7/docs/technotes/guides/jar/jar.html#Digital_Signatures
|
||||||
|
// for what filename extensions are legal
|
||||||
|
int extIndex = name.lastIndexOf('.');
|
||||||
|
if (extIndex != -1) {
|
||||||
|
String ext = name.substring(extIndex + 1);
|
||||||
|
// validate length first
|
||||||
|
if (ext.length() > 3 || ext.length() < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
// then check chars, must be in [a-zA-Z0-9] per the jar spec
|
||||||
|
for (int index = 0; index < ext.length(); index++) {
|
||||||
|
char cc = ext.charAt(index);
|
||||||
|
// chars are promoted to uppercase so skip lowercase checks
|
||||||
|
if ((cc < 'A' || cc > 'Z') && (cc < '0' || cc > '9')) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return true; // no extension is OK
|
||||||
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
/** get digest from cache */
|
/** get digest from cache */
|
||||||
|
|
||||||
private MessageDigest getDigest(String algorithm)
|
private MessageDigest getDigest(String algorithm)
|
||||||
|
@ -1,26 +0,0 @@
|
|||||||
ZipFileSystem is a file system provider that treats the contents of a zip or
|
|
||||||
JAR file as a java.nio.file.FileSystem.
|
|
||||||
|
|
||||||
The factory methods defined by the java.nio.file.FileSystems class can be
|
|
||||||
used to create a FileSystem, eg:
|
|
||||||
|
|
||||||
// use file type detection
|
|
||||||
Path jarfile = Paths.get("foo.jar");
|
|
||||||
FileSystem fs = FileSystems.newFileSystem(jarfile, null);
|
|
||||||
|
|
||||||
-or
|
|
||||||
|
|
||||||
// locate file system by the legacy JAR URL syntax
|
|
||||||
Map<String,?> env = Collections.emptyMap();
|
|
||||||
URI uri = URI.create("jar:file:/mydir/foo.jar");
|
|
||||||
FileSystem fs = FileSystems.newFileSystem(uri, env);
|
|
||||||
|
|
||||||
Once a FileSystem is created then classes in the java.nio.file package
|
|
||||||
can be used to access files in the zip/JAR file, eg:
|
|
||||||
|
|
||||||
Path mf = fs.getPath("/META-INF/MANIFEST.MF");
|
|
||||||
InputStream in = mf.newInputStream();
|
|
||||||
|
|
||||||
See Demo.java for more interesting usages.
|
|
||||||
|
|
||||||
|
|
@ -1,2 +0,0 @@
|
|||||||
com.sun.nio.zipfs.ZipFileSystemProvider
|
|
||||||
|
|
@ -1,97 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
|
|
||||||
*
|
|
||||||
* Redistribution and use in source and binary forms, with or without
|
|
||||||
* modification, are permitted provided that the following conditions
|
|
||||||
* are met:
|
|
||||||
*
|
|
||||||
* - Redistributions of source code must retain the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer.
|
|
||||||
*
|
|
||||||
* - Redistributions in binary form must reproduce the above copyright
|
|
||||||
* notice, this list of conditions and the following disclaimer in the
|
|
||||||
* documentation and/or other materials provided with the distribution.
|
|
||||||
*
|
|
||||||
* - Neither the name of Oracle nor the names of its
|
|
||||||
* contributors may be used to endorse or promote products derived
|
|
||||||
* from this software without specific prior written permission.
|
|
||||||
*
|
|
||||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS
|
|
||||||
* IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
|
|
||||||
* PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR
|
|
||||||
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
|
|
||||||
* EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
|
|
||||||
* PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
|
|
||||||
* PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
|
|
||||||
* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
|
||||||
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
|
|
||||||
* SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
|
||||||
*/
|
|
||||||
|
|
||||||
/*
|
|
||||||
* This source code is provided to illustrate the usage of a given feature
|
|
||||||
* or technique and has been deliberately simplified. Additional steps
|
|
||||||
* required for a production-quality application, such as security checks,
|
|
||||||
* input validation and proper error handling, might not be present in
|
|
||||||
* this sample code.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package com.sun.nio.zipfs;
|
|
||||||
|
|
||||||
import java.nio.file.*;
|
|
||||||
import java.nio.file.spi.*;
|
|
||||||
import java.nio.file.attribute.*;
|
|
||||||
import java.nio.file.spi.FileSystemProvider;
|
|
||||||
|
|
||||||
import java.net.URI;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URISyntaxException;
|
|
||||||
import java.nio.channels.FileChannel;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.Map;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class JarFileSystemProvider extends ZipFileSystemProvider
|
|
||||||
{
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public String getScheme() {
|
|
||||||
return "jar";
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
protected Path uriToPath(URI uri) {
|
|
||||||
String scheme = uri.getScheme();
|
|
||||||
if ((scheme == null) || !scheme.equalsIgnoreCase(getScheme())) {
|
|
||||||
throw new IllegalArgumentException("URI scheme is not '" + getScheme() + "'");
|
|
||||||
}
|
|
||||||
try {
|
|
||||||
String uristr = uri.toString();
|
|
||||||
int end = uristr.indexOf("!/");
|
|
||||||
uristr = uristr.substring(4, (end == -1) ? uristr.length() : end);
|
|
||||||
uri = new URI(uristr);
|
|
||||||
return Paths.get(new URI("file", uri.getHost(), uri.getPath(), null))
|
|
||||||
.toAbsolutePath();
|
|
||||||
} catch (URISyntaxException e) {
|
|
||||||
throw new AssertionError(e); //never thrown
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public Path getPath(URI uri) {
|
|
||||||
FileSystem fs = getFileSystem(uri);
|
|
||||||
String path = uri.getFragment();
|
|
||||||
if (path == null) {
|
|
||||||
String uristr = uri.toString();
|
|
||||||
int off = uristr.indexOf("!/");
|
|
||||||
if (off != -1)
|
|
||||||
path = uristr.substring(off + 2);
|
|
||||||
}
|
|
||||||
if (path != null)
|
|
||||||
return fs.getPath(path);
|
|
||||||
throw new IllegalArgumentException("URI: "
|
|
||||||
+ uri
|
|
||||||
+ " does not contain path fragment ex. jar:///c:/foo.zip!/BAR");
|
|
||||||
}
|
|
||||||
}
|
|
@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* Copyright (c) 2001, 2013, Oracle and/or its affiliates. All rights reserved.
|
* Copyright (c) 2001, 2014, Oracle and/or its affiliates. All rights reserved.
|
||||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||||
*
|
*
|
||||||
* This code is free software; you can redistribute it and/or modify it
|
* This code is free software; you can redistribute it and/or modify it
|
||||||
@ -5166,39 +5166,7 @@ void unpacker::redirect_stdio() {
|
|||||||
} else if (log_file[0] != '\0' && (errstrm = fopen(log_file,"a+")) != NULL) {
|
} else if (log_file[0] != '\0' && (errstrm = fopen(log_file,"a+")) != NULL) {
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
char log_file_name[PATH_MAX+100];
|
fprintf(stderr, "Can not open log file %s\n", log_file);
|
||||||
char tmpdir[PATH_MAX];
|
|
||||||
#ifdef WIN32
|
|
||||||
int n = GetTempPath(PATH_MAX,tmpdir); //API returns with trailing '\'
|
|
||||||
if (n < 1 || n > PATH_MAX) {
|
|
||||||
sprintf(tmpdir,"C:\\");
|
|
||||||
}
|
|
||||||
sprintf(log_file_name, "%sunpack.log", tmpdir);
|
|
||||||
#else
|
|
||||||
sprintf(tmpdir,"/tmp");
|
|
||||||
sprintf(log_file_name, "/tmp/unpack.log");
|
|
||||||
#endif
|
|
||||||
if ((errstrm = fopen(log_file_name, "a+")) != NULL) {
|
|
||||||
log_file = errstrm_name = saveStr(log_file_name);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
|
|
||||||
char *tname = tempnam(tmpdir,"#upkg");
|
|
||||||
if (tname == NULL) return;
|
|
||||||
sprintf(log_file_name, "%s", tname);
|
|
||||||
::free(tname);
|
|
||||||
if ((errstrm = fopen(log_file_name, "a+")) != NULL) {
|
|
||||||
log_file = errstrm_name = saveStr(log_file_name);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
#ifndef WIN32
|
|
||||||
sprintf(log_file_name, "/dev/null");
|
|
||||||
// On windows most likely it will fail.
|
|
||||||
if ( (errstrm = fopen(log_file_name, "a+")) != NULL) {
|
|
||||||
log_file = errstrm_name = saveStr(log_file_name);
|
|
||||||
return ;
|
|
||||||
}
|
|
||||||
#endif
|
|
||||||
// Last resort
|
// Last resort
|
||||||
// (Do not use stdout, since it might be jarout->jarfp.)
|
// (Do not use stdout, since it might be jarout->jarfp.)
|
||||||
errstrm = stderr;
|
errstrm = stderr;
|
||||||
|
@ -435,9 +435,7 @@ DGifGetImageDesc(GifFileType * GifFile) {
|
|||||||
Private->PixelCount = (long)GifFile->Image.Width *
|
Private->PixelCount = (long)GifFile->Image.Width *
|
||||||
(long)GifFile->Image.Height;
|
(long)GifFile->Image.Height;
|
||||||
|
|
||||||
DGifSetupDecompress(GifFile); /* Reset decompress algorithm parameters. */
|
return DGifSetupDecompress(GifFile); /* Reset decompress algorithm parameters. */
|
||||||
|
|
||||||
return GIF_OK;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/******************************************************************************
|
/******************************************************************************
|
||||||
|
@ -249,6 +249,7 @@ Java_sun_awt_image_GifImageDecoder_parseImage(JNIEnv *env,
|
|||||||
/* fill the block */
|
/* fill the block */
|
||||||
len = (*env)->CallIntMethod(env, this, readID,
|
len = (*env)->CallIntMethod(env, this, readID,
|
||||||
blockh, remain, blockLength + 1);
|
blockh, remain, blockLength + 1);
|
||||||
|
if (len > blockLength + 1) len = blockLength + 1;
|
||||||
if ((*env)->ExceptionOccurred(env)) {
|
if ((*env)->ExceptionOccurred(env)) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
@ -945,6 +945,9 @@ imageio_fill_input_buffer(j_decompress_ptr cinfo)
|
|||||||
JPEGImageReader_readInputDataID,
|
JPEGImageReader_readInputDataID,
|
||||||
sb->hstreamBuffer, 0,
|
sb->hstreamBuffer, 0,
|
||||||
sb->bufferLength);
|
sb->bufferLength);
|
||||||
|
if ((ret > 0) && ((unsigned int)ret > sb->bufferLength)) {
|
||||||
|
ret = sb->bufferLength;
|
||||||
|
}
|
||||||
if ((*env)->ExceptionOccurred(env)
|
if ((*env)->ExceptionOccurred(env)
|
||||||
|| !GET_ARRAYS(env, data, &(src->next_input_byte))) {
|
|| !GET_ARRAYS(env, data, &(src->next_input_byte))) {
|
||||||
cinfo->err->error_exit((j_common_ptr) cinfo);
|
cinfo->err->error_exit((j_common_ptr) cinfo);
|
||||||
@ -1041,6 +1044,7 @@ imageio_fill_suspended_buffer(j_decompress_ptr cinfo)
|
|||||||
JPEGImageReader_readInputDataID,
|
JPEGImageReader_readInputDataID,
|
||||||
sb->hstreamBuffer,
|
sb->hstreamBuffer,
|
||||||
offset, buflen);
|
offset, buflen);
|
||||||
|
if ((ret > 0) && ((unsigned int)ret > buflen)) ret = buflen;
|
||||||
if ((*env)->ExceptionOccurred(env)
|
if ((*env)->ExceptionOccurred(env)
|
||||||
|| !GET_ARRAYS(env, data, &(src->next_input_byte))) {
|
|| !GET_ARRAYS(env, data, &(src->next_input_byte))) {
|
||||||
cinfo->err->error_exit((j_common_ptr) cinfo);
|
cinfo->err->error_exit((j_common_ptr) cinfo);
|
||||||
|
@ -349,6 +349,12 @@ get_sos (j_decompress_ptr cinfo)
|
|||||||
|
|
||||||
TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
|
TRACEMS3(cinfo, 1, JTRC_SOS_COMPONENT, cc,
|
||||||
compptr->dc_tbl_no, compptr->ac_tbl_no);
|
compptr->dc_tbl_no, compptr->ac_tbl_no);
|
||||||
|
|
||||||
|
/* This CSi (cc) should differ from the previous CSi */
|
||||||
|
for (ci = 0; ci < i; ci++) {
|
||||||
|
if (cinfo->cur_comp_info[ci] == compptr)
|
||||||
|
ERREXIT1(cinfo, JERR_BAD_COMPONENT_ID, cc);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Collect the additional scan parameters Ss, Se, Ah/Al. */
|
/* Collect the additional scan parameters Ss, Se, Ah/Al. */
|
||||||
|
@ -289,6 +289,7 @@ sun_jpeg_fill_input_buffer(j_decompress_ptr cinfo)
|
|||||||
buflen = (*env)->GetArrayLength(env, src->hInputBuffer);
|
buflen = (*env)->GetArrayLength(env, src->hInputBuffer);
|
||||||
ret = (*env)->CallIntMethod(env, src->hInputStream, InputStream_readID,
|
ret = (*env)->CallIntMethod(env, src->hInputStream, InputStream_readID,
|
||||||
src->hInputBuffer, 0, buflen);
|
src->hInputBuffer, 0, buflen);
|
||||||
|
if (ret > buflen) ret = buflen;
|
||||||
if ((*env)->ExceptionOccurred(env) || !GET_ARRAYS(env, src)) {
|
if ((*env)->ExceptionOccurred(env) || !GET_ARRAYS(env, src)) {
|
||||||
cinfo->err->error_exit((struct jpeg_common_struct *) cinfo);
|
cinfo->err->error_exit((struct jpeg_common_struct *) cinfo);
|
||||||
}
|
}
|
||||||
@ -349,6 +350,7 @@ sun_jpeg_fill_suspended_buffer(j_decompress_ptr cinfo)
|
|||||||
}
|
}
|
||||||
ret = (*env)->CallIntMethod(env, src->hInputStream, InputStream_readID,
|
ret = (*env)->CallIntMethod(env, src->hInputStream, InputStream_readID,
|
||||||
src->hInputBuffer, offset, buflen);
|
src->hInputBuffer, offset, buflen);
|
||||||
|
if ((ret > 0) && ((unsigned int)ret > buflen)) ret = buflen;
|
||||||
if ((*env)->ExceptionOccurred(env) || !GET_ARRAYS(env, src)) {
|
if ((*env)->ExceptionOccurred(env) || !GET_ARRAYS(env, src)) {
|
||||||
cinfo->err->error_exit((struct jpeg_common_struct *) cinfo);
|
cinfo->err->error_exit((struct jpeg_common_struct *) cinfo);
|
||||||
}
|
}
|
||||||
@ -424,6 +426,7 @@ sun_jpeg_skip_input_data(j_decompress_ptr cinfo, long num_bytes)
|
|||||||
ret = (*env)->CallIntMethod(env, src->hInputStream,
|
ret = (*env)->CallIntMethod(env, src->hInputStream,
|
||||||
InputStream_readID,
|
InputStream_readID,
|
||||||
src->hInputBuffer, 0, buflen);
|
src->hInputBuffer, 0, buflen);
|
||||||
|
if (ret > buflen) ret = buflen;
|
||||||
if ((*env)->ExceptionOccurred(env)) {
|
if ((*env)->ExceptionOccurred(env)) {
|
||||||
cinfo->err->error_exit((struct jpeg_common_struct *) cinfo);
|
cinfo->err->error_exit((struct jpeg_common_struct *) cinfo);
|
||||||
}
|
}
|
||||||
|
@ -1862,6 +1862,9 @@ png_read_transform_info(png_structp png_ptr, png_infop info_ptr)
|
|||||||
|
|
||||||
info_ptr->bit_depth = 8;
|
info_ptr->bit_depth = 8;
|
||||||
info_ptr->num_trans = 0;
|
info_ptr->num_trans = 0;
|
||||||
|
|
||||||
|
if (png_ptr->palette == NULL)
|
||||||
|
png_error (png_ptr, "Palette is NULL in indexed image");
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
|
@ -512,6 +512,17 @@ png_set_PLTE(png_structp png_ptr, png_infop info_ptr,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if ((num_palette > 0 && palette == NULL) ||
|
||||||
|
(num_palette == 0
|
||||||
|
# ifdef PNG_MNG_FEATURES_SUPPORTED
|
||||||
|
&& (png_ptr->mng_features_permitted & PNG_FLAG_MNG_EMPTY_PLTE) == 0
|
||||||
|
# endif
|
||||||
|
))
|
||||||
|
{
|
||||||
|
png_error(png_ptr, "Invalid palette");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
/* It may not actually be necessary to set png_ptr->palette here;
|
/* It may not actually be necessary to set png_ptr->palette here;
|
||||||
* we do it for backward compatibility with the way the png_handle_tRNS
|
* we do it for backward compatibility with the way the png_handle_tRNS
|
||||||
* function used to do the allocation.
|
* function used to do the allocation.
|
||||||
|
@ -228,6 +228,49 @@ getMlibEdgeHint(jint edgeHint) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/*
|
||||||
|
* We have to make sure that awt_setPixels can be safely applied to the given pair of
|
||||||
|
* raster and mlib image.
|
||||||
|
*
|
||||||
|
* In particular, make sure that
|
||||||
|
* - dimension is the same
|
||||||
|
* - number of channels in mlib image corresponds to the number of bands in the raster
|
||||||
|
* - sample size in image and raster are the same.
|
||||||
|
*
|
||||||
|
* Returns:
|
||||||
|
* -1 to indicate failure,
|
||||||
|
* 1 to indicate success
|
||||||
|
*/
|
||||||
|
static int setPixelsFormMlibImage(JNIEnv *env, RasterS_t *rasterP, mlib_image* img) {
|
||||||
|
if (rasterP->width != img->width || rasterP->height != img->height) {
|
||||||
|
/* dimension does not match */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rasterP->numBands != img->channels) {
|
||||||
|
/* number of bands does not match */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (rasterP->dataType) {
|
||||||
|
case BYTE_DATA_TYPE:
|
||||||
|
if (img->type != MLIB_BYTE) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
case SHORT_DATA_TYPE:
|
||||||
|
if (img->type != MLIB_SHORT && img->type != MLIB_USHORT) {
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
/* awt_setPixels does not support such rasters */
|
||||||
|
return -1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return awt_setPixels(env, rasterP, mlib_ImageGetData(img));
|
||||||
|
}
|
||||||
|
|
||||||
/***************************************************************************
|
/***************************************************************************
|
||||||
* External Functions *
|
* External Functions *
|
||||||
***************************************************************************/
|
***************************************************************************/
|
||||||
@ -700,7 +743,9 @@ Java_sun_awt_image_ImagingLib_convolveRaster(JNIEnv *env, jobject this,
|
|||||||
|
|
||||||
/* Means that we couldn't write directly into the destination buffer */
|
/* Means that we couldn't write directly into the destination buffer */
|
||||||
if (ddata == NULL) {
|
if (ddata == NULL) {
|
||||||
retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
|
if (storeRasterArray(env, srcRasterP, dstRasterP, dst) < 0) {
|
||||||
|
retStatus = setPixelsFormMlibImage(env, dstRasterP, dst);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release the pinned memory */
|
/* Release the pinned memory */
|
||||||
@ -1107,7 +1152,7 @@ fprintf(stderr,"Flags : %d\n",dst->flags);
|
|||||||
/* Need to store it back into the array */
|
/* Need to store it back into the array */
|
||||||
if (storeRasterArray(env, srcRasterP, dstRasterP, dst) < 0) {
|
if (storeRasterArray(env, srcRasterP, dstRasterP, dst) < 0) {
|
||||||
(*env)->ExceptionClear(env); // Could not store the array, try another way
|
(*env)->ExceptionClear(env); // Could not store the array, try another way
|
||||||
retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
|
retStatus = setPixelsFormMlibImage(env, dstRasterP, dst);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1433,6 +1478,14 @@ Java_sun_awt_image_ImagingLib_lookupByteBI(JNIEnv *env, jobject thisLib,
|
|||||||
retStatus = 0;
|
retStatus = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Release the LUT */
|
||||||
|
for (i=0; i < lut_nbands; i++) {
|
||||||
|
(*env)->ReleasePrimitiveArrayCritical(env, jtable[i].jArray,
|
||||||
|
(jbyte *) jtable[i].table, JNI_ABORT);
|
||||||
|
}
|
||||||
|
free ((void *) jtable);
|
||||||
|
free ((void *) tbl);
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Means that we couldn't write directly into
|
* Means that we couldn't write directly into
|
||||||
* the destination buffer
|
* the destination buffer
|
||||||
@ -1446,13 +1499,6 @@ Java_sun_awt_image_ImagingLib_lookupByteBI(JNIEnv *env, jobject thisLib,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release the LUT */
|
|
||||||
for (i=0; i < lut_nbands; i++) {
|
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jtable[i].jArray,
|
|
||||||
(jbyte *) jtable[i].table, JNI_ABORT);
|
|
||||||
}
|
|
||||||
free ((void *) jtable);
|
|
||||||
free ((void *) tbl);
|
|
||||||
|
|
||||||
/* Release the pinned memory */
|
/* Release the pinned memory */
|
||||||
freeArray(env, srcImageP, src, sdata, dstImageP, dst, ddata);
|
freeArray(env, srcImageP, src, sdata, dstImageP, dst, ddata);
|
||||||
@ -1670,18 +1716,20 @@ Java_sun_awt_image_ImagingLib_lookupByteRaster(JNIEnv *env,
|
|||||||
retStatus = 0;
|
retStatus = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* Release the LUT */
|
||||||
|
for (i=0; i < lut_nbands; i++) {
|
||||||
|
(*env)->ReleasePrimitiveArrayCritical(env, jtable[i].jArray,
|
||||||
|
(jbyte *) jtable[i].table, JNI_ABORT);
|
||||||
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* Means that we couldn't write directly into
|
* Means that we couldn't write directly into
|
||||||
* the destination buffer
|
* the destination buffer
|
||||||
*/
|
*/
|
||||||
if (ddata == NULL) {
|
if (ddata == NULL) {
|
||||||
retStatus = awt_setPixels(env, dstRasterP, mlib_ImageGetData(dst));
|
if (storeRasterArray(env, srcRasterP, dstRasterP, dst) < 0) {
|
||||||
}
|
retStatus = setPixelsFormMlibImage(env, dstRasterP, dst);
|
||||||
|
}
|
||||||
/* Release the LUT */
|
|
||||||
for (i=0; i < lut_nbands; i++) {
|
|
||||||
(*env)->ReleasePrimitiveArrayCritical(env, jtable[i].jArray,
|
|
||||||
(jbyte *) jtable[i].table, JNI_ABORT);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/* Release the pinned memory */
|
/* Release the pinned memory */
|
||||||
@ -2643,7 +2691,7 @@ storeImageArray(JNIEnv *env, BufImageS_t *srcP, BufImageS_t *dstP,
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (mlibImP->type == MLIB_SHORT) {
|
else if (mlibImP->type == MLIB_SHORT) {
|
||||||
return awt_setPixels(env, rasterP, mlibImP->data);
|
return setPixelsFormMlibImage(env, rasterP, mlibImP);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
|
@ -154,6 +154,7 @@ TTGlyphID ContextualGlyphSubstitutionProcessor2::lookup(le_uint32 offset, LEGlyp
|
|||||||
TTGlyphID glyphCode = (TTGlyphID) LE_GET_GLYPH(gid);
|
TTGlyphID glyphCode = (TTGlyphID) LE_GET_GLYPH(gid);
|
||||||
if ((glyphCode >= firstGlyph) && (glyphCode < lastGlyph)) {
|
if ((glyphCode >= firstGlyph) && (glyphCode < lastGlyph)) {
|
||||||
LEReferenceToArrayOf<LookupValue> valueArray(lookupTable8, success, &lookupTable8->valueArray[0], glyphCount);
|
LEReferenceToArrayOf<LookupValue> valueArray(lookupTable8, success, &lookupTable8->valueArray[0], glyphCount);
|
||||||
|
if (LE_FAILURE(success)) { return newGlyph; }
|
||||||
newGlyph = SWAPW(valueArray(glyphCode - firstGlyph, success));
|
newGlyph = SWAPW(valueArray(glyphCode - firstGlyph, success));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -110,6 +110,8 @@ le_bool ContextualSubstitutionBase::matchGlyphClasses(
|
|||||||
LEErrorCode &success,
|
LEErrorCode &success,
|
||||||
le_bool backtrack)
|
le_bool backtrack)
|
||||||
{
|
{
|
||||||
|
if (LE_FAILURE(success)) { return FALSE; }
|
||||||
|
|
||||||
le_int32 direction = 1;
|
le_int32 direction = 1;
|
||||||
le_int32 match = 0;
|
le_int32 match = 0;
|
||||||
|
|
||||||
@ -255,6 +257,7 @@ le_uint32 ContextualSubstitutionFormat1Subtable::process(const LETableReference
|
|||||||
le_uint16 matchCount = SWAPW(subRuleTable->glyphCount) - 1;
|
le_uint16 matchCount = SWAPW(subRuleTable->glyphCount) - 1;
|
||||||
le_uint16 substCount = SWAPW(subRuleTable->substCount);
|
le_uint16 substCount = SWAPW(subRuleTable->substCount);
|
||||||
LEReferenceToArrayOf<TTGlyphID> inputGlyphArray(base, success, subRuleTable->inputGlyphArray, matchCount+2);
|
LEReferenceToArrayOf<TTGlyphID> inputGlyphArray(base, success, subRuleTable->inputGlyphArray, matchCount+2);
|
||||||
|
if (LE_FAILURE(success)) { return 0; }
|
||||||
if (matchGlyphIDs(inputGlyphArray, matchCount, glyphIterator)) {
|
if (matchGlyphIDs(inputGlyphArray, matchCount, glyphIterator)) {
|
||||||
LEReferenceToArrayOf<SubstitutionLookupRecord>
|
LEReferenceToArrayOf<SubstitutionLookupRecord>
|
||||||
substLookupRecordArray(base, success, (const SubstitutionLookupRecord *) &subRuleTable->inputGlyphArray[matchCount], substCount);
|
substLookupRecordArray(base, success, (const SubstitutionLookupRecord *) &subRuleTable->inputGlyphArray[matchCount], substCount);
|
||||||
@ -315,6 +318,7 @@ le_uint32 ContextualSubstitutionFormat2Subtable::process(const LETableReference
|
|||||||
|
|
||||||
LEReferenceToArrayOf<le_uint16> classArray(base, success, subClassRuleTable->classArray, matchCount+1);
|
LEReferenceToArrayOf<le_uint16> classArray(base, success, subClassRuleTable->classArray, matchCount+1);
|
||||||
|
|
||||||
|
if (LE_FAILURE(success)) { return 0; }
|
||||||
if (matchGlyphClasses(classArray, matchCount, glyphIterator, classDefinitionTable, success)) {
|
if (matchGlyphClasses(classArray, matchCount, glyphIterator, classDefinitionTable, success)) {
|
||||||
LEReferenceToArrayOf<SubstitutionLookupRecord>
|
LEReferenceToArrayOf<SubstitutionLookupRecord>
|
||||||
substLookupRecordArray(base, success, (const SubstitutionLookupRecord *) &subClassRuleTable->classArray[matchCount], substCount);
|
substLookupRecordArray(base, success, (const SubstitutionLookupRecord *) &subClassRuleTable->classArray[matchCount], substCount);
|
||||||
@ -573,7 +577,7 @@ le_uint32 ChainingContextualSubstitutionFormat2Subtable::process(const LETableRe
|
|||||||
if (matchGlyphClasses(inputClassArray, inputGlyphCount, glyphIterator, inputClassDefinitionTable, success)) {
|
if (matchGlyphClasses(inputClassArray, inputGlyphCount, glyphIterator, inputClassDefinitionTable, success)) {
|
||||||
LEReferenceToArrayOf<SubstitutionLookupRecord>
|
LEReferenceToArrayOf<SubstitutionLookupRecord>
|
||||||
substLookupRecordArray(base, success, (const SubstitutionLookupRecord *) lookaheadClassArray.getAlias(lookaheadGlyphCount + 1, success), substCount);
|
substLookupRecordArray(base, success, (const SubstitutionLookupRecord *) lookaheadClassArray.getAlias(lookaheadGlyphCount + 1, success), substCount);
|
||||||
|
if (LE_FAILURE(success)) { return 0; }
|
||||||
applySubstitutionLookups(lookupProcessor, substLookupRecordArray, substCount, glyphIterator, fontInstance, position, success);
|
applySubstitutionLookups(lookupProcessor, substLookupRecordArray, substCount, glyphIterator, fontInstance, position, success);
|
||||||
|
|
||||||
return inputGlyphCount + 1;
|
return inputGlyphCount + 1;
|
||||||
@ -601,9 +605,10 @@ le_uint32 ChainingContextualSubstitutionFormat3Subtable::process(const LETableRe
|
|||||||
le_uint16 backtrkGlyphCount = SWAPW(backtrackGlyphCount);
|
le_uint16 backtrkGlyphCount = SWAPW(backtrackGlyphCount);
|
||||||
le_uint16 inputGlyphCount = (le_uint16) SWAPW(backtrackCoverageTableOffsetArray[backtrkGlyphCount]);
|
le_uint16 inputGlyphCount = (le_uint16) SWAPW(backtrackCoverageTableOffsetArray[backtrkGlyphCount]);
|
||||||
LEReferenceToArrayOf<Offset> inputCoverageTableOffsetArray(base, success, &backtrackCoverageTableOffsetArray[backtrkGlyphCount + 1], inputGlyphCount+2); // offset
|
LEReferenceToArrayOf<Offset> inputCoverageTableOffsetArray(base, success, &backtrackCoverageTableOffsetArray[backtrkGlyphCount + 1], inputGlyphCount+2); // offset
|
||||||
|
if (LE_FAILURE(success)) { return 0; }
|
||||||
const le_uint16 lookaheadGlyphCount = (le_uint16) SWAPW(inputCoverageTableOffsetArray[inputGlyphCount]);
|
const le_uint16 lookaheadGlyphCount = (le_uint16) SWAPW(inputCoverageTableOffsetArray[inputGlyphCount]);
|
||||||
|
|
||||||
if( LE_FAILURE(success) ) { return 0; }
|
if( LE_FAILURE(success)) { return 0; }
|
||||||
LEReferenceToArrayOf<Offset> lookaheadCoverageTableOffsetArray(base, success, inputCoverageTableOffsetArray.getAlias(inputGlyphCount + 1, success), lookaheadGlyphCount+2);
|
LEReferenceToArrayOf<Offset> lookaheadCoverageTableOffsetArray(base, success, inputCoverageTableOffsetArray.getAlias(inputGlyphCount + 1, success), lookaheadGlyphCount+2);
|
||||||
|
|
||||||
if( LE_FAILURE(success) ) { return 0; }
|
if( LE_FAILURE(success) ) { return 0; }
|
||||||
|
@ -95,7 +95,7 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp
|
|||||||
|
|
||||||
if (actionOffset != 0) {
|
if (actionOffset != 0) {
|
||||||
LEReferenceTo<LigatureActionEntry> ap(stHeader, success, ligActionOffset); // byte offset
|
LEReferenceTo<LigatureActionEntry> ap(stHeader, success, ligActionOffset); // byte offset
|
||||||
ap.addObject(ligActionIndex - 1, success); // index offset ( one before the actual start, because we will pre-increment)
|
ap.addObject(ligActionIndex, success);
|
||||||
LEReferenceToArrayOf<TTGlyphID> ligatureTable(stHeader, success, ligatureOffset, LE_UNBOUNDED_ARRAY);
|
LEReferenceToArrayOf<TTGlyphID> ligatureTable(stHeader, success, ligatureOffset, LE_UNBOUNDED_ARRAY);
|
||||||
LigatureActionEntry action;
|
LigatureActionEntry action;
|
||||||
le_int32 offset, i = 0;
|
le_int32 offset, i = 0;
|
||||||
@ -111,7 +111,6 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp
|
|||||||
do {
|
do {
|
||||||
le_uint32 componentGlyph = componentStack[m--]; // pop off
|
le_uint32 componentGlyph = componentStack[m--]; // pop off
|
||||||
|
|
||||||
ap.addObject(success);
|
|
||||||
action = SWAPL(*ap.getAlias());
|
action = SWAPL(*ap.getAlias());
|
||||||
|
|
||||||
if (m < 0) {
|
if (m < 0) {
|
||||||
@ -145,7 +144,8 @@ le_uint16 LigatureSubstitutionProcessor2::processStateEntry(LEGlyphStorage &glyp
|
|||||||
LE_DEBUG_BAD_FONT("m<0")
|
LE_DEBUG_BAD_FONT("m<0")
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
} while (!(action & lafLast) && (m>=0) ); // stop if last bit is set, or if run out of items
|
ap.addObject(success);
|
||||||
|
} while (LE_SUCCESS(success) && !(action & lafLast) && (m>=0) ); // stop if last bit is set, or if run out of items
|
||||||
|
|
||||||
while (mm >= 0) {
|
while (mm >= 0) {
|
||||||
if (++m >= nComponents) {
|
if (++m >= nComponents) {
|
||||||
|
@ -282,6 +282,7 @@ LookupProcessor::LookupProcessor(const LETableReference &baseAddress,
|
|||||||
|
|
||||||
for (le_uint16 feature = 0; feature < featureCount; feature += 1) {
|
for (le_uint16 feature = 0; feature < featureCount; feature += 1) {
|
||||||
LEReferenceToArrayOf<le_uint16> featureIndexArray(langSysTable, success, langSysTable->featureIndexArray, featureCount);
|
LEReferenceToArrayOf<le_uint16> featureIndexArray(langSysTable, success, langSysTable->featureIndexArray, featureCount);
|
||||||
|
if (LE_FAILURE(success)) { continue; }
|
||||||
le_uint16 featureIndex = SWAPW(featureIndexArray.getObject(feature,success));
|
le_uint16 featureIndex = SWAPW(featureIndexArray.getObject(feature,success));
|
||||||
|
|
||||||
// don't add the required feature to the list more than once...
|
// don't add the required feature to the list more than once...
|
||||||
|
@ -67,6 +67,7 @@ le_int32 MarkToBasePositioningSubtable::process(const LETableReference &base, Gl
|
|||||||
|
|
||||||
LEPoint markAnchor;
|
LEPoint markAnchor;
|
||||||
LEReferenceTo<MarkArray> markArray(base, success, (const MarkArray *) ((char *) this + SWAPW(markArrayOffset)));
|
LEReferenceTo<MarkArray> markArray(base, success, (const MarkArray *) ((char *) this + SWAPW(markArrayOffset)));
|
||||||
|
if(LE_FAILURE(success)) return 0;
|
||||||
le_int32 markClass = markArray->getMarkClass(markArray, markGlyph, markCoverage, fontInstance, markAnchor, success);
|
le_int32 markClass = markArray->getMarkClass(markArray, markGlyph, markCoverage, fontInstance, markAnchor, success);
|
||||||
le_uint16 mcCount = SWAPW(classCount);
|
le_uint16 mcCount = SWAPW(classCount);
|
||||||
|
|
||||||
|
@ -79,8 +79,8 @@ le_int8 OpenTypeUtilities::highBit(le_int32 value)
|
|||||||
|
|
||||||
Offset OpenTypeUtilities::getTagOffset(LETag tag, const LEReferenceToArrayOf<TagAndOffsetRecord> &records, LEErrorCode &success)
|
Offset OpenTypeUtilities::getTagOffset(LETag tag, const LEReferenceToArrayOf<TagAndOffsetRecord> &records, LEErrorCode &success)
|
||||||
{
|
{
|
||||||
const TagAndOffsetRecord *r0 = (const TagAndOffsetRecord*)records.getAlias();
|
|
||||||
if(LE_FAILURE(success)) return 0;
|
if(LE_FAILURE(success)) return 0;
|
||||||
|
const TagAndOffsetRecord *r0 = (const TagAndOffsetRecord*)records.getAlias();
|
||||||
|
|
||||||
le_uint32 recordCount = records.getCount();
|
le_uint32 recordCount = records.getCount();
|
||||||
le_uint8 bit = highBit(recordCount);
|
le_uint8 bit = highBit(recordCount);
|
||||||
|
@ -73,6 +73,7 @@ void SegmentArrayProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &s
|
|||||||
|
|
||||||
if (offset != 0) {
|
if (offset != 0) {
|
||||||
LEReferenceToArrayOf<TTGlyphID> glyphArray(subtableHeader, success, offset, LE_UNBOUNDED_ARRAY);
|
LEReferenceToArrayOf<TTGlyphID> glyphArray(subtableHeader, success, offset, LE_UNBOUNDED_ARRAY);
|
||||||
|
if (LE_FAILURE(success)) { continue; }
|
||||||
TTGlyphID newGlyph = SWAPW(glyphArray(LE_GET_GLYPH(thisGlyph) - firstGlyph, success));
|
TTGlyphID newGlyph = SWAPW(glyphArray(LE_GET_GLYPH(thisGlyph) - firstGlyph, success));
|
||||||
glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
|
glyphStorage[glyph] = LE_SET_GLYPH(thisGlyph, newGlyph);
|
||||||
}
|
}
|
||||||
|
@ -97,6 +97,7 @@ void StateTableProcessor::process(LEGlyphStorage &glyphStorage, LEErrorCode &suc
|
|||||||
|
|
||||||
LEReferenceToArrayOf<EntryTableIndex> stateArray(stHeader, success, currentState, LE_UNBOUNDED_ARRAY);
|
LEReferenceToArrayOf<EntryTableIndex> stateArray(stHeader, success, currentState, LE_UNBOUNDED_ARRAY);
|
||||||
EntryTableIndex entryTableIndex = stateArray.getObject((le_uint8)classCode, success);
|
EntryTableIndex entryTableIndex = stateArray.getObject((le_uint8)classCode, success);
|
||||||
|
if (LE_FAILURE(success)) { break; }
|
||||||
LE_STATE_PATIENCE_CURR(le_int32, currGlyph);
|
LE_STATE_PATIENCE_CURR(le_int32, currGlyph);
|
||||||
currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex);
|
currentState = processStateEntry(glyphStorage, currGlyph, entryTableIndex);
|
||||||
LE_STATE_PATIENCE_INCR(currGlyph);
|
LE_STATE_PATIENCE_INCR(currGlyph);
|
||||||
|
@ -81,7 +81,7 @@ typedef struct {
|
|||||||
cmsUInt32Number surround;
|
cmsUInt32Number surround;
|
||||||
cmsFloat64Number n, Nbb, Ncb, z, FL, D;
|
cmsFloat64Number n, Nbb, Ncb, z, FL, D;
|
||||||
|
|
||||||
cmsContext ContextID;
|
cmsContext ContextID;
|
||||||
|
|
||||||
} cmsCIECAM02;
|
} cmsCIECAM02;
|
||||||
|
|
||||||
@ -467,6 +467,7 @@ void CMSEXPORT cmsCIECAM02Forward(cmsHANDLE hModel, const cmsCIEXYZ* pIn, cmsJCh
|
|||||||
CAM02COLOR clr;
|
CAM02COLOR clr;
|
||||||
cmsCIECAM02* lpMod = (cmsCIECAM02*) hModel;
|
cmsCIECAM02* lpMod = (cmsCIECAM02*) hModel;
|
||||||
|
|
||||||
|
memset(&clr, 0, sizeof(clr));
|
||||||
_cmsAssert(lpMod != NULL);
|
_cmsAssert(lpMod != NULL);
|
||||||
_cmsAssert(pIn != NULL);
|
_cmsAssert(pIn != NULL);
|
||||||
_cmsAssert(pOut != NULL);
|
_cmsAssert(pOut != NULL);
|
||||||
@ -491,6 +492,7 @@ void CMSEXPORT cmsCIECAM02Reverse(cmsHANDLE hModel, const cmsJCh* pIn, cmsCIEXYZ
|
|||||||
CAM02COLOR clr;
|
CAM02COLOR clr;
|
||||||
cmsCIECAM02* lpMod = (cmsCIECAM02*) hModel;
|
cmsCIECAM02* lpMod = (cmsCIECAM02*) hModel;
|
||||||
|
|
||||||
|
memset(&clr, 0, sizeof(clr));
|
||||||
_cmsAssert(lpMod != NULL);
|
_cmsAssert(lpMod != NULL);
|
||||||
_cmsAssert(pIn != NULL);
|
_cmsAssert(pIn != NULL);
|
||||||
_cmsAssert(pOut != NULL);
|
_cmsAssert(pOut != NULL);
|
||||||
|
@ -59,8 +59,8 @@
|
|||||||
// IT8.7 / CGATS.17-200x handling -----------------------------------------------------------------------------
|
// IT8.7 / CGATS.17-200x handling -----------------------------------------------------------------------------
|
||||||
|
|
||||||
|
|
||||||
#define MAXID 128 // Max lenght of identifier
|
#define MAXID 128 // Max length of identifier
|
||||||
#define MAXSTR 1024 // Max lenght of string
|
#define MAXSTR 1024 // Max length of string
|
||||||
#define MAXTABLES 255 // Max Number of tables in a single stream
|
#define MAXTABLES 255 // Max Number of tables in a single stream
|
||||||
#define MAXINCLUDE 20 // Max number of nested includes
|
#define MAXINCLUDE 20 // Max number of nested includes
|
||||||
|
|
||||||
@ -383,28 +383,28 @@ static const char* PredefinedSampleID[] = {
|
|||||||
//Forward declaration of some internal functions
|
//Forward declaration of some internal functions
|
||||||
static void* AllocChunk(cmsIT8* it8, cmsUInt32Number size);
|
static void* AllocChunk(cmsIT8* it8, cmsUInt32Number size);
|
||||||
|
|
||||||
// Checks if c is a separator
|
// Checks whatever c is a separator
|
||||||
static
|
static
|
||||||
cmsBool isseparator(int c)
|
cmsBool isseparator(int c)
|
||||||
{
|
{
|
||||||
return (c == ' ') || (c == '\t') || (c == '\r');
|
return (c == ' ') || (c == '\t') ;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks whatever if c is a valid identifier char
|
// Checks whatever c is a valid identifier char
|
||||||
static
|
static
|
||||||
cmsBool ismiddle(int c)
|
cmsBool ismiddle(int c)
|
||||||
{
|
{
|
||||||
return (!isseparator(c) && (c != '#') && (c !='\"') && (c != '\'') && (c > 32) && (c < 127));
|
return (!isseparator(c) && (c != '#') && (c !='\"') && (c != '\'') && (c > 32) && (c < 127));
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks whatsever if c is a valid identifier middle char.
|
// Checks whatsever c is a valid identifier middle char.
|
||||||
static
|
static
|
||||||
cmsBool isidchar(int c)
|
cmsBool isidchar(int c)
|
||||||
{
|
{
|
||||||
return isalnum(c) || ismiddle(c);
|
return isalnum(c) || ismiddle(c);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Checks whatsever if c is a valid identifier first char.
|
// Checks whatsever c is a valid identifier first char.
|
||||||
static
|
static
|
||||||
cmsBool isfirstidchar(int c)
|
cmsBool isfirstidchar(int c)
|
||||||
{
|
{
|
||||||
@ -436,7 +436,6 @@ cmsBool isabsolutepath(const char *path)
|
|||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
// Makes a file path based on a given reference path
|
// Makes a file path based on a given reference path
|
||||||
// NOTE: this function doesn't check if the path exists or even if it's legal
|
// NOTE: this function doesn't check if the path exists or even if it's legal
|
||||||
static
|
static
|
||||||
@ -634,6 +633,7 @@ cmsFloat64Number ParseFloatNumber(const char *Buffer)
|
|||||||
cmsFloat64Number dnum = 0.0;
|
cmsFloat64Number dnum = 0.0;
|
||||||
int sign = 1;
|
int sign = 1;
|
||||||
|
|
||||||
|
// keep safe
|
||||||
if (Buffer == NULL) return 0.0;
|
if (Buffer == NULL) return 0.0;
|
||||||
|
|
||||||
if (*Buffer == '-' || *Buffer == '+') {
|
if (*Buffer == '-' || *Buffer == '+') {
|
||||||
@ -869,6 +869,14 @@ void InSymbol(cmsIT8* it8)
|
|||||||
|
|
||||||
|
|
||||||
// Next line
|
// Next line
|
||||||
|
case '\r':
|
||||||
|
NextCh(it8);
|
||||||
|
if (it8 ->ch == '\n')
|
||||||
|
NextCh(it8);
|
||||||
|
it8->sy = SEOLN;
|
||||||
|
it8->lineno++;
|
||||||
|
break;
|
||||||
|
|
||||||
case '\n':
|
case '\n':
|
||||||
NextCh(it8);
|
NextCh(it8);
|
||||||
it8->sy = SEOLN;
|
it8->sy = SEOLN;
|
||||||
@ -878,7 +886,7 @@ void InSymbol(cmsIT8* it8)
|
|||||||
// Comment
|
// Comment
|
||||||
case '#':
|
case '#':
|
||||||
NextCh(it8);
|
NextCh(it8);
|
||||||
while (it8->ch && it8->ch != '\n')
|
while (it8->ch && it8->ch != '\n' && it8->ch != '\r')
|
||||||
NextCh(it8);
|
NextCh(it8);
|
||||||
|
|
||||||
it8->sy = SCOMMENT;
|
it8->sy = SCOMMENT;
|
||||||
@ -996,6 +1004,9 @@ cmsBool GetVal(cmsIT8* it8, char* Buffer, cmsUInt32Number max, const char* Error
|
|||||||
{
|
{
|
||||||
switch (it8->sy) {
|
switch (it8->sy) {
|
||||||
|
|
||||||
|
case SEOLN: // Empty value
|
||||||
|
Buffer[0]=0;
|
||||||
|
break;
|
||||||
case SIDENT: strncpy(Buffer, it8->id, max);
|
case SIDENT: strncpy(Buffer, it8->id, max);
|
||||||
Buffer[max-1]=0;
|
Buffer[max-1]=0;
|
||||||
break;
|
break;
|
||||||
@ -1145,9 +1156,9 @@ cmsBool IsAvailableOnList(KEYVALUE* p, const char* Key, const char* Subkey, KEYV
|
|||||||
if (*Key != '#') { // Comments are ignored
|
if (*Key != '#') { // Comments are ignored
|
||||||
|
|
||||||
if (cmsstrcasecmp(Key, p->Keyword) == 0)
|
if (cmsstrcasecmp(Key, p->Keyword) == 0)
|
||||||
break;
|
break;
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
if (p == NULL)
|
if (p == NULL)
|
||||||
return FALSE;
|
return FALSE;
|
||||||
@ -1157,11 +1168,13 @@ cmsBool IsAvailableOnList(KEYVALUE* p, const char* Key, const char* Subkey, KEYV
|
|||||||
|
|
||||||
for (; p != NULL; p = p->NextSubkey) {
|
for (; p != NULL; p = p->NextSubkey) {
|
||||||
|
|
||||||
|
if (p ->Subkey == NULL) continue;
|
||||||
|
|
||||||
if (LastPtr) *LastPtr = p;
|
if (LastPtr) *LastPtr = p;
|
||||||
|
|
||||||
if (cmsstrcasecmp(Subkey, p->Subkey) == 0)
|
if (cmsstrcasecmp(Subkey, p->Subkey) == 0)
|
||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
return FALSE;
|
return FALSE;
|
||||||
}
|
}
|
||||||
@ -1284,7 +1297,7 @@ cmsInt32Number CMSEXPORT cmsIT8SetTable(cmsHANDLE IT8, cmsUInt32Number nTable)
|
|||||||
|
|
||||||
it8 ->nTable = nTable;
|
it8 ->nTable = nTable;
|
||||||
|
|
||||||
return nTable;
|
return (cmsInt32Number) nTable;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -1389,7 +1402,7 @@ cmsBool CMSEXPORT cmsIT8SetPropertyHex(cmsHANDLE hIT8, const char* cProp, cmsUIn
|
|||||||
cmsIT8* it8 = (cmsIT8*) hIT8;
|
cmsIT8* it8 = (cmsIT8*) hIT8;
|
||||||
char Buffer[1024];
|
char Buffer[1024];
|
||||||
|
|
||||||
sprintf(Buffer, "%d", Val);
|
sprintf(Buffer, "%u", Val);
|
||||||
|
|
||||||
return AddToList(it8, &GetTable(it8)->HeaderList, cProp, NULL, Buffer, WRITE_HEXADECIMAL) != NULL;
|
return AddToList(it8, &GetTable(it8)->HeaderList, cProp, NULL, Buffer, WRITE_HEXADECIMAL) != NULL;
|
||||||
}
|
}
|
||||||
@ -1426,6 +1439,8 @@ cmsFloat64Number CMSEXPORT cmsIT8GetPropertyDbl(cmsHANDLE hIT8, const char* cPro
|
|||||||
{
|
{
|
||||||
const char *v = cmsIT8GetProperty(hIT8, cProp);
|
const char *v = cmsIT8GetProperty(hIT8, cProp);
|
||||||
|
|
||||||
|
if (v == NULL) return 0.0;
|
||||||
|
|
||||||
return ParseFloatNumber(v);
|
return ParseFloatNumber(v);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -1458,7 +1473,7 @@ void AllocateDataFormat(cmsIT8* it8)
|
|||||||
t -> nSamples = 10;
|
t -> nSamples = 10;
|
||||||
}
|
}
|
||||||
|
|
||||||
t -> DataFormat = (char**) AllocChunk (it8, (t->nSamples + 1) * sizeof(char *));
|
t -> DataFormat = (char**) AllocChunk (it8, ((cmsUInt32Number) t->nSamples + 1) * sizeof(char *));
|
||||||
if (t->DataFormat == NULL) {
|
if (t->DataFormat == NULL) {
|
||||||
|
|
||||||
SynError(it8, "AllocateDataFormat: Unable to allocate dataFormat array");
|
SynError(it8, "AllocateDataFormat: Unable to allocate dataFormat array");
|
||||||
@ -1514,7 +1529,7 @@ void AllocateDataSet(cmsIT8* it8)
|
|||||||
t-> nSamples = atoi(cmsIT8GetProperty(it8, "NUMBER_OF_FIELDS"));
|
t-> nSamples = atoi(cmsIT8GetProperty(it8, "NUMBER_OF_FIELDS"));
|
||||||
t-> nPatches = atoi(cmsIT8GetProperty(it8, "NUMBER_OF_SETS"));
|
t-> nPatches = atoi(cmsIT8GetProperty(it8, "NUMBER_OF_SETS"));
|
||||||
|
|
||||||
t-> Data = (char**)AllocChunk (it8, (t->nSamples + 1) * (t->nPatches + 1) *sizeof (char*));
|
t-> Data = (char**)AllocChunk (it8, ((cmsUInt32Number) t->nSamples + 1) * ((cmsUInt32Number) t->nPatches + 1) *sizeof (char*));
|
||||||
if (t->Data == NULL) {
|
if (t->Data == NULL) {
|
||||||
|
|
||||||
SynError(it8, "AllocateDataSet: Unable to allocate data array");
|
SynError(it8, "AllocateDataSet: Unable to allocate data array");
|
||||||
@ -1573,7 +1588,7 @@ void WriteStr(SAVESTREAM* f, const char *str)
|
|||||||
if (str == NULL)
|
if (str == NULL)
|
||||||
str = " ";
|
str = " ";
|
||||||
|
|
||||||
// Lenghth to write
|
// Length to write
|
||||||
len = (cmsUInt32Number) strlen(str);
|
len = (cmsUInt32Number) strlen(str);
|
||||||
f ->Used += len;
|
f ->Used += len;
|
||||||
|
|
||||||
@ -2097,7 +2112,7 @@ cmsBool ParseIT8(cmsIT8* it8, cmsBool nosheet)
|
|||||||
NextCh(it8);
|
NextCh(it8);
|
||||||
|
|
||||||
// If a newline is found, then this is a type string
|
// If a newline is found, then this is a type string
|
||||||
if (it8 ->ch == '\n') {
|
if (it8 ->ch == '\n' || it8->ch == '\r') {
|
||||||
|
|
||||||
cmsIT8SetSheetType(it8, it8 ->id);
|
cmsIT8SetSheetType(it8, it8 ->id);
|
||||||
InSymbol(it8);
|
InSymbol(it8);
|
||||||
@ -2212,7 +2227,7 @@ void CookPointers(cmsIT8* it8)
|
|||||||
char Buffer[256];
|
char Buffer[256];
|
||||||
|
|
||||||
char *Type = p ->Value;
|
char *Type = p ->Value;
|
||||||
int nTable = k;
|
int nTable = (int) k;
|
||||||
|
|
||||||
snprintf(Buffer, 255, "%s %d %s", Label, nTable, Type );
|
snprintf(Buffer, 255, "%s %d %s", Label, nTable, Type );
|
||||||
|
|
||||||
@ -2566,6 +2581,8 @@ cmsFloat64Number CMSEXPORT cmsIT8GetDataRowColDbl(cmsHANDLE hIT8, int row, int c
|
|||||||
|
|
||||||
Buffer = cmsIT8GetDataRowCol(hIT8, row, col);
|
Buffer = cmsIT8GetDataRowCol(hIT8, row, col);
|
||||||
|
|
||||||
|
if (Buffer == NULL) return 0.0;
|
||||||
|
|
||||||
return ParseFloatNumber(Buffer);
|
return ParseFloatNumber(Buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -2778,7 +2795,7 @@ void CMSEXPORT cmsIT8DefineDblFormat(cmsHANDLE hIT8, const char* Formatter)
|
|||||||
if (Formatter == NULL)
|
if (Formatter == NULL)
|
||||||
strcpy(it8->DoubleFormatter, DEFAULT_DBL_FORMAT);
|
strcpy(it8->DoubleFormatter, DEFAULT_DBL_FORMAT);
|
||||||
else
|
else
|
||||||
strcpy(it8->DoubleFormatter, Formatter);
|
strncpy(it8->DoubleFormatter, Formatter, sizeof(it8->DoubleFormatter));
|
||||||
|
|
||||||
it8 ->DoubleFormatter[sizeof(it8 ->DoubleFormatter)-1] = 0;
|
it8 ->DoubleFormatter[sizeof(it8 ->DoubleFormatter)-1] = 0;
|
||||||
}
|
}
|
||||||
|
@ -270,7 +270,7 @@ cmsBool ComputeAbsoluteIntent(cmsFloat64Number AdaptationState,
|
|||||||
// m2 holds CHAD from output white to D50 times abs. col. scaling
|
// m2 holds CHAD from output white to D50 times abs. col. scaling
|
||||||
|
|
||||||
// Observer is not adapted, undo the chromatic adaptation
|
// Observer is not adapted, undo the chromatic adaptation
|
||||||
_cmsMAT3per(m, &m3, ChromaticAdaptationMatrixOut);
|
_cmsMAT3per(m, &m2, ChromaticAdaptationMatrixOut);
|
||||||
|
|
||||||
m3 = *ChromaticAdaptationMatrixIn;
|
m3 = *ChromaticAdaptationMatrixIn;
|
||||||
if (!_cmsMAT3inverse(&m3, &m4)) return FALSE;
|
if (!_cmsMAT3inverse(&m3, &m4)) return FALSE;
|
||||||
@ -411,57 +411,61 @@ cmsBool AddConversion(cmsPipeline* Result, cmsColorSpaceSignature InPCS, cmsColo
|
|||||||
// Handle PCS mismatches. A specialized stage is added to the LUT in such case
|
// Handle PCS mismatches. A specialized stage is added to the LUT in such case
|
||||||
switch (InPCS) {
|
switch (InPCS) {
|
||||||
|
|
||||||
case cmsSigXYZData: // Input profile operates in XYZ
|
case cmsSigXYZData: // Input profile operates in XYZ
|
||||||
|
|
||||||
switch (OutPCS) {
|
switch (OutPCS) {
|
||||||
|
|
||||||
case cmsSigXYZData: // XYZ -> XYZ
|
case cmsSigXYZData: // XYZ -> XYZ
|
||||||
if (!IsEmptyLayer(m, off))
|
if (!IsEmptyLayer(m, off) &&
|
||||||
cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl));
|
!cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
|
||||||
break;
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
case cmsSigLabData: // XYZ -> Lab
|
case cmsSigLabData: // XYZ -> Lab
|
||||||
if (!IsEmptyLayer(m, off))
|
if (!IsEmptyLayer(m, off) &&
|
||||||
cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl));
|
!cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
|
||||||
cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocXYZ2Lab(Result ->ContextID));
|
return FALSE;
|
||||||
break;
|
if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocXYZ2Lab(Result ->ContextID)))
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
return FALSE; // Colorspace mismatch
|
return FALSE; // Colorspace mismatch
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case cmsSigLabData: // Input profile operates in Lab
|
||||||
|
|
||||||
case cmsSigLabData: // Input profile operates in Lab
|
switch (OutPCS) {
|
||||||
|
|
||||||
switch (OutPCS) {
|
case cmsSigXYZData: // Lab -> XYZ
|
||||||
|
|
||||||
case cmsSigXYZData: // Lab -> XYZ
|
if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocLab2XYZ(Result ->ContextID)))
|
||||||
|
return FALSE;
|
||||||
|
if (!IsEmptyLayer(m, off) &&
|
||||||
|
!cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)))
|
||||||
|
return FALSE;
|
||||||
|
break;
|
||||||
|
|
||||||
cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocLab2XYZ(Result ->ContextID));
|
case cmsSigLabData: // Lab -> Lab
|
||||||
if (!IsEmptyLayer(m, off))
|
|
||||||
cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl));
|
|
||||||
break;
|
|
||||||
|
|
||||||
case cmsSigLabData: // Lab -> Lab
|
if (!IsEmptyLayer(m, off)) {
|
||||||
|
if (!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocLab2XYZ(Result ->ContextID)) ||
|
||||||
if (!IsEmptyLayer(m, off)) {
|
!cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl)) ||
|
||||||
cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocLab2XYZ(Result ->ContextID));
|
!cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocXYZ2Lab(Result ->ContextID)))
|
||||||
cmsPipelineInsertStage(Result, cmsAT_END, cmsStageAllocMatrix(Result ->ContextID, 3, 3, m_as_dbl, off_as_dbl));
|
return FALSE;
|
||||||
cmsPipelineInsertStage(Result, cmsAT_END, _cmsStageAllocXYZ2Lab(Result ->ContextID));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
|
|
||||||
default:
|
|
||||||
return FALSE; // Mismatch
|
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
|
||||||
// On colorspaces other than PCS, check for same space
|
|
||||||
default:
|
default:
|
||||||
if (InPCS != OutPCS) return FALSE;
|
return FALSE; // Mismatch
|
||||||
break;
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
// On colorspaces other than PCS, check for same space
|
||||||
|
default:
|
||||||
|
if (InPCS != OutPCS) return FALSE;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return TRUE;
|
return TRUE;
|
||||||
@ -497,7 +501,8 @@ cmsPipeline* DefaultICCintents(cmsContext ContextID,
|
|||||||
cmsFloat64Number AdaptationStates[],
|
cmsFloat64Number AdaptationStates[],
|
||||||
cmsUInt32Number dwFlags)
|
cmsUInt32Number dwFlags)
|
||||||
{
|
{
|
||||||
cmsPipeline* Lut, *Result;
|
cmsPipeline* Lut = NULL;
|
||||||
|
cmsPipeline* Result;
|
||||||
cmsHPROFILE hProfile;
|
cmsHPROFILE hProfile;
|
||||||
cmsMAT3 m;
|
cmsMAT3 m;
|
||||||
cmsVEC3 off;
|
cmsVEC3 off;
|
||||||
@ -593,8 +598,11 @@ cmsPipeline* DefaultICCintents(cmsContext ContextID,
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Concatenate to the output LUT
|
// Concatenate to the output LUT
|
||||||
cmsPipelineCat(Result, Lut);
|
if (!cmsPipelineCat(Result, Lut))
|
||||||
|
goto Error;
|
||||||
|
|
||||||
cmsPipelineFree(Lut);
|
cmsPipelineFree(Lut);
|
||||||
|
Lut = NULL;
|
||||||
|
|
||||||
// Update current space
|
// Update current space
|
||||||
CurrentColorSpace = ColorSpaceOut;
|
CurrentColorSpace = ColorSpaceOut;
|
||||||
@ -604,6 +612,7 @@ cmsPipeline* DefaultICCintents(cmsContext ContextID,
|
|||||||
|
|
||||||
Error:
|
Error:
|
||||||
|
|
||||||
|
if (Lut != NULL) cmsPipelineFree(Lut);
|
||||||
if (Result != NULL) cmsPipelineFree(Result);
|
if (Result != NULL) cmsPipelineFree(Result);
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
@ -742,7 +751,8 @@ cmsPipeline* BlackPreservingKOnlyIntents(cmsContext ContextID,
|
|||||||
if (CLUT == NULL) goto Error;
|
if (CLUT == NULL) goto Error;
|
||||||
|
|
||||||
// This is the one and only MPE in this LUT
|
// This is the one and only MPE in this LUT
|
||||||
cmsPipelineInsertStage(Result, cmsAT_BEGIN, CLUT);
|
if (!cmsPipelineInsertStage(Result, cmsAT_BEGIN, CLUT))
|
||||||
|
goto Error;
|
||||||
|
|
||||||
// Sample it. We cannot afford pre/post linearization this time.
|
// Sample it. We cannot afford pre/post linearization this time.
|
||||||
if (!cmsStageSampleCLut16bit(CLUT, BlackPreservingGrayOnlySampler, (void*) &bp, 0))
|
if (!cmsStageSampleCLut16bit(CLUT, BlackPreservingGrayOnlySampler, (void*) &bp, 0))
|
||||||
@ -959,7 +969,8 @@ cmsPipeline* BlackPreservingKPlaneIntents(cmsContext ContextID,
|
|||||||
CLUT = cmsStageAllocCLut16bit(ContextID, nGridPoints, 4, 4, NULL);
|
CLUT = cmsStageAllocCLut16bit(ContextID, nGridPoints, 4, 4, NULL);
|
||||||
if (CLUT == NULL) goto Cleanup;
|
if (CLUT == NULL) goto Cleanup;
|
||||||
|
|
||||||
cmsPipelineInsertStage(Result, cmsAT_BEGIN, CLUT);
|
if (!cmsPipelineInsertStage(Result, cmsAT_BEGIN, CLUT))
|
||||||
|
goto Cleanup;
|
||||||
|
|
||||||
cmsStageSampleCLut16bit(CLUT, BlackPreservingSampler, (void*) &bp, 0);
|
cmsStageSampleCLut16bit(CLUT, BlackPreservingSampler, (void*) &bp, 0);
|
||||||
|
|
||||||
@ -1057,7 +1068,7 @@ cmsUInt32Number CMSEXPORT cmsGetSupportedIntents(cmsUInt32Number nMax, cmsUInt32
|
|||||||
}
|
}
|
||||||
|
|
||||||
// The plug-in registration. User can add new intents or override default routines
|
// The plug-in registration. User can add new intents or override default routines
|
||||||
cmsBool _cmsRegisterRenderingIntentPlugin(cmsPluginBase* Data)
|
cmsBool _cmsRegisterRenderingIntentPlugin(cmsContext id, cmsPluginBase* Data)
|
||||||
{
|
{
|
||||||
cmsPluginRenderingIntent* Plugin = (cmsPluginRenderingIntent*) Data;
|
cmsPluginRenderingIntent* Plugin = (cmsPluginRenderingIntent*) Data;
|
||||||
cmsIntentsList* fl;
|
cmsIntentsList* fl;
|
||||||
@ -1072,7 +1083,7 @@ cmsBool _cmsRegisterRenderingIntentPlugin(cmsPluginBase* Data)
|
|||||||
fl = SearchIntent(Plugin ->Intent);
|
fl = SearchIntent(Plugin ->Intent);
|
||||||
|
|
||||||
if (fl == NULL) {
|
if (fl == NULL) {
|
||||||
fl = (cmsIntentsList*) _cmsPluginMalloc(sizeof(cmsIntentsList));
|
fl = (cmsIntentsList*) _cmsPluginMalloc(id, sizeof(cmsIntentsList));
|
||||||
if (fl == NULL) return FALSE;
|
if (fl == NULL) return FALSE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -302,8 +302,6 @@ _cmsSubAllocator_chunk* _cmsCreateSubAllocChunk(cmsContext ContextID, cmsUInt32N
|
|||||||
return NULL;
|
return NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
chunk ->BlockSize = Initial;
|
chunk ->BlockSize = Initial;
|
||||||
chunk ->Used = 0;
|
chunk ->Used = 0;
|
||||||
chunk ->next = NULL;
|
chunk ->next = NULL;
|
||||||
|
@ -30,7 +30,7 @@
|
|||||||
//---------------------------------------------------------------------------------
|
//---------------------------------------------------------------------------------
|
||||||
//
|
//
|
||||||
// Little Color Management System
|
// Little Color Management System
|
||||||
// Copyright (c) 1998-2012 Marti Maria Saguer
|
// Copyright (c) 1998-2013 Marti Maria Saguer
|
||||||
//
|
//
|
||||||
// Permission is hereby granted, free of charge, to any person obtaining
|
// Permission is hereby granted, free of charge, to any person obtaining
|
||||||
// a copy of this software and associated documentation files (the "Software"),
|
// a copy of this software and associated documentation files (the "Software"),
|
||||||
@ -99,7 +99,7 @@ static _cmsParametricCurvesCollection DefaultCurves = {
|
|||||||
static _cmsParametricCurvesCollection* ParametricCurves = &DefaultCurves;
|
static _cmsParametricCurvesCollection* ParametricCurves = &DefaultCurves;
|
||||||
|
|
||||||
// As a way to install new parametric curves
|
// As a way to install new parametric curves
|
||||||
cmsBool _cmsRegisterParametricCurvesPlugin(cmsPluginBase* Data)
|
cmsBool _cmsRegisterParametricCurvesPlugin(cmsContext id, cmsPluginBase* Data)
|
||||||
{
|
{
|
||||||
cmsPluginParametricCurves* Plugin = (cmsPluginParametricCurves*) Data;
|
cmsPluginParametricCurves* Plugin = (cmsPluginParametricCurves*) Data;
|
||||||
_cmsParametricCurvesCollection* fl;
|
_cmsParametricCurvesCollection* fl;
|
||||||
@ -110,7 +110,7 @@ cmsBool _cmsRegisterParametricCurvesPlugin(cmsPluginBase* Data)
|
|||||||
return TRUE;
|
return TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
fl = (_cmsParametricCurvesCollection*) _cmsPluginMalloc(sizeof(_cmsParametricCurvesCollection));
|
fl = (_cmsParametricCurvesCollection*) _cmsPluginMalloc(id, sizeof(_cmsParametricCurvesCollection));
|
||||||
if (fl == NULL) return FALSE;
|
if (fl == NULL) return FALSE;
|
||||||
|
|
||||||
// Copy the parameters
|
// Copy the parameters
|
||||||
@ -258,7 +258,8 @@ cmsToneCurve* AllocateToneCurveStruct(cmsContext ContextID, cmsInt32Number nEntr
|
|||||||
}
|
}
|
||||||
|
|
||||||
p ->InterpParams = _cmsComputeInterpParams(ContextID, p ->nEntries, 1, 1, p->Table16, CMS_LERP_FLAGS_16BITS);
|
p ->InterpParams = _cmsComputeInterpParams(ContextID, p ->nEntries, 1, 1, p->Table16, CMS_LERP_FLAGS_16BITS);
|
||||||
return p;
|
if (p->InterpParams != NULL)
|
||||||
|
return p;
|
||||||
|
|
||||||
Error:
|
Error:
|
||||||
if (p -> Segments) _cmsFree(ContextID, p ->Segments);
|
if (p -> Segments) _cmsFree(ContextID, p ->Segments);
|
||||||
@ -423,7 +424,7 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu
|
|||||||
if (e > 0)
|
if (e > 0)
|
||||||
Val = pow(e, Params[0]) + Params[5];
|
Val = pow(e, Params[0]) + Params[5];
|
||||||
else
|
else
|
||||||
Val = 0;
|
Val = Params[5];
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
Val = R*Params[3] + Params[6];
|
Val = R*Params[3] + Params[6];
|
||||||
@ -458,7 +459,7 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu
|
|||||||
e = Params[1]*R + Params[2];
|
e = Params[1]*R + Params[2];
|
||||||
|
|
||||||
if (e < 0)
|
if (e < 0)
|
||||||
Val = 0;
|
Val = Params[3];
|
||||||
else
|
else
|
||||||
Val = pow(e, Params[0]) + Params[3];
|
Val = pow(e, Params[0]) + Params[3];
|
||||||
break;
|
break;
|
||||||
@ -478,7 +479,7 @@ cmsFloat64Number DefaultEvalParametricFn(cmsInt32Number Type, const cmsFloat64Nu
|
|||||||
|
|
||||||
e = Params[2] * pow(R, Params[0]) + Params[3];
|
e = Params[2] * pow(R, Params[0]) + Params[3];
|
||||||
if (e <= 0)
|
if (e <= 0)
|
||||||
Val = 0;
|
Val = Params[4];
|
||||||
else
|
else
|
||||||
Val = Params[1]*log10(e) + Params[4];
|
Val = Params[1]*log10(e) + Params[4];
|
||||||
break;
|
break;
|
||||||
@ -544,7 +545,7 @@ cmsFloat64Number EvalSegmentedFn(const cmsToneCurve *g, cmsFloat64Number R)
|
|||||||
// Type == 0 means segment is sampled
|
// Type == 0 means segment is sampled
|
||||||
if (g ->Segments[i].Type == 0) {
|
if (g ->Segments[i].Type == 0) {
|
||||||
|
|
||||||
cmsFloat32Number R1 = (cmsFloat32Number) (R - g ->Segments[i].x0);
|
cmsFloat32Number R1 = (cmsFloat32Number) (R - g ->Segments[i].x0) / (g ->Segments[i].x1 - g ->Segments[i].x0);
|
||||||
cmsFloat32Number Out;
|
cmsFloat32Number Out;
|
||||||
|
|
||||||
// Setup the table (TODO: clean that)
|
// Setup the table (TODO: clean that)
|
||||||
@ -629,20 +630,21 @@ cmsToneCurve* CMSEXPORT cmsBuildSegmentedToneCurve(cmsContext ContextID,
|
|||||||
// Use a segmented curve to store the floating point table
|
// Use a segmented curve to store the floating point table
|
||||||
cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cmsUInt32Number nEntries, const cmsFloat32Number values[])
|
cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cmsUInt32Number nEntries, const cmsFloat32Number values[])
|
||||||
{
|
{
|
||||||
cmsCurveSegment Seg[2];
|
cmsCurveSegment Seg[3];
|
||||||
|
|
||||||
// Initialize segmented curve part up to 0
|
// A segmented tone curve should have function segments in the first and last positions
|
||||||
Seg[0].x0 = -1;
|
// Initialize segmented curve part up to 0 to constant value = samples[0]
|
||||||
|
Seg[0].x0 = MINUS_INF;
|
||||||
Seg[0].x1 = 0;
|
Seg[0].x1 = 0;
|
||||||
Seg[0].Type = 6;
|
Seg[0].Type = 6;
|
||||||
|
|
||||||
Seg[0].Params[0] = 1;
|
Seg[0].Params[0] = 1;
|
||||||
Seg[0].Params[1] = 0;
|
Seg[0].Params[1] = 0;
|
||||||
Seg[0].Params[2] = 0;
|
Seg[0].Params[2] = 0;
|
||||||
Seg[0].Params[3] = 0;
|
Seg[0].Params[3] = values[0];
|
||||||
Seg[0].Params[4] = 0;
|
Seg[0].Params[4] = 0;
|
||||||
|
|
||||||
// From zero to any
|
// From zero to 1
|
||||||
Seg[1].x0 = 0;
|
Seg[1].x0 = 0;
|
||||||
Seg[1].x1 = 1.0;
|
Seg[1].x1 = 1.0;
|
||||||
Seg[1].Type = 0;
|
Seg[1].Type = 0;
|
||||||
@ -650,7 +652,19 @@ cmsToneCurve* CMSEXPORT cmsBuildTabulatedToneCurveFloat(cmsContext ContextID, cm
|
|||||||
Seg[1].nGridPoints = nEntries;
|
Seg[1].nGridPoints = nEntries;
|
||||||
Seg[1].SampledPoints = (cmsFloat32Number*) values;
|
Seg[1].SampledPoints = (cmsFloat32Number*) values;
|
||||||
|
|
||||||
return cmsBuildSegmentedToneCurve(ContextID, 2, Seg);
|
// Final segment is constant = lastsample
|
||||||
|
Seg[2].x0 = 1.0;
|
||||||
|
Seg[2].x1 = PLUS_INF;
|
||||||
|
Seg[2].Type = 6;
|
||||||
|
|
||||||
|
Seg[2].Params[0] = 1;
|
||||||
|
Seg[2].Params[1] = 0;
|
||||||
|
Seg[2].Params[2] = 0;
|
||||||
|
Seg[2].Params[3] = values[nEntries-1];
|
||||||
|
Seg[2].Params[4] = 0;
|
||||||
|
|
||||||
|
|
||||||
|
return cmsBuildSegmentedToneCurve(ContextID, 3, Seg);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Parametric curves
|
// Parametric curves
|
||||||
@ -993,7 +1007,7 @@ cmsBool CMSEXPORT cmsSmoothToneCurve(cmsToneCurve* Tab, cmsFloat64Number lambda
|
|||||||
|
|
||||||
if (Tab == NULL) return FALSE;
|
if (Tab == NULL) return FALSE;
|
||||||
|
|
||||||
if (cmsIsToneCurveLinear(Tab)) return FALSE; // Nothing to do
|
if (cmsIsToneCurveLinear(Tab)) return TRUE; // Nothing to do
|
||||||
|
|
||||||
nItems = Tab -> nEntries;
|
nItems = Tab -> nEntries;
|
||||||
|
|
||||||
@ -1020,11 +1034,20 @@ cmsBool CMSEXPORT cmsSmoothToneCurve(cmsToneCurve* Tab, cmsFloat64Number lambda
|
|||||||
|
|
||||||
if (z[i] == 0.) Zeros++;
|
if (z[i] == 0.) Zeros++;
|
||||||
if (z[i] >= 65535.) Poles++;
|
if (z[i] >= 65535.) Poles++;
|
||||||
if (z[i] < z[i-1]) return FALSE; // Non-Monotonic
|
if (z[i] < z[i-1]) {
|
||||||
|
cmsSignalError(Tab ->InterpParams->ContextID, cmsERROR_RANGE, "cmsSmoothToneCurve: Non-Monotonic.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (Zeros > (nItems / 3)) return FALSE; // Degenerated, mostly zeros
|
if (Zeros > (nItems / 3)) {
|
||||||
if (Poles > (nItems / 3)) return FALSE; // Degenerated, mostly poles
|
cmsSignalError(Tab ->InterpParams->ContextID, cmsERROR_RANGE, "cmsSmoothToneCurve: Degenerated, mostly zeros.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
if (Poles > (nItems / 3)) {
|
||||||
|
cmsSignalError(Tab ->InterpParams->ContextID, cmsERROR_RANGE, "cmsSmoothToneCurve: Degenerated, mostly poles.");
|
||||||
|
return FALSE;
|
||||||
|
}
|
||||||
|
|
||||||
// Seems ok
|
// Seems ok
|
||||||
for (i=0; i < nItems; i++) {
|
for (i=0; i < nItems; i++) {
|
||||||
|
@ -249,13 +249,10 @@ int GamutSampler(register const cmsUInt16Number In[], register cmsUInt16Number O
|
|||||||
cmsFloat64Number dE1, dE2, ErrorRatio;
|
cmsFloat64Number dE1, dE2, ErrorRatio;
|
||||||
|
|
||||||
// Assume in-gamut by default.
|
// Assume in-gamut by default.
|
||||||
dE1 = 0.;
|
|
||||||
dE2 = 0;
|
|
||||||
ErrorRatio = 1.0;
|
ErrorRatio = 1.0;
|
||||||
|
|
||||||
// Convert input to Lab
|
// Convert input to Lab
|
||||||
if (t -> hInput != NULL)
|
cmsDoTransform(t -> hInput, In, &LabIn1, 1);
|
||||||
cmsDoTransform(t -> hInput, In, &LabIn1, 1);
|
|
||||||
|
|
||||||
// converts from PCS to colorant. This always
|
// converts from PCS to colorant. This always
|
||||||
// does return in-gamut values,
|
// does return in-gamut values,
|
||||||
@ -267,7 +264,7 @@ int GamutSampler(register const cmsUInt16Number In[], register cmsUInt16Number O
|
|||||||
memmove(&LabIn2, &LabOut1, sizeof(cmsCIELab));
|
memmove(&LabIn2, &LabOut1, sizeof(cmsCIELab));
|
||||||
|
|
||||||
// Try again, but this time taking Check as input
|
// Try again, but this time taking Check as input
|
||||||
cmsDoTransform(t -> hForward, &LabOut1, Proof2, 1);
|
cmsDoTransform(t -> hForward, &LabOut1, Proof2, 1);
|
||||||
cmsDoTransform(t -> hReverse, Proof2, &LabOut2, 1);
|
cmsDoTransform(t -> hReverse, Proof2, &LabOut2, 1);
|
||||||
|
|
||||||
// Take difference of direct value
|
// Take difference of direct value
|
||||||
@ -374,7 +371,7 @@ cmsPipeline* _cmsCreateGamutCheckPipeline(cmsContext ContextID,
|
|||||||
ProfileList[nGamutPCSposition] = hLab;
|
ProfileList[nGamutPCSposition] = hLab;
|
||||||
BPCList[nGamutPCSposition] = 0;
|
BPCList[nGamutPCSposition] = 0;
|
||||||
AdaptationList[nGamutPCSposition] = 1.0;
|
AdaptationList[nGamutPCSposition] = 1.0;
|
||||||
Intents[nGamutPCSposition] = INTENT_RELATIVE_COLORIMETRIC;
|
IntentList[nGamutPCSposition] = INTENT_RELATIVE_COLORIMETRIC;
|
||||||
|
|
||||||
|
|
||||||
ColorSpace = cmsGetColorSpace(hGamut);
|
ColorSpace = cmsGetColorSpace(hGamut);
|
||||||
@ -385,45 +382,48 @@ cmsPipeline* _cmsCreateGamutCheckPipeline(cmsContext ContextID,
|
|||||||
|
|
||||||
// 16 bits to Lab double
|
// 16 bits to Lab double
|
||||||
Chain.hInput = cmsCreateExtendedTransform(ContextID,
|
Chain.hInput = cmsCreateExtendedTransform(ContextID,
|
||||||
nGamutPCSposition + 1,
|
nGamutPCSposition + 1,
|
||||||
ProfileList,
|
ProfileList,
|
||||||
BPCList,
|
BPCList,
|
||||||
Intents,
|
IntentList,
|
||||||
AdaptationList,
|
AdaptationList,
|
||||||
NULL, 0,
|
NULL, 0,
|
||||||
dwFormat, TYPE_Lab_DBL,
|
dwFormat, TYPE_Lab_DBL,
|
||||||
cmsFLAGS_NOCACHE);
|
cmsFLAGS_NOCACHE);
|
||||||
|
|
||||||
|
|
||||||
// Does create the forward step. Lab double to device
|
// Does create the forward step. Lab double to device
|
||||||
dwFormat = (CHANNELS_SH(nChannels)|BYTES_SH(2));
|
dwFormat = (CHANNELS_SH(nChannels)|BYTES_SH(2));
|
||||||
Chain.hForward = cmsCreateTransformTHR(ContextID,
|
Chain.hForward = cmsCreateTransformTHR(ContextID,
|
||||||
hLab, TYPE_Lab_DBL,
|
hLab, TYPE_Lab_DBL,
|
||||||
hGamut, dwFormat,
|
hGamut, dwFormat,
|
||||||
INTENT_RELATIVE_COLORIMETRIC,
|
INTENT_RELATIVE_COLORIMETRIC,
|
||||||
cmsFLAGS_NOCACHE);
|
cmsFLAGS_NOCACHE);
|
||||||
|
|
||||||
// Does create the backwards step
|
// Does create the backwards step
|
||||||
Chain.hReverse = cmsCreateTransformTHR(ContextID, hGamut, dwFormat,
|
Chain.hReverse = cmsCreateTransformTHR(ContextID, hGamut, dwFormat,
|
||||||
hLab, TYPE_Lab_DBL,
|
hLab, TYPE_Lab_DBL,
|
||||||
INTENT_RELATIVE_COLORIMETRIC,
|
INTENT_RELATIVE_COLORIMETRIC,
|
||||||
cmsFLAGS_NOCACHE);
|
cmsFLAGS_NOCACHE);
|
||||||
|
|
||||||
|
|
||||||
// All ok?
|
// All ok?
|
||||||
if (Chain.hForward && Chain.hReverse) {
|
if (Chain.hInput && Chain.hForward && Chain.hReverse) {
|
||||||
|
|
||||||
// Go on, try to compute gamut LUT from PCS. This consist on a single channel containing
|
// Go on, try to compute gamut LUT from PCS. This consist on a single channel containing
|
||||||
// dE when doing a transform back and forth on the colorimetric intent.
|
// dE when doing a transform back and forth on the colorimetric intent.
|
||||||
|
|
||||||
Gamut = cmsPipelineAlloc(ContextID, 3, 1);
|
Gamut = cmsPipelineAlloc(ContextID, 3, 1);
|
||||||
|
|
||||||
if (Gamut != NULL) {
|
if (Gamut != NULL) {
|
||||||
|
|
||||||
CLUT = cmsStageAllocCLut16bit(ContextID, nGridpoints, nChannels, 1, NULL);
|
CLUT = cmsStageAllocCLut16bit(ContextID, nGridpoints, nChannels, 1, NULL);
|
||||||
cmsPipelineInsertStage(Gamut, cmsAT_BEGIN, CLUT);
|
if (!cmsPipelineInsertStage(Gamut, cmsAT_BEGIN, CLUT)) {
|
||||||
|
cmsPipelineFree(Gamut);
|
||||||
cmsStageSampleCLut16bit(CLUT, GamutSampler, (void*) &Chain, 0);
|
Gamut = NULL;
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
cmsStageSampleCLut16bit(CLUT, GamutSampler, (void*) &Chain, 0);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
|
@ -83,7 +83,6 @@ cmsBool _cmsRegisterInterpPlugin(cmsPluginBase* Data)
|
|||||||
|
|
||||||
|
|
||||||
// Set the interpolation method
|
// Set the interpolation method
|
||||||
|
|
||||||
cmsBool _cmsSetInterpolationRoutine(cmsInterpParams* p)
|
cmsBool _cmsSetInterpolationRoutine(cmsInterpParams* p)
|
||||||
{
|
{
|
||||||
// Invoke factory, possibly in the Plug-in
|
// Invoke factory, possibly in the Plug-in
|
||||||
@ -831,7 +830,7 @@ void Eval4Inputs(register const cmsUInt16Number Input[],
|
|||||||
register cmsUInt16Number Output[],
|
register cmsUInt16Number Output[],
|
||||||
register const cmsInterpParams* p16)
|
register const cmsInterpParams* p16)
|
||||||
{
|
{
|
||||||
const cmsUInt16Number* LutTable = (cmsUInt16Number*) p16 -> Table;
|
const cmsUInt16Number* LutTable;
|
||||||
cmsS15Fixed16Number fk;
|
cmsS15Fixed16Number fk;
|
||||||
cmsS15Fixed16Number k0, rk;
|
cmsS15Fixed16Number k0, rk;
|
||||||
int K0, K1;
|
int K0, K1;
|
||||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
x
Reference in New Issue
Block a user