提交 96a915ac 编写于 作者: L lana

Merge

...@@ -134,3 +134,5 @@ f1ec21b8142168ff40f3278d2f6b5fe4bd5f3b26 jdk8-b09 ...@@ -134,3 +134,5 @@ f1ec21b8142168ff40f3278d2f6b5fe4bd5f3b26 jdk8-b09
4788745572ef2bde34924ef34e7e4d55ba07e979 jdk8-b10 4788745572ef2bde34924ef34e7e4d55ba07e979 jdk8-b10
7ab0d613cd1a271a9763ffb894dc1f0a5b95a7e4 jdk8-b11 7ab0d613cd1a271a9763ffb894dc1f0a5b95a7e4 jdk8-b11
09fd2067f715e4505c44b01c301258a4e8f8964e jdk8-b12 09fd2067f715e4505c44b01c301258a4e8f8964e jdk8-b12
4cb2e8679b27432854690cb688ea06d3b2d8e008 jdk8-b13
99632935785e2038b2fc836da9f2ede69dea294b jdk8-b14
...@@ -158,6 +158,8 @@ ifneq ($(strip $(DEMO_ALL_NATIVE_SOURCES)),) ...@@ -158,6 +158,8 @@ ifneq ($(strip $(DEMO_ALL_NATIVE_SOURCES)),)
# bit between them. # bit between them.
LINK.demo = $(LINK.c) LINK.demo = $(LINK.c)
LDLIBS.demo = $(EXTRA_LIBS) $(LFLAGS_$(COMPILER_VERSION)) LDLIBS.demo = $(EXTRA_LIBS) $(LFLAGS_$(COMPILER_VERSION))
DEMO_VERSION_INFO = $(OBJDIR)/$(LIBRARY).res
LDLIBS.demo += $(DEMO_VERSION_INFO)
else else
ifneq ($(DEMO_NEEDS_CPP),) ifneq ($(DEMO_NEEDS_CPP),)
LINK.demo = $(LINK.cpp) LINK.demo = $(LINK.cpp)
...@@ -288,6 +290,13 @@ ifndef DEMO_SKIP_SRCZIP ...@@ -288,6 +290,13 @@ ifndef DEMO_SKIP_SRCZIP
$(install-file) $(install-file)
endif endif
ifeq ($(PLATFORM),windows)
# JDK name required here
RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \
/D "JDK_INTERNAL_NAME=$(LIBRARY)" \
/D "JDK_FTYPE=0x2L"
endif
# Native library building # Native library building
ifdef DEMO_LIBRARY ifdef DEMO_LIBRARY
...@@ -308,6 +317,9 @@ $(OBJDIR)/%.$(OBJECT_SUFFIX): $(DEMO_BUILD_SRCDIR)/%.cpp ...@@ -308,6 +317,9 @@ $(OBJDIR)/%.$(OBJECT_SUFFIX): $(DEMO_BUILD_SRCDIR)/%.cpp
# Actual creation of the native shared library (C++ and C are different) # Actual creation of the native shared library (C++ and C are different)
$(DEMO_LIBRARY): $(DEMO_FULL_OBJECTS) $(DEMO_LIBRARY): $(DEMO_FULL_OBJECTS)
@$(prep-target) @$(prep-target)
ifeq ($(PLATFORM),windows)
$(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(DEMO_VERSION_INFO) $(VERSIONINFO_RESOURCE)
endif
$(LINK.demo) $(SHARED_LIBRARY_FLAG) $(CC_PROGRAM_OUTPUT_FLAG)$@ \ $(LINK.demo) $(SHARED_LIBRARY_FLAG) $(CC_PROGRAM_OUTPUT_FLAG)$@ \
$(DEMO_FULL_OBJECTS) $(LDLIBS.demo) $(DEMO_FULL_OBJECTS) $(LDLIBS.demo)
@$(call binary_file_verification,$@) @$(call binary_file_verification,$@)
......
/* /*
* Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2011, 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,6 +179,12 @@ class HttpsURLConnection extends HttpURLConnection ...@@ -179,6 +179,12 @@ class HttpsURLConnection extends HttpURLConnection
throw new IllegalArgumentException( throw new IllegalArgumentException(
"no SSLSocketFactory specified"); "no SSLSocketFactory specified");
} }
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkSetFactory();
}
sslSocketFactory = sf; sslSocketFactory = sf;
} }
......
/* /*
* Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2000, 2011, 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
...@@ -25,6 +25,7 @@ ...@@ -25,6 +25,7 @@
package java.awt; package java.awt;
import java.awt.event.KeyEvent; import java.awt.event.KeyEvent;
import sun.awt.AppContext;
import java.awt.event.InputEvent; import java.awt.event.InputEvent;
import java.util.Collections; import java.util.Collections;
import java.util.HashMap; import java.util.HashMap;
...@@ -66,9 +67,6 @@ import java.lang.reflect.Field; ...@@ -66,9 +67,6 @@ import java.lang.reflect.Field;
public class AWTKeyStroke implements Serializable { public class AWTKeyStroke implements Serializable {
static final long serialVersionUID = -6430539691155161871L; static final long serialVersionUID = -6430539691155161871L;
private static Map cache;
private static AWTKeyStroke cacheKey;
private static Constructor ctor = getCtor(AWTKeyStroke.class);
private static Map modifierKeywords; private static Map modifierKeywords;
/** /**
* Associates VK_XXX (as a String) with code (as Integer). This is * Associates VK_XXX (as a String) with code (as Integer). This is
...@@ -77,6 +75,25 @@ public class AWTKeyStroke implements Serializable { ...@@ -77,6 +75,25 @@ public class AWTKeyStroke implements Serializable {
*/ */
private static VKCollection vks; private static VKCollection vks;
//A key for the collection of AWTKeyStrokes within AppContext.
private static Object APP_CONTEXT_CACHE_KEY = new Object();
//A key withing the cache
private static AWTKeyStroke APP_CONTEXT_KEYSTROKE_KEY = new AWTKeyStroke();
/*
* Reads keystroke class from AppContext and if null, puts there the
* AWTKeyStroke class.
* Must be called under locked AWTKeyStro
*/
private static Class getAWTKeyStrokeClass() {
Class clazz = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
if (clazz == null) {
clazz = AWTKeyStroke.class;
AppContext.getAppContext().put(AWTKeyStroke.class, AWTKeyStroke.class);
}
return clazz;
}
private char keyChar = KeyEvent.CHAR_UNDEFINED; private char keyChar = KeyEvent.CHAR_UNDEFINED;
private int keyCode = KeyEvent.VK_UNDEFINED; private int keyCode = KeyEvent.VK_UNDEFINED;
private int modifiers; private int modifiers;
...@@ -164,9 +181,12 @@ public class AWTKeyStroke implements Serializable { ...@@ -164,9 +181,12 @@ public class AWTKeyStroke implements Serializable {
if (subclass == null) { if (subclass == null) {
throw new IllegalArgumentException("subclass cannot be null"); throw new IllegalArgumentException("subclass cannot be null");
} }
if (AWTKeyStroke.ctor.getDeclaringClass().equals(subclass)) { synchronized (AWTKeyStroke.class) {
// Already registered Class keyStrokeClass = (Class)AppContext.getAppContext().get(AWTKeyStroke.class);
return; if (keyStrokeClass != null && keyStrokeClass.equals(subclass)){
// Already registered
return;
}
} }
if (!AWTKeyStroke.class.isAssignableFrom(subclass)) { if (!AWTKeyStroke.class.isAssignableFrom(subclass)) {
throw new ClassCastException("subclass is not derived from AWTKeyStroke"); throw new ClassCastException("subclass is not derived from AWTKeyStroke");
...@@ -197,9 +217,9 @@ public class AWTKeyStroke implements Serializable { ...@@ -197,9 +217,9 @@ public class AWTKeyStroke implements Serializable {
} }
synchronized (AWTKeyStroke.class) { synchronized (AWTKeyStroke.class) {
AWTKeyStroke.ctor = ctor; AppContext.getAppContext().put(AWTKeyStroke.class, subclass);
cache = null; AppContext.getAppContext().remove(APP_CONTEXT_CACHE_KEY);
cacheKey = null; AppContext.getAppContext().remove(APP_CONTEXT_KEYSTROKE_KEY);
} }
} }
...@@ -229,13 +249,19 @@ public class AWTKeyStroke implements Serializable { ...@@ -229,13 +249,19 @@ public class AWTKeyStroke implements Serializable {
private static synchronized AWTKeyStroke getCachedStroke private static synchronized AWTKeyStroke getCachedStroke
(char keyChar, int keyCode, int modifiers, boolean onKeyRelease) (char keyChar, int keyCode, int modifiers, boolean onKeyRelease)
{ {
Map cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY);
AWTKeyStroke cacheKey = (AWTKeyStroke)AppContext.getAppContext().get(APP_CONTEXT_KEYSTROKE_KEY);
if (cache == null) { if (cache == null) {
cache = new HashMap(); cache = new HashMap();
AppContext.getAppContext().put(APP_CONTEXT_CACHE_KEY, cache);
} }
if (cacheKey == null) { if (cacheKey == null) {
try { try {
cacheKey = (AWTKeyStroke)ctor.newInstance((Object[]) null); Class clazz = getAWTKeyStrokeClass();
cacheKey = (AWTKeyStroke)getCtor(clazz).newInstance((Object[]) null);
AppContext.getAppContext().put(APP_CONTEXT_KEYSTROKE_KEY, cacheKey);
} catch (InstantiationException e) { } catch (InstantiationException e) {
assert(false); assert(false);
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
...@@ -253,9 +279,8 @@ public class AWTKeyStroke implements Serializable { ...@@ -253,9 +279,8 @@ public class AWTKeyStroke implements Serializable {
if (stroke == null) { if (stroke == null) {
stroke = cacheKey; stroke = cacheKey;
cache.put(stroke, stroke); cache.put(stroke, stroke);
cacheKey = null; AppContext.getAppContext().remove(APP_CONTEXT_KEYSTROKE_KEY);
} }
return stroke; return stroke;
} }
......
...@@ -44,10 +44,9 @@ package java.io; ...@@ -44,10 +44,9 @@ package java.io;
*/ */
public abstract class InputStream implements Closeable { public abstract class InputStream implements Closeable {
// SKIP_BUFFER_SIZE is used to determine the size of skipBuffer // MAX_SKIP_BUFFER_SIZE is used to determine the maximum buffer size to
private static final int SKIP_BUFFER_SIZE = 2048; // use when skipping.
// skipBuffer is initialized in skip(long), if needed. private static final int MAX_SKIP_BUFFER_SIZE = 2048;
private static byte[] skipBuffer;
/** /**
* Reads the next byte of data from the input stream. The value byte is * Reads the next byte of data from the input stream. The value byte is
...@@ -212,18 +211,15 @@ public abstract class InputStream implements Closeable { ...@@ -212,18 +211,15 @@ public abstract class InputStream implements Closeable {
long remaining = n; long remaining = n;
int nr; int nr;
if (skipBuffer == null)
skipBuffer = new byte[SKIP_BUFFER_SIZE];
byte[] localSkipBuffer = skipBuffer;
if (n <= 0) { if (n <= 0) {
return 0; return 0;
} }
int size = (int)Math.min(MAX_SKIP_BUFFER_SIZE, remaining);
byte[] skipBuffer = new byte[size];
while (remaining > 0) { while (remaining > 0) {
nr = read(localSkipBuffer, 0, nr = read(skipBuffer, 0, (int)Math.min(size, remaining));
(int) Math.min(SKIP_BUFFER_SIZE, remaining));
if (nr < 0) { if (nr < 0) {
break; break;
} }
......
...@@ -71,7 +71,7 @@ all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036 ...@@ -71,7 +71,7 @@ all=ADP020-AED784-AFA004-AFN971-ALL008-AMD051-ANG532-AOA973-ARS032-ATS040-AUD036
# #
# The table is based on the following web sites: # The table is based on the following web sites:
# http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/db_en.html # http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/db_en.html
# http://www.bsi-global.com/iso4217currency # http://www.currency-iso.org/iso_index/iso_tables.htm
# http://www.cia.gov/cia/publications/factbook/indexgeo.html # http://www.cia.gov/cia/publications/factbook/indexgeo.html
# AFGHANISTAN # AFGHANISTAN
...@@ -105,7 +105,7 @@ AU=AUD ...@@ -105,7 +105,7 @@ AU=AUD
# AUSTRIA # AUSTRIA
AT=EUR AT=EUR
# AZERBAIJAN # AZERBAIJAN
AZ=AZM;2005-12-31-20-00-00;AZN AZ=AZN
# BAHAMAS # BAHAMAS
BS=BSD BS=BSD
# BAHRAIN # BAHRAIN
...@@ -378,7 +378,7 @@ MS=XCD ...@@ -378,7 +378,7 @@ MS=XCD
# MOROCCO # MOROCCO
MA=MAD MA=MAD
# MOZAMBIQUE # MOZAMBIQUE
MZ=MZM;2006-06-30-22-00-00;MZN MZ=MZN
# MYANMAR # MYANMAR
MM=MMK MM=MMK
# NAMIBIA # NAMIBIA
...@@ -440,7 +440,7 @@ QA=QAR ...@@ -440,7 +440,7 @@ QA=QAR
# REUNION # REUNION
RE=EUR RE=EUR
# ROMANIA # ROMANIA
RO=ROL;2005-06-30-21-00-00;RON RO=RON
# RUSSIAN FEDERATION # RUSSIAN FEDERATION
RU=RUB RU=RUB
# RWANDA # RWANDA
...@@ -532,7 +532,7 @@ TT=TTD ...@@ -532,7 +532,7 @@ TT=TTD
# TUNISIA # TUNISIA
TN=TND TN=TND
# TURKEY # TURKEY
TR=TRL;2004-12-31-22-00-00;TRY TR=TRY
# TURKMENISTAN # TURKMENISTAN
TM=TMT TM=TMT
# TURKS AND CAICOS ISLANDS # TURKS AND CAICOS ISLANDS
...@@ -558,7 +558,7 @@ UZ=UZS ...@@ -558,7 +558,7 @@ UZ=UZS
# VANUATU # VANUATU
VU=VUV VU=VUV
# VENEZUELA # VENEZUELA
VE=VEB;2008-01-01-04-00-00;VEF VE=VEF
# VIET NAM # VIET NAM
VN=VND VN=VND
# VIRGIN ISLANDS, BRITISH # VIRGIN ISLANDS, BRITISH
......
/* /*
* Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1999, 2011, 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
...@@ -347,6 +347,9 @@ class HttpsURLConnection extends HttpURLConnection ...@@ -347,6 +347,9 @@ class HttpsURLConnection extends HttpURLConnection
* @param sf the SSL socket factory * @param sf the SSL socket factory
* @throws IllegalArgumentException if the <code>SSLSocketFactory</code> * @throws IllegalArgumentException if the <code>SSLSocketFactory</code>
* parameter is null. * parameter is null.
* @throws SecurityException if a security manager exists and its
* <code>checkSetFactory</code> method does not allow
* a socket factory to be specified.
* @see #getSSLSocketFactory() * @see #getSSLSocketFactory()
*/ */
public void setSSLSocketFactory(SSLSocketFactory sf) { public void setSSLSocketFactory(SSLSocketFactory sf) {
...@@ -355,6 +358,10 @@ class HttpsURLConnection extends HttpURLConnection ...@@ -355,6 +358,10 @@ class HttpsURLConnection extends HttpURLConnection
"no SSLSocketFactory specified"); "no SSLSocketFactory specified");
} }
SecurityManager sm = System.getSecurityManager();
if (sm != null) {
sm.checkSetFactory();
}
sslSocketFactory = sf; sslSocketFactory = sf;
} }
......
/* /*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, 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
...@@ -538,7 +538,7 @@ public abstract class SSLEngine { ...@@ -538,7 +538,7 @@ public abstract class SSLEngine {
* If this <code>SSLEngine</code> has not yet started its initial * If this <code>SSLEngine</code> has not yet started its initial
* handshake, this method will automatically start the handshake. * handshake, this method will automatically start the handshake.
* <P> * <P>
* This method will attempt to produce one SSL/TLS packet, and will * This method will attempt to produce SSL/TLS records, and will
* consume as much source data as possible, but will never consume * consume as much source data as possible, but will never consume
* more than the sum of the bytes remaining in each buffer. Each * more than the sum of the bytes remaining in each buffer. Each
* <code>ByteBuffer</code>'s position is updated to reflect the * <code>ByteBuffer</code>'s position is updated to reflect the
......
...@@ -1828,6 +1828,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable ...@@ -1828,6 +1828,8 @@ public class JTable extends JComponent implements TableModelListener, Scrollable
* table. While the {@code autoCreateRowSorter} property remains * table. While the {@code autoCreateRowSorter} property remains
* {@code true}, every time the model is changed, a new {@code * {@code true}, every time the model is changed, a new {@code
* TableRowSorter} is created and set as the table's row sorter. * TableRowSorter} is created and set as the table's row sorter.
* The default value for the {@code autoCreateRowSorter}
* property is {@code false}.
* *
* @param autoCreateRowSorter whether or not a {@code RowSorter} * @param autoCreateRowSorter whether or not a {@code RowSorter}
* should be automatically created * should be automatically created
......
...@@ -1838,7 +1838,9 @@ public class JTree extends JComponent implements Scrollable, Accessible ...@@ -1838,7 +1838,9 @@ public class JTree extends JComponent implements Scrollable, Accessible
* nodes, or <code>null</code> if nothing is currently selected * nodes, or <code>null</code> if nothing is currently selected
*/ */
public TreePath[] getSelectionPaths() { public TreePath[] getSelectionPaths() {
return getSelectionModel().getSelectionPaths(); TreePath[] selectionPaths = getSelectionModel().getSelectionPaths();
return (selectionPaths != null && selectionPaths.length > 0) ? selectionPaths : null;
} }
/** /**
......
...@@ -1326,7 +1326,7 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou ...@@ -1326,7 +1326,7 @@ public class DefaultCaret extends Rectangle implements Caret, FocusListener, Mou
if ( ! SwingUtilities2.canCurrentEventAccessSystemClipboard() ) { if ( ! SwingUtilities2.canCurrentEventAccessSystemClipboard() ) {
return; return;
} }
if (this.dot != this.mark && component != null) { if (this.dot != this.mark && component != null && component.hasFocus()) {
Clipboard clip = getSystemSelection(); Clipboard clip = getSystemSelection();
if (clip != null) { if (clip != null) {
String selectedText; String selectedText;
......
...@@ -1181,7 +1181,12 @@ public class HTMLDocument extends DefaultStyledDocument { ...@@ -1181,7 +1181,12 @@ public class HTMLDocument extends DefaultStyledDocument {
public void insertAfterStart(Element elem, String htmlText) throws public void insertAfterStart(Element elem, String htmlText) throws
BadLocationException, IOException { BadLocationException, IOException {
verifyParser(); verifyParser();
if (elem != null && elem.isLeaf()) {
if (elem == null || htmlText == null) {
return;
}
if (elem.isLeaf()) {
throw new IllegalArgumentException throw new IllegalArgumentException
("Can not insert HTML after start of a leaf"); ("Can not insert HTML after start of a leaf");
} }
......
/* /*
* Copyright (c) 1995, 2003, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1995, 2011, 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
...@@ -185,7 +185,7 @@ public class OffScreenImageSource implements ImageProducer { ...@@ -185,7 +185,7 @@ public class OffScreenImageSource implements ImageProducer {
theConsumer.setDimensions(image.getWidth(), image.getHeight()); theConsumer.setDimensions(image.getWidth(), image.getHeight());
theConsumer.setProperties(properties); theConsumer.setProperties(properties);
sendPixels(); sendPixels();
theConsumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE); theConsumer.imageComplete(ImageConsumer.STATICIMAGEDONE);
} catch (NullPointerException e) { } catch (NullPointerException e) {
if (theConsumer != null) { if (theConsumer != null) {
theConsumer.imageComplete(ImageConsumer.IMAGEERROR); theConsumer.imageComplete(ImageConsumer.IMAGEERROR);
......
...@@ -41,13 +41,14 @@ public class ResourceManager { ...@@ -41,13 +41,14 @@ public class ResourceManager {
/* default maximum number of udp sockets per VM /* default maximum number of udp sockets per VM
* when a security manager is enabled. * when a security manager is enabled.
* The default is 1024 which is high enough to be useful * The default is 25 which is high enough to be useful
* but low enough to be well below the maximum number * but low enough to be well below the maximum number
* of port numbers actually available on all OSes for * of port numbers actually available on all OSes
* such sockets (5000 on some versions of windows) * when multiplied by the maximum feasible number of VM processes
* that could practically be spawned.
*/ */
private static final int DEFAULT_MAX_SOCKETS = 1024; private static final int DEFAULT_MAX_SOCKETS = 25;
private static final int maxSockets; private static final int maxSockets;
private static final AtomicInteger numSockets; private static final AtomicInteger numSockets;
......
...@@ -68,14 +68,18 @@ import javax.print.attribute.standard.Sides; ...@@ -68,14 +68,18 @@ import javax.print.attribute.standard.Sides;
import java.io.BufferedInputStream; import java.io.BufferedInputStream;
import java.io.BufferedOutputStream; import java.io.BufferedOutputStream;
import java.io.BufferedReader;
import java.io.CharConversionException; import java.io.CharConversionException;
import java.io.File; import java.io.File;
import java.io.InputStream; import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.IOException; import java.io.IOException;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import java.io.PrintWriter;
import java.io.StringWriter;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Enumeration; import java.util.Enumeration;
...@@ -673,15 +677,38 @@ public class PSPrinterJob extends RasterPrinterJob { ...@@ -673,15 +677,38 @@ public class PSPrinterJob extends RasterPrinterJob {
private class PrinterSpooler implements java.security.PrivilegedAction { private class PrinterSpooler implements java.security.PrivilegedAction {
PrinterException pex; PrinterException pex;
private void handleProcessFailure(final Process failedProcess,
final String[] execCmd, final int result) throws IOException {
try (StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw)) {
pw.append("error=").append(Integer.toString(result));
pw.append(" running:");
for (String arg: execCmd) {
pw.append(" '").append(arg).append("'");
}
try (InputStream is = failedProcess.getErrorStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr)) {
while (br.ready()) {
pw.println();
pw.append("\t\t").append(br.readLine());
}
} finally {
pw.flush();
throw new IOException(sw.toString());
}
}
}
public Object run() { public Object run() {
if (spoolFile == null || !spoolFile.exists()) {
pex = new PrinterException("No spool file");
return null;
}
try { try {
/** /**
* Spool to the printer. * Spool to the printer.
*/ */
if (spoolFile == null || !spoolFile.exists()) {
pex = new PrinterException("No spool file");
return null;
}
String fileName = spoolFile.getAbsolutePath(); String fileName = spoolFile.getAbsolutePath();
String execCmd[] = printExecCmd(mDestination, mOptions, String execCmd[] = printExecCmd(mDestination, mOptions,
mNoJobSheet, getJobNameInt(), mNoJobSheet, getJobNameInt(),
...@@ -689,12 +716,16 @@ public class PSPrinterJob extends RasterPrinterJob { ...@@ -689,12 +716,16 @@ public class PSPrinterJob extends RasterPrinterJob {
Process process = Runtime.getRuntime().exec(execCmd); Process process = Runtime.getRuntime().exec(execCmd);
process.waitFor(); process.waitFor();
spoolFile.delete(); final int result = process.exitValue();
if (0 != result) {
handleProcessFailure(process, execCmd, result);
}
} catch (IOException ex) { } catch (IOException ex) {
pex = new PrinterIOException(ex); pex = new PrinterIOException(ex);
} catch (InterruptedException ie) { } catch (InterruptedException ie) {
pex = new PrinterException(ie.toString()); pex = new PrinterException(ie.toString());
} finally {
spoolFile.delete();
} }
return null; return null;
} }
......
...@@ -38,13 +38,23 @@ import java.rmi.server.ServerNotActiveException; ...@@ -38,13 +38,23 @@ import java.rmi.server.ServerNotActiveException;
import java.rmi.registry.Registry; import java.rmi.registry.Registry;
import java.rmi.server.RMIClientSocketFactory; import java.rmi.server.RMIClientSocketFactory;
import java.rmi.server.RMIServerSocketFactory; import java.rmi.server.RMIServerSocketFactory;
import java.security.AccessControlContext;
import java.security.AccessController;
import java.security.CodeSource;
import java.security.Policy;
import java.security.PrivilegedActionException; import java.security.PrivilegedActionException;
import java.security.PrivilegedExceptionAction;
import java.security.PermissionCollection;
import java.security.Permissions;
import java.security.ProtectionDomain;
import java.text.MessageFormat; import java.text.MessageFormat;
import sun.rmi.server.LoaderHandler;
import sun.rmi.server.UnicastServerRef; import sun.rmi.server.UnicastServerRef;
import sun.rmi.server.UnicastServerRef2; import sun.rmi.server.UnicastServerRef2;
import sun.rmi.transport.LiveRef; import sun.rmi.transport.LiveRef;
import sun.rmi.transport.ObjectTable; import sun.rmi.transport.ObjectTable;
import sun.rmi.transport.Target; import sun.rmi.transport.Target;
import sun.security.action.GetPropertyAction;
/** /**
* A "registry" exists on every node that allows RMI connections to * A "registry" exists on every node that allows RMI connections to
...@@ -325,6 +335,19 @@ public class RegistryImpl extends java.rmi.server.RemoteServer ...@@ -325,6 +335,19 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
URL[] urls = sun.misc.URLClassPath.pathToURLs(envcp); URL[] urls = sun.misc.URLClassPath.pathToURLs(envcp);
ClassLoader cl = new URLClassLoader(urls); ClassLoader cl = new URLClassLoader(urls);
String codebaseProperty = null;
String prop = java.security.AccessController.doPrivileged(
new GetPropertyAction("java.rmi.server.codebase"));
if (prop != null && prop.trim().length() > 0) {
codebaseProperty = prop;
}
URL[] codebaseURLs = null;
if (codebaseProperty != null) {
codebaseURLs = sun.misc.URLClassPath.pathToURLs(codebaseProperty);
} else {
codebaseURLs = new URL[0];
}
/* /*
* Fix bugid 4242317: Classes defined by this class loader should * Fix bugid 4242317: Classes defined by this class loader should
* be annotated with the value of the "java.rmi.server.codebase" * be annotated with the value of the "java.rmi.server.codebase"
...@@ -334,11 +357,19 @@ public class RegistryImpl extends java.rmi.server.RemoteServer ...@@ -334,11 +357,19 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
Thread.currentThread().setContextClassLoader(cl); Thread.currentThread().setContextClassLoader(cl);
int regPort = Registry.REGISTRY_PORT; final int regPort = (args.length >= 1) ? Integer.parseInt(args[0])
if (args.length >= 1) { : Registry.REGISTRY_PORT;
regPort = Integer.parseInt(args[0]); try {
registry = AccessController.doPrivileged(
new PrivilegedExceptionAction<RegistryImpl>() {
public RegistryImpl run() throws RemoteException {
return new RegistryImpl(regPort);
}
}, getAccessControlContext(codebaseURLs));
} catch (PrivilegedActionException ex) {
throw (RemoteException) ex.getException();
} }
registry = new RegistryImpl(regPort);
// prevent registry from exiting // prevent registry from exiting
while (true) { while (true) {
try { try {
...@@ -358,4 +389,48 @@ public class RegistryImpl extends java.rmi.server.RemoteServer ...@@ -358,4 +389,48 @@ public class RegistryImpl extends java.rmi.server.RemoteServer
} }
System.exit(1); System.exit(1);
} }
/**
* Generates an AccessControlContext from several URLs.
* The approach used here is taken from the similar method
* getAccessControlContext() in the sun.applet.AppletPanel class.
*/
private static AccessControlContext getAccessControlContext(URL[] urls) {
// begin with permissions granted to all code in current policy
PermissionCollection perms = AccessController.doPrivileged(
new java.security.PrivilegedAction<PermissionCollection>() {
public PermissionCollection run() {
CodeSource codesource = new CodeSource(null,
(java.security.cert.Certificate[]) null);
Policy p = java.security.Policy.getPolicy();
if (p != null) {
return p.getPermissions(codesource);
} else {
return new Permissions();
}
}
});
/*
* Anyone can connect to the registry and the registry can connect
* to and possibly download stubs from anywhere. Downloaded stubs and
* related classes themselves are more tightly limited by RMI.
*/
perms.add(new SocketPermission("*", "connect,accept"));
perms.add(new RuntimePermission("accessClassInPackage.sun.*"));
// add permissions required to load from codebase URL path
LoaderHandler.addPermissionsForURLs(urls, perms, false);
/*
* Create an AccessControlContext that consists of a single
* protection domain with only the permissions calculated above.
*/
ProtectionDomain pd = new ProtectionDomain(
new CodeSource((urls.length > 0 ? urls[0] : null),
(java.security.cert.Certificate[]) null),
perms);
return new AccessControlContext(new ProtectionDomain[] { pd });
}
} }
...@@ -1031,9 +1031,9 @@ public final class LoaderHandler { ...@@ -1031,9 +1031,9 @@ public final class LoaderHandler {
* loader. A given permission is only added to the collection if * loader. A given permission is only added to the collection if
* it is not already implied by the collection. * it is not already implied by the collection.
*/ */
private static void addPermissionsForURLs(URL[] urls, public static void addPermissionsForURLs(URL[] urls,
PermissionCollection perms, PermissionCollection perms,
boolean forLoader) boolean forLoader)
{ {
for (int i = 0; i < urls.length; i++) { for (int i = 0; i < urls.length; i++) {
URL url = urls[i]; URL url = urls[i];
......
...@@ -390,6 +390,12 @@ public class UnicastServerRef extends UnicastRef ...@@ -390,6 +390,12 @@ public class UnicastServerRef extends UnicastRef
ObjectInput in; ObjectInput in;
try { try {
in = call.getInputStream(); in = call.getInputStream();
try {
Class<?> clazz = Class.forName("sun.rmi.transport.DGCImpl_Skel");
if (clazz.isAssignableFrom(skel.getClass())) {
((MarshalInputStream)in).useCodebaseOnly();
}
} catch (ClassNotFoundException ignore) { }
hash = in.readLong(); hash = in.readLong();
} catch (Exception readEx) { } catch (Exception readEx) {
throw new UnmarshalException("error unmarshalling call header", throw new UnmarshalException("error unmarshalling call header",
......
/* /*
* Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2011, 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
...@@ -69,12 +69,38 @@ class AppOutputStream extends OutputStream { ...@@ -69,12 +69,38 @@ class AppOutputStream extends OutputStream {
// check if the Socket is invalid (error or closed) // check if the Socket is invalid (error or closed)
c.checkWrite(); c.checkWrite();
/*
* By default, we counter chosen plaintext issues on CBC mode
* ciphersuites in SSLv3/TLS1.0 by sending one byte of application
* data in the first record of every payload, and the rest in
* subsequent record(s). Note that the issues have been solved in
* TLS 1.1 or later.
*
* It is not necessary to split the very first application record of
* a freshly negotiated TLS session, as there is no previous
* application data to guess. To improve compatibility, we will not
* split such records.
*
* This avoids issues in the outbound direction. For a full fix,
* the peer must have similar protections.
*/
boolean isFirstRecordOfThePayload = true;
// Always flush at the end of each application level record. // Always flush at the end of each application level record.
// This lets application synchronize read and write streams // This lets application synchronize read and write streams
// however they like; if we buffered here, they couldn't. // however they like; if we buffered here, they couldn't.
try { try {
do { do {
int howmuch = Math.min(len, r.availableDataBytes()); int howmuch;
if (isFirstRecordOfThePayload && c.needToSplitPayload()) {
howmuch = Math.min(0x01, r.availableDataBytes());
} else {
howmuch = Math.min(len, r.availableDataBytes());
}
if (isFirstRecordOfThePayload && howmuch != 0) {
isFirstRecordOfThePayload = false;
}
// NOTE: *must* call c.writeRecord() even for howmuch == 0 // NOTE: *must* call c.writeRecord() even for howmuch == 0
if (howmuch > 0) { if (howmuch > 0) {
......
...@@ -112,6 +112,11 @@ final class CipherBox { ...@@ -112,6 +112,11 @@ final class CipherBox {
*/ */
private SecureRandom random; private SecureRandom random;
/**
* Is the cipher of CBC mode?
*/
private final boolean isCBCMode;
/** /**
* Fixed masks of various block size, as the initial decryption IVs * Fixed masks of various block size, as the initial decryption IVs
* for TLS 1.1 or later. * for TLS 1.1 or later.
...@@ -128,6 +133,7 @@ final class CipherBox { ...@@ -128,6 +133,7 @@ final class CipherBox {
private CipherBox() { private CipherBox() {
this.protocolVersion = ProtocolVersion.DEFAULT; this.protocolVersion = ProtocolVersion.DEFAULT;
this.cipher = null; this.cipher = null;
this.isCBCMode = false;
} }
/** /**
...@@ -148,6 +154,7 @@ final class CipherBox { ...@@ -148,6 +154,7 @@ final class CipherBox {
random = JsseJce.getSecureRandom(); random = JsseJce.getSecureRandom();
} }
this.random = random; this.random = random;
this.isCBCMode = bulkCipher.isCBCMode;
/* /*
* RFC 4346 recommends two algorithms used to generated the * RFC 4346 recommends two algorithms used to generated the
...@@ -694,4 +701,12 @@ final class CipherBox { ...@@ -694,4 +701,12 @@ final class CipherBox {
} }
} }
/*
* Does the cipher use CBC mode?
*
* @return true if the cipher use CBC mode, false otherwise.
*/
boolean isCBCMode() {
return isCBCMode;
}
} }
...@@ -420,10 +420,16 @@ final class CipherSuite implements Comparable<CipherSuite> { ...@@ -420,10 +420,16 @@ final class CipherSuite implements Comparable<CipherSuite> {
// exportable under 512/40 bit rules // exportable under 512/40 bit rules
final boolean exportable; final boolean exportable;
// Is the cipher algorithm of Cipher Block Chaining (CBC) mode?
final boolean isCBCMode;
BulkCipher(String transformation, int keySize, BulkCipher(String transformation, int keySize,
int expandedKeySize, int ivSize, boolean allowed) { int expandedKeySize, int ivSize, boolean allowed) {
this.transformation = transformation; this.transformation = transformation;
this.algorithm = transformation.split("/")[0]; String[] splits = transformation.split("/");
this.algorithm = splits[0];
this.isCBCMode =
splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]);
this.description = this.algorithm + "/" + (keySize << 3); this.description = this.algorithm + "/" + (keySize << 3);
this.keySize = keySize; this.keySize = keySize;
this.ivSize = ivSize; this.ivSize = ivSize;
...@@ -436,7 +442,10 @@ final class CipherSuite implements Comparable<CipherSuite> { ...@@ -436,7 +442,10 @@ final class CipherSuite implements Comparable<CipherSuite> {
BulkCipher(String transformation, int keySize, BulkCipher(String transformation, int keySize,
int ivSize, boolean allowed) { int ivSize, boolean allowed) {
this.transformation = transformation; this.transformation = transformation;
this.algorithm = transformation.split("/")[0]; String[] splits = transformation.split("/");
this.algorithm = splits[0];
this.isCBCMode =
splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]);
this.description = this.algorithm + "/" + (keySize << 3); this.description = this.algorithm + "/" + (keySize << 3);
this.keySize = keySize; this.keySize = keySize;
this.ivSize = ivSize; this.ivSize = ivSize;
......
/* /*
* Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, 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
...@@ -46,6 +46,7 @@ import sun.misc.HexDumpEncoder; ...@@ -46,6 +46,7 @@ import sun.misc.HexDumpEncoder;
*/ */
final class EngineOutputRecord extends OutputRecord { final class EngineOutputRecord extends OutputRecord {
private SSLEngineImpl engine;
private EngineWriter writer; private EngineWriter writer;
private boolean finishedMsg = false; private boolean finishedMsg = false;
...@@ -62,6 +63,7 @@ final class EngineOutputRecord extends OutputRecord { ...@@ -62,6 +63,7 @@ final class EngineOutputRecord extends OutputRecord {
*/ */
EngineOutputRecord(byte type, SSLEngineImpl engine) { EngineOutputRecord(byte type, SSLEngineImpl engine) {
super(type, recordSize(type)); super(type, recordSize(type));
this.engine = engine;
writer = engine.writer; writer = engine.writer;
} }
...@@ -227,11 +229,50 @@ final class EngineOutputRecord extends OutputRecord { ...@@ -227,11 +229,50 @@ final class EngineOutputRecord extends OutputRecord {
* implementations are fragile and don't like to see empty * implementations are fragile and don't like to see empty
* records, so this increases robustness. * records, so this increases robustness.
*/ */
int length = Math.min(ea.getAppRemaining(), maxDataSize); if (ea.getAppRemaining() == 0) {
if (length == 0) {
return; return;
} }
/*
* By default, we counter chosen plaintext issues on CBC mode
* ciphersuites in SSLv3/TLS1.0 by sending one byte of application
* data in the first record of every payload, and the rest in
* subsequent record(s). Note that the issues have been solved in
* TLS 1.1 or later.
*
* It is not necessary to split the very first application record of
* a freshly negotiated TLS session, as there is no previous
* application data to guess. To improve compatibility, we will not
* split such records.
*
* Because of the compatibility, we'd better produce no more than
* SSLSession.getPacketBufferSize() net data for each wrap. As we
* need a one-byte record at first, the 2nd record size should be
* equal to or less than Record.maxDataSizeMinusOneByteRecord.
*
* This avoids issues in the outbound direction. For a full fix,
* the peer must have similar protections.
*/
int length;
if (engine.needToSplitPayload(writeCipher, protocolVersion)) {
write(ea, writeMAC, writeCipher, 0x01);
ea.resetLim(); // reset application data buffer limit
length = Math.min(ea.getAppRemaining(),
maxDataSizeMinusOneByteRecord);
} else {
length = Math.min(ea.getAppRemaining(), maxDataSize);
}
// Don't bother to really write empty records.
if (length > 0) {
write(ea, writeMAC, writeCipher, length);
}
return;
}
void write(EngineArgs ea, MAC writeMAC, CipherBox writeCipher,
int length) throws IOException {
/* /*
* Copy out existing buffer values. * Copy out existing buffer values.
*/ */
......
/* /*
* Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 1996, 2011, 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
...@@ -67,6 +67,23 @@ interface Record { ...@@ -67,6 +67,23 @@ interface Record {
+ maxPadding // padding + maxPadding // padding
+ trailerSize; // MAC + trailerSize; // MAC
static final boolean enableCBCProtection =
Debug.getBooleanProperty("jsse.enableCBCProtection", true);
/*
* For CBC protection in SSL3/TLS1, we break some plaintext into two
* packets. Max application data size for the second packet.
*/
static final int maxDataSizeMinusOneByteRecord =
maxDataSize // max data size
- ( // max one byte record size
headerSize // header
+ maxIVLength // iv
+ 1 // one byte data
+ maxPadding // padding
+ trailerSize // MAC
);
/* /*
* The maximum large record size. * The maximum large record size.
* *
......
...@@ -308,6 +308,11 @@ final public class SSLEngineImpl extends SSLEngine { ...@@ -308,6 +308,11 @@ final public class SSLEngineImpl extends SSLEngine {
private Object unwrapLock; private Object unwrapLock;
Object writeLock; Object writeLock;
/*
* Is it the first application record to write?
*/
private boolean isFirstAppOutputRecord = true;
/* /*
* Class and subclass dynamic debugging support * Class and subclass dynamic debugging support
*/ */
...@@ -612,6 +617,9 @@ final public class SSLEngineImpl extends SSLEngine { ...@@ -612,6 +617,9 @@ final public class SSLEngineImpl extends SSLEngine {
// See comment above. // See comment above.
oldCipher.dispose(); oldCipher.dispose();
// reset the flag of the first application record
isFirstAppOutputRecord = true;
} }
/* /*
...@@ -1286,9 +1294,35 @@ final public class SSLEngineImpl extends SSLEngine { ...@@ -1286,9 +1294,35 @@ final public class SSLEngineImpl extends SSLEngine {
} }
} }
/*
* turn off the flag of the first application record if we really
* consumed at least byte.
*/
if (isFirstAppOutputRecord && ea.deltaApp() > 0) {
isFirstAppOutputRecord = false;
}
return hsStatus; return hsStatus;
} }
/*
* Need to split the payload except the following cases:
*
* 1. protocol version is TLS 1.1 or later;
* 2. bulk cipher does not use CBC mode, including null bulk cipher suites.
* 3. the payload is the first application record of a freshly
* negotiated TLS session.
* 4. the CBC protection is disabled;
*
* More details, please refer to
* EngineOutputRecord.write(EngineArgs, MAC, CipherBox).
*/
boolean needToSplitPayload(CipherBox cipher, ProtocolVersion protocol) {
return (protocol.v <= ProtocolVersion.TLS10.v) &&
cipher.isCBCMode() && !isFirstAppOutputRecord &&
Record.enableCBCProtection;
}
/* /*
* Non-application OutputRecords go through here. * Non-application OutputRecords go through here.
*/ */
......
...@@ -369,6 +369,11 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { ...@@ -369,6 +369,11 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
/* Class and subclass dynamic debugging support */ /* Class and subclass dynamic debugging support */
private static final Debug debug = Debug.getInstance("ssl"); private static final Debug debug = Debug.getInstance("ssl");
/*
* Is it the first application record to write?
*/
private boolean isFirstAppOutputRecord = true;
// //
// CONSTRUCTORS AND INITIALIZATION CODE // CONSTRUCTORS AND INITIALIZATION CODE
// //
...@@ -802,8 +807,35 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { ...@@ -802,8 +807,35 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
if (connectionState < cs_ERROR) { if (connectionState < cs_ERROR) {
checkSequenceNumber(writeMAC, r.contentType()); checkSequenceNumber(writeMAC, r.contentType());
} }
// turn off the flag of the first application record
if (isFirstAppOutputRecord &&
r.contentType() == Record.ct_application_data) {
isFirstAppOutputRecord = false;
}
} }
/*
* Need to split the payload except the following cases:
*
* 1. protocol version is TLS 1.1 or later;
* 2. bulk cipher does not use CBC mode, including null bulk cipher suites.
* 3. the payload is the first application record of a freshly
* negotiated TLS session.
* 4. the CBC protection is disabled;
*
* More details, please refer to AppOutputStream.write(byte[], int, int).
*/
boolean needToSplitPayload() {
writeLock.lock();
try {
return (protocolVersion.v <= ProtocolVersion.TLS10.v) &&
writeCipher.isCBCMode() && !isFirstAppOutputRecord &&
Record.enableCBCProtection;
} finally {
writeLock.unlock();
}
}
/* /*
* Read an application data record. Alerts and handshake * Read an application data record. Alerts and handshake
...@@ -2031,6 +2063,9 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl { ...@@ -2031,6 +2063,9 @@ final public class SSLSocketImpl extends BaseSSLSocketImpl {
// See comment above. // See comment above.
oldCipher.dispose(); oldCipher.dispose();
// reset the flag of the first application record
isFirstAppOutputRecord = true;
} }
/* /*
......
...@@ -524,55 +524,66 @@ public class SwingUtilities2 { ...@@ -524,55 +524,66 @@ public class SwingUtilities2 {
} }
// If we get here we're not printing // If we get here we're not printing
AATextInfo info = drawTextAntialiased(c); if (g instanceof Graphics2D) {
if (info != null && (g instanceof Graphics2D)) { AATextInfo info = drawTextAntialiased(c);
Graphics2D g2 = (Graphics2D)g; Graphics2D g2 = (Graphics2D)g;
Object oldContrast = null;
Object oldAAValue = g2.getRenderingHint(KEY_TEXT_ANTIALIASING);
if (info.aaHint != oldAAValue) {
g2.setRenderingHint(KEY_TEXT_ANTIALIASING, info.aaHint);
} else {
oldAAValue = null;
}
if (info.lcdContrastHint != null) {
oldContrast = g2.getRenderingHint(KEY_TEXT_LCD_CONTRAST);
if (info.lcdContrastHint.equals(oldContrast)) {
oldContrast = null;
} else {
g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST,
info.lcdContrastHint);
}
}
boolean needsTextLayout = ((c != null) && boolean needsTextLayout = ((c != null) &&
(c.getClientProperty(TextAttribute.NUMERIC_SHAPING) != null)); (c.getClientProperty(TextAttribute.NUMERIC_SHAPING) != null));
if (needsTextLayout) { if (needsTextLayout) {
synchronized(charsBufferLock) { synchronized(charsBufferLock) {
int length = syncCharsBuffer(text); int length = syncCharsBuffer(text);
needsTextLayout = isComplexLayout(charsBuffer, 0, length); needsTextLayout = isComplexLayout(charsBuffer, 0, length);
} }
} }
if (needsTextLayout) {
TextLayout layout = createTextLayout(c, text, g2.getFont(), if (info != null) {
Object oldContrast = null;
Object oldAAValue = g2.getRenderingHint(KEY_TEXT_ANTIALIASING);
if (info.aaHint != oldAAValue) {
g2.setRenderingHint(KEY_TEXT_ANTIALIASING, info.aaHint);
} else {
oldAAValue = null;
}
if (info.lcdContrastHint != null) {
oldContrast = g2.getRenderingHint(KEY_TEXT_LCD_CONTRAST);
if (info.lcdContrastHint.equals(oldContrast)) {
oldContrast = null;
} else {
g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST,
info.lcdContrastHint);
}
}
if (needsTextLayout) {
TextLayout layout = createTextLayout(c, text, g2.getFont(),
g2.getFontRenderContext()); g2.getFontRenderContext());
layout.draw(g2, x, y); layout.draw(g2, x, y);
} else { } else {
g.drawString(text, x, y); g.drawString(text, x, y);
} }
if (oldAAValue != null) { if (oldAAValue != null) {
g2.setRenderingHint(KEY_TEXT_ANTIALIASING, oldAAValue); g2.setRenderingHint(KEY_TEXT_ANTIALIASING, oldAAValue);
}
if (oldContrast != null) {
g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, oldContrast);
}
return;
} }
if (oldContrast != null) {
g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, oldContrast); if (needsTextLayout){
TextLayout layout = createTextLayout(c, text, g2.getFont(),
g2.getFontRenderContext());
layout.draw(g2, x, y);
return;
} }
} }
else {
g.drawString(text, x, y);
}
}
g.drawString(text, x, y);
}
/** /**
* Draws the string at the specified location underlining the specified * Draws the string at the specified location underlining the specified
......
/* /*
* Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2011, 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
...@@ -103,18 +103,13 @@ public class CollationData_th extends ListResourceBundle { ...@@ -103,18 +103,13 @@ public class CollationData_th extends ListResourceBundle {
// //
// Normal vowels // Normal vowels
// //
+ "< \u0E4D " // NIKHAHIT
+ "< \u0E30 " // SARA A + "< \u0E30 " // SARA A
+ "< \u0E31 " // MAI HAN-AKAT + "< \u0E31 " // MAI HAN-AKAT
+ "< \u0E32 " // SARA AA + "< \u0E32 " // SARA AA
// Normalizer will decompose this character to \u0e4d\u0e32. This is // Normalizer will decompose this character to \u0e4d\u0e32.
// a Bad Thing, because we want the separate characters to sort + "< \u0E33 = \u0E4D\u0E32 " // SARA AM
// differently than this individual one. Since there's no public way to
// set the decomposition to be used when creating a collator, there's
// no way around this right now.
// It's best to go ahead and leave the character in, because it occurs
// this way a lot more often than it occurs as separate characters.
+ "< \u0E33 " // SARA AM
+ "< \u0E34 " // SARA I + "< \u0E34 " // SARA I
...@@ -133,62 +128,58 @@ public class CollationData_th extends ListResourceBundle { ...@@ -133,62 +128,58 @@ public class CollationData_th extends ListResourceBundle {
+ "< \u0E43 " // SARA AI MAIMUAN + "< \u0E43 " // SARA AI MAIMUAN
+ "< \u0E44 " // SARA AI MAIMALAI + "< \u0E44 " // SARA AI MAIMALAI
//
// Digits
//
+ "< \u0E50 " // DIGIT ZERO
+ "< \u0E51 " // DIGIT ONE
+ "< \u0E52 " // DIGIT TWO
+ "< \u0E53 " // DIGIT THREE
+ "< \u0E54 " // DIGIT FOUR
+ "< \u0E55 " // DIGIT FIVE
+ "< \u0E56 " // DIGIT SIX
+ "< \u0E57 " // DIGIT SEVEN
+ "< \u0E58 " // DIGIT EIGHT
+ "< \u0E59 " // DIGIT NINE
// Sorta tonal marks, but maybe not really
+ "< \u0E4D " // NIKHAHIT
// //according to CLDR, it's after 0e44
// Thai symbols are supposed to sort "after white space". + "< \u0E3A " // PHINTHU
// I'm treating this as making them sort just after the normal Latin-1
// symbols, which are in turn after the white space.
//
+ "&'\u007d'" // right-brace // This rare symbol comes after all characters.
+ "< \u0E2F " // PAIYANNOI (ellipsis, abbreviation)
+ "< \u0E46 " // MAIYAMOK
+ "< \u0E4F " // FONGMAN
+ "< \u0E5A " // ANGKHANKHU
+ "< \u0E5B " // KHOMUT
+ "< \u0E3F " // CURRENCY SYMBOL BAHT
// These symbols are supposed to be "after all characters"
+ "< \u0E4E " // YAMAKKAN
// This rare symbol also comes after all characters. But when it is
// used in combination with RU and LU, the combination is treated as
// a separate letter, ala "CH" sorting after "C" in traditional Spanish.
+ "< \u0E45 " // LAKKHANGYAO + "< \u0E45 " // LAKKHANGYAO
+ "& \u0E24 < \u0E24\u0E45 " + "& \u0E32 , \0E45 " // According to CLDR, 0E45 is after 0E32 in tertiary level
+ "& \u0E26 < \u0E26\u0E45 "
// Tonal marks are primary ignorables but are treated as secondary
// differences
// Below are thai puntuation marks and Tonal(Accent) marks. According to CLDR 1.9 and
// ISO/IEC 14651, Annex C, C.2.1 Thai ordering principles, 0E2F to 0E5B are punctuaion marks that need to be ignored
// in the first three leveles. 0E4E to 0E4B are tonal marks to be compared in secondary level.
// In real implmentation, set puncutation marks in tertiary as there is no fourth level in Java.
// Set all these special marks after \u0301, the accute accent.
+ "& \u0301 " // acute accent + "& \u0301 " // acute accent
//puncutation marks
+ ", \u0E2F " // PAIYANNOI (ellipsis, abbreviation)
+ ", \u0E46 " // MAIYAMOK
+ ", \u0E4F " // FONGMAN
+ ", \u0E5A " // ANGKHANKHU
+ ", \u0E5B " // KHOMUT
//tonal marks
+ "; \u0E4E " // YAMAKKAN
+ "; \u0E4C " // THANTHAKHAT
+ "; \u0E47 " // MAITAIKHU + "; \u0E47 " // MAITAIKHU
+ "; \u0E48 " // MAI EK + "; \u0E48 " // MAI EK
+ "; \u0E49 " // MAI THO + "; \u0E49 " // MAI THO
+ "; \u0E4A " // MAI TRI + "; \u0E4A " // MAI TRI
+ "; \u0E4B " // MAI CHATTAWA + "; \u0E4B " // MAI CHATTAWA
+ "; \u0E4C " // THANTHAKHAT
// These are supposed to be ignored, so I'm treating them as controls //
+ "& \u0001 " // Digits are equal to their corresponding Arabic digits in the first level
+ "= \u0E3A " // PHINTHU //
+ "= '.' " // period + "& 0 = \u0E50 " // DIGIT ZERO
} + "& 1 = \u0E51 " // DIGIT ONE
+ "& 2 = \u0E52 " // DIGIT TWO
+ "& 3 = \u0E53 " // DIGIT THREE
+ "& 4 = \u0E54 " // DIGIT FOUR
+ "& 5 = \u0E55 " // DIGIT FIVE
+ "& 6 = \u0E56 " // DIGIT SIX
+ "& 7 = \u0E57 " // DIGIT SEVEN
+ "& 8 = \u0E58 " // DIGIT EIGHT
+ "& 9 = \u0E59 " // DIGIT NINE
}
}; };
} }
} }
# #
# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. # Copyright (c) 2005, 2011, 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
...@@ -23,21 +23,45 @@ ...@@ -23,21 +23,45 @@
# questions. # questions.
# #
# (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
# (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved
# #
# The original version of this source code and documentation # COPYRIGHT AND PERMISSION NOTICE
# is copyrighted and owned by Taligent, Inc., a wholly-owned
# subsidiary of IBM. These materials are provided under terms
# of a License Agreement between Taligent and Sun. This technology
# is protected by multiple US and International patents.
# #
# This notice and attribution to Taligent may not be removed. # Copyright (C) 1991-2011 Unicode, Inc. All rights reserved.
# Taligent is a registered trademark of Taligent, Inc. # Distributed under the Terms of Use in http://www.unicode.org/copyright.html.
#
# Permission is hereby granted, free of charge, to any person obtaining
# a copy of the Unicode data files and any associated documentation (the
# "Data Files") or Unicode software and any associated documentation
# (the "Software") to deal in the Data Files or Software without
# restriction, including without limitation the rights to use, copy,
# modify, merge, publish, distribute, and/or sell copies of the Data
# Files or Software, and to permit persons to whom the Data Files or
# Software are furnished to do so, provided that (a) the above copyright
# notice(s) and this permission notice appear with all copies of the
# Data Files or Software, (b) both the above copyright notice(s) and
# this permission notice appear in associated documentation, and (c)
# there is clear notice in each modified Data File or in the Software as
# well as in the documentation associated with the Data File(s) or
# Software that the data or software has been modified.
#
# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF
# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE
# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT
# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR
# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES
# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT
# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR
# SOFTWARE.
#
# Except as contained in this notice, the name of a copyright holder
# shall not be used in advertising or otherwise to promote the sale, use
# or other dealings in these Data Files or Software without prior
# written authorization of the copyright holder.
# This bundle is empty because the data of the base bundle #
# is adequate for this locale. # Generated automatically from the Common Locale Data Repository. DO NOT EDIT!
# The bundle is necessary to prevent the resource #
# bundle lookup from falling back to the default firstDayOfWeek=2
# locale. minimalDaysInFirstWeek=4
To run the Ruler demo: To run the Ruler demo:
java -jar Ruler.jar java -jar TransparentRuler.jar
These instructions assume that this installation's version of the java These instructions assume that this installation's version of the java
command is in your path. If it isn't, then you should either command is in your path. If it isn't, then you should either
specify the complete path to the java command or update your specify the complete path to the java command or update your
PATH environment variable as described in the installation PATH environment variable as described in the installation
instructions for the Java(TM) SE Development Kit. instructions for the Java(TM) SE Development Kit.
KNOWN ISSUES:
Context menu is clipped with the window shape. The issues are:
CR 7027486 JPopupMenu doesn't take window shape into account
...@@ -1112,11 +1112,14 @@ void unpacker::read_Utf8_values(entry* cpMap, int len) { ...@@ -1112,11 +1112,14 @@ void unpacker::read_Utf8_values(entry* cpMap, int len) {
uint size3 = suffix * 3; uint size3 = suffix * 3;
if (suffix == 0) continue; // done with empty string if (suffix == 0) continue; // done with empty string
chars.malloc(size3); chars.malloc(size3);
CHECK;
byte* chp = chars.ptr; byte* chp = chars.ptr;
band saved_band = cp_Utf8_big_chars; band saved_band = cp_Utf8_big_chars;
cp_Utf8_big_chars.readData(suffix); cp_Utf8_big_chars.readData(suffix);
CHECK;
for (int j = 0; j < suffix; j++) { for (int j = 0; j < suffix; j++) {
unsigned short ch = cp_Utf8_big_chars.getInt(); unsigned short ch = cp_Utf8_big_chars.getInt();
CHECK;
chp = store_Utf8_char(chp, ch); chp = store_Utf8_char(chp, ch);
} }
chars.realloc(chp - chars.ptr); chars.realloc(chp - chars.ptr);
...@@ -1134,10 +1137,12 @@ void unpacker::read_Utf8_values(entry* cpMap, int len) { ...@@ -1134,10 +1137,12 @@ void unpacker::read_Utf8_values(entry* cpMap, int len) {
CHECK; CHECK;
int prevlen = 0; // previous string length (in chars) int prevlen = 0; // previous string length (in chars)
tmallocs.add(bigbuf.ptr); // free after this block tmallocs.add(bigbuf.ptr); // free after this block
CHECK;
cp_Utf8_prefix.rewind(); cp_Utf8_prefix.rewind();
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
bytes& chars = allsuffixes[i]; bytes& chars = allsuffixes[i];
int prefix = (i < PREFIX_SKIP_2)? 0: cp_Utf8_prefix.getInt(); int prefix = (i < PREFIX_SKIP_2)? 0: cp_Utf8_prefix.getInt();
CHECK;
int suffix = (int)chars.len; int suffix = (int)chars.len;
byte* fillp; byte* fillp;
// by induction, the buffer is already filled with the prefix // by induction, the buffer is already filled with the prefix
......
/* /*
* Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -52,7 +52,7 @@ void* must_malloc(size_t size) { ...@@ -52,7 +52,7 @@ void* must_malloc(size_t size) {
if (msize >= 0 && msize < sizeof(int)) if (msize >= 0 && msize < sizeof(int))
msize = sizeof(int); // see 0xbaadf00d below msize = sizeof(int); // see 0xbaadf00d below
#endif #endif
void* ptr = (msize > PSIZE_MAX) ? null : malloc(msize); void* ptr = (msize > PSIZE_MAX || msize <= 0) ? null : malloc(msize);
if (ptr != null) { if (ptr != null) {
memset(ptr, 0, size); memset(ptr, 0, size);
} else { } else {
......
/* /*
* Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2001, 2011, 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
...@@ -33,7 +33,7 @@ void mtrace(char c, void* ptr, size_t size); ...@@ -33,7 +33,7 @@ void mtrace(char c, void* ptr, size_t size);
#endif #endif
// overflow management // overflow management
#define OVERFLOW ((size_t)-1) #define OVERFLOW ((uint)-1)
#define PSIZE_MAX (OVERFLOW/2) /* normal size limit */ #define PSIZE_MAX (OVERFLOW/2) /* normal size limit */
inline size_t scale_size(size_t size, size_t scale) { inline size_t scale_size(size_t size, size_t scale) {
......
/* /*
* Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2011, 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
...@@ -284,7 +284,7 @@ Java_sun_java2d_loops_TransformHelper_Transform ...@@ -284,7 +284,7 @@ Java_sun_java2d_loops_TransformHelper_Transform
TransformHelperFunc *pHelperFunc; TransformHelperFunc *pHelperFunc;
TransformInterpFunc *pInterpFunc; TransformInterpFunc *pInterpFunc;
jdouble xorig, yorig; jdouble xorig, yorig;
jint numedges; jlong numedges;
jint *pEdges; jint *pEdges;
jint edgebuf[2 + MAXEDGES * 2]; jint edgebuf[2 + MAXEDGES * 2];
union { union {
...@@ -379,19 +379,44 @@ Java_sun_java2d_loops_TransformHelper_Transform ...@@ -379,19 +379,44 @@ Java_sun_java2d_loops_TransformHelper_Transform
} }
Region_IntersectBounds(&clipInfo, &dstInfo.bounds); Region_IntersectBounds(&clipInfo, &dstInfo.bounds);
numedges = (dstInfo.bounds.y2 - dstInfo.bounds.y1); numedges = (((jlong) dstInfo.bounds.y2) - ((jlong) dstInfo.bounds.y1));
if (numedges > MAXEDGES) { if (numedges <= 0) {
pEdges = malloc((2 + 2 * numedges) * sizeof (*pEdges)); pEdges = NULL;
if (pEdges == NULL) { } else if (!JNU_IsNull(env, edgeArray)) {
SurfaceData_InvokeUnlock(env, dstOps, &dstInfo); /*
SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); * Ideally Java should allocate an array large enough, but if
/* edgeArray should already contain zeros for min/maxy */ * we ever have a miscommunication about the number of edge
return; * lines, or if the Java array calculation should overflow to
} * a positive number and succeed in allocating an array that
* is too small, we need to verify that it can still hold the
* number of integers that we plan to store to be safe.
*/
jsize edgesize = (*env)->GetArrayLength(env, edgeArray);
/* (edgesize/2 - 1) should avoid any overflow or underflow. */
pEdges = (((edgesize / 2) - 1) >= numedges)
? (*env)->GetPrimitiveArrayCritical(env, edgeArray, NULL)
: NULL;
} else if (numedges > MAXEDGES) {
/* numedges variable (jlong) can be at most ((1<<32)-1) */
/* memsize can overflow a jint, but not a jlong */
jlong memsize = ((numedges * 2) + 2) * sizeof(*pEdges);
pEdges = (memsize == ((size_t) memsize))
? malloc((size_t) memsize)
: NULL;
} else { } else {
pEdges = edgebuf; pEdges = edgebuf;
} }
if (pEdges == NULL) {
if (numedges > 0) {
JNU_ThrowInternalError(env, "Unable to allocate edge list");
}
SurfaceData_InvokeUnlock(env, dstOps, &dstInfo);
SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
/* edgeArray should already contain zeros for min/maxy */
return;
}
Transform_GetInfo(env, itxform, &itxInfo); Transform_GetInfo(env, itxform, &itxInfo);
if (!Region_IsEmpty(&clipInfo)) { if (!Region_IsEmpty(&clipInfo)) {
...@@ -500,14 +525,14 @@ Java_sun_java2d_loops_TransformHelper_Transform ...@@ -500,14 +525,14 @@ Java_sun_java2d_loops_TransformHelper_Transform
} else { } else {
pEdges[0] = pEdges[1] = 0; pEdges[0] = pEdges[1] = 0;
} }
SurfaceData_InvokeUnlock(env, dstOps, &dstInfo);
SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
if (!JNU_IsNull(env, edgeArray)) { if (!JNU_IsNull(env, edgeArray)) {
(*env)->SetIntArrayRegion(env, edgeArray, 0, 2+numedges*2, pEdges); (*env)->ReleasePrimitiveArrayCritical(env, edgeArray, pEdges, 0);
} } else if (pEdges != edgebuf) {
if (pEdges != edgebuf) {
free(pEdges); free(pEdges);
} }
SurfaceData_InvokeUnlock(env, dstOps, &dstInfo);
SurfaceData_InvokeUnlock(env, srcOps, &srcInfo);
} }
static void static void
......
...@@ -466,12 +466,16 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget ...@@ -466,12 +466,16 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
if (true) { if (true) {
switch(e.getID()) { switch(e.getID()) {
case PaintEvent.UPDATE: case PaintEvent.UPDATE:
log.finer("XCP coalescePaintEvent : UPDATE : add : x = " + if (log.isLoggable(PlatformLogger.FINER)) {
log.finer("XCP coalescePaintEvent : UPDATE : add : x = " +
r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height); r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height);
}
return; return;
case PaintEvent.PAINT: case PaintEvent.PAINT:
log.finer("XCP coalescePaintEvent : PAINT : add : x = " + if (log.isLoggable(PlatformLogger.FINER)) {
log.finer("XCP coalescePaintEvent : PAINT : add : x = " +
r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height); r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height);
}
return; return;
} }
} }
...@@ -1248,7 +1252,9 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget ...@@ -1248,7 +1252,9 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
* ButtonPress, ButtonRelease, KeyPress, KeyRelease, EnterNotify, LeaveNotify, MotionNotify * ButtonPress, ButtonRelease, KeyPress, KeyRelease, EnterNotify, LeaveNotify, MotionNotify
*/ */
protected boolean isEventDisabled(XEvent e) { protected boolean isEventDisabled(XEvent e) {
enableLog.finest("Component is {1}, checking for disabled event {0}", e, (isEnabled()?"enabled":"disable")); if (enableLog.isLoggable(PlatformLogger.FINEST)) {
enableLog.finest("Component is {1}, checking for disabled event {0}", e, (isEnabled()?"enabled":"disable"));
}
if (!isEnabled()) { if (!isEnabled()) {
switch (e.get_type()) { switch (e.get_type()) {
case XConstants.ButtonPress: case XConstants.ButtonPress:
...@@ -1258,7 +1264,9 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget ...@@ -1258,7 +1264,9 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget
case XConstants.EnterNotify: case XConstants.EnterNotify:
case XConstants.LeaveNotify: case XConstants.LeaveNotify:
case XConstants.MotionNotify: case XConstants.MotionNotify:
enableLog.finer("Event {0} is disable", e); if (enableLog.isLoggable(PlatformLogger.FINER)) {
enableLog.finer("Event {0} is disable", e);
}
return true; return true;
} }
} }
......
...@@ -678,7 +678,7 @@ public class WrapperGenerator { ...@@ -678,7 +678,7 @@ public class WrapperGenerator {
public void writeToString(StructType stp, PrintWriter pw) { public void writeToString(StructType stp, PrintWriter pw) {
int type; int type;
pw.println("\n\n\tString getName() {\n\t\treturn \"" + stp.getName()+ "\"; \n\t}"); pw.println("\n\n\tString getName() {\n\t\treturn \"" + stp.getName()+ "\"; \n\t}");
pw.println("\n\n\tString getFieldsAsString() {\n\t\tString ret=\"\";\n"); pw.println("\n\n\tString getFieldsAsString() {\n\t\tStringBuilder ret = new StringBuilder(" + stp.getNumFields() * 40 + ");\n");
for (Enumeration e = stp.getMembers() ; e.hasMoreElements() ;) { for (Enumeration e = stp.getMembers() ; e.hasMoreElements() ;) {
AtomicType tp = (AtomicType) e.nextElement(); AtomicType tp = (AtomicType) e.nextElement();
...@@ -688,24 +688,24 @@ public class WrapperGenerator { ...@@ -688,24 +688,24 @@ public class WrapperGenerator {
if ((name != null) && (name.length() > 0)) if ((name != null) && (name.length() > 0))
{ {
if (type == AtomicType.TYPE_ATOM) { if (type == AtomicType.TYPE_ATOM) {
pw.println("\t\tret += \"\"+\"" + name + " = \" + XAtom.get(get_" + name + "()) +\", \";"); pw.println("\t\tret.append(\"" + name + " = \" ).append( XAtom.get(get_" + name + "()) ).append(\", \");");
} else if (name.equals("type")) { } else if (name.equals("type")) {
pw.println("\t\tret += \"\"+\"type = \" + XlibWrapper.eventToString[get_type()] +\", \";"); pw.println("\t\tret.append(\"type = \").append( XlibWrapper.eventToString[get_type()] ).append(\", \");");
} else if (name.equals("window")){ } else if (name.equals("window")){
pw.println("\t\tret += \"\"+\"window = \" + getWindow(get_window()) + \", \";"); pw.println("\t\tret.append(\"window = \" ).append( getWindow(get_window()) ).append(\", \");");
} else if (type == AtomicType.TYPE_ARRAY) { } else if (type == AtomicType.TYPE_ARRAY) {
pw.print("\t\tret += \"{\""); pw.print("\t\tret.append(\"{\")");
for (int i = 0; i < tp.getArrayLength(); i++) { for (int i = 0; i < tp.getArrayLength(); i++) {
pw.print(" + get_" + name + "(" + i + ") + \" \""); pw.print("\n\t\t.append( get_" + name + "(" + i + ") ).append(\" \")");
} }
pw.println(" + \"}\";"); pw.println(".append( \"}\");");
} else { } else {
pw.println("\t\tret += \"\"+\"" + name +" = \" + get_"+ name+"() +\", \";"); pw.println("\t\tret.append(\"" + name +" = \").append( get_"+ name+"() ).append(\", \");");
} }
} }
} }
pw.println("\t\treturn ret;\n\t}\n\n"); pw.println("\t\treturn ret.toString();\n\t}\n\n");
} }
public void writeStubs(StructType stp, PrintWriter pw) { public void writeStubs(StructType stp, PrintWriter pw) {
......
...@@ -38,7 +38,9 @@ import java.io.InputStreamReader; ...@@ -38,7 +38,9 @@ import java.io.InputStreamReader;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.OutputStreamWriter; import java.io.OutputStreamWriter;
import java.io.IOException; import java.io.IOException;
import java.io.PrintWriter;
import java.io.Reader; import java.io.Reader;
import java.io.StringWriter;
import java.io.UnsupportedEncodingException; import java.io.UnsupportedEncodingException;
import java.util.Vector; import java.util.Vector;
...@@ -955,23 +957,49 @@ public class UnixPrintJob implements CancelablePrintJob { ...@@ -955,23 +957,49 @@ public class UnixPrintJob implements CancelablePrintJob {
private class PrinterSpooler implements java.security.PrivilegedAction { private class PrinterSpooler implements java.security.PrivilegedAction {
PrintException pex; PrintException pex;
private void handleProcessFailure(final Process failedProcess,
final String[] execCmd, final int result) throws IOException {
try (StringWriter sw = new StringWriter();
PrintWriter pw = new PrintWriter(sw)) {
pw.append("error=").append(Integer.toString(result));
pw.append(" running:");
for (String arg: execCmd) {
pw.append(" '").append(arg).append("'");
}
try (InputStream is = failedProcess.getErrorStream();
InputStreamReader isr = new InputStreamReader(is);
BufferedReader br = new BufferedReader(isr)) {
while (br.ready()) {
pw.println();
pw.append("\t\t").append(br.readLine());
}
} finally {
pw.flush();
throw new IOException(sw.toString());
}
}
}
public Object run() { public Object run() {
if (spoolFile == null || !spoolFile.exists()) {
pex = new PrintException("No spool file");
notifyEvent(PrintJobEvent.JOB_FAILED);
return null;
}
try { try {
/** /**
* Spool to the printer. * Spool to the printer.
*/ */
if (spoolFile == null || !spoolFile.exists()) {
pex = new PrintException("No spool file");
notifyEvent(PrintJobEvent.JOB_FAILED);
return null;
}
String fileName = spoolFile.getAbsolutePath(); String fileName = spoolFile.getAbsolutePath();
String execCmd[] = printExecCmd(mDestination, mOptions, String execCmd[] = printExecCmd(mDestination, mOptions,
mNoJobSheet, jobName, copies, fileName); mNoJobSheet, jobName, copies, fileName);
Process process = Runtime.getRuntime().exec(execCmd); Process process = Runtime.getRuntime().exec(execCmd);
process.waitFor(); process.waitFor();
spoolFile.delete(); final int result = process.exitValue();
if (0 != result) {
handleProcessFailure(process, execCmd, result);
}
notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE); notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE);
} catch (IOException ex) { } catch (IOException ex) {
notifyEvent(PrintJobEvent.JOB_FAILED); notifyEvent(PrintJobEvent.JOB_FAILED);
...@@ -981,6 +1009,7 @@ public class UnixPrintJob implements CancelablePrintJob { ...@@ -981,6 +1009,7 @@ public class UnixPrintJob implements CancelablePrintJob {
notifyEvent(PrintJobEvent.JOB_FAILED); notifyEvent(PrintJobEvent.JOB_FAILED);
pex = new PrintException(ie); pex = new PrintException(ie);
} finally { } finally {
spoolFile.delete();
notifyEvent(PrintJobEvent.NO_MORE_EVENTS); notifyEvent(PrintJobEvent.NO_MORE_EVENTS);
} }
return null; return null;
......
...@@ -32,7 +32,7 @@ ...@@ -32,7 +32,7 @@
#include <X11/Xutil.h> #include <X11/Xutil.h>
#include <X11/extensions/shape.h> #include <X11/extensions/shape.h>
#include <sys/types.h> #include <sys/types.h>
#include <sys/unistd.h> #include <unistd.h>
#include <pthread.h> #include <pthread.h>
#include <signal.h> #include <signal.h>
#include <inttypes.h> #include <inttypes.h>
......
...@@ -60,10 +60,11 @@ final class ProcessImpl extends Process { ...@@ -60,10 +60,11 @@ final class ProcessImpl extends Process {
throws IOException throws IOException
{ {
if (append) { if (append) {
String path = f.getPath();
SecurityManager sm = System.getSecurityManager(); SecurityManager sm = System.getSecurityManager();
if (sm != null) if (sm != null)
sm.checkWrite(f.getPath()); sm.checkWrite(path);
long handle = openForAtomicAppend(f.getPath()); long handle = openForAtomicAppend(path);
final FileDescriptor fd = new FileDescriptor(); final FileDescriptor fd = new FileDescriptor();
fdAccess.setHandle(fd, handle); fdAccess.setHandle(fd, handle);
return AccessController.doPrivileged( return AccessController.doPrivileged(
......
...@@ -355,7 +355,7 @@ void AwtWindow::RepositionSecurityWarning(JNIEnv *env) ...@@ -355,7 +355,7 @@ void AwtWindow::RepositionSecurityWarning(JNIEnv *env)
RECT rect; RECT rect;
CalculateWarningWindowBounds(env, &rect); CalculateWarningWindowBounds(env, &rect);
::SetWindowPos(warningWindow, IsAlwaysOnTop() ? HWND_TOPMOST : GetHWnd(), ::SetWindowPos(warningWindow, IsAlwaysOnTop() ? HWND_TOPMOST : HWND_NOTOPMOST,
rect.left, rect.top, rect.left, rect.top,
rect.right - rect.left, rect.bottom - rect.top, rect.right - rect.left, rect.bottom - rect.top,
SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE |
...@@ -835,7 +835,7 @@ void AwtWindow::StartSecurityAnimation(AnimationKind kind) ...@@ -835,7 +835,7 @@ void AwtWindow::StartSecurityAnimation(AnimationKind kind)
if (securityAnimationKind == akShow) { if (securityAnimationKind == akShow) {
::SetWindowPos(warningWindow, ::SetWindowPos(warningWindow,
IsAlwaysOnTop() ? HWND_TOPMOST : GetHWnd(), IsAlwaysOnTop() ? HWND_TOPMOST : HWND_NOTOPMOST,
0, 0, 0, 0, 0, 0, 0, 0,
SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE |
SWP_SHOWWINDOW | SWP_NOOWNERZORDER); SWP_SHOWWINDOW | SWP_NOOWNERZORDER);
......
...@@ -128,18 +128,20 @@ public class CurrencyTest { ...@@ -128,18 +128,20 @@ public class CurrencyTest {
checkCountryCurrency(country1[i], currency1[i]); checkCountryCurrency(country1[i], currency1[i]);
} }
// check currency changes /*
String[] switchOverCtry = {"DE", "FR", "ES", "IT", "NL", "BE", "TR", "RO", "AZ", "MZ", "GH", "VE"}; * check currency changes
String[] switchOverOld = {"DEM", "FRF", "ESP", "ITL", "NLG", "BEF", "TRL", "ROL", "AZM", "MZM", "GHC", "VEB"}; * In current implementation, there is no data of old currency and transition date at jdk/src/share/classes/java/util/CurrencyData.properties.
String[] switchOverNew = {"EUR", "EUR", "EUR", "EUR", "EUR", "EUR", "TRY", "RON", "AZN", "MZN", "GHS", "VEF"}; * So, all the switch data arrays are empty. In the future, if data of old currency and transition date are necessary for any country, the
String[] switchOverTZ = {"Europe/Paris", "Europe/Paris", "Europe/Paris", "Europe/Paris", * arrays here can be updated so that the program can check the currency switch.
"Europe/Paris", "Europe/Paris", "Asia/Istanbul", "Europe/Bucharest", */
"Asia/Baku", "Africa/Maputo", "Africa/Accra", "America/Caracas"}; String[] switchOverCtry = {};
int[] switchOverYear = {2002, 2002, 2002, 2002, 2002, 2002, 2005, 2005, 2006, 2006, 2007, 2008}; String[] switchOverOld = {};
int[] switchOverMonth = {Calendar.JANUARY, Calendar.JANUARY, Calendar.JANUARY, Calendar.JANUARY, String[] switchOverNew = {};
Calendar.JANUARY, Calendar.JANUARY, Calendar.JANUARY, Calendar.JULY, String[] switchOverTZ = {};
Calendar.JANUARY, Calendar.JULY, Calendar.JULY, Calendar.JANUARY}; int[] switchOverYear = {};
int[] switchOverDay = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int[] switchOverMonth = {};
int[] switchOverDay = {};
for (int i = 0; i < switchOverCtry.length; i++) { for (int i = 0; i < switchOverCtry.length; i++) {
TimeZone.setDefault(TimeZone.getTimeZone(switchOverTZ[i])); TimeZone.setDefault(TimeZone.getTimeZone(switchOverTZ[i]));
Calendar date = new GregorianCalendar(switchOverYear[i], switchOverMonth[i], switchOverDay[i]); Calendar date = new GregorianCalendar(switchOverYear[i], switchOverMonth[i], switchOverDay[i]);
......
...@@ -92,7 +92,7 @@ public class ValidateISO4217 { ...@@ -92,7 +92,7 @@ public class ValidateISO4217 {
/* Codes that are obsolete, do not have related country */ /* Codes that are obsolete, do not have related country */
static final String otherCodes = static final String otherCodes =
"ADP-AFA-ATS-AYM-BEF-BGL-BOV-BYB-CLF-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-NLG-PTE-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-USN-USS-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZWD-ZWN-ZWR"; "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-CLF-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZWD-ZWN-ZWR";
static boolean err = false; static boolean err = false;
......
...@@ -23,7 +23,7 @@ AW AWG 533 2 ...@@ -23,7 +23,7 @@ AW AWG 533 2
AU AUD 36 2 AU AUD 36 2
AT EUR 978 2 AT EUR 978 2
# MA 129 # MA 129
AZ AZM 31 2 2005-12-31-20-00-00 AZN 944 2 AZ AZN 944 2
BS BSD 44 2 BS BSD 44 2
BH BHD 48 3 BH BHD 48 3
BD BDT 50 2 BD BDT 50 2
...@@ -96,7 +96,7 @@ GA XAF 950 0 ...@@ -96,7 +96,7 @@ GA XAF 950 0
GM GMD 270 2 GM GMD 270 2
GE GEL 981 2 GE GEL 981 2
DE EUR 978 2 DE EUR 978 2
GH GHC 288 2 2007-07-01-00-00-00 GHS 936 2 GH GHS 936 2
GI GIP 292 2 GI GIP 292 2
GR EUR 978 2 GR EUR 978 2
GL DKK 208 2 GL DKK 208 2
...@@ -166,7 +166,7 @@ MN MNT 496 2 ...@@ -166,7 +166,7 @@ MN MNT 496 2
MS XCD 951 2 MS XCD 951 2
MA MAD 504 2 MA MAD 504 2
# MA 130 # MA 130
MZ MZM 508 2 2006-06-30-22-00-00 MZN 943 2 MZ MZN 943 2
MM MMK 104 2 MM MMK 104 2
# MA 134 # MA 134
ME EUR 978 2 ME EUR 978 2
...@@ -200,7 +200,7 @@ PT EUR 978 2 ...@@ -200,7 +200,7 @@ PT EUR 978 2
PR USD 840 2 PR USD 840 2
QA QAR 634 2 QA QAR 634 2
RE EUR 978 2 RE EUR 978 2
RO ROL 946 2 2005-06-30-21-00-00 RON 946 2 RO RON 946 2
RU RUB 643 2 RU RUB 643 2
RW RWF 646 0 RW RWF 646 0
SH SHP 654 2 SH SHP 654 2
...@@ -266,7 +266,7 @@ UM USD 840 2 ...@@ -266,7 +266,7 @@ UM USD 840 2
UY UYU 858 2 UY UYU 858 2
UZ UZS 860 2 UZ UZS 860 2
VU VUV 548 0 VU VUV 548 0
VE VEB 862 2 2008-01-01-04-00-00 VEF 937 2 VE VEF 937 2
VN VND 704 2 VN VND 704 2
VG USD 840 2 VG USD 840 2
VI USD 840 2 VI USD 840 2
......
/*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/* @test
* @bug 4492274
* @summary Tests if JEditorPane.getPage() correctly returns anchor reference.
* @author Denis Sharypov
*/
import sun.awt.SunToolkit;
import javax.swing.*;
import javax.swing.text.html.HTMLEditorKit;
import java.awt.*;
import java.io.File;
import java.net.URL;
public class bug4492274 {
private static URL page;
private static JEditorPane jep;
public static void main(String args[]) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
try {
page = new URL(page, "#linkname");
jep.setPage(page);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
});
toolkit.realSync();
if (getPageAnchor() == null) {
throw new RuntimeException("JEditorPane.getPage() returns null anchor reference");
}
}
private static String getPageAnchor() throws Exception {
final String[] result = new String[1];
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
result[0] = jep.getPage().getRef();
}
});
return result[0];
}
private static void createAndShowGUI() {
try {
File file = new File(System.getProperty("test.src", "."), "test.html");
page = file.toURI().toURL();
JFrame f = new JFrame();
jep = new JEditorPane();
jep.setEditorKit(new HTMLEditorKit());
jep.setEditable(false);
jep.setPage(page);
JScrollPane sp = new JScrollPane(jep);
f.getContentPane().add(sp);
f.setSize(500, 500);
f.setVisible(true);
} catch (Exception e) {
throw new RuntimeException(e);
}
}
}
<html>
<body>
<a name="top">top</a>
<img src=a.jpg width=500 height=1000>
<a name="linkname">bottom</a>
</body>
</html>
/*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6348946
* @summary Tests that JSlider's thumb moves in the right direction
* when it is used as a JTable cell editor.
* @author Mikhail Lapshin
*/
import sun.awt.SunToolkit;
import java.awt.*;
import java.awt.event.InputEvent;
import javax.swing.*;
import javax.swing.event.*;
import javax.swing.table.*;
public class bug6348946 {
private static JFrame frame;
private static JPanel panel;
private static volatile boolean passed = false;
public static void main(String[] args) throws Exception {
String lf = "javax.swing.plaf.metal.MetalLookAndFeel";
UIManager.setLookAndFeel(lf);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
try {
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
setupUI();
}
});
toolkit.realSync();
clickOnSlider();
toolkit.realSync();
checkResult();
} finally {
stopEDT();
}
}
private static void setupUI() {
frame = new JFrame();
panel = new JPanel();
panel.setLayout(new BorderLayout());
panel.add(new ParameterTable(), BorderLayout.CENTER);
frame.getContentPane().add(panel);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
}
private static void clickOnSlider() throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(10);
Rectangle rect = getPanelRectangle();
double clickX = rect.getX() + rect.getWidth() / 4;
double clickY = rect.getY() + rect.getHeight() / 2;
robot.mouseMove((int) clickX, (int) clickY);
robot.mousePress(InputEvent.BUTTON1_MASK);
robot.mouseRelease(InputEvent.BUTTON1_MASK);
}
private static void checkResult(){
if (passed) {
System.out.println("Test passed");
} else {
throw new RuntimeException("The thumb moved " +
"to the right instead of the left!");
}
}
private static void stopEDT() {
SwingUtilities.invokeLater(new Runnable() {
public void run() {
frame.dispose();
}
});
}
private static class ParameterTable extends JTable {
public ParameterTable() {
super(new Object[][]{{5}}, new String[]{"Value"});
getColumnModel().getColumn(0).setCellRenderer(new Renderer());
getColumnModel().getColumn(0).setCellEditor(new Editor());
}
}
private static class Renderer implements TableCellRenderer {
private JSlider slider = new JSlider(0, 10);
public Component getTableCellRendererComponent(JTable table,
Object value,
boolean isSelected,
boolean hasFocus,
int row, int col) {
int val = (Integer) value;
slider.setValue(val);
return slider;
}
}
private static class Editor extends AbstractCellEditor implements TableCellEditor {
private JSlider slider = new JSlider(0, 10);
public Component getTableCellEditorComponent(JTable table, Object value,
boolean isSelected,
int row, int col) {
int val = (Integer) value;
slider.setValue(val);
return slider;
}
public Editor() {
slider.addChangeListener(new ChangeListener() {
public void stateChanged(ChangeEvent e) {
if (!slider.getValueIsAdjusting()) {
passed = slider.getValue() <= 5;
}
}
});
}
public Object getCellEditorValue() {
return slider.getValue();
}
}
private static Rectangle getPanelRectangle() throws Exception{
final Rectangle[] result = new Rectangle[1];
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
result[0] = new Rectangle(panel.getLocationOnScreen(), panel.getSize());
}
});
return result[0];
}
}
/*
* Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* Portions Copyright (c) 2011 IBM Corporation
*/
/* @test
* @bug 7049024
* @summary DnD fails with JTextArea and JTextField
* @author Sean Chou
*/
import sun.awt.SunToolkit;
import javax.swing.*;
import javax.swing.text.DefaultCaret;
import java.awt.*;
import java.awt.datatransfer.Clipboard;
import java.awt.datatransfer.DataFlavor;
public class bug7049024 {
public static Clipboard clipboard = null;
public static JTextField textField = null;
// This button is used to move focus away from textField.
public static JButton button = null;
public static JFrame frame = null;
public static DefaultCaret caret = null;
public static void main(String[] args) throws Exception {
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame = new JFrame("Test");
textField = new JTextField("test selection for textfield");
button = new JButton("To compete the focus");
frame.setLayout(new FlowLayout());
frame.getContentPane().add(textField);
frame.getContentPane().add(button);
frame.pack();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setVisible(true);
}
});
toolkit.realSync();
clipboard = textField.getToolkit().getSystemSelection();
if (null == clipboard) {
return;
}
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
textField.requestFocusInWindow();
}
});
toolkit.realSync();
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
caret = (DefaultCaret) textField.getCaret();
caret.setDot(2);
caret.moveDot(4);
}
});
toolkit.realSync();
String oldSelection = (String) clipboard.getData(DataFlavor.stringFlavor);
System.out.println("oldSelection is " + oldSelection);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
button.requestFocusInWindow();
}
});
toolkit.realSync(); // So JTextField loses the focus.
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
caret.setDot(4);
caret.moveDot(6);
}
});
toolkit.realSync();
String newSelection = (String) clipboard.getData(DataFlavor.stringFlavor);
System.out.println("newSelection is " + newSelection);
boolean passed = newSelection.equals(oldSelection);
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
frame.dispose();
}
});
if (!passed) {
throw new RuntimeException("The test for bug 7049024 failed");
}
}
}
/*
* Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6256140
* @summary Esc key doesn't restore old value in JFormattedtextField when ToolTip is set
* @author Alexander Potochkin
* @run main Test6256140
*/
import sun.awt.SunToolkit;
import javax.swing.*;
import java.awt.*;
import java.awt.event.KeyEvent;
public class Test6256140 {
private static volatile JFormattedTextField ft;
private final static String initialText = "value";
private final static JLabel toolTipLabel = new JLabel("tip");
public static void main(String[] args) throws Exception {
Robot robot = new Robot();
robot.setAutoDelay(10);
SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit();
SwingUtilities.invokeAndWait(new Runnable() {
public void run() {
createAndShowGUI();
}
});
toolkit.realSync();
Point point = ft.getLocationOnScreen();
robot.mouseMove(point.x, point.y);
robot.mouseMove(point.x + 3, point.y + 3);
robot.keyPress(KeyEvent.VK_A);
robot.keyRelease(KeyEvent.VK_A);
toolkit.realSync();
if (!isTooltipShowning()) {
throw new RuntimeException("Tooltip is not shown");
}
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
toolkit.realSync();
if (isTooltipShowning()) {
throw new RuntimeException("Tooltip must be hidden now");
}
if (isTextEqual()) {
throw new RuntimeException("FormattedTextField must *not* cancel the updated value this time");
}
robot.keyPress(KeyEvent.VK_ESCAPE);
robot.keyRelease(KeyEvent.VK_ESCAPE);
toolkit.realSync();
if (!isTextEqual()) {
throw new RuntimeException("FormattedTextField must cancel the updated value");
}
}
private static boolean isTooltipShowning() throws Exception {
final boolean[] result = new boolean[1];
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
result[0] = toolTipLabel.isShowing();
}
});
return result[0];
}
private static boolean isTextEqual() throws Exception {
final boolean[] result = new boolean[1];
SwingUtilities.invokeAndWait(new Runnable() {
@Override
public void run() {
result[0] = initialText.equals(ft.getText());
}
});
return result[0];
}
private static void createAndShowGUI() {
ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE);
ToolTipManager.sharedInstance().setInitialDelay(0);
final JFrame frame = new JFrame();
frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
frame.setLayout(new FlowLayout());
ft = new JFormattedTextField() {
public JToolTip createToolTip() {
JToolTip toolTip = super.createToolTip();
toolTip.setLayout(new BorderLayout());
toolTip.add(toolTipLabel);
return toolTip;
}
};
ft.setToolTipText(" ");
ft.setValue(initialText);
frame.add(ft);
frame.pack();
frame.setLocationRelativeTo(null);
frame.setVisible(true);
ft.requestFocus();
}
}
/* /*
* @test * @test
* @build TestThread Traffic Handler ServerHandler ServerThread ClientThread * @build TestThread Traffic Handler ServerHandler ServerThread ClientThread
* @run main/othervm/timeout=140 main * @run main/othervm/timeout=140 -Djsse.enableCBCProtection=false main
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* @summary Make sure that different configurations of SSL sockets work * @summary Make sure that different configurations of SSL sockets work
*/ */
......
/* /*
* Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2003, 2011, 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,8 @@ ...@@ -29,6 +29,8 @@
* This is a simple hack to test a bunch of conditions and check * This is a simple hack to test a bunch of conditions and check
* their return codes. * their return codes.
* *
* @run main/othervm -Djsse.enableCBCProtection=false CheckStatus
*
* @author Brad Wetmore * @author Brad Wetmore
*/ */
......
/* /*
* Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2004, 2011, 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
...@@ -30,6 +30,8 @@ ...@@ -30,6 +30,8 @@
* This is to test larger buffer arrays, and make sure the maximum * This is to test larger buffer arrays, and make sure the maximum
* is being passed. * is being passed.
* *
* @run main/othervm -Djsse.enableCBCProtection=false LargeBufs
*
* @author Brad R. Wetmore * @author Brad R. Wetmore
*/ */
......
/* /*
* Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. * Copyright (c) 2006, 2011, 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
...@@ -27,10 +27,7 @@ ...@@ -27,10 +27,7 @@
* @bug 6388456 * @bug 6388456
* @summary Need adjustable TLS max record size for interoperability * @summary Need adjustable TLS max record size for interoperability
* with non-compliant * with non-compliant
* @run main/othervm LargePacket * @run main/othervm -Djsse.enableCBCProtection=false LargePacket
*
* SunJSSE does not support dynamic system properties, no way to re-use
* system properties in samevm/agentvm mode.
* *
* @author Xuelei Fan * @author Xuelei Fan
*/ */
......
/*
* Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved.
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
*
* This code is free software; you can redistribute it and/or modify it
* under the terms of the GNU General Public License version 2 only, as
* published by the Free Software Foundation.
*
* This code is distributed in the hope that it will be useful, but WITHOUT
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
* version 2 for more details (a copy is included in the LICENSE file that
* accompanied this code).
*
* You should have received a copy of the GNU General Public License version
* 2 along with this work; if not, write to the Free Software Foundation,
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
*
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
* or visit www.oracle.com if you need additional information or have any
* questions.
*/
/*
* @test
* @bug 6755060
* @summary updating collation tables for thai to make it consistent with CLDR 1.9
*/
import java.text.*;
import java.util.*;
public class Bug6755060 {
/********************************************************
*********************************************************/
public static void main (String[] args) {
Locale reservedLocale = Locale.getDefault();
try{
int errors=0;
Locale loc = new Locale ("th", "TH"); // Thai
Locale.setDefault (loc);
Collator col = Collator.getInstance ();
/*
* The original data "data" are the data to be sorted provided by the submitter of the CR.
* It's in correct order in accord with thai collation in CLDR 1.9. If we use old Java without this fix,
* the output order will be incorrect. Correct order will be turned into incorrect order.
* If fix is there, "data" after sorting will be unchanged, same as "sortedData". If fix is lost (regression),
* "data" after sorting will be changed, not as "sortedData".(not correct anymore)
* The submitter of the CR also gives a expected "sortedData" in the CR, but it's in accord with collation in CLDR 1.4.
* His data to be sorted are actually well sorted in accord with CLDR 1.9.
*/
String[] data = {"\u0e01", "\u0e01\u0e2f", "\u0e01\u0e46", "\u0e01\u0e4f", "\u0e01\u0e5a", "\u0e01\u0e5b", "\u0e01\u0e4e", "\u0e01\u0e4c", "\u0e01\u0e48", "\u0e01\u0e01", "\u0e01\u0e4b\u0e01", "\u0e01\u0e4d", "\u0e01\u0e30", "\u0e01\u0e31\u0e01", "\u0e01\u0e32", "\u0e01\u0e33", "\u0e01\u0e34", "\u0e01\u0e35", "\u0e01\u0e36", "\u0e01\u0e37", "\u0e01\u0e38", "\u0e01\u0e39", "\u0e40\u0e01", "\u0e40\u0e01\u0e48", "\u0e40\u0e01\u0e49", "\u0e40\u0e01\u0e4b", "\u0e41\u0e01", "\u0e42\u0e01", "\u0e43\u0e01", "\u0e44\u0e01", "\u0e01\u0e3a", "\u0e24\u0e32", "\u0e24\u0e45", "\u0e40\u0e25", "\u0e44\u0e26"};
String[] sortedData = {"\u0e01", "\u0e01\u0e2f", "\u0e01\u0e46", "\u0e01\u0e4f", "\u0e01\u0e5a", "\u0e01\u0e5b", "\u0e01\u0e4e", "\u0e01\u0e4c", "\u0e01\u0e48", "\u0e01\u0e01", "\u0e01\u0e4b\u0e01", "\u0e01\u0e4d", "\u0e01\u0e30", "\u0e01\u0e31\u0e01", "\u0e01\u0e32", "\u0e01\u0e33", "\u0e01\u0e34", "\u0e01\u0e35", "\u0e01\u0e36", "\u0e01\u0e37", "\u0e01\u0e38", "\u0e01\u0e39", "\u0e40\u0e01", "\u0e40\u0e01\u0e48", "\u0e40\u0e01\u0e49", "\u0e40\u0e01\u0e4b", "\u0e41\u0e01", "\u0e42\u0e01", "\u0e43\u0e01", "\u0e44\u0e01", "\u0e01\u0e3a", "\u0e24\u0e32", "\u0e24\u0e45", "\u0e40\u0e25", "\u0e44\u0e26"};
Arrays.sort (data, col);
System.out.println ("Using " + loc.getDisplayName());
for (int i = 0; i < data.length; i++) {
System.out.println(data[i] + " : " + sortedData[i]);
if (sortedData[i].compareTo(data[i]) != 0) {
errors++;
}
}//end for
if (errors > 0){
StringBuffer expected = new StringBuffer(), actual = new StringBuffer();
expected.append(sortedData[0]);
actual.append(data[0]);
for (int i=1; i<data.length; i++) {
expected.append(",");
expected.append(sortedData[i]);
actual.append(",");
actual.append(data[i]);
}
String errmsg = "Error is found in collation testing in Thai\n" + "exepected order is: " + expected.toString() + "\n" + "actual order is: " + actual.toString() + "\n";
throw new RuntimeException(errmsg);
}
}finally{
// restore the reserved locale
Locale.setDefault(reservedLocale);
}
}//end main
}//end class CollatorTest
...@@ -7006,3 +7006,7 @@ CurrencyNames/zh_CN/zwl=\u6d25\u5df4\u5e03\u97e6\u5143 (2009) ...@@ -7006,3 +7006,7 @@ CurrencyNames/zh_CN/zwl=\u6d25\u5df4\u5e03\u97e6\u5143 (2009)
CurrencyNames/zh_TW/cuc=\u53e4\u5df4\u53ef\u8f49\u63db\u62ab\u7d22 CurrencyNames/zh_TW/cuc=\u53e4\u5df4\u53ef\u8f49\u63db\u62ab\u7d22
CurrencyNames/zh_TW/tmt=\u571f\u5eab\u66fc\u65b0\u99ac\u7d0d\u7279 CurrencyNames/zh_TW/tmt=\u571f\u5eab\u66fc\u65b0\u99ac\u7d0d\u7279
CurrencyNames/zh_TW/zwl=\u8f9b\u5df4\u5a01\u5143 (2009) CurrencyNames/zh_TW/zwl=\u8f9b\u5df4\u5a01\u5143 (2009)
# bug 7101495
CalendarData/lv/firstDayOfWeek=2
CalendarData/lv/minimalDaysInFirstWeek=4
...@@ -33,7 +33,7 @@ ...@@ -33,7 +33,7 @@
* 6379214 6485516 6486607 4225362 4494727 6533691 6531591 6531593 6570259 * 6379214 6485516 6486607 4225362 4494727 6533691 6531591 6531593 6570259
* 6509039 6609737 6610748 6645271 6507067 6873931 6450945 6645268 6646611 * 6509039 6609737 6610748 6645271 6507067 6873931 6450945 6645268 6646611
* 6645405 6650730 6910489 6573250 6870908 6585666 6716626 6914413 6916787 * 6645405 6650730 6910489 6573250 6870908 6585666 6716626 6914413 6916787
* 6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 * 6919624 6998391 7019267 7020960 7025837 7020583 7036905 7066203 7101495
* @summary Verify locale data * @summary Verify locale data
* *
*/ */
......
...@@ -22,7 +22,7 @@ ...@@ -22,7 +22,7 @@
# #
# @test # @test
# @bug 4990825 # @bug 4990825 7092186
# @run shell/timeout=90 jstatdExternalRegistry.sh # @run shell/timeout=90 jstatdExternalRegistry.sh
# @summary Test functionality of 'jstatd -p<port>&' with an external RMI registry # @summary Test functionality of 'jstatd -p<port>&' with an external RMI registry
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册