diff options
-rw-r--r-- | HOWTO | 4 | ||||
-rw-r--r-- | openjdk/allsources.lst | 27 | ||||
-rw-r--r-- | openjdk/java/lang/Class.java | 5 | ||||
-rw-r--r-- | openjdk/java/nio/Bits.java | 12 | ||||
-rw-r--r-- | openjdk/java/util/TimeZone.java | 6 | ||||
-rw-r--r-- | openjdk/openjdk.build | 2 | ||||
-rw-r--r-- | openjdk/response.txt | 6 | ||||
-rw-r--r-- | openjdk/sun/awt/AppContext.java | 182 | ||||
-rw-r--r-- | openjdk/sun/awt/AppContextDC.java | 45 | ||||
-rw-r--r-- | openjdk/sun/awt/SunToolkit.java | 684 | ||||
-rw-r--r-- | openjdk/sun/misc/SharedSecrets.java | 11 | ||||
-rw-r--r-- | runtime/openjdk.cs | 6 | ||||
-rw-r--r-- | runtime/openjdk/sun.security.krb5.cs | 12 | ||||
-rw-r--r-- | runtime/vfs.cs | 1 |
14 files changed, 441 insertions, 562 deletions
@@ -1,11 +1,11 @@ IKVM.NET Build Instructions --------------------------- -This IKVM.NET source bundle requires OpenJDK 7 b147 sources (and build artifacts). +This IKVM.NET source bundle requires OpenJDK 7u4 b22 sources (and build artifacts). They can be downloaded from the SourceForge IKVM project, or from: -http://www.frijters.net/openjdk7-b147-stripped.zip +http://www.frijters.net/openjdk-7u4-stripped.zip This file should be unzipped in the same directory as where the ikvm directory (that contains this unzipped source bundle) lives. diff --git a/openjdk/allsources.lst b/openjdk/allsources.lst index a8198c3c..b7305755 100644 --- a/openjdk/allsources.lst +++ b/openjdk/allsources.lst @@ -129,6 +129,7 @@ java/sql/DriverManager.java java/util/concurrent/locks/AbstractQueuedSynchronizer.java java/util/concurrent/locks/LockSupport.java java/util/ResourceBundle.java +java/util/TimeZone.java java/util/zip/Adler32.java java/util/zip/CRC32.java java/util/zip/Deflater.java @@ -145,6 +146,7 @@ java/util/zip/StreamManipulator.java java/util/zip/ZipEntry.java java/util/zip/ZipFile.java sun/awt/AppContext.java +sun/awt/AppContextDC.java sun/awt/EmbeddedFrame.java sun/awt/IkvmDataTransferer.java sun/awt/image/ByteComponentRaster.java @@ -814,6 +816,7 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/build/linux-amd64/gensrc/sun/util/resources/CurrencyNames_es_CL.java @OPENJDK7@/build/linux-amd64/gensrc/sun/util/resources/CurrencyNames_es_CO.java @OPENJDK7@/build/linux-amd64/gensrc/sun/util/resources/CurrencyNames_es_CR.java +@OPENJDK7@/build/linux-amd64/gensrc/sun/util/resources/CurrencyNames_es_CU.java @OPENJDK7@/build/linux-amd64/gensrc/sun/util/resources/CurrencyNames_es_DO.java @OPENJDK7@/build/linux-amd64/gensrc/sun/util/resources/CurrencyNames_es_EC.java @OPENJDK7@/build/linux-amd64/gensrc/sun/util/resources/CurrencyNames_es_ES.java @@ -2227,7 +2230,12 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_CN.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/res/XSLTErrorResources_zh_TW.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/templates/Constants.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/utils/ConfigurationError.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/utils/FactoryImpl.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/utils/ObjectFactory.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/utils/SecuritySupport.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/Version.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/XalanConstants.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xslt/EnvironmentCheck.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xslt/ObjectFactory.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xslt/Process.java @@ -2380,7 +2388,9 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages_zh_TW.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/FilterGenerator.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/InternalError.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/IntType.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MarkerInstruction.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MatchGenerator.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodGenerator.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/MethodType.java @@ -2394,6 +2404,8 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/NumberType.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ObjectFactory.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ObjectType.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/OutlineableChunkEnd.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/OutlineableChunkStart.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/RealType.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ReferenceType.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ResultTreeType.java @@ -2425,6 +2437,7 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/dom/AbsoluteIterator.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/dom/AdaptiveResultTreeImpl.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/dom/AnyNodeCounter.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/dom/ArrayNodeListIterator.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/dom/BitArray.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/dom/CachedNodeListIterator.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/dom/ClonedNodeListIterator.java @@ -2489,6 +2502,7 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_zh_CN.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/runtime/ErrorMessages_zh_TW.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/runtime/Hashtable.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/runtime/InternalRuntimeError.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/runtime/MessageHandler.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/runtime/Node.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/xsltc/runtime/ObjectFactory.java @@ -2953,6 +2967,9 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/util/XMLResourceIdentifierImpl.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/util/XMLStringBuffer.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/util/XMLSymbols.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/utils/ConfigurationError.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/utils/ObjectFactory.java +@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/utils/SecuritySupport.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/xinclude/MultipleScopeNamespaceSupport.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/xinclude/ObjectFactory.java @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/xinclude/SecuritySupport.java @@ -8798,6 +8815,7 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/jdk/src/share/classes/java/beans/SimpleBeanInfo.java @OPENJDK7@/jdk/src/share/classes/java/beans/Statement.java @OPENJDK7@/jdk/src/share/classes/java/beans/Transient.java +@OPENJDK7@/jdk/src/share/classes/java/beans/ThreadGroupContext.java @OPENJDK7@/jdk/src/share/classes/java/beans/VetoableChangeListener.java @OPENJDK7@/jdk/src/share/classes/java/beans/VetoableChangeListenerProxy.java @OPENJDK7@/jdk/src/share/classes/java/beans/VetoableChangeSupport.java @@ -9794,7 +9812,6 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/jdk/src/share/classes/java/util/StringTokenizer.java @OPENJDK7@/jdk/src/share/classes/java/util/Timer.java @OPENJDK7@/jdk/src/share/classes/java/util/TimerTask.java -@OPENJDK7@/jdk/src/share/classes/java/util/TimeZone.java @OPENJDK7@/jdk/src/share/classes/java/util/TimSort.java @OPENJDK7@/jdk/src/share/classes/java/util/TooManyListenersException.java @OPENJDK7@/jdk/src/share/classes/java/util/TreeMap.java @@ -11998,10 +12015,12 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/jdk/src/share/classes/sun/misc/JavaIOFileDescriptorAccess.java @OPENJDK7@/jdk/src/share/classes/sun/misc/JavaLangAccess.java @OPENJDK7@/jdk/src/share/classes/sun/misc/JavaNetAccess.java +@OPENJDK7@/jdk/src/share/classes/sun/misc/JavaNetHttpCookieAccess.java @OPENJDK7@/jdk/src/share/classes/sun/misc/JavaNioAccess.java @OPENJDK7@/jdk/src/share/classes/sun/misc/JavaSecurityAccess.java @OPENJDK7@/jdk/src/share/classes/sun/misc/JavaSecurityProtectionDomainAccess.java @OPENJDK7@/jdk/src/share/classes/sun/misc/JavaUtilJarAccess.java +@OPENJDK7@/jdk/src/share/classes/sun/misc/JavaUtilZipAccess.java @OPENJDK7@/jdk/src/share/classes/sun/misc/JavaxSecurityAuthKerberosAccess.java @OPENJDK7@/jdk/src/share/classes/sun/misc/Launcher.java @OPENJDK7@/jdk/src/share/classes/sun/misc/Lock.java @@ -12699,6 +12718,7 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/jdk/src/share/classes/sun/security/krb5/PrincipalName.java @OPENJDK7@/jdk/src/share/classes/sun/security/krb5/Realm.java @OPENJDK7@/jdk/src/share/classes/sun/security/krb5/RealmException.java +@OPENJDK7@/jdk/src/share/classes/sun/security/krb5/SCDynamicStoreConfig.java @OPENJDK7@/jdk/src/share/classes/sun/security/krb5/ServiceName.java @OPENJDK7@/jdk/src/share/classes/sun/security/pkcs/ContentInfo.java @OPENJDK7@/jdk/src/share/classes/sun/security/pkcs/EncodingException.java @@ -12750,6 +12770,7 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/jdk/src/share/classes/sun/security/provider/certpath/SunCertPathBuilderException.java @OPENJDK7@/jdk/src/share/classes/sun/security/provider/certpath/SunCertPathBuilderParameters.java @OPENJDK7@/jdk/src/share/classes/sun/security/provider/certpath/SunCertPathBuilderResult.java +@OPENJDK7@/jdk/src/share/classes/sun/security/provider/certpath/UntrustedChecker.java @OPENJDK7@/jdk/src/share/classes/sun/security/provider/certpath/URICertStore.java @OPENJDK7@/jdk/src/share/classes/sun/security/provider/certpath/Vertex.java @OPENJDK7@/jdk/src/share/classes/sun/security/provider/certpath/X509CertificatePair.java @@ -12888,6 +12909,8 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/jdk/src/share/classes/sun/security/util/DerValue.java @OPENJDK7@/jdk/src/share/classes/sun/security/util/DisabledAlgorithmConstraints.java @OPENJDK7@/jdk/src/share/classes/sun/security/util/HostnameChecker.java +@OPENJDK7@/jdk/src/share/classes/sun/security/util/KeyLength.java +@OPENJDK7@/jdk/src/share/classes/sun/security/util/Length.java @OPENJDK7@/jdk/src/share/classes/sun/security/util/ManifestDigester.java @OPENJDK7@/jdk/src/share/classes/sun/security/util/ManifestEntryVerifier.java @OPENJDK7@/jdk/src/share/classes/sun/security/util/ObjectIdentifier.java @@ -12911,6 +12934,7 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/jdk/src/share/classes/sun/security/util/ResourcesMgr.java @OPENJDK7@/jdk/src/share/classes/sun/security/util/SecurityConstants.java @OPENJDK7@/jdk/src/share/classes/sun/security/util/SignatureFileVerifier.java +@OPENJDK7@/jdk/src/share/classes/sun/security/util/UntrustedCertificates.java @OPENJDK7@/jdk/src/share/classes/sun/security/validator/EndEntityChecker.java @OPENJDK7@/jdk/src/share/classes/sun/security/validator/KeyStores.java @OPENJDK7@/jdk/src/share/classes/sun/security/validator/PKIXValidator.java @@ -13542,6 +13566,7 @@ sun/security/jgss/wrapper/SunNativeProvider.java @OPENJDK7@/jdk/src/windows/classes/java/io/Win32FileSystem.java @OPENJDK7@/jdk/src/windows/classes/java/lang/ProcessEnvironment.java @OPENJDK7@/jdk/src/windows/classes/java/lang/Terminator.java +@OPENJDK7@/jdk/src/windows/classes/java/net/DefaultInterface.java @OPENJDK7@/jdk/src/windows/classes/java/util/prefs/WindowsPreferences.java @OPENJDK7@/jdk/src/windows/classes/java/util/prefs/WindowsPreferencesFactory.java @OPENJDK7@/jdk/src/windows/classes/sun/awt/Win32ColorModel24.java diff --git a/openjdk/java/lang/Class.java b/openjdk/java/lang/Class.java index a3d083e0..20f35534 100644 --- a/openjdk/java/lang/Class.java +++ b/openjdk/java/lang/Class.java @@ -3237,4 +3237,9 @@ public final AnnotationType getAnnotationType() { return annotationType; } + + /* Backing store of user-defined values pertaining to this class. + * Maintained by the ClassValue class. + */ + transient ClassValue.ClassValueMap classValueMap; } diff --git a/openjdk/java/nio/Bits.java b/openjdk/java/nio/Bits.java index fc32811c..cea374fc 100644 --- a/openjdk/java/nio/Bits.java +++ b/openjdk/java/nio/Bits.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2012, 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 @@ -638,7 +638,7 @@ class Bits { // package-private String arch = AccessController.doPrivileged( new sun.security.action.GetPropertyAction("os.arch")); unaligned = arch.equals("i386") || arch.equals("x86") - || arch.equals("amd64"); + || arch.equals("amd64") || arch.equals("x86_64"); unalignedKnown = true; return unaligned; } @@ -728,6 +728,14 @@ class Bits { // package-private } }; } + @Override + public ByteBuffer newDirectByteBuffer(long addr, int cap, Object ob) { + return new DirectByteBuffer(addr, cap, ob); + } + @Override + public void truncate(Buffer buf) { + buf.truncate(); + } }); } diff --git a/openjdk/java/util/TimeZone.java b/openjdk/java/util/TimeZone.java index b22a7a38..e3b7cbd5 100644 --- a/openjdk/java/util/TimeZone.java +++ b/openjdk/java/util/TimeZone.java @@ -43,7 +43,7 @@ import java.lang.ref.SoftReference; import java.security.AccessController; import java.security.PrivilegedAction; import java.util.concurrent.ConcurrentHashMap; -import sun.awt.AppContext; +import sun.awt.AppContextDC; import sun.security.action.GetPropertyAction; import sun.util.TimeZoneNameUtility; import sun.util.calendar.ZoneInfo; @@ -724,7 +724,7 @@ abstract public class TimeZone implements Serializable, Cloneable { return null; } - AppContext ac = AppContext.getAppContext(); + AppContextDC ac = AppContextDC.getAppContext(); if (ac != null && !ac.isDisposed()) { return (TimeZone) ac.get(TimeZone.class); } @@ -742,7 +742,7 @@ abstract public class TimeZone implements Serializable, Cloneable { return; } - AppContext ac = AppContext.getAppContext(); + AppContextDC ac = AppContextDC.getAppContext(); if (ac != null && !ac.isDisposed()) { if (tz != null) { ac.put(TimeZone.class, tz); diff --git a/openjdk/openjdk.build b/openjdk/openjdk.build index dbe2f0d4..18b4f9e6 100644 --- a/openjdk/openjdk.build +++ b/openjdk/openjdk.build @@ -3,7 +3,7 @@ <include buildfile="../ikvm.include" /> <property name="pathsep" value=":" /> <property overwrite="false" name="signoption" value="" /> - <property name="OpenJDK7.dir" value="${project::get-base-directory()}/../../openjdk7-b147" /> + <property name="OpenJDK7.dir" value="${project::get-base-directory()}/../../openjdk-7u4-b22" /> <if test="${platform::is-win32()}"> <property name="pathsep" value=";" /> </if> diff --git a/openjdk/response.txt b/openjdk/response.txt index ef6b8095..e5121637 100644 --- a/openjdk/response.txt +++ b/openjdk/response.txt @@ -1,5 +1,5 @@ # -# Copyright (C) 2002-2011 Jeroen Frijters +# Copyright (C) 2002-2012 Jeroen Frijters # # This software is provided 'as-is', without any express or implied # warranty. In no event will the authors be held liable for any damages @@ -45,6 +45,7 @@ assembly.class java/util/*.class java/util/concurrent/locks/*.class gnu/java/util/*.class + sun/awt/AppContextDC.class sun/misc/*.class sun/net/sdp/*.class sun/net/www/protocol/file/*.class @@ -162,6 +163,7 @@ assembly.class @OPENJDK7@/jdk/src/solaris/classes/sun/net/www/protocol/http/ntlm/*.class @OPENJDK7@/jdk/src/windows/classes/java/io/*.class @OPENJDK7@/jdk/src/windows/classes/java/lang/*.class + @OPENJDK7@/jdk/src/windows/classes/java/net/DefaultInterface.class @OPENJDK7@/jdk/src/windows/classes/sun/net/*.class @OPENJDK7@/jdk/src/windows/classes/sun/nio/ch/*.class @OPENJDK7@/jdk/src/windows/classes/sun/nio/fs/*.class @@ -349,6 +351,7 @@ assembly.class -resource:com/sun/org/apache/xml/internal/serialize/HTMLEntities.res=@OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xml/internal/serialize/HTMLEntities.res -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/org/apache/xerces/* -recurse:@OPENJDK7@/build/linux-amd64/j2re-image/lib/resources.jar/com/sun/org/apache/xml/internal/serializer/* + @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xalan/internal/utils/*.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/dom/*.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/dom/events/*.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/impl/*.class @@ -374,6 +377,7 @@ assembly.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/jaxp/validation/*.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/parsers/*.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/util/*.class + @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/utils/*.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/xinclude/*.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/xni/*.class @OPENJDK7@/build/linux-amd64/impsrc/com/sun/org/apache/xerces/internal/xni/grammars/*.class diff --git a/openjdk/sun/awt/AppContext.java b/openjdk/sun/awt/AppContext.java index cff72134..be6734e4 100644 --- a/openjdk/sun/awt/AppContext.java +++ b/openjdk/sun/awt/AppContext.java @@ -27,8 +27,8 @@ package sun.awt; import java.awt.EventQueue; import java.awt.Window; -//import java.awt.SystemTray; -//import java.awt.TrayIcon; +import java.awt.SystemTray; +import java.awt.TrayIcon; import java.awt.Toolkit; import java.awt.GraphicsEnvironment; import java.awt.event.InvocationEvent; @@ -42,6 +42,7 @@ import java.util.Set; import java.util.HashSet; import java.beans.PropertyChangeSupport; import java.beans.PropertyChangeListener; +import sun.util.logging.PlatformLogger; import java.util.concurrent.locks.Condition; import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; @@ -128,12 +129,14 @@ import java.util.concurrent.locks.ReentrantLock; * @author Thomas Ball * @author Fred Ecks */ -public final class AppContext { +public final class AppContext extends AppContextDC { + private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.AppContext"); /* Since the contents of an AppContext are unique to each Java * session, this class should never be serialized. */ - /* The key to put()/get() the Java EventQueue into/from the AppContext. + /* + * The key to put()/get() the Java EventQueue into/from the AppContext. */ public static final Object EVENT_QUEUE_KEY = new StringBuffer("EventQueue"); @@ -152,7 +155,9 @@ public final class AppContext { * Returns a set containing all <code>AppContext</code>s. */ public static Set<AppContext> getAppContexts() { - return new HashSet<AppContext>(threadGroup2appContext.values()); + synchronized (threadGroup2appContext) { + return new HashSet<AppContext>(threadGroup2appContext.values()); + } } /* The main "system" AppContext, used by everything not otherwise @@ -194,19 +199,19 @@ public final class AppContext { // AppContext, and instantiate the Java EventQueue. This way, legacy // code is unaffected by the move to multiple AppContext ability. AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - ThreadGroup currentThreadGroup = - Thread.currentThread().getThreadGroup(); - ThreadGroup parentThreadGroup = currentThreadGroup.getParent(); - while (parentThreadGroup != null) { - // Find the root ThreadGroup to construct our main AppContext - currentThreadGroup = parentThreadGroup; - parentThreadGroup = currentThreadGroup.getParent(); + public Object run() { + ThreadGroup currentThreadGroup = + Thread.currentThread().getThreadGroup(); + ThreadGroup parentThreadGroup = currentThreadGroup.getParent(); + while (parentThreadGroup != null) { + // Find the root ThreadGroup to construct our main AppContext + currentThreadGroup = parentThreadGroup; + parentThreadGroup = currentThreadGroup.getParent(); + } + mainAppContext = new AppContext(currentThreadGroup); + numAppContexts = 1; + return mainAppContext; } - mainAppContext = new AppContext(currentThreadGroup); - numAppContexts = 1; - return mainAppContext; - } }); } @@ -244,8 +249,8 @@ public final class AppContext { threadGroup2appContext.put(threadGroup, this); this.contextClassLoader = - (ClassLoader) AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { + AccessController.doPrivileged(new PrivilegedAction<ClassLoader>() { + public ClassLoader run() { return Thread.currentThread().getContextClassLoader(); } }); @@ -258,7 +263,8 @@ public final class AppContext { put(EVENT_QUEUE_COND_KEY, eventQueuePushPopCond); } - private static MostRecentThreadAppContext mostRecentThreadAppContext = null; + private static final ThreadLocal<AppContext> threadAppContext = + new ThreadLocal<AppContext>(); /** * Returns the appropriate AppContext for the caller, @@ -275,59 +281,46 @@ public final class AppContext { if (numAppContexts == 1) // If there's only one system-wide, return mainAppContext; // return the main system AppContext. - final Thread currentThread = Thread.currentThread(); - - AppContext appContext = null; - - // Note: this most recent Thread/AppContext caching is thread-hot. - // A simple test using SwingSet found that 96.8% of lookups - // were matched using the most recent Thread/AppContext. By - // instantiating a simple MostRecentThreadAppContext object on - // cache misses, the cache hits can be processed without - // synchronization. + AppContext appContext = threadAppContext.get(); + + if (null == appContext) { + appContext = AccessController.doPrivileged(new PrivilegedAction<AppContext>() + { + public AppContext run() { + // Get the current ThreadGroup, and look for it and its + // parents in the hash from ThreadGroup to AppContext -- + // it should be found, because we use createNewContext() + // when new AppContext objects are created. + ThreadGroup currentThreadGroup = Thread.currentThread().getThreadGroup(); + ThreadGroup threadGroup = currentThreadGroup; + AppContext context = threadGroup2appContext.get(threadGroup); + while (context == null) { + threadGroup = threadGroup.getParent(); + if (threadGroup == null) { + // If we get here, we're running under a ThreadGroup that + // has no AppContext associated with it. This should never + // happen, because createNewContext() should be used by the + // toolkit to create the ThreadGroup that everything runs + // under. + throw new RuntimeException("Invalid ThreadGroup"); + } + context = threadGroup2appContext.get(threadGroup); + } + // In case we did anything in the above while loop, we add + // all the intermediate ThreadGroups to threadGroup2appContext + // so we won't spin again. + for (ThreadGroup tg = currentThreadGroup; tg != threadGroup; tg = tg.getParent()) { + threadGroup2appContext.put(tg, context); + } + // Now we're done, so we cache the latest key/value pair. + // (we do this before checking with any AWTSecurityManager, so if + // this Thread equates with the main AppContext in the cache, it + // still will) + threadAppContext.set(context); - MostRecentThreadAppContext recent = mostRecentThreadAppContext; - if ((recent != null) && (recent.thread == currentThread)) { - appContext = recent.appContext; // Cache hit - } else { - appContext = (AppContext)AccessController.doPrivileged( - new PrivilegedAction() { - public Object run() { - // Get the current ThreadGroup, and look for it and its - // parents in the hash from ThreadGroup to AppContext -- - // it should be found, because we use createNewContext() - // when new AppContext objects are created. - ThreadGroup currentThreadGroup = currentThread.getThreadGroup(); - ThreadGroup threadGroup = currentThreadGroup; - AppContext context = threadGroup2appContext.get(threadGroup); - while (context == null) { - threadGroup = threadGroup.getParent(); - if (threadGroup == null) { - // If we get here, we're running under a ThreadGroup that - // has no AppContext associated with it. This should never - // happen, because createNewContext() should be used by the - // toolkit to create the ThreadGroup that everything runs - // under. - throw new RuntimeException("Invalid ThreadGroup"); + return context; } - context = threadGroup2appContext.get(threadGroup); - } - // In case we did anything in the above while loop, we add - // all the intermediate ThreadGroups to threadGroup2appContext - // so we won't spin again. - for (ThreadGroup tg = currentThreadGroup; tg != threadGroup; tg = tg.getParent()) { - threadGroup2appContext.put(tg, context); - } - // Now we're done, so we cache the latest key/value pair. - // (we do this before checking with any AWTSecurityManager, so if - // this Thread equates with the main AppContext in the cache, it - // still will) - mostRecentThreadAppContext = - new MostRecentThreadAppContext(currentThread, context); - - return context; - } - }); + }); } if (appContext == mainAppContext) { @@ -336,9 +329,9 @@ public final class AppContext { // allow it to choose the AppContext to return. SecurityManager securityManager = System.getSecurityManager(); if ((securityManager != null) && - (securityManager instanceof AWTSecurityManager)) { - AWTSecurityManager awtSecMgr = - (AWTSecurityManager)securityManager; + (securityManager instanceof AWTSecurityManager)) + { + AWTSecurityManager awtSecMgr = (AWTSecurityManager)securityManager; AppContext secAppContext = awtSecMgr.getAppContext(); if (secAppContext != null) { appContext = secAppContext; // Return what we're told @@ -349,6 +342,16 @@ public final class AppContext { return appContext; } + /** + * Returns the main ("system") AppContext. + * + * @return the main AppContext + * @since 1.8 + */ + final static AppContext getMainAppContext() { + return mainAppContext; + } + private long DISPOSAL_TIMEOUT = 5000; // Default to 5-second timeout // for disposal of all Frames // (we wait for this time twice, @@ -398,23 +401,6 @@ public final class AppContext { Runnable runnable = new Runnable() { public void run() { -// Window[] windowsToDispose = Window.getOwnerlessWindows(); -// for (Window w : windowsToDispose) { -// w.dispose(); -// } -// AccessController.doPrivileged(new PrivilegedAction() { -// public Object run() { -// if (!GraphicsEnvironment.isHeadless() && SystemTray.isSupported()) -// { -// SystemTray systemTray = SystemTray.getSystemTray(); -// TrayIcon[] trayIconsToDispose = systemTray.getTrayIcons(); -// for (TrayIcon ti : trayIconsToDispose) { -// systemTray.remove(ti); -// } -// } -// return null; -// } -// }); // Alert PropertyChangeListeners that the GUI has been disposed. if (changeSupport != null) { changeSupport.firePropertyChange(GUI_DISPOSED, false, true); @@ -493,10 +479,7 @@ public final class AppContext { } threadGroup2appContext.remove(this.threadGroup); - MostRecentThreadAppContext recent = mostRecentThreadAppContext; - if ((recent != null) && (recent.appContext == this)) - mostRecentThreadAppContext = null; - // If the "most recent" points to this, clear it for GC + threadAppContext.set(null); // Finally, we destroy the ThreadGroup entirely. try { @@ -785,15 +768,6 @@ public final class AppContext { } } -final class MostRecentThreadAppContext { - final Thread thread; - final AppContext appContext; - MostRecentThreadAppContext(Thread key, AppContext value) { - thread = key; - appContext = value; - } -} - final class MostRecentKeyValue { Object key; Object value; diff --git a/openjdk/sun/awt/AppContextDC.java b/openjdk/sun/awt/AppContextDC.java new file mode 100644 index 00000000..47e71d62 --- /dev/null +++ b/openjdk/sun/awt/AppContextDC.java @@ -0,0 +1,45 @@ +/* + Copyright (C) 2012 Jeroen Frijters + + This software is provided 'as-is', without any express or implied + warranty. In no event will the authors be held liable for any damages + arising from the use of this software. + + Permission is granted to anyone to use this software for any purpose, + including commercial applications, and to alter it and redistribute it + freely, subject to the following restrictions: + + 1. The origin of this software must not be misrepresented; you must not + claim that you wrote the original software. If you use this software + in a product, an acknowledgment in the product documentation would be + appreciated but is not required. + 2. Altered source versions must be plainly marked as such, and must not be + misrepresented as being the original software. + 3. This notice may not be removed or altered from any source distribution. + + Jeroen Frijters + jeroen@frijters.net + +*/ +package sun.awt; + +/* This class exists to decouple java.util.TimeZone from sun.awt.AppContext */ +public abstract class AppContextDC +{ + public abstract boolean isDisposed(); + public abstract Object get(Object key); + public abstract Object put(Object key, Object value); + public abstract Object remove(Object key); + + public static AppContextDC getAppContext() + { + try + { + return (AppContextDC)Class.forName("sun.awt.AppContext").getMethod("getAppContext").invoke(null); + } + catch (Exception _) + { + return null; + } + } +} diff --git a/openjdk/sun/awt/SunToolkit.java b/openjdk/sun/awt/SunToolkit.java index df32417e..fa457d53 100644 --- a/openjdk/sun/awt/SunToolkit.java +++ b/openjdk/sun/awt/SunToolkit.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -32,24 +32,25 @@ import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.peer.*; import java.awt.event.WindowEvent; import java.awt.event.KeyEvent; -import java.awt.im.spi.InputMethodDescriptor; import java.awt.image.*; -import java.awt.geom.AffineTransform; -import java.io.*; +import java.awt.TrayIcon; +import java.awt.SystemTray; +import java.awt.event.InputEvent; import java.net.URL; -import java.net.JarURLConnection; import java.util.*; import java.util.concurrent.TimeUnit; import java.util.concurrent.locks.Condition; +import java.util.concurrent.locks.Lock; import java.util.concurrent.locks.ReentrantLock; -import java.util.logging.Level; -import java.util.logging.Logger; + +import sun.security.util.SecurityConstants; +import sun.util.logging.PlatformLogger; import sun.misc.SoftCache; +import sun.font.FontDesignMetrics; +import sun.awt.im.InputContext; import sun.awt.image.*; import sun.security.action.GetPropertyAction; import sun.security.action.GetBooleanAction; -import sun.util.logging.PlatformLogger; - import java.lang.reflect.Field; import java.lang.reflect.Method; import java.lang.reflect.Constructor; @@ -59,20 +60,11 @@ import java.security.PrivilegedAction; import java.security.PrivilegedActionException; import java.security.PrivilegedExceptionAction; - public abstract class SunToolkit extends Toolkit implements WindowClosingSupport, WindowClosingListener, - ComponentFactory, InputMethodSupport { - - private static final Logger log = Logger.getLogger("sun.awt.SunToolkit"); + ComponentFactory, InputMethodSupport, KeyboardFocusManagerPeerProvider { - /* Load debug settings for native code */ -// static { -// String nativeDebug = System.getProperty("sun.awt.nativedebug"); -// if ("true".equalsIgnoreCase(nativeDebug)) { -// DebugSettings.init(); -// } -// }; + private static final PlatformLogger log = PlatformLogger.getLogger("sun.awt.SunToolkit"); /** * Special mask for the UngrabEvent events, in addition to the @@ -81,72 +73,52 @@ public abstract class SunToolkit extends Toolkit */ public static final int GRAB_EVENT_MASK = 0x80000000; - private static Field syncLWRequestsField; private static Method wakeupMethod; - private static Field componentKeyField; - private static Field menuComponentKeyField; - private static Field trayIconKeyField; - private static Field componentAppContextField; - private static Field menuComponentAppContextField; - private static Field isPostedField; /* The key to put()/get() the PostEventQueue into/from the AppContext. */ private static final String POST_EVENT_QUEUE_KEY = "PostEventQueue"; - public SunToolkit() { - /* If awt.threadgroup is set to class name the instance of - * this class is created (should be subclass of ThreadGroup) - * and EventDispatchThread is created inside of it - * - * If loaded class overrides uncaughtException instance - * handles all uncaught exception on EventDispatchThread - */ - ThreadGroup threadGroup = null; - String tgName = System.getProperty("awt.threadgroup", ""); - - if (tgName.length() != 0) { - try { - Constructor ctor = Class.forName(tgName). - getConstructor(new Class[] {String.class}); - threadGroup = (ThreadGroup)ctor.newInstance(new Object[] {"AWT-ThreadGroup"}); - } catch (Exception e) { - System.err.println("Failed loading " + tgName + ": " + e); - } - } + /** + * Number of buttons. + * By default it's taken from the system. If system value does not + * fit into int type range, use our own MAX_BUTTONS_SUPPORT value. + */ + protected static int numberOfButtons = 0; - Runnable initEQ = new Runnable() { - public void run () { - EventQueue eventQueue; - String eqName = System.getProperty("AWT.EventQueueClass", - "java.awt.EventQueue"); + /* XFree standard mention 24 buttons as maximum: + * http://www.xfree86.org/current/mouse.4.html + * We workaround systems supporting more than 24 buttons. + * Otherwise, we have to use long type values as masks + * which leads to API change. + * InputEvent.BUTTON_DOWN_MASK may contain only 21 masks due to + * the 4-bytes limit for the int type. (CR 6799099) + * One more bit is reserved for FIRST_HIGH_BIT. + */ + public final static int MAX_BUTTONS_SUPPORTED = 20; - try { - eventQueue = (EventQueue)Class.forName(eqName).newInstance(); - } catch (Exception e) { - e.printStackTrace(); - System.err.println("Failed loading " + eqName + ": " + e); - eventQueue = new EventQueue(); - } - AppContext appContext = AppContext.getAppContext(); - appContext.put(AppContext.EVENT_QUEUE_KEY, eventQueue); + private static void initEQ(AppContext appContext) { + EventQueue eventQueue; - PostEventQueue postEventQueue = new PostEventQueue(eventQueue); - appContext.put(POST_EVENT_QUEUE_KEY, postEventQueue); - } - }; + String eqName = System.getProperty("AWT.EventQueueClass", + "java.awt.EventQueue"); - if (threadGroup != null) { - Thread eqInitThread = new Thread(threadGroup, initEQ, "EventQueue-Init"); - eqInitThread.start(); - try { - eqInitThread.join(); - } catch (InterruptedException e) { - e.printStackTrace(); - } - } else { - initEQ.run(); + try { + eventQueue = (EventQueue)Class.forName(eqName).newInstance(); + } catch (Exception e) { + e.printStackTrace(); + System.err.println("Failed loading " + eqName + ": " + e); + eventQueue = new EventQueue(); } + appContext.put(AppContext.EVENT_QUEUE_KEY, eventQueue); + + PostEventQueue postEventQueue = new PostEventQueue(eventQueue); + appContext.put(POST_EVENT_QUEUE_KEY, postEventQueue); + } + + public SunToolkit() { + // 7122796: Always create an EQ for the main AppContext + initEQ(AppContext.getMainAppContext()); } public boolean useBufferPerWindow() { @@ -224,8 +196,9 @@ public abstract class SunToolkit extends Toolkit public abstract RobotPeer createRobot(Robot target, GraphicsDevice screen) throws AWTException; - public abstract KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) throws HeadlessException; - + public abstract KeyboardFocusManagerPeer createKeyboardFocusManagerPeer(KeyboardFocusManager manager) + throws HeadlessException; + /** * The AWT lock is typically only used on Unix platforms to synchronize * access to Xlib, OpenGL, etc. However, these methods are implemented @@ -304,20 +277,12 @@ public abstract class SunToolkit extends Toolkit */ public static AppContext createNewAppContext() { ThreadGroup threadGroup = Thread.currentThread().getThreadGroup(); - EventQueue eventQueue; - String eqName = System.getProperty("AWT.EventQueueClass", - "java.awt.EventQueue"); - try { - eventQueue = (EventQueue)Class.forName(eqName).newInstance(); - } catch (Exception e) { - System.err.println("Failed loading " + eqName + ": " + e); - eventQueue = new EventQueue(); - } + // Create appContext before initialization of EventQueue, so all + // the calls to AppContext.getAppContext() from EventQueue ctor + // return correct values AppContext appContext = new AppContext(threadGroup); - appContext.put(AppContext.EVENT_QUEUE_KEY, eventQueue); - PostEventQueue postEventQueue = new PostEventQueue(eventQueue); - appContext.put(POST_EVENT_QUEUE_KEY, postEventQueue); + initEQ(appContext); return appContext; } @@ -406,32 +371,21 @@ public abstract class SunToolkit extends Toolkit private static final Map appContextMap = Collections.synchronizedMap(new WeakHashMap()); - /** * Sets the appContext field of target. If target is not a Component or * MenuComponent, this returns false. */ - private static boolean setAppContext(Object target, AppContext context) - { - if (!(target instanceof Component) && !(target instanceof MenuComponent)) { + private static boolean setAppContext(Object target, + AppContext context) { + if (target instanceof Component) { + AWTAccessor.getComponentAccessor(). + setAppContext((Component)target, context); + } else if (target instanceof MenuComponent) { + AWTAccessor.getMenuComponentAccessor(). + setAppContext((MenuComponent)target, context); + } else { return false; } - try{ - if (target instanceof Component){ - if (componentAppContextField == null) { - componentAppContextField = getField(Component.class, "appContext"); - } - componentAppContextField.set(target, context); - } else if (target instanceof MenuComponent) { - if (menuComponentAppContextField == null) { - menuComponentAppContextField = getField(MenuComponent.class, "appContext"); - } - menuComponentAppContextField.set(target, context); - } - } catch( IllegalAccessException e){ - assert false; - } - return true; } @@ -440,23 +394,15 @@ public abstract class SunToolkit extends Toolkit * Component or MenuComponent this returns null. */ private static AppContext getAppContext(Object target) { - AppContext retObj = null; - try{ - if (target instanceof Component){ - if (componentAppContextField == null) { - componentAppContextField = getField(Component.class, "appContext"); - } - retObj = (AppContext) componentAppContextField.get(target); - } else if (target instanceof MenuComponent) { - if (menuComponentAppContextField == null) { - menuComponentAppContextField = getField(MenuComponent.class, "appContext"); - } - retObj = (AppContext) menuComponentAppContextField.get(target); - } - } catch( IllegalAccessException e){ - assert false; + if (target instanceof Component) { + return AWTAccessor.getComponentAccessor(). + getAppContext((Component)target); + } else if (target instanceof MenuComponent) { + return AWTAccessor.getMenuComponentAccessor(). + getAppContext((MenuComponent)target); + } else { + return null; } - return retObj; } /* @@ -476,7 +422,7 @@ public abstract class SunToolkit extends Toolkit context = (AppContext)appContextMap.get(target); } return context; - } + } /** * Sets the synchronous status of focus requests on lightweight @@ -504,60 +450,14 @@ public abstract class SunToolkit extends Toolkit */ public static void setLWRequestStatus(Window changed,boolean status){ - if (syncLWRequestsField == null){ - syncLWRequestsField = getField(Window.class, "syncLWRequests"); - } - try{ - if (syncLWRequestsField != null){ - syncLWRequestsField.setBoolean(changed, status); - } - } catch( IllegalAccessException e){ - assert false; - } + AWTAccessor.getWindowAccessor().setLWRequestStatus(changed, status); }; - public static void checkAndSetPolicy(Container cont, boolean isSwingCont) - { - FocusTraversalPolicy defaultPolicy = KeyboardFocusManager - .getCurrentKeyboardFocusManager().getDefaultFocusTraversalPolicy(); - - String toolkitName = Toolkit.getDefaultToolkit().getClass().getName(); - // if this is not XAWT then use default policy - // because Swing change it - if (!"sun.awt.X11.XToolkit".equals(toolkitName)) { - cont.setFocusTraversalPolicy(defaultPolicy); - return; - } - - String policyName = defaultPolicy.getClass().getName(); - - if (DefaultFocusTraversalPolicy.class != defaultPolicy.getClass()) { - // Policy was changed - // Check if it is awt policy or swing policy - // If it is Swing policy we shouldn't use it in AWT frames - // If it is AWT policy we shouldn't use it in Swing frames - // Otherwise we should use this policy - if (policyName.startsWith("java.awt.")) { - // AWT - if (isSwingCont) { - // Can't use AWT policy in Swing windows - should use Swing's one. - defaultPolicy = createLayoutPolicy(); - } else { - // New awt policy. - } - } else if (policyName.startsWith("javax.swing.")) { - if (isSwingCont) { - // New Swing's policy - } else { - defaultPolicy = new DefaultFocusTraversalPolicy(); - } - } - } else { - // Policy is default, use different default policy for swing - if (isSwingCont) { - defaultPolicy = createLayoutPolicy(); - } - } + public static void checkAndSetPolicy(Container cont) { + FocusTraversalPolicy defaultPolicy = KeyboardFocusManager. + getCurrentKeyboardFocusManager(). + getDefaultFocusTraversalPolicy(); + cont.setFocusTraversalPolicy(defaultPolicy); } @@ -606,13 +506,19 @@ public abstract class SunToolkit extends Toolkit if (event == null) { throw new NullPointerException(); } + // All events posted via this method are system-generated. + // Placing the following call here reduces considerably the + // number of places throughout the toolkit that would + // otherwise have to be modified to precisely identify + // system-generated events. + setSystemGenerated(event); AppContext eventContext = targetToAppContext(event.getSource()); if (eventContext != null && !eventContext.equals(appContext)) { log.fine("Event posted on wrong app context : " + event); } PostEventQueue postEventQueue = (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY); - if(postEventQueue != null) { + if (postEventQueue != null) { postEventQueue.postEvent(event); } } @@ -621,34 +527,38 @@ public abstract class SunToolkit extends Toolkit * Post AWTEvent of high priority. */ public static void postPriorityEvent(final AWTEvent e) { - if (isPostedField == null) { - isPostedField = getField(AWTEvent.class, "isPosted"); - } PeerEvent pe = new PeerEvent(Toolkit.getDefaultToolkit(), new Runnable() { public void run() { - try { - isPostedField.setBoolean(e, true); - } catch (IllegalArgumentException e) { - assert(false); - } catch (IllegalAccessException e) { - assert(false); - } + AWTAccessor.getAWTEventAccessor().setPosted(e); ((Component)e.getSource()).dispatchEvent(e); } }, PeerEvent.ULTIMATE_PRIORITY_EVENT); postEvent(targetToAppContext(e.getSource()), pe); } + protected static final Lock flushLock = new ReentrantLock(); + private static boolean isFlushingPendingEvents = false; + /* * Flush any pending events which haven't been posted to the AWT * EventQueue yet. */ public static void flushPendingEvents() { - AppContext appContext = AppContext.getAppContext(); - PostEventQueue postEventQueue = - (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY); - if(postEventQueue != null) { - postEventQueue.flush(); + flushLock.lock(); + try { + // Don't call flushPendingEvents() recursively + if (!isFlushingPendingEvents) { + isFlushingPendingEvents = true; + AppContext appContext = AppContext.getAppContext(); + PostEventQueue postEventQueue = + (PostEventQueue)appContext.get(POST_EVENT_QUEUE_KEY); + if (postEventQueue != null) { + postEventQueue.flush(); + } + } + } finally { + isFlushingPendingEvents = false; + flushLock.unlock(); } } @@ -731,7 +641,9 @@ public abstract class SunToolkit extends Toolkit synchronized (lock) { executeOnEventHandlerThread(event); - lock.wait(); + while(!event.isDispatched()) { + lock.wait(); + } } Throwable eventThrowable = event.getThrowable(); @@ -741,36 +653,6 @@ public abstract class SunToolkit extends Toolkit } /* - * Returns next queue for the given EventQueue which has private access - */ - private static EventQueue getNextQueue(final Object o) { - EventQueue result = null; - try{ - Field nextQueueField = getField(EventQueue.class, - "nextQueue"); - result = (EventQueue)nextQueueField.get(o); - } catch( IllegalAccessException e){ - assert false; - } - return result; - } - - /* - * Returns dispatch thread for the given EventQueue which has private access - */ - private static Thread getDispatchThread(final Object o) { - Thread result = null; - try{ - Field dispatchThreadField = getField(EventQueue.class, - "dispatchThread"); - result = (Thread)dispatchThreadField.get(o); - } catch( IllegalAccessException e){ - assert false; - } - return result; - } - - /* * Returns true if the calling thread is the event dispatch thread * contained within AppContext which associated with the given target. * Use this call to ensure that a given task is being executed @@ -780,13 +662,8 @@ public abstract class SunToolkit extends Toolkit AppContext appContext = targetToAppContext(target); EventQueue eq = (EventQueue)appContext.get(AppContext.EVENT_QUEUE_KEY); - EventQueue next = getNextQueue(eq); - while (next != null) { - eq = next; - next = getNextQueue(eq); - } - - return (Thread.currentThread() == getDispatchThread(eq)); + AWTAccessor.EventQueueAccessor accessor = AWTAccessor.getEventQueueAccessor(); + return accessor.isDispatchThreadImpl(eq); } public Dimension getScreenSize() { @@ -795,21 +672,17 @@ public abstract class SunToolkit extends Toolkit protected abstract int getScreenWidth(); protected abstract int getScreenHeight(); -// public FontMetrics getFontMetrics(Font font) { -// return FontDesignMetrics.getMetrics(font); -// } -// -// public String[] getFontList() { -// String[] hardwiredFontList = { -// Font.DIALOG, Font.SANS_SERIF, Font.SERIF, Font.MONOSPACED, -// Font.DIALOG_INPUT -// -// // -- Obsolete font names from 1.0.2. It was decided that -// // -- getFontList should not return these old names: -// // "Helvetica", "TimesRoman", "Courier", "ZapfDingbats" -// }; -// return hardwiredFontList; -// } + public String[] getFontList() { + String[] hardwiredFontList = { + Font.DIALOG, Font.SANS_SERIF, Font.SERIF, Font.MONOSPACED, + Font.DIALOG_INPUT + + // -- Obsolete font names from 1.0.2. It was decided that + // -- getFontList should not return these old names: + // "Helvetica", "TimesRoman", "Courier", "ZapfDingbats" + }; + return hardwiredFontList; + } public PanelPeer createPanel(Panel target) { return (PanelPeer)createComponent(target); @@ -820,16 +693,31 @@ public abstract class SunToolkit extends Toolkit } /** - * Disables erasing of background on the canvas before painting - * if this is supported by the current toolkit. - * - * @throws IllegalStateException if the canvas is not displayable - * @see java.awt.Component#isDisplayable + * Disables erasing of background on the canvas before painting if + * this is supported by the current toolkit. It is recommended to + * call this method early, before the Canvas becomes displayable, + * because some Toolkit implementations do not support changing + * this property once the Canvas becomes displayable. */ public void disableBackgroundErase(Canvas canvas) { - if (!canvas.isDisplayable()) { - throw new IllegalStateException("Canvas must have a valid peer"); - } + disableBackgroundEraseImpl(canvas); + } + + /** + * Disables the native erasing of the background on the given + * component before painting if this is supported by the current + * toolkit. This only has an effect for certain components such as + * Canvas, Panel and Window. It is recommended to call this method + * early, before the Component becomes displayable, because some + * Toolkit implementations do not support changing this property + * once the Component becomes displayable. + */ + public void disableBackgroundErase(Component component) { + disableBackgroundEraseImpl(component); + } + + private void disableBackgroundEraseImpl(Component component) { + AWTAccessor.getComponentAccessor().setBackgroundEraseDisabled(component, true); } /** @@ -848,123 +736,6 @@ public abstract class SunToolkit extends Toolkit return AccessController.doPrivileged(new GetBooleanAction("sun.awt.erasebackgroundonresize")); } - /** - * Makes the window OverrideRedirect, on X11 platforms. See - * ICCCM specification for more details about OverrideRedirect - * windows. Implemented in XToolkit, no-op in WToolkit. - */ - public void setOverrideRedirect(Window target) { - } - -// static SoftCache imgCache = new SoftCache(); -// -// static synchronized Image getImageFromHash(Toolkit tk, URL url) { -// SecurityManager sm = System.getSecurityManager(); -// if (sm != null) { -// try { -// java.security.Permission perm = -// url.openConnection().getPermission(); -// if (perm != null) { -// try { -// sm.checkPermission(perm); -// } catch (SecurityException se) { -// // fallback to checkRead/checkConnect for pre 1.2 -// // security managers -// if ((perm instanceof java.io.FilePermission) && -// perm.getActions().indexOf("read") != -1) { -// sm.checkRead(perm.getName()); -// } else if ((perm instanceof -// java.net.SocketPermission) && -// perm.getActions().indexOf("connect") != -1) { -// sm.checkConnect(url.getHost(), url.getPort()); -// } else { -// throw se; -// } -// } -// } -// } catch (java.io.IOException ioe) { -// sm.checkConnect(url.getHost(), url.getPort()); -// } -// } -// Image img = (Image)imgCache.get(url); -// if (img == null) { -// try { -// img = tk.createImage(new URLImageSource(url)); -// imgCache.put(url, img); -// } catch (Exception e) { -// } -// } -// return img; -// } - -// static synchronized Image getImageFromHash(Toolkit tk, -// String filename) { -// SecurityManager security = System.getSecurityManager(); -// if (security != null) { -// security.checkRead(filename); -// } -// Image img = (Image)imgCache.get(filename); -// if (img == null) { -// try { -// img = tk.createImage(new FileImageSource(filename)); -// imgCache.put(filename, img); -// } catch (Exception e) { -// } -// } -// return img; -// } -// -// public Image getImage(String filename) { -// return getImageFromHash(this, filename); -// } -// -// public Image getImage(URL url) { -// return getImageFromHash(this, url); -// } -// -// public Image createImage(String filename) { -// SecurityManager security = System.getSecurityManager(); -// if (security != null) { -// security.checkRead(filename); -// } -// return createImage(new FileImageSource(filename)); -// } -// -// public Image createImage(URL url) { -// SecurityManager sm = System.getSecurityManager(); -// if (sm != null) { -// try { -// java.security.Permission perm = -// url.openConnection().getPermission(); -// if (perm != null) { -// try { -// sm.checkPermission(perm); -// } catch (SecurityException se) { -// // fallback to checkRead/checkConnect for pre 1.2 -// // security managers -// if ((perm instanceof java.io.FilePermission) && -// perm.getActions().indexOf("read") != -1) { -// sm.checkRead(perm.getName()); -// } else if ((perm instanceof -// java.net.SocketPermission) && -// perm.getActions().indexOf("connect") != -1) { -// sm.checkConnect(url.getHost(), url.getPort()); -// } else { -// throw se; -// } -// } -// } -// } catch (java.io.IOException ioe) { -// sm.checkConnect(url.getHost(), url.getPort()); -// } -// } -// return createImage(new URLImageSource(url)); -// } -// -// public Image createImage(byte[] data, int offset, int length) { -// return createImage(new ByteArrayImageSource(data, offset, length)); -// } - public Image createImage(ImageProducer producer) { return new ToolkitImage(producer); } @@ -1027,9 +798,9 @@ public abstract class SunToolkit extends Toolkit //with scale factors x1, x3/4, x2/3, xN, x1/N. Image im = i.next(); if (im == null) { - if (log.isLoggable(Level.FINER)) { - log.log(Level.FINER, "SunToolkit.getScaledIconImage: " + - "Skipping the image passed into Java because it's null."); + if (log.isLoggable(PlatformLogger.FINER)) { + log.finer("SunToolkit.getScaledIconImage: " + + "Skipping the image passed into Java because it's null."); } continue; } @@ -1043,9 +814,9 @@ public abstract class SunToolkit extends Toolkit iw = im.getWidth(null); ih = im.getHeight(null); } catch (Exception e){ - if (log.isLoggable(Level.FINER)) { - log.log(Level.FINER, "SunToolkit.getScaledIconImage: " + - "Perhaps the image passed into Java is broken. Skipping this icon."); + if (log.isLoggable(PlatformLogger.FINER)) { + log.finer("SunToolkit.getScaledIconImage: " + + "Perhaps the image passed into Java is broken. Skipping this icon."); } continue; } @@ -1118,8 +889,8 @@ public abstract class SunToolkit extends Toolkit try { int x = (width - bestWidth) / 2; int y = (height - bestHeight) / 2; - if (log.isLoggable(Level.FINER)) { - log.log(Level.FINER, "WWindowPeer.getScaledIconData() result : " + + if (log.isLoggable(PlatformLogger.FINER)) { + log.finer("WWindowPeer.getScaledIconData() result : " + "w : " + width + " h : " + height + " iW : " + bestImage.getWidth(null) + " iH : " + bestImage.getHeight(null) + " sim : " + bestSimilarity + " sf : " + bestScaleFactor + @@ -1136,9 +907,9 @@ public abstract class SunToolkit extends Toolkit public static DataBufferInt getScaledIconData(java.util.List<Image> imageList, int width, int height) { BufferedImage bimage = getScaledIconImage(imageList, width, height); if (bimage == null) { - if (log.isLoggable(Level.FINER)) { - log.log(Level.FINER, "SunToolkit.getScaledIconData: " + - "Perhaps the image passed into Java is broken. Skipping this icon."); + if (log.isLoggable(PlatformLogger.FINER)) { + log.finer("SunToolkit.getScaledIconData: " + + "Perhaps the image passed into Java is broken. Skipping this icon."); } return null; } @@ -1171,18 +942,53 @@ public abstract class SunToolkit extends Toolkit } /** - * Returns a new input method window, with behavior as specified in - * {@link java.awt.im.spi.InputMethodContext#createInputMethodWindow}. - * If the inputContext is not null, the window should return it from its - * getInputContext() method. The window needs to implement - * sun.awt.im.InputMethodWindow. - * <p> - * SunToolkit subclasses can override this method to return better input - * method windows. - */ -// public Window createInputMethodWindow(String title, InputContext context) { -// return new sun.awt.im.SimpleInputMethodWindow(title, context); -// } + * Gives native peers the ability to query the closest HW component. + * If the given component is heavyweight, then it returns this. Otherwise, + * it goes one level up in the hierarchy and tests next component. + */ + public static Component getHeavyweightComponent(Component c) { + while (c != null && AWTAccessor.getComponentAccessor().isLightweight(c)) { + c = AWTAccessor.getComponentAccessor().getParent(c); + } + return c; + } + + /** + * Returns key modifiers used by Swing to set up a focus accelerator key stroke. + */ + public int getFocusAcceleratorKeyMask() { + return InputEvent.ALT_MASK; + } + + /** + * Tests whether specified key modifiers mask can be used to enter a printable + * character. This is a default implementation of this method, which reflects + * the way things work on Windows: here, pressing ctrl + alt allows user to enter + * characters from the extended character set (like euro sign or math symbols) + */ + public boolean isPrintableCharacterModifiersMask(int mods) { + return ((mods & InputEvent.ALT_MASK) == (mods & InputEvent.CTRL_MASK)); + } + + /** + * Returns whether popup is allowed to be shown above the task bar. + * This is a default implementation of this method, which checks + * corresponding security permission. + */ + public boolean canPopupOverlapTaskBar() { + boolean result = true; + try { + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkPermission( + SecurityConstants.AWT.SET_WINDOW_ALWAYS_ON_TOP_PERMISSION); + } + } catch (SecurityException se) { + // There is no permission to show popups over the task bar + result = false; + } + return result; + } /** * Returns whether enableInputMethods should be set to true for peered @@ -1239,8 +1045,7 @@ public abstract class SunToolkit extends Toolkit dataTransfererClassName = className; } - public static String getDataTransfererClassName() - { + public static String getDataTransfererClassName() { if (dataTransfererClassName == null) { Toolkit.getDefaultToolkit(); // transferer set during toolkit init } @@ -1283,14 +1088,6 @@ public abstract class SunToolkit extends Toolkit } } -// private static DefaultMouseInfoPeer mPeer = null; -// -// protected synchronized MouseInfoPeer getMouseInfoPeer() { -// if (mPeer == null) { -// mPeer = new DefaultMouseInfoPeer(); -// } -// return mPeer; -// } /** @@ -1325,22 +1122,7 @@ public abstract class SunToolkit extends Toolkit return false; } - private static Dialog.ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE; - - static { - DEFAULT_MODAL_EXCLUSION_TYPE = (Dialog.ModalExclusionType)AccessController.doPrivileged(new PrivilegedAction() { - public Object run() { - Dialog.ModalExclusionType defaultType = Dialog.ModalExclusionType.NO_EXCLUDE; - try { - java.lang.reflect.Field f = Dialog.class.getDeclaredField("DEFAULT_MODAL_EXCLUSION_TYPE"); - f.setAccessible(true); - defaultType = (Dialog.ModalExclusionType)f.get(null); - } catch (Exception e) { - } - return defaultType; - } - }); - } + private static Dialog.ModalExclusionType DEFAULT_MODAL_EXCLUSION_TYPE = null; /** * Returns whether the XEmbed server feature is requested by @@ -1399,6 +1181,9 @@ public abstract class SunToolkit extends Toolkit */ public static void setModalExcluded(Window window) { + if (DEFAULT_MODAL_EXCLUSION_TYPE == null) { + DEFAULT_MODAL_EXCLUSION_TYPE = Dialog.ModalExclusionType.APPLICATION_EXCLUDE; + } window.setModalExclusionType(DEFAULT_MODAL_EXCLUSION_TYPE); } @@ -1420,6 +1205,9 @@ public abstract class SunToolkit extends Toolkit */ public static boolean isModalExcluded(Window window) { + if (DEFAULT_MODAL_EXCLUSION_TYPE == null) { + DEFAULT_MODAL_EXCLUSION_TYPE = Dialog.ModalExclusionType.APPLICATION_EXCLUDE; + } return window.getModalExclusionType().compareTo(DEFAULT_MODAL_EXCLUSION_TYPE) >= 0; } @@ -2020,7 +1808,6 @@ public abstract class SunToolkit extends Toolkit public boolean isNativeGTKAvailable() { return false; } - // Cosntant alpha public boolean isWindowOpacitySupported() { @@ -2040,7 +1827,6 @@ public abstract class SunToolkit extends Toolkit public boolean isTranslucencyCapable(GraphicsConfiguration gc) { return false; } - /** * Returns whether or not a containing top level window for the passed @@ -2059,6 +1845,22 @@ public abstract class SunToolkit extends Toolkit } /** + * Returns whether or not a containing top level window for the passed + * component is + * {@link GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT}. + * + * @param c a Component which toplevel's to check + * @return {@code true} if the passed component is not null and has a + * containing toplevel window which has opacity less than + * 1.0f (which means that it is translucent), {@code false} otherwise + * @see GraphicsDevice.WindowTranslucency#TRANSLUCENT + */ + public static boolean isContainingTopLevelTranslucent(Component c) { + Window w = getContainingWindow(c); + return w != null && ((Window)w).getOpacity() < 1.0f; + } + + /** * Returns whether the native system requires using the peer.updateWindow() * method to update the contents of a non-opaque window, or if usual * painting procedures are sufficient. The default return value covers @@ -2111,7 +1913,7 @@ public abstract class SunToolkit extends Toolkit } return isInstanceOf(cls.getSuperclass(), type); } - + /////////////////////////////////////////////////////////////////////////// // // The following methods help set and identify whether a particular @@ -2151,33 +1953,21 @@ class PostEventQueue { eventQueue = eq; } - public boolean noEvents() { + public synchronized boolean noEvents() { return queueHead == null; } /* - * Continually post pending AWTEvents to the Java EventQueue. - */ - public void flush() { - if (queueHead != null) { - EventQueueItem tempQueue; - /* - * We have to execute the loop inside the synchronized block - * to ensure that the flush is completed before a new event - * can be posted to this queue. - */ - synchronized (this) { - tempQueue = queueHead; - queueHead = queueTail = null; - /* - * If this PostEventQueue is flushed in parallel on two - * different threads tempQueue will be null for one of them. - */ - while (tempQueue != null) { - eventQueue.postEvent(tempQueue.event); - tempQueue = tempQueue.next; - } - } + * Continually post pending AWTEvents to the Java EventQueue. The method + * is synchronized to ensure the flush is completed before a new event + * can be posted to this queue. + */ + public synchronized void flush() { + EventQueueItem tempQueue = queueHead; + queueHead = queueTail = null; + while (tempQueue != null) { + eventQueue.postEvent(tempQueue.event); + tempQueue = tempQueue.next; } } diff --git a/openjdk/sun/misc/SharedSecrets.java b/openjdk/sun/misc/SharedSecrets.java index 03c1ffb5..af2174c9 100644 --- a/openjdk/sun/misc/SharedSecrets.java +++ b/openjdk/sun/misc/SharedSecrets.java @@ -47,6 +47,7 @@ public class SharedSecrets { private static JavaLangAccess javaLangAccess = LangHelper.getJavaLangAccess(); private static JavaIOAccess javaIOAccess; private static JavaNetAccess javaNetAccess; + private static JavaNetHttpCookieAccess javaNetHttpCookieAccess; private static JavaNioAccess javaNioAccess; private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess; private static JavaSecurityAccess javaSecurityAccess; @@ -77,6 +78,16 @@ public class SharedSecrets { return javaNetAccess; } + public static void setJavaNetHttpCookieAccess(JavaNetHttpCookieAccess a) { + javaNetHttpCookieAccess = a; + } + + public static JavaNetHttpCookieAccess getJavaNetHttpCookieAccess() { + if (javaNetHttpCookieAccess == null) + unsafe.ensureClassInitialized(java.net.HttpCookie.class); + return javaNetHttpCookieAccess; + } + public static void setJavaNioAccess(JavaNioAccess jna) { javaNioAccess = jna; } diff --git a/runtime/openjdk.cs b/runtime/openjdk.cs index 922062a5..1e5c489a 100644 --- a/runtime/openjdk.cs +++ b/runtime/openjdk.cs @@ -8234,13 +8234,17 @@ namespace IKVM.NativeCode.com.sun.security.auth.module SetField(thisObj, "groupIDs", groups); // HACK it turns out that Groups[0] is the primary group, but AFAIK this is not documented anywhere SetField(thisObj, "primaryGroupID", groups[0]); - SetField(thisObj, "impersonationToken", id.Token.ToInt64()); } private static void SetField(object thisObj, string field, object value) { thisObj.GetType().GetField(field, BindingFlags.NonPublic | BindingFlags.Instance).SetValue(thisObj, value); } + + public static long getImpersonationToken0(object thisObj) + { + return WindowsIdentity.GetCurrent().Token.ToInt64(); + } } static class SolarisSystem diff --git a/runtime/openjdk/sun.security.krb5.cs b/runtime/openjdk/sun.security.krb5.cs index afd9126c..ef2551eb 100644 --- a/runtime/openjdk/sun.security.krb5.cs +++ b/runtime/openjdk/sun.security.krb5.cs @@ -340,3 +340,15 @@ static class Java_sun_security_krb5_Credentials } } } + +static class Java_sun_security_krb5_SCDynamicStoreConfig +{ + public static void installNotificationCallback() + { + } + + public static object getKerberosConfig() + { + return null; + } +} diff --git a/runtime/vfs.cs b/runtime/vfs.cs index 47cc2ec6..2a68a0d0 100644 --- a/runtime/vfs.cs +++ b/runtime/vfs.cs @@ -752,6 +752,7 @@ namespace IKVM.Internal AddDummyLibrary(bin, "unpack"); AddDummyLibrary(bin, "net"); AddDummyLibrary(bin, "splashscreen"); + AddDummyLibrary(bin, "osx"); bin.Add("java", new VfsJavaExe()); bin.Add("javaw", new VfsJavaExe()); bin.Add("java.exe", new VfsJavaExe()); |