--- a/.hgtags Tue Nov 30 10:35:55 2010 +0300
+++ b/.hgtags Tue Nov 30 14:51:07 2010 -0800
@@ -93,3 +93,4 @@
a4e6aa1f45ad23a6f083ed98d970b5006ea4d292 jdk7-b116
228e73f288c543a8c34e2a54227103ae5649e6af jdk7-b117
2e876e59938a853934aa738c811b26c452bd9fe8 jdk7-b118
+4951967a61b4dbbf514828879f57bd1a0d4b420b jdk7-b119
--- a/.hgtags-top-repo Tue Nov 30 10:35:55 2010 +0300
+++ b/.hgtags-top-repo Tue Nov 30 14:51:07 2010 -0800
@@ -93,3 +93,4 @@
94e9a1bfba8b8d1fe0bfd43b88629b1f27b02a76 jdk7-b116
7220e60b097fa027e922f1aeecdd330f3e37409f jdk7-b117
a12a9e78df8a9d534da0b4a244ed68f0de0bd58e jdk7-b118
+661360bef6ccad6c119f067f5829b207de80c936 jdk7-b119
--- a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/ClientRequestInfoImpl.java Tue Nov 30 10:35:55 2010 +0300
+++ b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/ClientRequestInfoImpl.java Tue Nov 30 14:51:07 2010 -0800
@@ -74,6 +74,7 @@
import com.sun.corba.se.spi.ior.iiop.GIOPVersion;
import com.sun.corba.se.spi.orb.ORB;
import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
+import com.sun.corba.se.spi.protocol.RetryType;
import com.sun.corba.se.spi.transport.CorbaContactInfo;
import com.sun.corba.se.spi.transport.CorbaContactInfoList;
import com.sun.corba.se.spi.transport.CorbaContactInfoListIterator;
@@ -110,7 +111,7 @@
// The current retry request status. True if this request is being
// retried and this info object is to be reused, or false otherwise.
- private boolean retryRequest;
+ private RetryType retryRequest;
// The number of times this info object has been (re)used. This is
// incremented every time a request is retried, and decremented every
@@ -163,7 +164,8 @@
// Please keep these in the same order that they're declared above.
- retryRequest = false;
+ // 6763340
+ retryRequest = RetryType.NONE;
// Do not reset entryCount because we need to know when to pop this
// from the stack.
@@ -824,14 +826,15 @@
/**
* Set or reset the retry request flag.
*/
- void setRetryRequest( boolean retryRequest ) {
+ void setRetryRequest( RetryType retryRequest ) {
this.retryRequest = retryRequest;
}
/**
* Retrieve the current retry request status.
*/
- boolean getRetryRequest() {
+ RetryType getRetryRequest() {
+ // 6763340
return this.retryRequest;
}
--- a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PIHandlerImpl.java Tue Nov 30 10:35:55 2010 +0300
+++ b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PIHandlerImpl.java Tue Nov 30 14:51:07 2010 -0800
@@ -70,6 +70,7 @@
import com.sun.corba.se.spi.protocol.CorbaMessageMediator;
import com.sun.corba.se.spi.protocol.ForwardException;
import com.sun.corba.se.spi.protocol.PIHandler;
+import com.sun.corba.se.spi.protocol.RetryType;
import com.sun.corba.se.spi.logging.CORBALogDomains;
import com.sun.corba.se.impl.logging.InterceptorsSystemException;
@@ -372,9 +373,24 @@
}
}
- public Exception invokeClientPIEndingPoint(
- int replyStatus, Exception exception )
- {
+ // Needed when an error forces a retry AFTER initiateClientPIRequest
+ // but BEFORE invokeClientPIStartingPoint.
+ public Exception makeCompletedClientRequest( int replyStatus,
+ Exception exception ) {
+
+ // 6763340
+ return handleClientPIEndingPoint( replyStatus, exception, false ) ;
+ }
+
+ public Exception invokeClientPIEndingPoint( int replyStatus,
+ Exception exception ) {
+
+ // 6763340
+ return handleClientPIEndingPoint( replyStatus, exception, true ) ;
+ }
+
+ public Exception handleClientPIEndingPoint(
+ int replyStatus, Exception exception, boolean invokeEndingPoint ) {
if( !hasClientInterceptors ) return exception;
if( !isClientPIEnabledForThisThread() ) return exception;
@@ -388,24 +404,31 @@
ClientRequestInfoImpl info = peekClientRequestInfoImplStack();
info.setReplyStatus( piReplyStatus );
info.setException( exception );
- interceptorInvoker.invokeClientInterceptorEndingPoint( info );
- piReplyStatus = info.getReplyStatus();
+
+ if (invokeEndingPoint) {
+ // 6763340
+ interceptorInvoker.invokeClientInterceptorEndingPoint( info );
+ piReplyStatus = info.getReplyStatus();
+ }
// Check reply status:
if( (piReplyStatus == LOCATION_FORWARD.value) ||
- (piReplyStatus == TRANSPORT_RETRY.value) )
- {
+ (piReplyStatus == TRANSPORT_RETRY.value) ) {
// If this is a forward or a retry, reset and reuse
// info object:
info.reset();
- info.setRetryRequest( true );
+
+ // fix for 6763340:
+ if (invokeEndingPoint) {
+ info.setRetryRequest( RetryType.AFTER_RESPONSE ) ;
+ } else {
+ info.setRetryRequest( RetryType.BEFORE_RESPONSE ) ;
+ }
// ... and return a RemarshalException so the orb internals know
exception = new RemarshalException();
- }
- else if( (piReplyStatus == SYSTEM_EXCEPTION.value) ||
- (piReplyStatus == USER_EXCEPTION.value) )
- {
+ } else if( (piReplyStatus == SYSTEM_EXCEPTION.value) ||
+ (piReplyStatus == USER_EXCEPTION.value) ) {
exception = info.getException();
}
@@ -421,18 +444,21 @@
RequestInfoStack infoStack =
(RequestInfoStack)threadLocalClientRequestInfoStack.get();
ClientRequestInfoImpl info = null;
- if( !infoStack.empty() ) info =
- (ClientRequestInfoImpl)infoStack.peek();
- if( !diiRequest && (info != null) && info.isDIIInitiate() ) {
+ if (!infoStack.empty() ) {
+ info = (ClientRequestInfoImpl)infoStack.peek();
+ }
+
+ if (!diiRequest && (info != null) && info.isDIIInitiate() ) {
// In RequestImpl.doInvocation we already called
// initiateClientPIRequest( true ), so ignore this initiate.
info.setDIIInitiate( false );
- }
- else {
+ } else {
// If there is no info object or if we are not retrying a request,
// push a new ClientRequestInfoImpl on the stack:
- if( (info == null) || !info.getRetryRequest() ) {
+
+ // 6763340: don't push unless this is not a retry
+ if( (info == null) || !info.getRetryRequest().isRetry() ) {
info = new ClientRequestInfoImpl( orb );
infoStack.push( info );
printPush();
@@ -442,9 +468,15 @@
// Reset the retry request flag so that recursive calls will
// push a new info object, and bump up entry count so we know
// when to pop this info object:
- info.setRetryRequest( false );
+ info.setRetryRequest( RetryType.NONE );
info.incrementEntryCount();
+ // KMC 6763340: I don't know why this wasn't set earlier,
+ // but we do not want a retry to pick up the previous
+ // reply status, so clear it here. Most likely a new
+ // info was pushed before, so that this was not a problem.
+ info.setReplyStatus( RequestInfoImpl.UNINITIALIZED ) ;
+
// If this is a DII request, make sure we ignore the next initiate.
if( diiRequest ) {
info.setDIIInitiate( true );
@@ -457,25 +489,34 @@
if( !isClientPIEnabledForThisThread() ) return;
ClientRequestInfoImpl info = peekClientRequestInfoImplStack();
+ RetryType rt = info.getRetryRequest() ;
- // If the replyStatus has not yet been set, this is an indication
- // that the ORB threw an exception before we had a chance to
- // invoke the client interceptor ending points.
- //
- // _REVISIT_ We cannot handle any exceptions or ForwardRequests
- // flagged by the ending points here because there is no way
- // to gracefully handle this in any of the calling code.
- // This is a rare corner case, so we will ignore this for now.
- short replyStatus = info.getReplyStatus();
- if( replyStatus == info.UNINITIALIZED ) {
- invokeClientPIEndingPoint( ReplyMessage.SYSTEM_EXCEPTION,
- wrapper.unknownRequestInvoke(
- CompletionStatus.COMPLETED_MAYBE ) ) ;
+ // fix for 6763340
+ if (!rt.equals( RetryType.BEFORE_RESPONSE )) {
+
+ // If the replyStatus has not yet been set, this is an indication
+ // that the ORB threw an exception before we had a chance to
+ // invoke the client interceptor ending points.
+ //
+ // _REVISIT_ We cannot handle any exceptions or ForwardRequests
+ // flagged by the ending points here because there is no way
+ // to gracefully handle this in any of the calling code.
+ // This is a rare corner case, so we will ignore this for now.
+ short replyStatus = info.getReplyStatus();
+ if (replyStatus == info.UNINITIALIZED ) {
+ invokeClientPIEndingPoint( ReplyMessage.SYSTEM_EXCEPTION,
+ wrapper.unknownRequestInvoke(
+ CompletionStatus.COMPLETED_MAYBE ) ) ;
+ }
}
// Decrement entry count, and if it is zero, pop it from the stack.
info.decrementEntryCount();
- if( info.getEntryCount() == 0 ) {
+
+ // fix for 6763340, and probably other cases (non-recursive retry)
+ if (info.getEntryCount() == 0 && !info.getRetryRequest().isRetry()) {
+ // RequestInfoStack<ClientRequestInfoImpl> infoStack =
+ // threadLocalClientRequestInfoStack.get();
RequestInfoStack infoStack =
(RequestInfoStack)threadLocalClientRequestInfoStack.get();
infoStack.pop();
--- a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PINoOpHandlerImpl.java Tue Nov 30 10:35:55 2010 +0300
+++ b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/PINoOpHandlerImpl.java Tue Nov 30 14:51:07 2010 -0800
@@ -107,6 +107,11 @@
return null;
}
+ public Exception makeCompletedClientRequest(
+ int replyStatus, Exception exception ) {
+ return null;
+ }
+
public void initiateClientPIRequest( boolean diiRequest ) {
}
--- a/corba/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java Tue Nov 30 10:35:55 2010 +0300
+++ b/corba/src/share/classes/com/sun/corba/se/impl/interceptors/RequestInfoImpl.java Tue Nov 30 14:51:07 2010 -0800
@@ -187,7 +187,8 @@
startingPointCall = 0;
intermediatePointCall = 0;
endingPointCall = 0;
- replyStatus = UNINITIALIZED;
+ // 6763340
+ setReplyStatus( UNINITIALIZED ) ;
currentExecutionPoint = EXECUTION_POINT_STARTING;
alreadyExecuted = false;
connection = null;
--- a/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java Tue Nov 30 10:35:55 2010 +0300
+++ b/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java Tue Nov 30 14:51:07 2010 -0800
@@ -1012,7 +1012,11 @@
* else,
* Handle it as a serializable class.
*/
- if (currentClassDesc.isExternalizable()) {
+ if (Enum.class.isAssignableFrom( clz )) {
+ int ordinal = orbStream.read_long() ;
+ String value = (String)orbStream.read_value( String.class ) ;
+ return Enum.valueOf( clz, value ) ;
+ } else if (currentClassDesc.isExternalizable()) {
try {
currentObject = (currentClass == null) ?
null : currentClassDesc.newInstance();
--- a/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java Tue Nov 30 10:35:55 2010 +0300
+++ b/corba/src/share/classes/com/sun/corba/se/impl/orb/ORBImpl.java Tue Nov 30 14:51:07 2010 -0800
@@ -1672,6 +1672,7 @@
{
StackImpl invocationInfoStack =
(StackImpl)clientInvocationInfoStack.get();
+ int entryCount = -1;
ClientInvocationInfo clientInvocationInfo = null;
if (!invocationInfoStack.empty()) {
clientInvocationInfo =
@@ -1680,8 +1681,12 @@
throw wrapper.invocationInfoStackEmpty() ;
}
clientInvocationInfo.decrementEntryCount();
+ entryCount = clientInvocationInfo.getEntryCount();
if (clientInvocationInfo.getEntryCount() == 0) {
- invocationInfoStack.pop();
+ // 6763340: don't pop if this is a retry!
+ if (!clientInvocationInfo.isRetryInvocation()) {
+ invocationInfoStack.pop();
+ }
finishedDispatch();
}
}
--- a/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java Tue Nov 30 10:35:55 2010 +0300
+++ b/corba/src/share/classes/com/sun/corba/se/impl/protocol/CorbaClientRequestDispatcherImpl.java Tue Nov 30 14:51:07 2010 -0800
@@ -185,6 +185,7 @@
if(getContactInfoListIterator(orb).hasNext()) {
contactInfo = (ContactInfo)
getContactInfoListIterator(orb).next();
+ unregisterWaiter(orb);
return beginRequest(self, opName,
isOneWay, contactInfo);
} else {
@@ -292,10 +293,22 @@
// ContactInfoList outside of subcontract.
// Want to move that update to here.
if (getContactInfoListIterator(orb).hasNext()) {
- contactInfo = (ContactInfo)
- getContactInfoListIterator(orb).next();
+ contactInfo = (ContactInfo)getContactInfoListIterator(orb).next();
+ if (orb.subcontractDebugFlag) {
+ dprint( "RemarshalException: hasNext true\ncontact info " + contactInfo );
+ }
+
+ // Fix for 6763340: Complete the first attempt before starting another.
+ orb.getPIHandler().makeCompletedClientRequest(
+ ReplyMessage.LOCATION_FORWARD, null ) ;
+ unregisterWaiter(orb);
+ orb.getPIHandler().cleanupClientPIRequest() ;
+
return beginRequest(self, opName, isOneWay, contactInfo);
} else {
+ if (orb.subcontractDebugFlag) {
+ dprint( "RemarshalException: hasNext false" );
+ }
ORBUtilSystemException wrapper =
ORBUtilSystemException.get(orb,
CORBALogDomains.RPC_PROTOCOL);
--- a/corba/src/share/classes/com/sun/corba/se/spi/protocol/PIHandler.java Tue Nov 30 10:35:55 2010 +0300
+++ b/corba/src/share/classes/com/sun/corba/se/spi/protocol/PIHandler.java Tue Nov 30 14:51:07 2010 -0800
@@ -142,6 +142,27 @@
int replyStatus, Exception exception ) ;
/**
+ * Called when a retry is needed after initiateClientPIRequest but
+ * before invokeClientPIRequest. In this case, we need to properly
+ * balance initiateClientPIRequest/cleanupClientPIRequest calls,
+ * but WITHOUT extraneous calls to invokeClientPIEndingPoint
+ * (see bug 6763340).
+ *
+ * @param replyStatus One of the constants in iiop.messages.ReplyMessage
+ * indicating which reply status to set.
+ * @param exception The exception before ending interception points have
+ * been invoked, or null if no exception at the moment.
+ * @return The exception to be thrown, after having gone through
+ * all ending points, or null if there is no exception to be
+ * thrown. Note that this exception can be either the same or
+ * different from the exception set using setClientPIException.
+ * There are four possible return types: null (no exception),
+ * SystemException, UserException, or RemarshalException.
+ */
+ Exception makeCompletedClientRequest(
+ int replyStatus, Exception exception ) ;
+
+ /**
* Invoked when a request is about to be created. Must be called before
* any of the setClientPI* methods so that a new info object can be
* prepared for information collection.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/corba/src/share/classes/com/sun/corba/se/spi/protocol/RetryType.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,52 @@
+/*
+ * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved.
+ * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
+ *
+ * This code is free software; you can redistribute it and/or modify it
+ * under the terms of the GNU General Public License version 2 only, as
+ * published by the Free Software Foundation. Oracle designates this
+ * particular file as subject to the "Classpath" exception as provided
+ * by Oracle in the LICENSE file that accompanied this code.
+ *
+ * This code is distributed in the hope that it will be useful, but WITHOUT
+ * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
+ * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
+ * version 2 for more details (a copy is included in the LICENSE file that
+ * accompanied this code).
+ *
+ * You should have received a copy of the GNU General Public License version
+ * 2 along with this work; if not, write to the Free Software Foundation,
+ * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
+ * or visit www.oracle.com if you need additional information or have any
+ * questions.
+ */
+
+package com.sun.corba.se.spi.protocol ;
+
+// Introduce more information about WHY we are re-trying a request
+// so we can properly handle the two cases:
+// - BEFORE_RESPONSE means that the retry is caused by
+// something that happened BEFORE the message was sent: either
+// an exception from the SocketFactory, or one from the
+// Client side send_request interceptor point.
+// - AFTER_RESPONSE means that the retry is a result either of the
+// request sent to the server (from the response), or from the
+// Client side receive_xxx interceptor point.
+public enum RetryType {
+ NONE( false ),
+ BEFORE_RESPONSE( true ),
+ AFTER_RESPONSE( true ) ;
+
+ private final boolean isRetry ;
+
+ RetryType( boolean isRetry ) {
+ this.isRetry = isRetry ;
+ }
+
+ public boolean isRetry() {
+ return this.isRetry ;
+ }
+} ;
+
--- a/jaxp/.hgtags Tue Nov 30 10:35:55 2010 +0300
+++ b/jaxp/.hgtags Tue Nov 30 14:51:07 2010 -0800
@@ -93,3 +93,4 @@
f8d4e6c6cfce1cda23fcbd144628a9791a9e1a63 jdk7-b116
9ee4d96e893436a48607924227dadd2d93b9b00d jdk7-b117
b2f6d9c4f12ffd307a5de40455b2b61b31a5cb79 jdk7-b118
+9ee900f01c5872551c06f33ae909662ffd8463ac jdk7-b119
--- a/jaxws/.hgtags Tue Nov 30 10:35:55 2010 +0300
+++ b/jaxws/.hgtags Tue Nov 30 14:51:07 2010 -0800
@@ -93,3 +93,4 @@
376ac153078dd3b5f6d4a0981feee092c1492c96 jdk7-b116
1320fb3bb588298c79716bd2d10b5b4afacb9370 jdk7-b117
19a2fab3f91a275f90791c15d1c21a24e820ff2d jdk7-b118
+41fa02b3663795ddf529690df7aa6714210093ec jdk7-b119
--- a/jdk/make/sun/xawt/mapfile-vers Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/make/sun/xawt/mapfile-vers Tue Nov 30 14:51:07 2010 -0800
@@ -432,6 +432,7 @@
Java_sun_awt_X11_GtkFileDialogPeer_initIDs;
Java_sun_awt_X11_GtkFileDialogPeer_run;
Java_sun_awt_X11_GtkFileDialogPeer_quit;
+ Java_sun_awt_X11_GtkFileDialogPeer_toFront;
Java_sun_print_CUPSPrinter_initIDs;
Java_sun_print_CUPSPrinter_getCupsServer;
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/AdaptiveCoding.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,8 +25,10 @@
package com.sun.java.util.jar.pack;
-import java.util.*;
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
/**
* Adaptive coding.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Attribute.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,9 +25,17 @@
package com.sun.java.util.jar.pack;
-import java.io.*;
-import java.util.*;
-import com.sun.java.util.jar.pack.ConstantPool.*;
+import com.sun.java.util.jar.pack.ConstantPool.Entry;
+import com.sun.java.util.jar.pack.ConstantPool.Index;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.Map;
/**
* Represents an attribute in a class-file.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/BandStructure.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,12 +25,28 @@
package com.sun.java.util.jar.pack;
-import java.io.*;
-import java.util.*;
-import java.util.jar.*;
-import com.sun.java.util.jar.pack.Package.Class;
-import com.sun.java.util.jar.pack.Package.InnerClass;
-import com.sun.java.util.jar.pack.ConstantPool.*;
+import com.sun.java.util.jar.pack.ConstantPool.Entry;
+import com.sun.java.util.jar.pack.ConstantPool.Index;
+import com.sun.java.util.jar.pack.Package.Class.Field;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.EOFException;
+import java.io.File;
+import java.io.FileOutputStream;
+import java.io.FilterInputStream;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.jar.Pack200;
/**
* Define the structure and ordering of "bands" in a packed file.
@@ -1629,7 +1645,7 @@
}
}
- protected void setConstantValueIndex(Class.Field f) {
+ protected void setConstantValueIndex(com.sun.java.util.jar.pack.Package.Class.Field f) {
Index ix = null;
if (f != null) {
byte tag = f.getLiteralTag();
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassReader.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,11 +25,19 @@
package com.sun.java.util.jar.pack;
-import java.io.*;
-import java.util.*;
+import com.sun.java.util.jar.pack.ConstantPool.ClassEntry;
+import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry;
+import com.sun.java.util.jar.pack.ConstantPool.Entry;
+import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry;
+import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry;
import com.sun.java.util.jar.pack.Package.Class;
import com.sun.java.util.jar.pack.Package.InnerClass;
-import com.sun.java.util.jar.pack.ConstantPool.*;
+import java.io.DataInputStream;
+import java.io.FilterInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.util.ArrayList;
+import java.util.Map;
/**
* Reader for a class file that is being incorporated into a package.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ClassWriter.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,11 +25,19 @@
package com.sun.java.util.jar.pack;
-import java.io.*;
-import java.util.*;
+
+import com.sun.java.util.jar.pack.ConstantPool.Entry;
+import com.sun.java.util.jar.pack.ConstantPool.Index;
+import com.sun.java.util.jar.pack.ConstantPool.NumberEntry;
import com.sun.java.util.jar.pack.Package.Class;
import com.sun.java.util.jar.pack.Package.InnerClass;
-import com.sun.java.util.jar.pack.ConstantPool.*;
+import java.io.BufferedOutputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.DataOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.Iterator;
+import java.util.List;
/**
* Writer for a class file that is incorporated into a package.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Code.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,10 +25,10 @@
package com.sun.java.util.jar.pack;
-import java.io.*;
-import java.util.*;
import com.sun.java.util.jar.pack.Package.Class;
import java.lang.reflect.Modifier;
+import java.util.Arrays;
+import java.util.Collection;
/**
* Represents a chunk of bytecodes.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Coding.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,8 +25,10 @@
package com.sun.java.util.jar.pack;
-import java.io.*;
-import java.util.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashMap;
/**
* Define the conversions between sequences of small integers and raw bytes.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingChooser.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,9 +25,17 @@
package com.sun.java.util.jar.pack;
-import java.io.*;
-import java.util.*;
-import java.util.zip.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Random;
+import java.util.zip.Deflater;
+import java.util.zip.DeflaterOutputStream;
/**
* Heuristic chooser of basic encodings.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/CodingMethod.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,7 +25,9 @@
package com.sun.java.util.jar.pack;
-import java.io.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
/**
* Interface for encoding and decoding int arrays using bytewise codes.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/ConstantPool.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,7 +25,14 @@
package com.sun.java.util.jar.pack;
-import java.util.*;
+import java.util.AbstractList;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
/**
* Representation of constant pool entries and indexes.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Constants.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,7 +25,8 @@
package com.sun.java.util.jar.pack;
-import java.util.*;
+import java.util.Arrays;
+import java.util.List;
/**
* Shared constants
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Driver.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,11 +25,32 @@
package com.sun.java.util.jar.pack;
-import java.io.*;
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.FileOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.PrintStream;
import java.text.MessageFormat;
-import java.util.*;
-import java.util.jar.*;
-import java.util.zip.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Properties;
+import java.util.ResourceBundle;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.jar.JarFile;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Pack200;
+import java.util.zip.GZIPInputStream;
+import java.util.zip.GZIPOutputStream;
/** Command line interface for Pack200.
*/
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Fixups.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,9 +25,11 @@
package com.sun.java.util.jar.pack;
-import java.io.*;
-import java.util.*;
-import com.sun.java.util.jar.pack.ConstantPool.*;
+import com.sun.java.util.jar.pack.ConstantPool.Entry;
+import java.util.AbstractCollection;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.Iterator;
/**
* Collection of relocatable constant pool references.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Histogram.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,8 +25,10 @@
package com.sun.java.util.jar.pack;
-import java.util.*;
-import java.io.*;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.util.Arrays;
/**
* Histogram derived from an integer array of events (int[]).
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/NativeUnpack.java Tue Nov 30 14:51:07 2010 -0800
@@ -26,10 +26,18 @@
package com.sun.java.util.jar.pack;
-import java.nio.*;
-import java.io.*;
-import java.util.jar.*;
-import java.util.zip.*;
+import java.io.BufferedInputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.nio.ByteBuffer;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Pack200;
+import java.util.zip.CRC32;
+import java.util.zip.Deflater;
+import java.util.zip.ZipEntry;
+import java.util.zip.ZipOutputStream;
class NativeUnpack {
// Pointer to the native unpacker obj
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Package.java Tue Nov 30 14:51:07 2010 -0800
@@ -26,11 +26,32 @@
package com.sun.java.util.jar.pack;
import com.sun.java.util.jar.pack.Attribute.Layout;
+import com.sun.java.util.jar.pack.ConstantPool.ClassEntry;
+import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry;
+import com.sun.java.util.jar.pack.ConstantPool.Index;
+import com.sun.java.util.jar.pack.ConstantPool.LiteralEntry;
+import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry;
+import com.sun.java.util.jar.pack.ConstantPool.Entry;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.io.SequenceInputStream;
import java.lang.reflect.Modifier;
-import java.util.*;
-import java.util.jar.*;
-import java.io.*;
-import com.sun.java.util.jar.pack.ConstantPool.*;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Collection;
+import java.util.Collections;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.Set;
+import java.util.jar.JarFile;
/**
* Define the main data structure transmitted by pack/unpack.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageReader.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,12 +25,18 @@
package com.sun.java.util.jar.pack;
+import com.sun.java.util.jar.pack.ConstantPool.ClassEntry;
+import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry;
+import com.sun.java.util.jar.pack.ConstantPool.Entry;
+import com.sun.java.util.jar.pack.ConstantPool.Index;
+import com.sun.java.util.jar.pack.ConstantPool.MemberEntry;
+import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry;
+import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry;
import java.io.*;
import java.util.*;
import com.sun.java.util.jar.pack.Package.Class;
import com.sun.java.util.jar.pack.Package.File;
import com.sun.java.util.jar.pack.Package.InnerClass;
-import com.sun.java.util.jar.pack.ConstantPool.*;
/**
* Reader for a package file.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackageWriter.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,12 +25,30 @@
package com.sun.java.util.jar.pack;
-import java.io.*;
-import java.util.*;
+import com.sun.java.util.jar.pack.ConstantPool.ClassEntry;
+import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry;
+import com.sun.java.util.jar.pack.ConstantPool.Entry;
+import com.sun.java.util.jar.pack.ConstantPool.Index;
+import com.sun.java.util.jar.pack.ConstantPool.IndexGroup;
+import com.sun.java.util.jar.pack.ConstantPool.MemberEntry;
+import com.sun.java.util.jar.pack.ConstantPool.NumberEntry;
+import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry;
+import com.sun.java.util.jar.pack.ConstantPool.StringEntry;
import com.sun.java.util.jar.pack.Package.Class;
import com.sun.java.util.jar.pack.Package.File;
import com.sun.java.util.jar.pack.Package.InnerClass;
-import com.sun.java.util.jar.pack.ConstantPool.*;
+import java.io.IOException;
+import java.io.OutputStream;
+import java.io.PrintStream;
+import java.util.ArrayList;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.HashMap;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
/**
* Writer for a package file.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PackerImpl.java Tue Nov 30 14:51:07 2010 -0800
@@ -26,10 +26,27 @@
package com.sun.java.util.jar.pack;
import com.sun.java.util.jar.pack.Attribute.Layout;
-import java.util.*;
-import java.util.jar.*;
-import java.io.*;
import java.beans.PropertyChangeListener;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.ArrayList;
+import java.util.Collections;
+import java.util.HashMap;
+import java.util.List;
+import java.util.ListIterator;
+import java.util.Map;
+import java.util.SortedMap;
+import java.util.TimeZone;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.Pack200;
/*
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PopulationCoding.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,8 +25,12 @@
package com.sun.java.util.jar.pack;
-import java.util.*;
-import java.io.*;
+import java.io.ByteArrayOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Arrays;
+import java.util.HashSet;
/**
* Population-based coding.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/PropMap.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,13 +25,24 @@
package com.sun.java.util.jar.pack;
-import java.util.*;
-import java.util.jar.*;
-import java.util.jar.Pack200;
-import java.util.zip.*;
-import java.io.*;
import java.beans.PropertyChangeListener;
import java.beans.PropertyChangeEvent;
+import java.io.BufferedInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.PrintStream;
+import java.io.PrintWriter;
+import java.util.ArrayList;
+import java.util.Collection;
+import java.util.HashMap;
+import java.util.Iterator;
+import java.util.List;
+import java.util.Map;
+import java.util.Properties;
+import java.util.Set;
+import java.util.SortedMap;
+import java.util.TreeMap;
+import java.util.jar.Pack200;
/**
* Control block for publishing Pack200 options to the other classes.
*/
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/UnpackerImpl.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,11 +25,25 @@
package com.sun.java.util.jar.pack;
-import java.util.*;
-import java.util.jar.*;
-import java.util.zip.*;
-import java.io.*;
import java.beans.PropertyChangeListener;
+import java.io.BufferedInputStream;
+import java.io.ByteArrayOutputStream;
+import java.io.File;
+import java.io.FileInputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.HashSet;
+import java.util.Iterator;
+import java.util.SortedMap;
+import java.util.TimeZone;
+import java.util.jar.JarEntry;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.jar.Pack200;
+import java.util.zip.CRC32;
+import java.util.zip.CheckedOutputStream;
+import java.util.zip.ZipEntry;
/*
* Implementation of the Pack provider.
--- a/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/com/sun/java/util/jar/pack/Utils.java Tue Nov 30 14:51:07 2010 -0800
@@ -25,18 +25,27 @@
package com.sun.java.util.jar.pack;
-import com.sun.java.util.jar.pack.Attribute.Layout;
import com.sun.java.util.jar.pack.ConstantPool.ClassEntry;
import com.sun.java.util.jar.pack.ConstantPool.DescriptorEntry;
import com.sun.java.util.jar.pack.ConstantPool.LiteralEntry;
import com.sun.java.util.jar.pack.ConstantPool.MemberEntry;
import com.sun.java.util.jar.pack.ConstantPool.SignatureEntry;
import com.sun.java.util.jar.pack.ConstantPool.Utf8Entry;
-import java.util.*;
-import java.util.jar.*;
-import java.util.zip.*;
-import java.io.*;
-
+import java.io.BufferedInputStream;
+import java.io.BufferedOutputStream;
+import java.io.File;
+import java.io.FilterOutputStream;
+import java.io.IOException;
+import java.io.InputStream;
+import java.io.OutputStream;
+import java.util.Date;
+import java.util.Enumeration;
+import java.util.Map;
+import java.util.jar.JarEntry;
+import java.util.jar.JarFile;
+import java.util.jar.JarInputStream;
+import java.util.jar.JarOutputStream;
+import java.util.zip.ZipEntry;
import sun.util.logging.PlatformLogger;
class Utils {
--- a/jdk/src/share/classes/java/awt/Color.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/java/awt/Color.java Tue Nov 30 14:51:07 2010 -0800
@@ -611,12 +611,15 @@
* <p>
* This method applies an arbitrary scale factor to each of the three RGB
* components of this <code>Color</code> to create a brighter version
- * of this <code>Color</code>. Although <code>brighter</code> and
+ * of this <code>Color</code>.
+ * The {@code alpha} value is preserved.
+ * Although <code>brighter</code> and
* <code>darker</code> are inverse operations, the results of a
* series of invocations of these two methods might be inconsistent
* because of rounding errors.
* @return a new <code>Color</code> object that is
- * a brighter version of this <code>Color</code>.
+ * a brighter version of this <code>Color</code>
+ * with the same {@code alpha} value.
* @see java.awt.Color#darker
* @since JDK1.0
*/
@@ -624,6 +627,7 @@
int r = getRed();
int g = getGreen();
int b = getBlue();
+ int alpha = getAlpha();
/* From 2D group:
* 1. black.brighter() should return grey
@@ -632,7 +636,7 @@
*/
int i = (int)(1.0/(1.0-FACTOR));
if ( r == 0 && g == 0 && b == 0) {
- return new Color(i, i, i);
+ return new Color(i, i, i, alpha);
}
if ( r > 0 && r < i ) r = i;
if ( g > 0 && g < i ) g = i;
@@ -640,7 +644,8 @@
return new Color(Math.min((int)(r/FACTOR), 255),
Math.min((int)(g/FACTOR), 255),
- Math.min((int)(b/FACTOR), 255));
+ Math.min((int)(b/FACTOR), 255),
+ alpha);
}
/**
@@ -649,19 +654,23 @@
* <p>
* This method applies an arbitrary scale factor to each of the three RGB
* components of this <code>Color</code> to create a darker version of
- * this <code>Color</code>. Although <code>brighter</code> and
+ * this <code>Color</code>.
+ * The {@code alpha} value is preserved.
+ * Although <code>brighter</code> and
* <code>darker</code> are inverse operations, the results of a series
* of invocations of these two methods might be inconsistent because
* of rounding errors.
* @return a new <code>Color</code> object that is
- * a darker version of this <code>Color</code>.
+ * a darker version of this <code>Color</code>
+ * with the same {@code alpha} value.
* @see java.awt.Color#brighter
* @since JDK1.0
*/
public Color darker() {
return new Color(Math.max((int)(getRed() *FACTOR), 0),
Math.max((int)(getGreen()*FACTOR), 0),
- Math.max((int)(getBlue() *FACTOR), 0));
+ Math.max((int)(getBlue() *FACTOR), 0),
+ getAlpha());
}
/**
--- a/jdk/src/share/classes/java/awt/Container.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/java/awt/Container.java Tue Nov 30 14:51:07 2010 -0800
@@ -51,6 +51,7 @@
import sun.util.logging.PlatformLogger;
import sun.awt.AppContext;
+import sun.awt.AWTAccessor;
import sun.awt.CausedFocusEvent;
import sun.awt.PeerEvent;
import sun.awt.SunToolkit;
@@ -247,6 +248,13 @@
if (!GraphicsEnvironment.isHeadless()) {
initIDs();
}
+
+ AWTAccessor.setContainerAccessor(new AWTAccessor.ContainerAccessor() {
+ @Override
+ public void validateUnconditionally(Container cont) {
+ cont.validateUnconditionally();
+ }
+ });
}
/**
--- a/jdk/src/share/classes/java/awt/Dialog.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/java/awt/Dialog.java Tue Nov 30 14:51:07 2010 -0800
@@ -1248,14 +1248,31 @@
/**
* Disables or enables decorations for this dialog.
- * This method can only be called while the dialog is not displayable.
- * @param undecorated <code>true</code> if no dialog decorations are
- * to be enabled;
- * <code>false</code> if dialog decorations are to be enabled.
- * @throws <code>IllegalComponentStateException</code> if the dialog
- * is displayable.
+ * <p>
+ * This method can only be called while the dialog is not displayable. To
+ * make this dialog decorated, it must be opaque and have the default shape,
+ * otherwise the {@code IllegalComponentStateException} will be thrown.
+ * Refer to {@link Window#setShape}, {@link Window#setOpacity} and {@link
+ * Window#setBackground} for details
+ *
+ * @param undecorated {@code true} if no dialog decorations are to be
+ * enabled; {@code false} if dialog decorations are to be enabled
+ *
+ * @throws IllegalComponentStateException if the dialog is displayable
+ * @throws IllegalComponentStateException if {@code undecorated} is
+ * {@code false}, and this dialog does not have the default shape
+ * @throws IllegalComponentStateException if {@code undecorated} is
+ * {@code false}, and this dialog opacity is less than {@code 1.0f}
+ * @throws IllegalComponentStateException if {@code undecorated} is
+ * {@code false}, and the alpha value of this dialog background
+ * color is less than {@code 1.0f}
+ *
* @see #isUndecorated
* @see Component#isDisplayable
+ * @see Window#getShape
+ * @see Window#getOpacity
+ * @see Window#getBackground
+ *
* @since 1.4
*/
public void setUndecorated(boolean undecorated) {
@@ -1264,6 +1281,18 @@
if (isDisplayable()) {
throw new IllegalComponentStateException("The dialog is displayable.");
}
+ if (!undecorated) {
+ if (getOpacity() < 1.0f) {
+ throw new IllegalComponentStateException("The dialog is not opaque");
+ }
+ if (getShape() != null) {
+ throw new IllegalComponentStateException("The dialog does not have a default shape");
+ }
+ Color bg = getBackground();
+ if ((bg != null) && (bg.getAlpha() < 255)) {
+ throw new IllegalComponentStateException("The dialog background color is not opaque");
+ }
+ }
this.undecorated = undecorated;
}
}
@@ -1281,6 +1310,45 @@
}
/**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setOpacity(float opacity) {
+ synchronized (getTreeLock()) {
+ if ((opacity < 1.0f) && !isUndecorated()) {
+ throw new IllegalComponentStateException("The dialog is decorated");
+ }
+ super.setOpacity(opacity);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setShape(Shape shape) {
+ synchronized (getTreeLock()) {
+ if ((shape != null) && !isUndecorated()) {
+ throw new IllegalComponentStateException("The dialog is decorated");
+ }
+ super.setShape(shape);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setBackground(Color bgColor) {
+ synchronized (getTreeLock()) {
+ if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) {
+ throw new IllegalComponentStateException("The dialog is decorated");
+ }
+ super.setBackground(bgColor);
+ }
+ }
+
+ /**
* Returns a string representing the state of this dialog. This
* method is intended to be used only for debugging purposes, and the
* content and format of the returned string may vary between
--- a/jdk/src/share/classes/java/awt/FileDialog.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/java/awt/FileDialog.java Tue Nov 30 14:51:07 2010 -0800
@@ -99,7 +99,7 @@
* Contains the File instances for all the files that the user selects.
*
* @serial
- * @see getFiles
+ * @see #getFiles
* @since 1.7
*/
private File[] files;
--- a/jdk/src/share/classes/java/awt/Frame.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/java/awt/Frame.java Tue Nov 30 14:51:07 2010 -0800
@@ -828,6 +828,11 @@
return frame.state;
}
}
+ public Rectangle getMaximizedBounds(Frame frame) {
+ synchronized(frame.getObjectLock()) {
+ return frame.maximizedBounds;
+ }
+ }
}
);
}
@@ -855,8 +860,10 @@
* @see #getMaximizedBounds()
* @since 1.4
*/
- public synchronized void setMaximizedBounds(Rectangle bounds) {
- this.maximizedBounds = bounds;
+ public void setMaximizedBounds(Rectangle bounds) {
+ synchronized(getObjectLock()) {
+ this.maximizedBounds = bounds;
+ }
FramePeer peer = (FramePeer)this.peer;
if (peer != null) {
peer.setMaximizedBounds(bounds);
@@ -873,21 +880,40 @@
* @since 1.4
*/
public Rectangle getMaximizedBounds() {
- return maximizedBounds;
+ synchronized(getObjectLock()) {
+ return maximizedBounds;
+ }
}
/**
* Disables or enables decorations for this frame.
- * This method can only be called while the frame is not displayable.
- * @param undecorated <code>true</code> if no frame decorations are
- * to be enabled;
- * <code>false</code> if frame decorations are to be enabled.
- * @throws <code>IllegalComponentStateException</code> if the frame
- * is displayable.
+ * <p>
+ * This method can only be called while the frame is not displayable. To
+ * make this frame decorated, it must be opaque and have the default shape,
+ * otherwise the {@code IllegalComponentStateException} will be thrown.
+ * Refer to {@link Window#setShape}, {@link Window#setOpacity} and {@link
+ * Window#setBackground} for details
+ *
+ * @param undecorated {@code true} if no frame decorations are to be
+ * enabled; {@code false} if frame decorations are to be enabled
+ *
+ * @throws IllegalComponentStateException if the frame is displayable
+ * @throws IllegalComponentStateException if {@code undecorated} is
+ * {@code false}, and this frame does not have the default shape
+ * @throws IllegalComponentStateException if {@code undecorated} is
+ * {@code false}, and this frame opacity is less than {@code 1.0f}
+ * @throws IllegalComponentStateException if {@code undecorated} is
+ * {@code false}, and the alpha value of this frame background
+ * color is less than {@code 1.0f}
+ *
* @see #isUndecorated
* @see Component#isDisplayable
+ * @see Window#getShape
+ * @see Window#getOpacity
+ * @see Window#getBackground
* @see javax.swing.JFrame#setDefaultLookAndFeelDecorated(boolean)
+ *
* @since 1.4
*/
public void setUndecorated(boolean undecorated) {
@@ -896,6 +922,18 @@
if (isDisplayable()) {
throw new IllegalComponentStateException("The frame is displayable.");
}
+ if (!undecorated) {
+ if (getOpacity() < 1.0f) {
+ throw new IllegalComponentStateException("The frame is not opaque");
+ }
+ if (getShape() != null) {
+ throw new IllegalComponentStateException("The frame does not have a default shape");
+ }
+ Color bg = getBackground();
+ if ((bg != null) && (bg.getAlpha() < 255)) {
+ throw new IllegalComponentStateException("The frame background color is not opaque");
+ }
+ }
this.undecorated = undecorated;
}
}
@@ -913,6 +951,45 @@
}
/**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setOpacity(float opacity) {
+ synchronized (getTreeLock()) {
+ if ((opacity < 1.0f) && !isUndecorated()) {
+ throw new IllegalComponentStateException("The frame is decorated");
+ }
+ super.setOpacity(opacity);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setShape(Shape shape) {
+ synchronized (getTreeLock()) {
+ if ((shape != null) && !isUndecorated()) {
+ throw new IllegalComponentStateException("The frame is decorated");
+ }
+ super.setShape(shape);
+ }
+ }
+
+ /**
+ * {@inheritDoc}
+ */
+ @Override
+ public void setBackground(Color bgColor) {
+ synchronized (getTreeLock()) {
+ if ((bgColor != null) && (bgColor.getAlpha() < 255) && !isUndecorated()) {
+ throw new IllegalComponentStateException("The frame is decorated");
+ }
+ super.setBackground(bgColor);
+ }
+ }
+
+ /**
* Removes the specified menu bar from this frame.
* @param m the menu component to remove.
* If <code>m</code> is <code>null</code>, then
--- a/jdk/src/share/classes/java/awt/Window.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/java/awt/Window.java Tue Nov 30 14:51:07 2010 -0800
@@ -3474,14 +3474,20 @@
* level of 0 may or may not disable the mouse event handling on this
* window. This is a platform-dependent behavior.
* <p>
- * In order for this method to enable the translucency effect, the {@link
- * GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)} method must indicate that
- * the {@link GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT}
- * translucency is supported.
+ * The following conditions must be met in order to set the opacity value
+ * less than {@code 1.0f}:
+ * <ul>
+ * <li>The {@link GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT}
+ * translucency must be supported by the underlying system
+ * <li>The window must be undecorated (see {@link Frame#setUndecorated}
+ * and {@link Dialog#setUndecorated})
+ * <li>The window must not be in full-screen mode (see {@link
+ * GraphicsDevice#setFullScreenWindow(Window)})
+ * </ul>
* <p>
- * Also note that the window must not be in the full-screen mode when
- * setting the opacity value < 1.0f. Otherwise the {@code
- * IllegalComponentStateException} is thrown.
+ * If the requested opacity value is less than {@code 1.0f}, and any of the
+ * above conditions are not met, the window opacity will not change,
+ * and the {@code IllegalComponentStateException} will be thrown.
* <p>
* The translucency levels of individual pixels may also be effected by the
* alpha component of their color (see {@link Window#setBackground(Color)}) and the
@@ -3491,15 +3497,20 @@
*
* @throws IllegalArgumentException if the opacity is out of the range
* [0..1]
+ * @throws IllegalComponentStateException if the window is decorated and
+ * the opacity is less than {@code 1.0f}
* @throws IllegalComponentStateException if the window is in full screen
- * mode, and the opacity is less than 1.0f
+ * mode, and the opacity is less than {@code 1.0f}
* @throws UnsupportedOperationException if the {@code
* GraphicsDevice.WindowTranslucency#TRANSLUCENT TRANSLUCENT}
- * translucency kind is not supported and the opacity is less than 1.0f
+ * translucency is not supported and the opacity is less than
+ * {@code 1.0f}
*
* @see Window#getOpacity
* @see Window#setBackground(Color)
* @see Window#setShape(Shape)
+ * @see Frame#isUndecorated
+ * @see Dialog#isUndecorated
* @see GraphicsDevice.WindowTranslucency
* @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
*
@@ -3557,24 +3568,26 @@
/**
* Sets the shape of the window.
* <p>
- * Setting a shape enables cutting off some parts of the window, leaving
- * visible and clickable only those parts belonging to the given shape
- * (see {@link Shape}). If the shape argument is null, this methods
- * restores the default shape (making the window rectangular on most
- * platforms.)
+ * Setting a shape cuts off some parts of the window. Only the parts that
+ * belong to the given {@link Shape} remain visible and clickable. If
+ * the shape argument is {@code null}, this method restores the default
+ * shape, making the window rectangular on most platforms.
* <p>
- * The following conditions must be met in order to set a non-null shape:
+ * The following conditions must be met to set a non-null shape:
* <ul>
* <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
- * PERPIXEL_TRANSPARENT} translucency kind must be supported by the
+ * PERPIXEL_TRANSPARENT} translucency must be supported by the
* underlying system
- * <i>and</i>
- * <li>The window must not be in the full-screen mode (see
- * {@link GraphicsDevice#setFullScreenWindow(Window)})
+ * <li>The window must be undecorated (see {@link Frame#setUndecorated}
+ * and {@link Dialog#setUndecorated})
+ * <li>The window must not be in full-screen mode (see {@link
+ * GraphicsDevice#setFullScreenWindow(Window)})
* </ul>
- * If a certain condition is not met, either the {@code
- * UnsupportedOperationException} or {@code IllegalComponentStateException}
- * is thrown.
+ * <p>
+ * If the requested shape is not {@code null}, and any of the above
+ * conditions are not met, the shape of this window will not change,
+ * and either the {@code UnsupportedOperationException} or {@code
+ * IllegalComponentStateException} will be thrown.
* <p>
* The tranlucency levels of individual pixels may also be effected by the
* alpha component of their color (see {@link Window#setBackground(Color)}) and the
@@ -3584,6 +3597,8 @@
* @param shape the shape to set to the window
*
* @throws IllegalComponentStateException if the shape is not {@code
+ * null} and the window is decorated
+ * @throws IllegalComponentStateException if the shape is not {@code
* null} and the window is in full-screen mode
* @throws UnsupportedOperationException if the shape is not {@code
* null} and {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSPARENT
@@ -3592,6 +3607,8 @@
* @see Window#getShape()
* @see Window#setBackground(Color)
* @see Window#setOpacity(float)
+ * @see Frame#isUndecorated
+ * @see Dialog#isUndecorated
* @see GraphicsDevice.WindowTranslucency
* @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
*
@@ -3645,37 +3662,46 @@
* GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT PERPIXEL_TRANSLUCENT}
* tranclucency, the alpha component of the given background color
* may effect the mode of operation for this window: it indicates whether
- * this window must be opaque (alpha == 1.0f) or per-pixel translucent
- * (alpha < 1.0f). All the following conditions must be met in order
- * to be able to enable the per-pixel transparency mode for this window:
+ * this window must be opaque (alpha equals {@code 1.0f}) or per-pixel translucent
+ * (alpha is less than {@code 1.0f}). If the given background color is
+ * {@code null}, the window is considered completely opaque.
+ * <p>
+ * All the following conditions must be met to enable the per-pixel
+ * transparency mode for this window:
* <ul>
* <li>The {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
- * PERPIXEL_TRANSLUCENT} translucency must be supported
- * by the graphics device where this window is located <i>and</i>
- * <li>The window must not be in the full-screen mode (see {@link
+ * PERPIXEL_TRANSLUCENT} translucency must be supported by the graphics
+ * device where this window is located
+ * <li>The window must be undecorated (see {@link Frame#setUndecorated}
+ * and {@link Dialog#setUndecorated})
+ * <li>The window must not be in full-screen mode (see {@link
* GraphicsDevice#setFullScreenWindow(Window)})
* </ul>
- * If a certain condition is not met at the time of calling this method,
- * the alpha component of the given background color will not effect the
- * mode of operation for this window.
+ * <p>
+ * If the alpha component of the requested background color is less than
+ * {@code 1.0f}, and any of the above conditions are not met, the background
+ * color of this window will not change, the alpha component of the given
+ * background color will not affect the mode of operation for this window,
+ * and either the {@code UnsupportedOperationException} or {@code
+ * IllegalComponentStateException} will be thrown.
* <p>
* When the window is per-pixel translucent, the drawing sub-system
* respects the alpha value of each individual pixel. If a pixel gets
* painted with the alpha color component equal to zero, it becomes
- * visually transparent, if the alpha of the pixel is equal to 1.0f, the
+ * visually transparent. If the alpha of the pixel is equal to 1.0f, the
* pixel is fully opaque. Interim values of the alpha color component make
- * the pixel semi-transparent. In this mode the background of the window
- * gets painted with the alpha value of the given background color (meaning
- * that it is not painted at all if the alpha value of the argument of this
- * method is equal to zero.)
+ * the pixel semi-transparent. In this mode, the background of the window
+ * gets painted with the alpha value of the given background color. If the
+ * alpha value of the argument of this method is equal to {@code 0}, the
+ * background is not painted at all.
* <p>
* The actual level of translucency of a given pixel also depends on window
* opacity (see {@link #setOpacity(float)}), as well as the current shape of
* this window (see {@link #setShape(Shape)}).
* <p>
- * Note that painting a pixel with the alpha value of 0 may or may not
- * disable the mouse event handling on this pixel. This is a
- * platform-dependent behavior. To make sure the mouse clicks do not get
+ * Note that painting a pixel with the alpha value of {@code 0} may or may
+ * not disable the mouse event handling on this pixel. This is a
+ * platform-dependent behavior. To make sure the mouse events do not get
* dispatched to a particular pixel, the pixel must be excluded from the
* shape of the window.
* <p>
@@ -3685,17 +3711,21 @@
* @param bgColor the color to become this window's background color.
*
* @throws IllegalComponentStateException if the alpha value of the given
- * background color is less than 1.0f and the window is in
+ * background color is less than {@code 1.0f} and the window is decorated
+ * @throws IllegalComponentStateException if the alpha value of the given
+ * background color is less than {@code 1.0f} and the window is in
* full-screen mode
* @throws UnsupportedOperationException if the alpha value of the given
- * background color is less than 1.0f and
- * {@link GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
+ * background color is less than {@code 1.0f} and {@link
+ * GraphicsDevice.WindowTranslucency#PERPIXEL_TRANSLUCENT
* PERPIXEL_TRANSLUCENT} translucency is not supported
*
* @see Window#getBackground
* @see Window#isOpaque
* @see Window#setOpacity(float)
* @see Window#setShape(Shape)
+ * @see Frame#isUndecorated
+ * @see Dialog#isUndecorated
* @see GraphicsDevice.WindowTranslucency
* @see GraphicsDevice#isWindowTranslucencySupported(GraphicsDevice.WindowTranslucency)
* @see GraphicsConfiguration#isTranslucencyCapable()
@@ -3739,7 +3769,7 @@
* <p>
* The method returns {@code false} if the background color of the window
* is not {@code null} and the alpha component of the color is less than
- * 1.0f. The method returns {@code true} otherwise.
+ * {@code 1.0f}. The method returns {@code true} otherwise.
*
* @return {@code true} if the window is opaque, {@code false} otherwise
*
--- a/jdk/src/share/classes/sun/awt/AWTAccessor.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/classes/sun/awt/AWTAccessor.java Tue Nov 30 14:51:07 2010 -0800
@@ -224,6 +224,16 @@
}
/*
+ * An interface of accessor for the java.awt.Container class.
+ */
+ public interface ContainerAccessor {
+ /**
+ * Validates the container unconditionally.
+ */
+ void validateUnconditionally(Container cont);
+ }
+
+ /*
* An interface of accessor for java.awt.Window class.
*/
public interface WindowAccessor {
@@ -334,6 +344,10 @@
* Gets the state of this frame.
*/
int getExtendedState(Frame frame);
+ /*
+ * Gets the maximized bounds of this frame.
+ */
+ Rectangle getMaximizedBounds(Frame frame);
}
/*
@@ -440,53 +454,19 @@
}
/*
- * The java.awt.Component class accessor object.
+ * Accessor instances are initialized in the static initializers of
+ * corresponding AWT classes by using setters defined below.
*/
private static ComponentAccessor componentAccessor;
-
- /*
- * The java.awt.Window class accessor object.
- */
+ private static ContainerAccessor containerAccessor;
private static WindowAccessor windowAccessor;
-
- /*
- * The java.awt.AWTEvent class accessor object.
- */
private static AWTEventAccessor awtEventAccessor;
-
- /*
- * The java.awt.event.InputEvent class accessor object.
- */
private static InputEventAccessor inputEventAccessor;
-
- /*
- * The java.awt.Frame class accessor object.
- */
private static FrameAccessor frameAccessor;
-
- /*
- * The java.awt.KeyboardFocusManager class accessor object.
- */
private static KeyboardFocusManagerAccessor kfmAccessor;
-
- /*
- * The java.awt.MenuComponent class accessor object.
- */
private static MenuComponentAccessor menuComponentAccessor;
-
- /*
- * The java.awt.EventQueue class accessor object.
- */
private static EventQueueAccessor eventQueueAccessor;
-
- /*
- * The java.awt.PopupMenu class accessor object.
- */
private static PopupMenuAccessor popupMenuAccessor;
-
- /*
- * The java.awt.FileDialog class accessor object.
- */
private static FileDialogAccessor fileDialogAccessor;
/*
@@ -497,7 +477,7 @@
}
/*
- * Retrieve the accessor object for the java.awt.Window class.
+ * Retrieve the accessor object for the java.awt.Component class.
*/
public static ComponentAccessor getComponentAccessor() {
if (componentAccessor == null) {
@@ -508,6 +488,24 @@
}
/*
+ * Set an accessor object for the java.awt.Container class.
+ */
+ public static void setContainerAccessor(ContainerAccessor ca) {
+ containerAccessor = ca;
+ }
+
+ /*
+ * Retrieve the accessor object for the java.awt.Container class.
+ */
+ public static ContainerAccessor getContainerAccessor() {
+ if (containerAccessor == null) {
+ unsafe.ensureClassInitialized(Container.class);
+ }
+
+ return containerAccessor;
+ }
+
+ /*
* Set an accessor object for the java.awt.Window class.
*/
public static void setWindowAccessor(WindowAccessor wa) {
--- a/jdk/src/share/demo/applets/NervousText/example1.html Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/demo/applets/NervousText/example1.html Tue Nov 30 14:51:07 2010 -0800
@@ -1,7 +1,7 @@
<title>Nervous Text 1.1</title>
<hr>
<applet code="NervousText.class" width=534 height=50>
-<param name=text value="Java^T^M 2 SDK, Standard Edition 6.0">
+<param name=text value="Java SE Development Kit (JDK) 7.0">
</applet>
<hr>
<a href="NervousText.java">The source.</a>
--- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/J2DBench.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/J2DBench.java Tue Nov 30 14:51:07 2010 -0800
@@ -75,7 +75,8 @@
static JFrame guiFrame;
- static final SimpleDateFormat sdf = new SimpleDateFormat("MM.dd.yyyy 'at' HH:mm aaa z");
+ static final SimpleDateFormat sdf =
+ new SimpleDateFormat("MM.dd.yyyy 'at' HH:mm aaa z");
public static void init() {
progoptroot = new Group("prog", "Program Options");
@@ -176,6 +177,8 @@
public static void main(String argv[]) {
init();
TestEnvironment.init();
+ Result.init();
+
Destinations.init();
GraphicsTests.init();
RenderTests.init();
@@ -323,7 +326,7 @@
} else if (type.equalsIgnoreCase("m")) {
multiplyWith = 60;
} else {
- System.out.println("Invalid \"-loop\" option specified.");
+ System.err.println("Invalid \"-loop\" option specified.");
usage(1);
}
@@ -331,32 +334,20 @@
try {
val = Integer.parseInt(argv[i].substring(0, argv[i].length() - 1));
} catch(Exception e) {
- System.out.println("Invalid \"-loop\" option specified.");
+ System.err.println("Invalid \"-loop\" option specified.");
usage(1);
}
requiredLoopTime = val * multiplyWith * 1000;
}
- } else if (arg.length() > 7 &&
- arg.substring(0, 7).equalsIgnoreCase("-report"))
- {
- for (int j = 7; j < arg.length(); j++) {
- char c = arg.charAt(j);
- switch (c) {
- case 'N': Result.unitScale = Result.UNITS_WHOLE; break;
- case 'M': Result.unitScale = Result.UNITS_MILLIONS; break;
- case 'K': Result.unitScale = Result.UNITS_THOUSANDS; break;
- case 'A': Result.unitScale = Result.UNITS_AUTO; break;
- case 'U': Result.useUnits = true; break;
- case 'O': Result.useUnits = false; break;
- case 's': Result.timeScale = Result.SECONDS_WHOLE; break;
- case 'm': Result.timeScale = Result.SECONDS_MILLIS; break;
- case 'u': Result.timeScale = Result.SECONDS_MICROS; break;
- case 'n': Result.timeScale = Result.SECONDS_NANOS; break;
- case 'a': Result.timeScale = Result.SECONDS_AUTO; break;
- case '/': Result.invertRate = !Result.invertRate; break;
- }
+ } else if (arg.length() > 8 &&
+ arg.substring(0, 8).equalsIgnoreCase("-report:"))
+ {
+ String error = Result.parseRateOpt(arg.substring(8));
+ if (error != null) {
+ System.err.println("Invalid rate: "+error);
+ usage(1);
}
} else {
String reason = Group.root.setOption(arg);
@@ -411,7 +402,7 @@
writer.flush();
} catch(IOException ioe) {
ioe.printStackTrace();
- System.out.println("\nERROR : Could not create Loop-Report. Exit");
+ System.err.println("\nERROR : Could not create Loop-Report. Exit");
System.exit(1);
}
}
@@ -466,7 +457,7 @@
} while(J2DBench.looping);
- if(J2DBench.looping) {
+ if (J2DBench.looping) {
writer.println("</html>");
writer.flush();
writer.close();
--- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Option.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Option.java Tue Nov 30 14:51:07 2010 -0800
@@ -170,7 +170,7 @@
updateGUI();
jcb.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
- if (e.getStateChange() == e.SELECTED) {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
JComboBox jcb = (JComboBox) e.getItemSelectable();
value = jcb.getSelectedIndex();
if (J2DBench.verbose.isEnabled()) {
@@ -261,7 +261,7 @@
updateGUI();
jcb.addItemListener(new ItemListener() {
public void itemStateChanged(ItemEvent e) {
- value = (e.getStateChange() == e.SELECTED);
+ value = (e.getStateChange() == ItemEvent.SELECTED);
if (J2DBench.verbose.isEnabled()) {
System.out.println(getOptionString());
}
@@ -569,8 +569,6 @@
}
public String setValueFromString(String value) {
- int prev = 0;
- int next = 0;
int enabled = 0;
StringTokenizer st = new StringTokenizer(value, ",");
while (st.hasMoreTokens()) {
@@ -588,7 +586,6 @@
if (s != null) {
return "Bad value in list ("+s+")";
}
- prev = next+1;
}
this.enabled = enabled;
updateGUI();
@@ -623,6 +620,175 @@
}
}
+ public static class ObjectChoice extends Option {
+ int size;
+ String optionnames[];
+ Object optionvalues[];
+ String abbrevnames[];
+ String descnames[];
+ int defaultselected;
+ int selected;
+ JPanel jp;
+ JComboBox jcombo;
+
+ public ObjectChoice(Group parent, String nodeName, String description,
+ String optionnames[],
+ Object optionvalues[],
+ String abbrevnames[],
+ String descnames[],
+ int defaultselected)
+ {
+ this(parent, nodeName, description,
+ Math.min(Math.min(optionnames.length,
+ optionvalues.length),
+ Math.min(abbrevnames.length,
+ descnames.length)),
+ optionnames, optionvalues,
+ abbrevnames, descnames, defaultselected);
+ }
+
+ public ObjectChoice(Group parent, String nodeName, String description,
+ int size,
+ String optionnames[],
+ Object optionvalues[],
+ String abbrevnames[],
+ String descnames[],
+ int defaultselected)
+ {
+ super(parent, nodeName, description);
+ this.size = size;
+ this.optionnames = trim(optionnames, size);
+ this.optionvalues = trim(optionvalues, size);
+ this.abbrevnames = trim(abbrevnames, size);
+ this.descnames = trim(descnames, size);
+ this.selected = this.defaultselected = defaultselected;
+ }
+
+ private static String[] trim(String list[], int size) {
+ if (list.length == size) {
+ return list;
+ }
+ String newlist[] = new String[size];
+ System.arraycopy(list, 0, newlist, 0, size);
+ return newlist;
+ }
+
+ private static Object[] trim(Object list[], int size) {
+ if (list.length == size) {
+ return list;
+ }
+ Object newlist[] = new Object[size];
+ System.arraycopy(list, 0, newlist, 0, size);
+ return newlist;
+ }
+
+ public void restoreDefault() {
+ if (selected != defaultselected) {
+ selected = defaultselected;
+ updateGUI();
+ }
+ }
+
+ public void updateGUI() {
+ if (jcombo != null) {
+ jcombo.setSelectedIndex(this.selected);
+ }
+ }
+
+ public boolean isDefault() {
+ return (selected == defaultselected);
+ }
+
+ public Modifier.Iterator getIterator(TestEnvironment env) {
+ return new SwitchIterator(optionvalues, 1 << selected);
+ }
+
+ public JComponent getJComponent() {
+ if (jp == null) {
+ jp = new JPanel();
+ jp.setLayout(new BorderLayout());
+ jp.add(new JLabel(getDescription()), BorderLayout.WEST);
+ jcombo = new JComboBox(descnames);
+ updateGUI();
+ jcombo.addItemListener(new ItemListener() {
+ public void itemStateChanged(ItemEvent e) {
+ if (e.getStateChange() == ItemEvent.SELECTED) {
+ selected = jcombo.getSelectedIndex();
+ if (J2DBench.verbose.isEnabled()) {
+ System.out.println(getOptionString());
+ }
+ }
+ }
+ });
+ jp.add(jcombo, BorderLayout.EAST);
+ }
+ return jp;
+ }
+
+ public Object getValue() {
+ return optionvalues[selected];
+ }
+
+ public int getIntValue() {
+ return ((Integer) optionvalues[selected]).intValue();
+ }
+
+ public boolean getBooleanValue() {
+ return ((Boolean) optionvalues[selected]).booleanValue();
+ }
+
+ public String getValString() {
+ return optionnames[selected];
+ }
+
+ int findValueIndex(Object value) {
+ for (int i = 0; i < size; i++) {
+ if (optionvalues[i] == value) {
+ return i;
+ }
+ }
+ return -1;
+ }
+
+ public String getValString(Object value) {
+ return optionnames[findValueIndex(value)];
+ }
+
+ public String getAbbreviatedModifierDescription(Object value) {
+ return abbrevnames[findValueIndex(value)];
+ }
+
+ public String setValue(int v) {
+ return setValue(new Integer(v));
+ }
+
+ public String setValue(boolean v) {
+ return setValue(new Boolean(v));
+ }
+
+ public String setValue(Object value) {
+ for (int i = 0; i < size; i++) {
+ if (optionvalues[i].equals(value)) {
+ this.selected = i;
+ updateGUI();
+ return null;
+ }
+ }
+ return "Bad value";
+ }
+
+ public String setValueFromString(String value) {
+ for (int i = 0; i < size; i++) {
+ if (optionnames[i].equals(value)) {
+ this.selected = i;
+ updateGUI();
+ return null;
+ }
+ }
+ return "Bad value";
+ }
+ }
+
public static class BooleanIterator implements Modifier.Iterator {
private Boolean list[];
private int index;
--- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Result.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/Result.java Tue Nov 30 14:51:07 2010 -0800
@@ -35,23 +35,199 @@
import java.util.Hashtable;
import java.util.Enumeration;
import java.io.PrintWriter;
+import java.util.HashMap;
public class Result {
- public static final int UNITS_WHOLE = 0;
- public static final int UNITS_THOUSANDS = 1;
- public static final int UNITS_MILLIONS = 2;
- public static final int UNITS_AUTO = 3;
+ public static final int RATE_UNKNOWN = 0;
+
+ public static final int WORK_OPS = 1;
+ public static final int WORK_UNITS = 2;
+ public static final int WORK_THOUSANDS = 4;
+ public static final int WORK_MILLIONS = 6;
+ public static final int WORK_AUTO = 8;
+
+ public static final int TIME_SECONDS = 10;
+ public static final int TIME_MILLIS = 11;
+ public static final int TIME_MICROS = 12;
+ public static final int TIME_NANOS = 13;
+ public static final int TIME_AUTO = 14;
+
+ static Group resultoptroot;
+ static Option.ObjectChoice timeOpt;
+ static Option.ObjectChoice workOpt;
+ static Option.ObjectChoice rateOpt;
+
+ public static void init() {
+ resultoptroot = new Group(TestEnvironment.globaloptroot,
+ "results", "Result Options");
- public static final int SECONDS_WHOLE = 0;
- public static final int SECONDS_MILLIS = 1;
- public static final int SECONDS_MICROS = 2;
- public static final int SECONDS_NANOS = 3;
- public static final int SECONDS_AUTO = 4;
+ String workStrings[] = {
+ "units",
+ "kilounits",
+ "megaunits",
+ "autounits",
+ "ops",
+ "kiloops",
+ "megaops",
+ "autoops",
+ };
+ String workDescriptions[] = {
+ "Test Units",
+ "Thousands of Test Units",
+ "Millions of Test Units",
+ "Auto-scaled Test Units",
+ "Operations",
+ "Thousands of Operations",
+ "Millions of Operations",
+ "Auto-scaled Operations",
+ };
+ Integer workObjects[] = {
+ new Integer(WORK_UNITS),
+ new Integer(WORK_THOUSANDS),
+ new Integer(WORK_MILLIONS),
+ new Integer(WORK_AUTO),
+ new Integer(WORK_OPS | WORK_UNITS),
+ new Integer(WORK_OPS | WORK_THOUSANDS),
+ new Integer(WORK_OPS | WORK_MILLIONS),
+ new Integer(WORK_OPS | WORK_AUTO),
+ };
+ workOpt = new Option.ObjectChoice(resultoptroot,
+ "workunits", "Work Units",
+ workStrings, workObjects,
+ workStrings, workDescriptions,
+ 0);
+ String timeStrings[] = {
+ "sec",
+ "msec",
+ "usec",
+ "nsec",
+ "autosec",
+ };
+ String timeDescriptions[] = {
+ "Seconds",
+ "Milliseconds",
+ "Microseconds",
+ "Nanoseconds",
+ "Auto-scaled seconds",
+ };
+ Integer timeObjects[] = {
+ new Integer(TIME_SECONDS),
+ new Integer(TIME_MILLIS),
+ new Integer(TIME_MICROS),
+ new Integer(TIME_NANOS),
+ new Integer(TIME_AUTO),
+ };
+ timeOpt = new Option.ObjectChoice(resultoptroot,
+ "timeunits", "Time Units",
+ timeStrings, timeObjects,
+ timeStrings, timeDescriptions,
+ 0);
+ String rateStrings[] = {
+ "unitspersec",
+ "secsperunit",
+ };
+ String rateDescriptions[] = {
+ "Work units per Time",
+ "Time units per Work",
+ };
+ Boolean rateObjects[] = {
+ Boolean.FALSE,
+ Boolean.TRUE,
+ };
+ rateOpt = new Option.ObjectChoice(resultoptroot,
+ "ratio", "Rate Ratio",
+ rateStrings, rateObjects,
+ rateStrings, rateDescriptions,
+ 0);
+ }
+
+ public static boolean isTimeUnit(int unit) {
+ return (unit >= TIME_SECONDS && unit <= TIME_AUTO);
+ }
- public static int unitScale = UNITS_WHOLE;
- public static int timeScale = SECONDS_WHOLE;
- public static boolean useUnits = true;
- public static boolean invertRate = false;
+ public static boolean isWorkUnit(int unit) {
+ return (unit >= WORK_OPS && unit <= (WORK_AUTO | WORK_OPS));
+ }
+
+ public static String parseRateOpt(String opt) {
+ int timeScale = timeOpt.getIntValue();
+ int workScale = workOpt.getIntValue();
+ boolean invertRate = rateOpt.getBooleanValue();
+ int divindex = opt.indexOf('/');
+ if (divindex < 0) {
+ int unit = parseUnit(opt);
+ if (isTimeUnit(unit)) {
+ timeScale = unit;
+ } else if (isWorkUnit(unit)) {
+ workScale = unit;
+ } else {
+ return "Bad unit: "+opt;
+ }
+ } else {
+ int unit1 = parseUnit(opt.substring(0,divindex));
+ int unit2 = parseUnit(opt.substring(divindex+1));
+ if (isTimeUnit(unit1)) {
+ if (isWorkUnit(unit2)) {
+ timeScale = unit1;
+ workScale = unit2;
+ invertRate = true;
+ } else if (isTimeUnit(unit2)) {
+ return "Both time units: "+opt;
+ } else {
+ return "Bad denominator: "+opt;
+ }
+ } else if (isWorkUnit(unit1)) {
+ if (isWorkUnit(unit2)) {
+ return "Both work units: "+opt;
+ } else if (isTimeUnit(unit2)) {
+ timeScale = unit2;
+ workScale = unit1;
+ invertRate = false;
+ } else {
+ return "Bad denominator: "+opt;
+ }
+ } else {
+ return "Bad numerator: "+opt;
+ }
+ }
+ timeOpt.setValue(timeScale);
+ workOpt.setValue(workScale);
+ rateOpt.setValue(invertRate);
+ return null;
+ }
+
+ private static HashMap unitMap;
+
+ static {
+ unitMap = new HashMap();
+ unitMap.put("U", new Integer(WORK_UNITS));
+ unitMap.put("M", new Integer(WORK_MILLIONS));
+ unitMap.put("K", new Integer(WORK_THOUSANDS));
+ unitMap.put("A", new Integer(WORK_AUTO));
+ unitMap.put("MU", new Integer(WORK_MILLIONS));
+ unitMap.put("KU", new Integer(WORK_THOUSANDS));
+ unitMap.put("AU", new Integer(WORK_AUTO));
+
+ unitMap.put("O", new Integer(WORK_UNITS | WORK_OPS));
+ unitMap.put("NO", new Integer(WORK_UNITS | WORK_OPS));
+ unitMap.put("MO", new Integer(WORK_MILLIONS | WORK_OPS));
+ unitMap.put("KO", new Integer(WORK_THOUSANDS | WORK_OPS));
+ unitMap.put("AO", new Integer(WORK_AUTO | WORK_OPS));
+
+ unitMap.put("s", new Integer(TIME_SECONDS));
+ unitMap.put("m", new Integer(TIME_MILLIS));
+ unitMap.put("u", new Integer(TIME_MICROS));
+ unitMap.put("n", new Integer(TIME_NANOS));
+ unitMap.put("a", new Integer(TIME_AUTO));
+ }
+
+ public static int parseUnit(String c) {
+ Integer u = (Integer) unitMap.get(c);
+ if (u != null) {
+ return u.intValue();
+ }
+ return RATE_UNKNOWN;
+ }
String unitname = "unit";
Test test;
@@ -157,69 +333,76 @@
}
public String getAverageString() {
- double units = (useUnits ? getTotalUnits() : getTotalReps());
+ int timeScale = timeOpt.getIntValue();
+ int workScale = workOpt.getIntValue();
+ boolean invertRate = rateOpt.getBooleanValue();
double time = getTotalTime();
+ String timeprefix = "";
+ switch (timeScale) {
+ case TIME_AUTO:
+ case TIME_SECONDS:
+ time /= 1000;
+ break;
+ case TIME_MILLIS:
+ timeprefix = "m";
+ break;
+ case TIME_MICROS:
+ time *= 1000.0;
+ timeprefix = "u";
+ break;
+ case TIME_NANOS:
+ time *= 1000000.0;
+ timeprefix = "n";
+ break;
+ }
+
+ String workprefix = "";
+ boolean isOps = (workScale & WORK_OPS) != 0;
+ String workname = isOps ? "op" : unitname;
+ double work = isOps ? getTotalReps() : getTotalUnits();
+ switch (workScale & (~WORK_OPS)) {
+ case WORK_AUTO:
+ case WORK_UNITS:
+ break;
+ case WORK_THOUSANDS:
+ work /= 1000.0;
+ workprefix = "K";
+ break;
+ case WORK_MILLIONS:
+ work /= 1000000.0;
+ workprefix = "M";
+ break;
+ }
if (invertRate) {
- double rate = time / units;
- String prefix = "";
- switch (timeScale) {
- case SECONDS_WHOLE:
- rate /= 1000;
- break;
- case SECONDS_MILLIS:
- prefix = "m";
- break;
- case SECONDS_MICROS:
- rate *= 1000.0;
- prefix = "u";
- break;
- case SECONDS_NANOS:
- rate *= 1000000.0;
- prefix = "n";
- break;
- case SECONDS_AUTO:
- rate /= 1000.0;
+ double rate = time / work;
+ if (timeScale == TIME_AUTO) {
if (rate < 1.0) {
rate *= 1000.0;
- prefix = "m";
+ timeprefix = "m";
if (rate < 1.0) {
rate *= 1000.0;
- prefix = "u";
+ timeprefix = "u";
if (rate < 1.0) {
rate *= 1000.0;
- prefix = "n";
+ timeprefix = "n";
}
}
}
- break;
}
- return rate+" "+prefix+"secs/"+(useUnits ? unitname : "op");
+ return rate+" "+timeprefix+"secs/"+workprefix+workname;
} else {
- double rate = units / (time / 1000.0);
- String prefix = "";
- switch (unitScale) {
- case UNITS_WHOLE:
- break;
- case UNITS_THOUSANDS:
- rate /= 1000.0;
- prefix = "K";
- break;
- case UNITS_MILLIONS:
- rate /= 1000000.0;
- prefix = "M";
- break;
- case UNITS_AUTO:
+ double rate = work / time;
+ if (workScale == WORK_AUTO) {
if (rate > 1000.0) {
rate /= 1000.0;
- prefix = "K";
+ workprefix = "K";
if (rate > 1000.0) {
rate /= 1000.0;
- prefix = "M";
+ workprefix = "M";
}
}
- break;
}
- return rate+" "+prefix+(useUnits ? unitname : "op")+"s/sec";
+ return rate+" "+workprefix+workname+"s/"+timeprefix+"sec";
}
}
--- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/report/J2DAnalyzer.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/report/J2DAnalyzer.java Tue Nov 30 14:51:07 2010 -0800
@@ -61,6 +61,8 @@
"the following result sets are combined into a group");
out.println(" -NoGroup "+
"the following result sets stand on their own");
+ out.println(" -ShowUncontested "+
+ "show results even when only result set has a result");
out.println(" -Graph "+
"graph the results visually (using lines of *'s)");
out.println(" -Best "+
@@ -83,6 +85,7 @@
public static void main(String argv[]) {
boolean gavehelp = false;
boolean graph = false;
+ boolean ignoreuncontested = true;
if (argv.length > 0 && argv[0].equalsIgnoreCase("-html")) {
String newargs[] = new String[argv.length-1];
System.arraycopy(argv, 1, newargs, 0, newargs.length);
@@ -97,6 +100,8 @@
results.add(groupHolder);
} else if (arg.equalsIgnoreCase("-NoGroup")) {
groupHolder = null;
+ } else if (arg.equalsIgnoreCase("-ShowUncontested")) {
+ ignoreuncontested = false;
} else if (arg.equalsIgnoreCase("-Graph")) {
graph = true;
} else if (arg.equalsIgnoreCase("-Best")) {
@@ -171,18 +176,23 @@
String key = keys[k];
ResultHolder rh = base.getResultByKey(key);
double score = rh.getScore();
- System.out.println(rh.getShortKey()+":");
double maxscore = score;
- if (graph) {
- for (int i = 0; i < numsets; i++) {
- ResultSetHolder rsh =
- (ResultSetHolder) results.elementAt(i);
- ResultHolder rh2 = rsh.getResultByKey(key);
- if (rh2 != null) {
+ int numcontesting = 0;
+ for (int i = 0; i < numsets; i++) {
+ ResultSetHolder rsh =
+ (ResultSetHolder) results.elementAt(i);
+ ResultHolder rh2 = rsh.getResultByKey(key);
+ if (rh2 != null) {
+ if (graph) {
maxscore = Math.max(maxscore, rh2.getBestScore());
}
+ numcontesting++;
}
}
+ if (ignoreuncontested && numcontesting < 2) {
+ continue;
+ }
+ System.out.println(rh.getShortKey()+":");
for (int i = 0; i < numsets; i++) {
ResultSetHolder rsh = (ResultSetHolder) results.elementAt(i);
System.out.print(rsh.getTitle()+": ");
--- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/GraphicsTests.java Tue Nov 30 14:51:07 2010 -0800
@@ -38,6 +38,8 @@
import java.awt.Polygon;
import java.awt.Color;
import java.awt.Dimension;
+import java.awt.geom.Point2D;
+import java.awt.geom.AffineTransform;
import java.lang.reflect.Field;
import j2dbench.Destinations;
@@ -74,6 +76,7 @@
static Option animList;
static Option sizeList;
static Option compRules;
+ static Option transforms;
static Option doExtraAlpha;
static Option doXor;
static Option doClipping;
@@ -167,6 +170,29 @@
j, rulenames, rules, rulenames,
ruledescs, (1 << defrule));
((Option.ObjectList) compRules).setNumRows(4);
+
+ Transform xforms[] = {
+ Identity.instance,
+ FTranslate.instance,
+ Scale2x2.instance,
+ Rotate15.instance,
+ ShearX.instance,
+ ShearY.instance,
+ };
+ String xformnames[] = new String[xforms.length];
+ String xformdescs[] = new String[xforms.length];
+ for (int i = 0; i < xforms.length; i++) {
+ xformnames[i] = xforms[i].getShortName();
+ xformdescs[i] = xforms[i].getDescription();
+ }
+ transforms =
+ new Option.ObjectList(groptroot, "transform",
+ "Affine Transform",
+ xforms.length,
+ xformnames, xforms, xformnames,
+ xformdescs, 0x1);
+ ((Option.ObjectList) transforms).setNumRows(3);
+
doExtraAlpha =
new Option.Toggle(groptroot, "extraalpha",
"Render with an \"extra alpha\" of 0.125",
@@ -200,6 +226,7 @@
int orgX, orgY;
int initX, initY;
int maxX, maxY;
+ double pixscale;
}
public GraphicsTests(Group parent, String nodeName, String description) {
@@ -211,7 +238,7 @@
public Object initTest(TestEnvironment env, Result result) {
Context ctx = createContext();
initContext(env, ctx);
- result.setUnits(pixelsTouched(ctx));
+ result.setUnits((int) (ctx.pixscale * pixelsTouched(ctx)));
result.setUnitName("pixel");
return ctx;
}
@@ -232,6 +259,9 @@
ctx.graphics = env.getGraphics();
int w = env.getWidth();
int h = env.getHeight();
+ ctx.size = env.getIntValue(sizeList);
+ ctx.outdim = getOutputSize(ctx.size, ctx.size);
+ ctx.pixscale = 1.0;
if (hasGraphics2D) {
Graphics2D g2d = (Graphics2D) ctx.graphics;
AlphaComposite ac = (AlphaComposite) env.getModifier(compRules);
@@ -251,11 +281,14 @@
p.addPoint(0, 0);
g2d.clip(p);
}
+ Transform tx = (Transform) env.getModifier(transforms);
+ Dimension envdim = new Dimension(w, h);
+ tx.init(g2d, ctx, envdim);
+ w = envdim.width;
+ h = envdim.height;
g2d.setRenderingHint(RenderingHints.KEY_RENDERING,
env.getModifier(renderHint));
}
- ctx.size = env.getIntValue(sizeList);
- ctx.outdim = getOutputSize(ctx.size, ctx.size);
switch (env.getIntValue(animList)) {
case 0:
ctx.animate = false;
@@ -290,4 +323,201 @@
graphics.dispose();
((Context) ctx).graphics = null;
}
+
+ public abstract static class Transform {
+ public abstract String getShortName();
+ public abstract String getDescription();
+ public abstract void init(Graphics2D g2d, Context ctx, Dimension dim);
+
+ public static double scaleForPoint(AffineTransform at,
+ double xorig, double yorig,
+ double x, double y,
+ int w, int h)
+ {
+ Point2D.Double ptd = new Point2D.Double(x, y);
+ at.transform(ptd, ptd);
+ x = ptd.getX();
+ y = ptd.getY();
+ double scale = 1.0;
+ if (x < 0) {
+ scale = Math.min(scale, xorig / (xorig - x));
+ } else if (x > w) {
+ scale = Math.min(scale, (w - xorig) / (x - xorig));
+ }
+ if (y < 0) {
+ scale = Math.min(scale, yorig / (yorig - y));
+ } else if (y > h) {
+ scale = Math.min(scale, (h - yorig) / (y - yorig));
+ }
+ return scale;
+ }
+
+ public static Dimension scaleForTransform(AffineTransform at,
+ Dimension dim)
+ {
+ int w = dim.width;
+ int h = dim.height;
+ Point2D.Double ptd = new Point2D.Double(0, 0);
+ at.transform(ptd, ptd);
+ double ox = ptd.getX();
+ double oy = ptd.getY();
+ if (ox < 0 || ox > w || oy < 0 || oy > h) {
+ throw new InternalError("origin outside destination");
+ }
+ double scalex = scaleForPoint(at, ox, oy, w, h, w, h);
+ double scaley = scalex;
+ scalex = Math.min(scaleForPoint(at, ox, oy, w, 0, w, h), scalex);
+ scaley = Math.min(scaleForPoint(at, ox, oy, 0, h, w, h), scaley);
+ if (scalex < 0 || scaley < 0) {
+ throw new InternalError("could not fit dims to transform");
+ }
+ return new Dimension((int) Math.floor(w * scalex),
+ (int) Math.floor(h * scaley));
+ }
+ }
+
+ public static class Identity extends Transform {
+ public static final Identity instance = new Identity();
+
+ private Identity() {}
+
+ public String getShortName() {
+ return "ident";
+ }
+
+ public String getDescription() {
+ return "Identity";
+ }
+
+ public void init(Graphics2D g2d, Context ctx, Dimension dim) {
+ }
+ }
+
+ public static class FTranslate extends Transform {
+ public static final FTranslate instance = new FTranslate();
+
+ private FTranslate() {}
+
+ public String getShortName() {
+ return "ftrans";
+ }
+
+ public String getDescription() {
+ return "FTranslate 1.5";
+ }
+
+ public void init(Graphics2D g2d, Context ctx, Dimension dim) {
+ int w = dim.width;
+ int h = dim.height;
+ AffineTransform at = new AffineTransform();
+ at.translate(1.5, 1.5);
+ g2d.transform(at);
+ dim.setSize(w-3, h-3);
+ }
+ }
+
+ public static class Scale2x2 extends Transform {
+ public static final Scale2x2 instance = new Scale2x2();
+
+ private Scale2x2() {}
+
+ public String getShortName() {
+ return "scale2x2";
+ }
+
+ public String getDescription() {
+ return "Scale 2x by 2x";
+ }
+
+ public void init(Graphics2D g2d, Context ctx, Dimension dim) {
+ int w = dim.width;
+ int h = dim.height;
+ AffineTransform at = new AffineTransform();
+ at.scale(2.0, 2.0);
+ g2d.transform(at);
+ dim.setSize(w/2, h/2);
+ ctx.pixscale = 4;
+ }
+ }
+
+ public static class Rotate15 extends Transform {
+ public static final Rotate15 instance = new Rotate15();
+
+ private Rotate15() {}
+
+ public String getShortName() {
+ return "rot15";
+ }
+
+ public String getDescription() {
+ return "Rotate 15 degrees";
+ }
+
+ public void init(Graphics2D g2d, Context ctx, Dimension dim) {
+ int w = dim.width;
+ int h = dim.height;
+ double theta = Math.toRadians(15);
+ double cos = Math.cos(theta);
+ double sin = Math.sin(theta);
+ double xsize = sin * h + cos * w;
+ double ysize = sin * w + cos * h;
+ double scale = Math.min(w / xsize, h / ysize);
+ xsize *= scale;
+ ysize *= scale;
+ AffineTransform at = new AffineTransform();
+ at.translate((w - xsize) / 2.0, (h - ysize) / 2.0);
+ at.translate(sin * h * scale, 0.0);
+ at.rotate(theta);
+ g2d.transform(at);
+ dim.setSize(scaleForTransform(at, dim));
+ }
+ }
+
+ public static class ShearX extends Transform {
+ public static final ShearX instance = new ShearX();
+
+ private ShearX() {}
+
+ public String getShortName() {
+ return "shearx";
+ }
+
+ public String getDescription() {
+ return "Shear X to the right";
+ }
+
+ public void init(Graphics2D g2d, Context ctx, Dimension dim) {
+ int w = dim.width;
+ int h = dim.height;
+ AffineTransform at = new AffineTransform();
+ at.translate(0.0, (h - (w*h)/(w + h*0.1)) / 2);
+ at.shear(0.1, 0.0);
+ g2d.transform(at);
+ dim.setSize(scaleForTransform(at, dim));
+ }
+ }
+
+ public static class ShearY extends Transform {
+ public static final ShearY instance = new ShearY();
+
+ private ShearY() {}
+
+ public String getShortName() {
+ return "sheary";
+ }
+
+ public String getDescription() {
+ return "Shear Y down";
+ }
+
+ public void init(Graphics2D g2d, Context ctx, Dimension dim) {
+ int w = dim.width;
+ int h = dim.height;
+ AffineTransform at = new AffineTransform();
+ at.translate((w - (w*h)/(h + w*0.1)) / 2, 0.0);
+ at.shear(0.0, 0.1);
+ g2d.transform(at);
+ dim.setSize(scaleForTransform(at, dim));
+ }
+ }
}
--- a/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/text/TextTests.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/share/demo/java2d/J2DBench/src/j2dbench/tests/text/TextTests.java Tue Nov 30 14:51:07 2010 -0800
@@ -454,7 +454,7 @@
taaNames, taaHints,
taaNames, taaNames,
0x1);
- ((Option.ObjectList) taaList).setNumRows(2);
+ ((Option.ObjectList) taaList).setNumRows(6);
// add special TextAAOpt for backwards compatibility with
// older options files
new TextAAOpt();
@@ -707,3 +707,4 @@
}
}
}
+
--- a/jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/solaris/classes/sun/awt/X11/GtkFileDialogPeer.java Tue Nov 30 14:51:07 2010 -0800
@@ -57,8 +57,11 @@
private native void run(String title, int mode, String dir, String file,
FilenameFilter filter, boolean isMultipleMode);
+ private native void quit();
- private native void quit();
+ @Override
+ public native void toFront();
+
/**
* Called exclusively by the native C code.
--- a/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/solaris/classes/sun/awt/X11/XFramePeer.java Tue Nov 30 14:51:07 2010 -0800
@@ -150,6 +150,8 @@
void updateChildrenSizes() {
super.updateChildrenSizes();
+ int height = getMenuBarHeight();
+
// XWindow.reshape calls XBaseWindow.xSetBounds, which acquires
// the AWT lock, so we have to acquire the AWT lock here
// before getStateLock() to avoid a deadlock with the Toolkit thread
@@ -159,7 +161,7 @@
synchronized(getStateLock()) {
int width = dimensions.getClientSize().width;
if (menubarPeer != null) {
- menubarPeer.reshape(0, 0, width, getMenuBarHeight());
+ menubarPeer.reshape(0, 0, width, height);
}
}
} finally {
--- a/jdk/src/solaris/native/sun/awt/gtk2_interface.c Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.c Tue Nov 30 14:51:07 2010 -0800
@@ -607,6 +607,7 @@
fp_gtk_tree_view_new = dl_symbol("gtk_tree_view_new");
fp_gtk_viewport_new = dl_symbol("gtk_viewport_new");
fp_gtk_window_new = dl_symbol("gtk_window_new");
+ fp_gtk_window_present = dl_symbol("gtk_window_present");
fp_gtk_dialog_new = dl_symbol("gtk_dialog_new");
fp_gtk_frame_new = dl_symbol("gtk_frame_new");
--- a/jdk/src/solaris/native/sun/awt/gtk2_interface.h Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/solaris/native/sun/awt/gtk2_interface.h Tue Nov 30 14:51:07 2010 -0800
@@ -749,6 +749,7 @@
int (*fp_gdk_pixbuf_get_width)(const GdkPixbuf *pixbuf);
GdkPixbuf *(*fp_gdk_pixbuf_new_from_file)(const char *filename, GError **error);
void (*fp_gtk_widget_destroy)(GtkWidget *widget);
+void (*fp_gtk_window_present)(GtkWindow *window);
/**
--- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.c Tue Nov 30 14:51:07 2010 -0800
@@ -80,6 +80,28 @@
quit(env, jpeer, FALSE);
}
+/*
+ * Class: sun_awt_X11_GtkFileDialogPeer
+ * Method: toFront
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront
+(JNIEnv * env, jobject jpeer)
+{
+ GtkWidget * dialog;
+
+ fp_gdk_threads_enter();
+
+ dialog = (GtkWidget*)jlong_to_ptr(
+ (*env)->GetLongField(env, jpeer, widgetFieldID));
+
+ if (dialog != NULL) {
+ fp_gtk_window_present((GtkWindow*)dialog);
+ }
+
+ fp_gdk_threads_leave();
+}
+
/**
* Convert a GSList to an array of filenames (without the parent folder)
*/
--- a/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/solaris/native/sun/awt/sun_awt_X11_GtkFileDialogPeer.h Tue Nov 30 14:51:07 2010 -0800
@@ -33,6 +33,14 @@
JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_quit
(JNIEnv *, jobject);
+/*
+ * Class: sun_awt_X11_GtkFileDialogPeer
+ * Method: toFront
+ * Signature: ()V
+ */
+JNIEXPORT void JNICALL Java_sun_awt_X11_GtkFileDialogPeer_toFront
+(JNIEnv *, jobject);
+
#ifdef __cplusplus
}
#endif
--- a/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/windows/classes/sun/awt/windows/WFramePeer.java Tue Nov 30 14:51:07 2010 -0800
@@ -79,10 +79,50 @@
if (b == null) {
clearMaximizedBounds();
} else {
- setMaximizedBounds(b.x, b.y, b.width, b.height);
+ Rectangle adjBounds = (Rectangle)b.clone();
+ adjustMaximizedBounds(adjBounds);
+ setMaximizedBounds(adjBounds.x, adjBounds.y, adjBounds.width, adjBounds.height);
}
}
+ /**
+ * The incoming bounds describe the maximized size and position of the
+ * window on the monitor that displays the window. But the window manager
+ * expects that the bounds are based on the size and position of the
+ * primary monitor, even if the window ultimately maximizes onto a
+ * secondary monitor. And the window manager adjusts these values to
+ * compensate for differences between the primary monitor and the monitor
+ * that displays the window.
+ * The method translates the incoming bounds to the values acceptable
+ * by the window manager. For more details, please refer to 6699851.
+ */
+ private void adjustMaximizedBounds(Rectangle b) {
+ GraphicsConfiguration currentDevGC = getGraphicsConfiguration();
+
+ GraphicsDevice primaryDev = GraphicsEnvironment
+ .getLocalGraphicsEnvironment().getDefaultScreenDevice();
+ GraphicsConfiguration primaryDevGC = primaryDev.getDefaultConfiguration();
+
+ if (currentDevGC != null && currentDevGC != primaryDevGC) {
+ Rectangle currentDevBounds = currentDevGC.getBounds();
+ Rectangle primaryDevBounds = primaryDevGC.getBounds();
+
+ b.width -= (currentDevBounds.width - primaryDevBounds.width);
+ b.height -= (currentDevBounds.height - primaryDevBounds.height);
+ }
+ }
+
+ @Override
+ public boolean updateGraphicsData(GraphicsConfiguration gc) {
+ boolean result = super.updateGraphicsData(gc);
+ Rectangle bounds = AWTAccessor.getFrameAccessor().
+ getMaximizedBounds((Frame)target);
+ if (bounds != null) {
+ setMaximizedBounds(bounds);
+ }
+ return result;
+ }
+
@Override
boolean isTargetUndecorated() {
return ((Frame)target).isUndecorated();
--- a/jdk/src/windows/native/sun/windows/awt_Choice.cpp Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/windows/native/sun/windows/awt_Choice.cpp Tue Nov 30 14:51:07 2010 -0800
@@ -86,6 +86,7 @@
AwtChoice::AwtChoice() {
m_hList = NULL;
m_listDefWindowProc = NULL;
+ m_selectedItem = -1;
}
LPCTSTR AwtChoice::GetClassName() {
@@ -437,9 +438,10 @@
MsgRouting AwtChoice::WmNotify(UINT notifyCode)
{
if (notifyCode == CBN_SELCHANGE) {
- int itemSelect = (int)SendMessage(CB_GETCURSEL);
- if (itemSelect != CB_ERR){
- DoCallback("handleAction", "(I)V", itemSelect);
+ int selectedItem = (int)SendMessage(CB_GETCURSEL);
+ if (selectedItem != CB_ERR && m_selectedItem != selectedItem){
+ m_selectedItem = selectedItem;
+ DoCallback("handleAction", "(I)V", selectedItem);
}
} else if (notifyCode == CBN_DROPDOWN) {
--- a/jdk/src/windows/native/sun/windows/awt_Choice.h Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/windows/native/sun/windows/awt_Choice.h Tue Nov 30 14:51:07 2010 -0800
@@ -94,6 +94,7 @@
static BOOL sm_isMouseMoveInList;
HWND m_hList;
WNDPROC m_listDefWindowProc;
+ int m_selectedItem;
static LRESULT CALLBACK ListWindowProc(HWND hwnd, UINT message,
WPARAM wParam, LPARAM lParam);
};
--- a/jdk/src/windows/resource/java.manifest Tue Nov 30 10:35:55 2010 +0300
+++ b/jdk/src/windows/resource/java.manifest Tue Nov 30 14:51:07 2010 -0800
@@ -3,7 +3,7 @@
<assemblyIdentity
version="1.0.0.0"
processorArchitecture="X86"
- name="Sun Microsystems, Inc., Java(tm) 2 Standard Edition"
+ name="Oracle Corporation, Java(tm) 2 Standard Edition"
type="win32"
/>
<description>AWT</description>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/Color/OpacityChange/OpacityChange.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,54 @@
+/*
+ * Copyright (c) 2010, 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 6783910
+ @summary java.awt.Color.brighter()/darker() methods make color opaque
+ @author Andrei Dmitriev: area=awt-color
+ @run main OpacityChange
+*/
+
+import java.awt.*;
+
+public class OpacityChange {
+ private final static int INITIAL_ALPHA = 125;
+
+ public static void main(String argv[]) {
+ Color color = new Color(20, 20, 20, INITIAL_ALPHA);
+ System.out.println("Initial alpha: " + color.getAlpha());
+ Color colorBrighter = color.brighter();
+ System.out.println("New alpha (after brighter): " + colorBrighter.getAlpha());
+
+ Color colorDarker = color.darker();
+ System.out.println("New alpha (after darker): " + colorDarker.getAlpha());
+
+
+ if (INITIAL_ALPHA != colorBrighter.getAlpha()) {
+ throw new RuntimeException("Brighter color alpha has changed from : " +INITIAL_ALPHA + " to " + colorBrighter.getAlpha());
+ }
+ if (INITIAL_ALPHA != colorDarker.getAlpha()) {
+ throw new RuntimeException("Darker color alpha has changed from : " +INITIAL_ALPHA + " to " + colorDarker.getAlpha());
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/jdk/test/java/awt/MenuBar/DeadlockTest1/DeadlockTest1.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,73 @@
+/*
+ * Copyright (c) 2010, 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 6990904
+ @summary on oel5.5, Frame doesn't show if the Frame has only a MenuBar as its component.
+ @author Andrei Dmitriev: area=awt-menubar
+ @run main/timeout=30 DeadlockTest1
+*/
+
+import java.awt.*;
+
+public class DeadlockTest1 {
+ Frame f = new Frame("Menu Frame");
+
+ DeadlockTest1() {
+ MenuBar menubar = new MenuBar();
+
+ Menu file = new Menu("File");
+ Menu edit = new Menu("Edit");
+ Menu help = new Menu("Help");
+
+ MenuItem open = new MenuItem("Open");
+ MenuItem close = new MenuItem("Close");
+ MenuItem copy = new MenuItem("Copy");
+ MenuItem paste = new MenuItem("Paste");
+
+ file.add(open);
+ file.add(close);
+
+ edit.add(copy);
+ edit.add(paste);
+ menubar.add(file);
+ menubar.add(edit);
+ menubar.add(help);
+ menubar.setHelpMenu(help);
+
+ f.setMenuBar(menubar);
+ f.setSize(400,200);
+ f.setVisible(true);
+ try {
+ Thread.sleep(5000);
+ } catch (InterruptedException z) {
+ throw new RuntimeException(z);
+ }
+ f.dispose();
+ }
+
+ public static void main(String argv[]) {
+ new DeadlockTest1();
+ }
+}
--- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Tue Nov 30 14:51:07 2010 -0800
@@ -49,6 +49,7 @@
import com.sun.tools.javac.code.Symbol.ClassSymbol;
import com.sun.tools.javac.code.Symbol.TypeSymbol;
import com.sun.tools.javac.code.Symbol;
+import com.sun.tools.javac.code.Type;
import com.sun.tools.javac.comp.Attr;
import com.sun.tools.javac.comp.AttrContext;
import com.sun.tools.javac.comp.Enter;
@@ -230,7 +231,7 @@
public boolean isAccessible(Scope scope, TypeElement type) {
if (scope instanceof JavacScope && type instanceof ClassSymbol) {
Env<AttrContext> env = ((JavacScope) scope).env;
- return resolve.isAccessible(env, (ClassSymbol)type);
+ return resolve.isAccessible(env, (ClassSymbol)type, true);
} else
return false;
}
@@ -240,7 +241,7 @@
&& member instanceof Symbol
&& type instanceof com.sun.tools.javac.code.Type) {
Env<AttrContext> env = ((JavacScope) scope).env;
- return resolve.isAccessible(env, (com.sun.tools.javac.code.Type)type, (Symbol)member);
+ return resolve.isAccessible(env, (com.sun.tools.javac.code.Type)type, (Symbol)member, true);
} else
return false;
}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Flags.java Tue Nov 30 14:51:07 2010 -0800
@@ -247,6 +247,11 @@
*/
public static final long OVERRIDE_BRIDGE = 1L<<41;
+ /**
+ * Flag that marks an 'effectively final' local variable
+ */
+ public static final long EFFECTIVELY_FINAL = 1L<<42;
+
/** Modifier masks.
*/
public static final int
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Lint.java Tue Nov 30 14:51:07 2010 -0800
@@ -212,9 +212,9 @@
VARARGS("varargs"),
/**
- * Warn about arm resources
+ * Warn about issues relating to use of try blocks (i.e. try-with-resources)
*/
- ARM("arm");
+ TRY("try");
LintCategory(String option) {
this(option, false);
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Scope.java Tue Nov 30 14:51:07 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2010, 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
@@ -31,7 +31,8 @@
/** A scope represents an area of visibility in a Java program. The
* Scope class is a container for symbols which provides
* efficient access to symbols given their names. Scopes are implemented
- * as hash tables. Scopes can be nested; the next field of a scope points
+ * as hash tables with "open addressing" and "double hashing".
+ * Scopes can be nested; the next field of a scope points
* to its next outer scope. Nested scopes can share their hash tables.
*
* <p><b>This is NOT part of any supported API.
@@ -55,7 +56,7 @@
/** A hash table for the scope's entries.
*/
- public Entry[] table;
+ Entry[] table;
/** Mask for hash codes, always equal to (table.length - 1).
*/
@@ -67,8 +68,9 @@
public Entry elems;
/** The number of elements in this scope.
+ * This includes deleted elements, whose value is the sentinel.
*/
- public int nelems = 0;
+ int nelems = 0;
/** A timestamp - useful to quickly check whether a scope has changed or not
*/
@@ -109,7 +111,8 @@
}
}
- /** Every hash bucket is a list of Entry's which ends in sentinel.
+ /** Use as a "not-found" result for lookup.
+ * Also used to mark deleted entries in the table.
*/
private static final Entry sentinel = new Entry(null, null, null, null);
@@ -130,12 +133,15 @@
this.owner = owner;
this.table = table;
this.hashMask = table.length - 1;
- this.elems = null;
- this.nelems = 0;
- this.shared = 0;
this.scopeCounter = scopeCounter;
}
+ /** Convenience constructor used for dup and dupUnshared. */
+ private Scope(Scope next, Symbol owner, Entry[] table) {
+ this(next, owner, table, next.scopeCounter);
+ this.nelems = next.nelems;
+ }
+
/** Construct a new scope, within scope next, with given owner,
* using a fresh table of length INITIAL_SIZE.
*/
@@ -145,7 +151,6 @@
protected Scope(Symbol owner, ScopeCounter scopeCounter) {
this(null, owner, new Entry[INITIAL_SIZE], scopeCounter);
- for (int i = 0; i < INITIAL_SIZE; i++) table[i] = sentinel;
}
/** Construct a fresh scope within this scope, with same owner,
@@ -154,11 +159,7 @@
* of fresh tables.
*/
public Scope dup() {
- Scope result = new Scope(this, this.owner, this.table, scopeCounter);
- shared++;
- // System.out.println("====> duping scope " + this.hashCode() + " owned by " + this.owner + " to " + result.hashCode());
- // new Error().printStackTrace(System.out);
- return result;
+ return dup(this.owner);
}
/** Construct a fresh scope within this scope, with new owner,
@@ -167,7 +168,7 @@
* of fresh tables.
*/
public Scope dup(Symbol newOwner) {
- Scope result = new Scope(this, newOwner, this.table, scopeCounter);
+ Scope result = new Scope(this, newOwner, this.table);
shared++;
// System.out.println("====> duping scope " + this.hashCode() + " owned by " + newOwner + " to " + result.hashCode());
// new Error().printStackTrace(System.out);
@@ -179,7 +180,7 @@
* the table of its outer scope.
*/
public Scope dupUnshared() {
- return new Scope(this, this.owner, this.table.clone(), scopeCounter);
+ return new Scope(this, this.owner, this.table.clone());
}
/** Remove all entries of this scope from its table, if shared
@@ -189,7 +190,7 @@
assert shared == 0;
if (table != next.table) return next;
while (elems != null) {
- int hash = elems.sym.name.hashCode() & hashMask;
+ int hash = getIndex(elems.sym.name);
Entry e = table[hash];
assert e == elems : elems.sym;
table[hash] = elems.shadowed;
@@ -197,6 +198,7 @@
}
assert next.shared > 0;
next.shared--;
+ next.nelems = nelems;
// System.out.println("====> leaving scope " + this.hashCode() + " owned by " + this.owner + " to " + next.hashCode());
// new Error().printStackTrace(System.out);
return next;
@@ -215,19 +217,17 @@
s.hashMask = newtable.length - 1;
}
}
- for (int i = 0; i < newtable.length; i++) newtable[i] = sentinel;
- for (int i = 0; i < oldtable.length; i++) copy(oldtable[i]);
- }
-
- /** Copy the given entry and all entries shadowed by it to table
- */
- private void copy(Entry e) {
- if (e.sym != null) {
- copy(e.shadowed);
- int hash = e.sym.name.hashCode() & hashMask;
- e.shadowed = table[hash];
- table[hash] = e;
+ int n = 0;
+ for (int i = oldtable.length; --i >= 0; ) {
+ Entry e = oldtable[i];
+ if (e != null && e != sentinel && ! e.isBogus()) {
+ table[getIndex(e.sym.name)] = e;
+ n++;
+ }
}
+ // We don't need to update nelems for shared inherited scopes,
+ // since that gets handled by leave().
+ nelems = n;
}
/** Enter symbol sym in this scope.
@@ -248,13 +248,17 @@
*/
public void enter(Symbol sym, Scope s, Scope origin) {
assert shared == 0;
- // Temporarily disabled (bug 6460352):
- // if (nelems * 3 >= hashMask * 2) dble();
- int hash = sym.name.hashCode() & hashMask;
- Entry e = makeEntry(sym, table[hash], elems, s, origin);
+ if (nelems * 3 >= hashMask * 2)
+ dble();
+ int hash = getIndex(sym.name);
+ Entry old = table[hash];
+ if (old == null) {
+ old = sentinel;
+ nelems++;
+ }
+ Entry e = makeEntry(sym, old, elems, s, origin);
table[hash] = e;
elems = e;
- nelems++;
scopeCounter.inc();
}
@@ -268,15 +272,15 @@
public void remove(Symbol sym) {
assert shared == 0;
Entry e = lookup(sym.name);
- while (e.scope == this && e.sym != sym) e = e.next();
if (e.scope == null) return;
scopeCounter.inc();
// remove e from table and shadowed list;
- Entry te = table[sym.name.hashCode() & hashMask];
+ int i = getIndex(sym.name);
+ Entry te = table[i];
if (te == e)
- table[sym.name.hashCode() & hashMask] = e.shadowed;
+ table[i] = e.shadowed;
else while (true) {
if (te.shadowed == e) {
te.shadowed = e.shadowed;
@@ -335,12 +339,50 @@
return lookup(name, noFilter);
}
public Entry lookup(Name name, Filter<Symbol> sf) {
- Entry e = table[name.hashCode() & hashMask];
+ Entry e = table[getIndex(name)];
+ if (e == null || e == sentinel)
+ return sentinel;
while (e.scope != null && (e.sym.name != name || !sf.accepts(e.sym)))
e = e.shadowed;
return e;
}
+ /*void dump (java.io.PrintStream out) {
+ out.println(this);
+ for (int l=0; l < table.length; l++) {
+ Entry le = table[l];
+ out.print("#"+l+": ");
+ if (le==sentinel) out.println("sentinel");
+ else if(le == null) out.println("null");
+ else out.println(""+le+" s:"+le.sym);
+ }
+ }*/
+
+ /** Look for slot in the table.
+ * We use open addressing with double hashing.
+ */
+ int getIndex (Name name) {
+ int h = name.hashCode();
+ int i = h & hashMask;
+ // The expression below is always odd, so it is guaranteed
+ // be be mutually prime with table.length, a power of 2.
+ int x = hashMask - ((h + (h >> 16)) << 1);
+ int d = -1; // Index of a deleted item.
+ for (;;) {
+ Entry e = table[i];
+ if (e == null)
+ return d >= 0 ? d : i;
+ if (e == sentinel) {
+ // We have to keep searching even if we see a deleted item.
+ // However, remember the index in case we fail to find the name.
+ if (d < 0)
+ d = i;
+ } else if (e.sym.name == name)
+ return i;
+ i = (i + x) & hashMask;
+ }
+ }
+
public Iterable<Symbol> getElements() {
return getElements(noFilter);
}
@@ -441,10 +483,7 @@
* outwards if not found in this scope.
*/
public Entry next() {
- Entry e = shadowed;
- while (e.scope != null && e.sym.name != sym.name)
- e = e.shadowed;
- return e;
+ return shadowed;
}
public Scope getOrigin() {
@@ -456,6 +495,8 @@
// in many cases.
return scope;
}
+
+ protected boolean isBogus () { return false; }
}
public static class ImportScope extends Scope {
@@ -470,22 +511,10 @@
}
public Entry lookup(Name name) {
- Entry e = table[name.hashCode() & hashMask];
- while (e.scope != null &&
- (e.sym.name != name ||
- /* Since an inner class will show up in package and
- * import scopes until its inner class attribute has
- * been processed, we have to weed it out here. This
- * is done by comparing the owners of the entry's
- * scope and symbol fields. The scope field's owner
- * points to where the class originally was imported
- * from. The symbol field's owner points to where the
- * class is situated now. This can change when an
- * inner class is read (see ClassReader.enterClass).
- * By comparing the two fields we make sure that we do
- * not accidentally import an inner class that started
- * life as a flat class in a package. */
- e.sym.owner != e.scope.owner))
+ Entry e = table[getIndex(name)];
+ if (e == null)
+ return sentinel;
+ while (e.isBogus())
e = e.shadowed;
return e;
}
@@ -499,15 +528,33 @@
}
public Entry next() {
Entry e = super.shadowed;
- while (e.scope != null &&
- (e.sym.name != sym.name ||
- e.sym.owner != e.scope.owner)) // see lookup()
+ while (isBogus())
e = e.shadowed;
return e;
}
@Override
public Scope getOrigin() { return origin; }
+
+ /**
+ * Is this a bogus inner-class import?
+ * An inner class {@code Outer$Inner.class} read from a class file
+ * starts out in a package scope under the name {@code Outer$Inner},
+ * which (if star-imported) gets copied to the import scope.
+ * When the InnerClasses attribute is processed, the ClassSymbol
+ * is renamed in place (to {@code Inner}), and the owner changed
+ * to the {@code Outer} class. The ImportScope still has the old
+ * Entry that was created and hashed as {@code "Outer$Inner"},
+ * but whose name was changed to {@code "Inner"}. This violates
+ * the invariants for the Scope hash table, and so is pretty bogus.
+ * When the symbol was renamed, it should have been removed from
+ * the import scope (and not just the package scope); however,
+ * doing so is difficult. A better fix would be to change
+ * import scopes to indirectly reference package symbols, rather
+ * than copy from them.
+ * Until then, we detect and skip the bogus entries using this test.
+ */
+ protected boolean isBogus () { return sym.owner != scope.owner; }
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/code/Types.java Tue Nov 30 14:51:07 2010 -0800
@@ -3151,7 +3151,7 @@
return to.isParameterized() &&
(!(isUnbounded(to) ||
isSubtype(from, to) ||
- ((subFrom != null) && isSameType(subFrom, to))));
+ ((subFrom != null) && containsType(to.allparams(), subFrom.allparams()))));
}
private List<Type> superClosure(Type t, Type s) {
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Tue Nov 30 14:51:07 2010 -0800
@@ -252,10 +252,12 @@
(base.getTag() == JCTree.IDENT && TreeInfo.name(base) == names._this)) &&
isAssignableAsBlankFinal(v, env)))) {
if (v.isResourceVariable()) { //TWR resource
- log.error(pos, "twr.resource.may.not.be.assigned", v);
+ log.error(pos, "try.resource.may.not.be.assigned", v);
} else {
log.error(pos, "cant.assign.val.to.final.var", v);
}
+ } else if ((v.flags() & EFFECTIVELY_FINAL) != 0) {
+ v.flags_field &= ~EFFECTIVELY_FINAL;
}
}
@@ -799,6 +801,7 @@
memberEnter.memberEnter(tree, env);
annotate.flush();
}
+ tree.sym.flags_field |= EFFECTIVELY_FINAL;
}
VarSymbol v = tree.sym;
@@ -1042,11 +1045,11 @@
for (JCTree resource : tree.resources) {
if (resource.getTag() == JCTree.VARDEF) {
attribStat(resource, tryEnv);
- chk.checkType(resource, resource.type, syms.autoCloseableType, "twr.not.applicable.to.type");
+ chk.checkType(resource, resource.type, syms.autoCloseableType, "try.not.applicable.to.type");
VarSymbol var = (VarSymbol)TreeInfo.symbolFor(resource);
var.setData(ElementKind.RESOURCE_VARIABLE);
} else {
- attribExpr(resource, tryEnv, syms.autoCloseableType, "twr.not.applicable.to.type");
+ attribExpr(resource, tryEnv, syms.autoCloseableType, "try.not.applicable.to.type");
}
}
// Attribute body
@@ -1061,11 +1064,8 @@
localEnv.dup(c, localEnv.info.dup(localEnv.info.scope.dup()));
Type ctype = attribStat(c.param, catchEnv);
if (TreeInfo.isMultiCatch(c)) {
- //check that multi-catch parameter is marked as final
- if ((c.param.sym.flags() & FINAL) == 0) {
- log.error(c.param.pos(), "multicatch.param.must.be.final", c.param.sym);
- }
- c.param.sym.flags_field = c.param.sym.flags() | DISJUNCTION;
+ //multi-catch parameter is implicitly marked as final
+ c.param.sym.flags_field |= FINAL | DISJUNCTION;
}
if (c.param.sym.kind == Kinds.VAR) {
c.param.sym.setData(ElementKind.EXCEPTION_PARAMETER);
@@ -1552,7 +1552,7 @@
// Attribute clazz expression and store
// symbol + type back into the attributed tree.
Type clazztype = attribType(clazz, env);
- Pair<Scope,Scope> mapping = getSyntheticScopeMapping(clazztype);
+ Pair<Scope,Scope> mapping = getSyntheticScopeMapping(clazztype, cdef != null);
if (!TreeInfo.isDiamond(tree)) {
clazztype = chk.checkClassType(
tree.clazz.pos(), clazztype, true);
@@ -1849,7 +1849,7 @@
* inference. The inferred return type of the synthetic constructor IS
* the inferred type for the diamond operator.
*/
- private Pair<Scope, Scope> getSyntheticScopeMapping(Type ctype) {
+ private Pair<Scope, Scope> getSyntheticScopeMapping(Type ctype, boolean overrideProtectedAccess) {
if (ctype.tag != CLASS) {
return erroneousMapping;
}
@@ -1860,6 +1860,12 @@
e.scope != null;
e = e.next()) {
MethodSymbol newConstr = (MethodSymbol) e.sym.clone(ctype.tsym);
+ if (overrideProtectedAccess && (newConstr.flags() & PROTECTED) != 0) {
+ //make protected constructor public (this is required for
+ //anonymous inner class creation expressions using diamond)
+ newConstr.flags_field |= PUBLIC;
+ newConstr.flags_field &= ~PROTECTED;
+ }
newConstr.name = names.init;
List<Type> oldTypeargs = List.nil();
if (newConstr.type.tag == FORALL) {
@@ -2252,8 +2258,8 @@
((VarSymbol)sitesym).isResourceVariable() &&
sym.kind == MTH &&
sym.overrides(syms.autoCloseableClose, sitesym.type.tsym, types, true) &&
- env.info.lint.isEnabled(Lint.LintCategory.ARM)) {
- log.warning(tree, "twr.explicit.close.call");
+ env.info.lint.isEnabled(Lint.LintCategory.TRY)) {
+ log.warning(Lint.LintCategory.TRY, tree, "try.explicit.close.call");
}
// Disallow selecting a type from an expression
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Tue Nov 30 14:51:07 2010 -0800
@@ -1510,14 +1510,7 @@
Type t1,
Type t2,
Type site) {
- Symbol sym = firstIncompatibility(t1, t2, site);
- if (sym != null) {
- log.error(pos, "types.incompatible.diff.ret",
- t1, t2, sym.name +
- "(" + types.memberType(t2, sym).getParameterTypes() + ")");
- return false;
- }
- return true;
+ return firstIncompatibility(pos, t1, t2, site) == null;
}
/** Return the first method which is defined with same args
@@ -1528,7 +1521,7 @@
* @param site The most derived type.
* @returns symbol from t2 that conflicts with one in t1.
*/
- private Symbol firstIncompatibility(Type t1, Type t2, Type site) {
+ private Symbol firstIncompatibility(DiagnosticPosition pos, Type t1, Type t2, Type site) {
Map<TypeSymbol,Type> interfaces1 = new HashMap<TypeSymbol,Type>();
closure(t1, interfaces1);
Map<TypeSymbol,Type> interfaces2;
@@ -1539,7 +1532,7 @@
for (Type t3 : interfaces1.values()) {
for (Type t4 : interfaces2.values()) {
- Symbol s = firstDirectIncompatibility(t3, t4, site);
+ Symbol s = firstDirectIncompatibility(pos, t3, t4, site);
if (s != null) return s;
}
}
@@ -1568,7 +1561,7 @@
}
/** Return the first method in t2 that conflicts with a method from t1. */
- private Symbol firstDirectIncompatibility(Type t1, Type t2, Type site) {
+ private Symbol firstDirectIncompatibility(DiagnosticPosition pos, Type t1, Type t2, Type site) {
for (Scope.Entry e1 = t1.tsym.members().elems; e1 != null; e1 = e1.sibling) {
Symbol s1 = e1.sym;
Type st1 = null;
@@ -1592,7 +1585,18 @@
(types.covariantReturnType(rt1, rt2, Warner.noWarnings) ||
types.covariantReturnType(rt2, rt1, Warner.noWarnings)) ||
checkCommonOverriderIn(s1,s2,site);
- if (!compat) return s2;
+ if (!compat) {
+ log.error(pos, "types.incompatible.diff.ret",
+ t1, t2, s2.name +
+ "(" + types.memberType(t2, s2).getParameterTypes() + ")");
+ return s2;
+ }
+ } else if (!checkNameClash((ClassSymbol)site.tsym, s1, s2)) {
+ log.error(pos,
+ "name.clash.same.erasure.no.override",
+ s1, s1.location(),
+ s2, s2.location());
+ return s2;
}
}
}
@@ -1644,32 +1648,52 @@
log.error(tree.pos(), "enum.no.finalize");
return;
}
- for (Type t = types.supertype(origin.type); t.tag == CLASS;
+ for (Type t = origin.type; t.tag == CLASS;
t = types.supertype(t)) {
- TypeSymbol c = t.tsym;
- Scope.Entry e = c.members().lookup(m.name);
- while (e.scope != null) {
- if (m.overrides(e.sym, origin, types, false))
- checkOverride(tree, m, (MethodSymbol)e.sym, origin);
- else if (e.sym.kind == MTH &&
- e.sym.isInheritedIn(origin, types) &&
- (e.sym.flags() & SYNTHETIC) == 0 &&
- !m.isConstructor()) {
- Type er1 = m.erasure(types);
- Type er2 = e.sym.erasure(types);
- if (types.isSameTypes(er1.getParameterTypes(),
- er2.getParameterTypes())) {
- log.error(TreeInfo.diagnosticPositionFor(m, tree),
- "name.clash.same.erasure.no.override",
- m, m.location(),
- e.sym, e.sym.location());
- }
- }
- e = e.next();
+ if (t != origin.type) {
+ checkOverride(tree, t, origin, m);
+ }
+ for (Type t2 : types.interfaces(t)) {
+ checkOverride(tree, t2, origin, m);
}
}
}
+ void checkOverride(JCTree tree, Type site, ClassSymbol origin, MethodSymbol m) {
+ TypeSymbol c = site.tsym;
+ Scope.Entry e = c.members().lookup(m.name);
+ while (e.scope != null) {
+ if (m.overrides(e.sym, origin, types, false)) {
+ if ((e.sym.flags() & ABSTRACT) == 0) {
+ checkOverride(tree, m, (MethodSymbol)e.sym, origin);
+ }
+ }
+ else if (!checkNameClash(origin, e.sym, m)) {
+ log.error(tree,
+ "name.clash.same.erasure.no.override",
+ m, m.location(),
+ e.sym, e.sym.location());
+ }
+ e = e.next();
+ }
+ }
+
+ private boolean checkNameClash(ClassSymbol origin, Symbol s1, Symbol s2) {
+ if (s1.kind == MTH &&
+ s1.isInheritedIn(origin, types) &&
+ (s1.flags() & SYNTHETIC) == 0 &&
+ !s2.isConstructor()) {
+ Type er1 = s2.erasure(types);
+ Type er2 = s1.erasure(types);
+ if (types.isSameTypes(er1.getParameterTypes(),
+ er2.getParameterTypes())) {
+ return false;
+ }
+ }
+ return true;
+ }
+
+
/** Check that all abstract members of given class have definitions.
* @param pos Position to be used for error reporting.
* @param c The class.
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Tue Nov 30 14:51:07 2010 -0800
@@ -226,7 +226,7 @@
*/
Bits uninits;
- HashMap<Symbol, List<Type>> multicatchTypes;
+ HashMap<Symbol, List<Type>> preciseRethrowTypes;
/** The set of variables that are definitely unassigned everywhere
* in current try block. This variable is maintained lazily; it is
@@ -332,7 +332,7 @@
if (!chk.isUnchecked(tree.pos(), exc)) {
if (!chk.isHandled(exc, caught))
pendingExits.append(new PendingExit(tree, exc));
- thrown = chk.incl(exc, thrown);
+ thrown = chk.incl(exc, thrown);
}
}
@@ -1037,10 +1037,10 @@
int nextadrCatch = nextadr;
if (!unrefdResources.isEmpty() &&
- lint.isEnabled(Lint.LintCategory.ARM)) {
+ lint.isEnabled(Lint.LintCategory.TRY)) {
for (Map.Entry<VarSymbol, JCVariableDecl> e : unrefdResources.entrySet()) {
- log.warning(e.getValue().pos(),
- "automatic.resource.not.referenced", e.getKey());
+ log.warning(Lint.LintCategory.TRY, e.getValue().pos(),
+ "try.resource.not.referenced", e.getKey());
}
}
@@ -1077,12 +1077,12 @@
scan(param);
inits.incl(param.sym.adr);
uninits.excl(param.sym.adr);
- multicatchTypes.put(param.sym, chk.intersect(ctypes, rethrownTypes));
+ preciseRethrowTypes.put(param.sym, chk.intersect(ctypes, rethrownTypes));
scanStat(l.head.body);
initsEnd.andSet(inits);
uninitsEnd.andSet(uninits);
nextadr = nextadrCatch;
- multicatchTypes.remove(param.sym);
+ preciseRethrowTypes.remove(param.sym);
aliveEnd |= alive;
}
if (tree.finalizer != null) {
@@ -1215,10 +1215,10 @@
Symbol sym = TreeInfo.symbol(tree.expr);
if (sym != null &&
sym.kind == VAR &&
- (sym.flags() & FINAL) != 0 &&
- multicatchTypes.get(sym) != null &&
+ (sym.flags() & (FINAL | EFFECTIVELY_FINAL)) != 0 &&
+ preciseRethrowTypes.get(sym) != null &&
allowRethrowAnalysis) {
- for (Type t : multicatchTypes.get(sym)) {
+ for (Type t : preciseRethrowTypes.get(sym)) {
markThrown(tree, t);
}
}
@@ -1371,11 +1371,24 @@
if (!tree.type.isErroneous()
&& lint.isEnabled(Lint.LintCategory.CAST)
&& types.isSameType(tree.expr.type, tree.clazz.type)
- && !(ignoreAnnotatedCasts && containsTypeAnnotation(tree.clazz))) {
+ && !(ignoreAnnotatedCasts && containsTypeAnnotation(tree.clazz))
+ && !is292targetTypeCast(tree)) {
log.warning(Lint.LintCategory.CAST,
tree.pos(), "redundant.cast", tree.expr.type);
}
}
+ //where
+ private boolean is292targetTypeCast(JCTypeCast tree) {
+ boolean is292targetTypeCast = false;
+ if (tree.expr.getTag() == JCTree.APPLY) {
+ JCMethodInvocation apply = (JCMethodInvocation)tree.expr;
+ Symbol sym = TreeInfo.symbol(apply.meth);
+ is292targetTypeCast = sym != null &&
+ sym.kind == MTH &&
+ (sym.flags() & POLYMORPHIC_SIGNATURE) != 0;
+ }
+ return is292targetTypeCast;
+ }
public void visitTopLevel(JCCompilationUnit tree) {
// Do nothing for TopLevel since each class is visited individually
@@ -1422,7 +1435,7 @@
firstadr = 0;
nextadr = 0;
pendingExits = new ListBuffer<PendingExit>();
- multicatchTypes = new HashMap<Symbol, List<Type>>();
+ preciseRethrowTypes = new HashMap<Symbol, List<Type>>();
alive = true;
this.thrown = this.caught = null;
this.classDef = null;
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Tue Nov 30 14:51:07 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2009, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2010, 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
@@ -1509,17 +1509,17 @@
}
private JCBlock makeArmFinallyClause(Symbol primaryException, JCExpression resource) {
- // primaryException.addSuppressedException(catchException);
+ // primaryException.addSuppressed(catchException);
VarSymbol catchException =
new VarSymbol(0, make.paramName(2),
syms.throwableType,
currentMethodSym);
JCStatement addSuppressionStatement =
make.Exec(makeCall(make.Ident(primaryException),
- names.fromString("addSuppressedException"),
+ names.addSuppressed,
List.<JCExpression>of(make.Ident(catchException))));
- // try { resource.close(); } catch (e) { primaryException.addSuppressedException(e); }
+ // try { resource.close(); } catch (e) { primaryException.addSuppressed(e); }
JCBlock tryBlock =
make.Block(0L, List.<JCStatement>of(makeResourceCloseInvocation(resource)));
JCVariableDecl catchExceptionDecl = make.VarDef(catchException, null);
--- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Tue Nov 30 14:51:07 2010 -0800
@@ -159,33 +159,45 @@
* @param c The class whose accessibility is checked.
*/
public boolean isAccessible(Env<AttrContext> env, TypeSymbol c) {
+ return isAccessible(env, c, false);
+ }
+
+ public boolean isAccessible(Env<AttrContext> env, TypeSymbol c, boolean checkInner) {
+ boolean isAccessible = false;
switch ((short)(c.flags() & AccessFlags)) {
- case PRIVATE:
- return
- env.enclClass.sym.outermostClass() ==
- c.owner.outermostClass();
- case 0:
- return
- env.toplevel.packge == c.owner // fast special case
- ||
- env.toplevel.packge == c.packge()
- ||
- // Hack: this case is added since synthesized default constructors
- // of anonymous classes should be allowed to access
- // classes which would be inaccessible otherwise.
- env.enclMethod != null &&
- (env.enclMethod.mods.flags & ANONCONSTR) != 0;
- default: // error recovery
- case PUBLIC:
- return true;
- case PROTECTED:
- return
- env.toplevel.packge == c.owner // fast special case
- ||
- env.toplevel.packge == c.packge()
- ||
- isInnerSubClass(env.enclClass.sym, c.owner);
+ case PRIVATE:
+ isAccessible =
+ env.enclClass.sym.outermostClass() ==
+ c.owner.outermostClass();
+ break;
+ case 0:
+ isAccessible =
+ env.toplevel.packge == c.owner // fast special case
+ ||
+ env.toplevel.packge == c.packge()
+ ||
+ // Hack: this case is added since synthesized default constructors
+ // of anonymous classes should be allowed to access
+ // classes which would be inaccessible otherwise.
+ env.enclMethod != null &&
+ (env.enclMethod.mods.flags & ANONCONSTR) != 0;
+ break;
+ default: // error recovery
+ case PUBLIC:
+ isAccessible = true;
+ break;
+ case PROTECTED:
+ isAccessible =
+ env.toplevel.packge == c.owner // fast special case
+ ||
+ env.toplevel.packge == c.packge()
+ ||
+ isInnerSubClass(env.enclClass.sym, c.owner);
+ break;
}
+ return (checkInner == false || c.type.getEnclosingType() == Type.noType) ?
+ isAccessible :
+ isAccessible & isAccessible(env, c.type.getEnclosingType(), checkInner);
}
//where
/** Is given class a subclass of given base class, or an inner class
@@ -202,9 +214,13 @@
}
boolean isAccessible(Env<AttrContext> env, Type t) {
+ return isAccessible(env, t, false);
+ }
+
+ boolean isAccessible(Env<AttrContext> env, Type t, boolean checkInner) {
return (t.tag == ARRAY)
? isAccessible(env, types.elemtype(t))
- : isAccessible(env, t.tsym);
+ : isAccessible(env, t.tsym, checkInner);
}
/** Is symbol accessible as a member of given type in given evironment?
@@ -214,6 +230,9 @@
* @param sym The symbol.
*/
public boolean isAccessible(Env<AttrContext> env, Type site, Symbol sym) {
+ return isAccessible(env, site, sym, false);
+ }
+ public boolean isAccessible(Env<AttrContext> env, Type site, Symbol sym, boolean checkInner) {
if (sym.name == names.init && sym.owner != site.tsym) return false;
ClassSymbol sub;
switch ((short)(sym.flags() & AccessFlags)) {
@@ -231,7 +250,7 @@
||
env.toplevel.packge == sym.packge())
&&
- isAccessible(env, site)
+ isAccessible(env, site, checkInner)
&&
sym.isInheritedIn(site.tsym, types)
&&
@@ -248,11 +267,11 @@
// (but type names should be disallowed elsewhere!)
env.info.selectSuper && (sym.flags() & STATIC) == 0 && sym.kind != TYP)
&&
- isAccessible(env, site)
+ isAccessible(env, site, checkInner)
&&
notOverriddenIn(site, sym);
default: // this case includes erroneous combinations as well
- return isAccessible(env, site) && notOverriddenIn(site, sym);
+ return isAccessible(env, site, checkInner) && notOverriddenIn(site, sym);
}
}
//where
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassWriter.java Tue Nov 30 14:51:07 2010 -0800
@@ -993,7 +993,9 @@
/** Enter an inner class into the `innerClasses' set/queue.
*/
void enterInner(ClassSymbol c) {
- assert !c.type.isCompound();
+ if (c.type.isCompound()) {
+ throw new AssertionError("Unexpected intersection type: " + c.type);
+ }
try {
c.complete();
} catch (CompletionFailure ex) {
--- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Code.java Tue Nov 30 14:51:07 2010 -0800
@@ -1304,7 +1304,7 @@
stackCount = 0;
for (int i=0; i<state.stacksize; i++) {
if (state.stack[i] != null) {
- frame.stack[stackCount++] = state.stack[i];
+ frame.stack[stackCount++] = types.erasure(state.stack[i]);
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Tue Nov 30 14:51:07 2010 -0800
@@ -1712,7 +1712,7 @@
S.nextToken();
List<JCTree> resources = List.<JCTree>nil();
if (S.token() == LPAREN) {
- checkAutomaticResourceManagement();
+ checkTryWithResources();
S.nextToken();
resources = resources();
accept(RPAREN);
@@ -2970,9 +2970,9 @@
allowMulticatch = true;
}
}
- void checkAutomaticResourceManagement() {
+ void checkTryWithResources() {
if (!allowTWR) {
- error(S.pos(), "automatic.resource.management.not.supported.in.source", source.name);
+ error(S.pos(), "try.with.resources.not.supported.in.source", source.name);
allowTWR = true;
}
}
--- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties Tue Nov 30 14:51:07 2010 -0800
@@ -63,8 +63,6 @@
anonymous class implements interface; cannot have type arguments
compiler.err.anon.class.impl.intf.no.qual.for.new=\
anonymous class implements interface; cannot have qualifier for new
-compiler.misc.twr.not.applicable.to.type=\
- automatic resource management not applicable to variable type
compiler.err.array.and.varargs=\
cannot declare both {0} and {1} in {2}
compiler.err.array.dimension.missing=\
@@ -183,12 +181,10 @@
compiler.err.final.parameter.may.not.be.assigned=\
final parameter {0} may not be assigned
-compiler.err.twr.resource.may.not.be.assigned=\
- automatic resource {0} may not be assigned
+compiler.err.try.resource.may.not.be.assigned=\
+ auto-closeable resource {0} may not be assigned
compiler.err.multicatch.parameter.may.not.be.assigned=\
multi-catch parameter {0} may not be assigned
-compiler.err.multicatch.param.must.be.final=\
- multi-catch parameter {0} must be final
compiler.err.finally.without.try=\
''finally'' without ''try''
compiler.err.foreach.not.applicable.to.type=\
@@ -825,10 +821,10 @@
compiler.warn.proc.unmatched.processor.options=\
The following options were not recognized by any processor: ''{0}''
-compiler.warn.twr.explicit.close.call=\
- [arm] explicit call to close() on an automatic resource
-compiler.warn.automatic.resource.not.referenced=\
- [arm] automatic resource {0} is never referenced in body of corresponding try statement
+compiler.warn.try.explicit.close.call=\
+ explicit call to close() on an auto-closeable resource
+compiler.warn.try.resource.not.referenced=\
+ auto-closeable resource {0} is never referenced in body of corresponding try statement
compiler.warn.unchecked.assign=\
unchecked assignment: {0} to {1}
compiler.warn.unchecked.assign.to.var=\
@@ -1052,6 +1048,9 @@
# compiler.err.no.elem.type=\
# \[\*\] cannot have a type
+compiler.misc.try.not.applicable.to.type=\
+ try-with-resources not applicable to variable type
+
#####
compiler.err.type.found.req=\
@@ -1274,9 +1273,9 @@
exotic identifiers #"___" are not supported in -source {0}\n\
(use -source 7 or higher to enable exotic identifiers)
-compiler.err.automatic.resource.management.not.supported.in.source=\
- automatic resource management is not supported in -source {0}\n\
-(use -source 7 or higher to enable automatic resource management)
+compiler.err.try.with.resources.not.supported.in.source=\
+ try-with-resources is not supported in -source {0}\n\
+(use -source 7 or higher to enable try-with-resources)
compiler.warn.enum.as.identifier=\
as of release 5, ''enum'' is a keyword, and may not be used as an identifier\n\
--- a/langtools/src/share/classes/com/sun/tools/javac/util/Names.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/src/share/classes/com/sun/tools/javac/util/Names.java Tue Nov 30 14:51:07 2010 -0800
@@ -1,5 +1,5 @@
/*
- * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 1999, 2010, 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
@@ -150,6 +150,7 @@
public final Name finalize;
public final Name java_lang_AutoCloseable;
public final Name close;
+ public final Name addSuppressed;
public final Name.Table table;
@@ -268,6 +269,7 @@
java_lang_AutoCloseable = fromString("java.lang.AutoCloseable");
close = fromString("close");
+ addSuppressed = fromString("addSuppressed");
}
protected Name.Table createTable(Options options) {
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6996626/Main.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,45 @@
+/*
+ * Copyright (c) 2010, 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 6996626
+ * @summary Scope fix issues for ImportScope
+ * @compile pack1/Symbol.java
+ * @compile Main.java
+ */
+
+import pack1.*;
+import pack1.Symbol.*;
+
+// The following imports are just to trigger re-hashing (in
+// com.sun.tools.javac.code.Scope.dble()) of the star-import scope.
+import java.io.*;
+import java.net.*;
+import java.util.*;
+
+public class Main {
+ public void main (String[] args) {
+ throw new CompletionFailure();
+ }
+}
+
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/6996626/pack1/Symbol.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010, 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.
+ */
+
+package pack1;
+
+public class Symbol {
+ public static class CompletionFailure extends RuntimeException { }
+}
+
+
+
--- a/langtools/test/tools/javac/TryWithResources/ArmLint.java Tue Nov 30 10:35:55 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,55 +0,0 @@
-/*
- * @test /nodynamiccopyright/
- * @bug 6911256 6964740 6965277 6967065
- * @author Joseph D. Darcy
- * @summary Check that -Xlint:arm warnings are generated as expected
- * @compile/ref=ArmLint.out -Xlint:arm,deprecation -XDrawDiagnostics ArmLint.java
- */
-
-class ArmLint implements AutoCloseable {
- private static void test1() {
- try(ArmLint r1 = new ArmLint();
- ArmLint r2 = new ArmLint();
- ArmLint r3 = new ArmLint()) {
- r1.close(); // The resource's close
- r2.close(42); // *Not* the resource's close
- // r3 not referenced
- }
-
- }
-
- @SuppressWarnings("arm")
- private static void test2() {
- try(@SuppressWarnings("deprecation") AutoCloseable r4 =
- new DeprecatedAutoCloseable()) {
- // r4 not referenced
- } catch(Exception e) {
- ;
- }
- }
-
- /**
- * The AutoCloseable method of a resource.
- */
- @Override
- public void close () {
- return;
- }
-
- /**
- * <em>Not</em> the AutoCloseable method of a resource.
- */
- public void close (int arg) {
- return;
- }
-}
-
-@Deprecated
-class DeprecatedAutoCloseable implements AutoCloseable {
- public DeprecatedAutoCloseable(){super();}
-
- @Override
- public void close () {
- return;
- }
-}
--- a/langtools/test/tools/javac/TryWithResources/ArmLint.out Tue Nov 30 10:35:55 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,3 +0,0 @@
-ArmLint.java:14:15: compiler.warn.twr.explicit.close.call
-ArmLint.java:13:13: compiler.warn.automatic.resource.not.referenced: r3
-2 warnings
--- a/langtools/test/tools/javac/TryWithResources/ImplicitFinal.out Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/TryWithResources/ImplicitFinal.out Tue Nov 30 14:51:07 2010 -0800
@@ -1,2 +1,2 @@
-ImplicitFinal.java:14:13: compiler.err.twr.resource.may.not.be.assigned: r
+ImplicitFinal.java:14:13: compiler.err.try.resource.may.not.be.assigned: r
1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/TryWithResources/TwrLint.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,55 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6911256 6964740 6965277 6967065
+ * @author Joseph D. Darcy
+ * @summary Check that -Xlint:twr warnings are generated as expected
+ * @compile/ref=TwrLint.out -Xlint:try,deprecation -XDrawDiagnostics TwrLint.java
+ */
+
+class TwrLint implements AutoCloseable {
+ private static void test1() {
+ try(TwrLint r1 = new TwrLint();
+ TwrLint r2 = new TwrLint();
+ TwrLint r3 = new TwrLint()) {
+ r1.close(); // The resource's close
+ r2.close(42); // *Not* the resource's close
+ // r3 not referenced
+ }
+
+ }
+
+ @SuppressWarnings("try")
+ private static void test2() {
+ try(@SuppressWarnings("deprecation") AutoCloseable r4 =
+ new DeprecatedAutoCloseable()) {
+ // r4 not referenced - but no warning is generated because of @SuppressWarnings
+ } catch(Exception e) {
+ ;
+ }
+ }
+
+ /**
+ * The AutoCloseable method of a resource.
+ */
+ @Override
+ public void close () {
+ return;
+ }
+
+ /**
+ * <em>Not</em> the AutoCloseable method of a resource.
+ */
+ public void close (int arg) {
+ return;
+ }
+}
+
+@Deprecated
+class DeprecatedAutoCloseable implements AutoCloseable {
+ public DeprecatedAutoCloseable(){super();}
+
+ @Override
+ public void close () {
+ return;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/TryWithResources/TwrLint.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,3 @@
+TwrLint.java:14:15: compiler.warn.try.explicit.close.call
+TwrLint.java:13:13: compiler.warn.try.resource.not.referenced: r3
+2 warnings
--- a/langtools/test/tools/javac/TryWithResources/TwrOnNonResource.out Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/TryWithResources/TwrOnNonResource.out Tue Nov 30 14:51:07 2010 -0800
@@ -1,7 +1,7 @@
-TwrOnNonResource.java:12:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:15:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:18:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:24:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:27:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
-TwrOnNonResource.java:30:13: compiler.err.prob.found.req: (compiler.misc.twr.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
+TwrOnNonResource.java:12:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
+TwrOnNonResource.java:15:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
+TwrOnNonResource.java:18:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
+TwrOnNonResource.java:24:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
+TwrOnNonResource.java:27:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
+TwrOnNonResource.java:30:13: compiler.err.prob.found.req: (compiler.misc.try.not.applicable.to.type), TwrOnNonResource, java.lang.AutoCloseable
6 errors
--- a/langtools/test/tools/javac/TryWithResources/TwrSuppression.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/TryWithResources/TwrSuppression.java Tue Nov 30 14:51:07 2010 -0800
@@ -36,7 +36,7 @@
throw new RuntimeException();
}
} catch(RuntimeException e) {
- Throwable[] suppressedExceptions = e.getSuppressedExceptions();
+ Throwable[] suppressedExceptions = e.getSuppressed();
int length = suppressedExceptions.length;
if (length != 2)
throw new RuntimeException("Unexpected length " + length);
--- a/langtools/test/tools/javac/TryWithResources/TwrTests.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/TryWithResources/TwrTests.java Tue Nov 30 14:51:07 2010 -0800
@@ -90,7 +90,7 @@
} catch (Resource.CreateFailException e) {
creationFailuresDetected++;
checkCreateFailureId(e.resourceId(), createFailureId);
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
throw new AssertionError("Secondary exception suppression failed");
}
@@ -112,7 +112,7 @@
} catch (Resource.CreateFailException e) {
creationFailuresDetected++;
checkCreateFailureId(e.resourceId(), createFailureId);
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
throw new AssertionError("Secondary exception suppression failed");
}
@@ -134,7 +134,7 @@
} catch (Resource.CreateFailException e) {
creationFailuresDetected++;
checkCreateFailureId(e.resourceId(), createFailureId);
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
throw new AssertionError("Secondary exception suppression failed:" + e);
}
@@ -158,7 +158,7 @@
} catch (Resource.CreateFailException e) {
creationFailuresDetected++;
checkCreateFailureId(e.resourceId(), createFailureId);
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
throw new AssertionError("Secondary exception suppression failed:" + e);
}
@@ -181,7 +181,7 @@
} catch (Resource.CreateFailException e) {
creationFailuresDetected++;
checkCreateFailureId(e.resourceId(), createFailureId);
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
throw new AssertionError("Secondary exception suppression failed:" + e);
}
@@ -207,7 +207,7 @@
} catch (Resource.CreateFailException e) {
creationFailuresDetected++;
checkCreateFailureId(e.resourceId(), createFailureId);
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
throw new AssertionError("Secondary exception suppression failed:" + e);
}
@@ -231,7 +231,7 @@
} catch (Resource.CreateFailException e) {
creationFailuresDetected++;
checkCreateFailureId(e.resourceId(), createFailureId);
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
throw new AssertionError("Secondary exception suppression failed:" + e);
}
@@ -259,7 +259,7 @@
} catch (Resource.CreateFailException e) {
creationFailuresDetected++;
checkCreateFailureId(e.resourceId(), createFailureId);
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
throw new AssertionError("Secondary exception suppression failed:" + e);
}
@@ -310,7 +310,7 @@
* Check for proper suppressed exceptions in proper order.
*
* @param suppressedExceptions the suppressed exceptions array returned by
- * getSuppressedExceptions()
+ * getSuppressed()
* @bitmap a bitmap indicating which suppressed exceptions are expected.
* Bit i is set iff id should throw a CloseFailException.
*/
@@ -376,7 +376,7 @@
} catch (MyKindOfException e) {
if (failure == 0)
throw new AssertionError("Unexpected MyKindOfException");
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
if (failure == 1)
throw new AssertionError("Secondary exception suppression failed");
@@ -388,7 +388,7 @@
throw new AssertionError("CloseFailException: got id " + id
+ ", expected lg(" + highestCloseFailBit +")");
}
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit);
}
checkClosedList(closedList, 1);
}
@@ -409,7 +409,7 @@
} catch (MyKindOfException e) {
if (failure == 0)
throw new AssertionError("Unexpected MyKindOfException");
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
if (failure == 1)
throw new AssertionError("Secondary exception suppression failed");
@@ -421,7 +421,7 @@
throw new AssertionError("CloseFailException: got id " + id
+ ", expected lg(" + highestCloseFailBit +")");
}
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit);
}
checkClosedList(closedList, 2);
}
@@ -443,7 +443,7 @@
} catch (MyKindOfException e) {
if (failure == 0)
throw new AssertionError("Unexpected MyKindOfException");
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
if (failure == 1)
throw new AssertionError("Secondary exception suppression failed");
@@ -455,7 +455,7 @@
throw new AssertionError("CloseFailException: got id " + id
+ ", expected lg(" + highestCloseFailBit +")");
}
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit);
}
checkClosedList(closedList, 2);
}
@@ -477,7 +477,7 @@
} catch (MyKindOfException e) {
if (failure == 0)
throw new AssertionError("Unexpected MyKindOfException");
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
if (failure == 1)
throw new AssertionError("Secondary exception suppression failed");
@@ -489,7 +489,7 @@
throw new AssertionError("CloseFailException: got id " + id
+ ", expected lg(" + highestCloseFailBit +")");
}
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit);
}
checkClosedList(closedList, 3);
}
@@ -513,7 +513,7 @@
} catch (MyKindOfException e) {
if (failure == 0)
throw new AssertionError("Unexpected MyKindOfException");
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
if (failure == 1)
throw new AssertionError("Secondary exception suppression failed");
@@ -525,7 +525,7 @@
throw new AssertionError("CloseFailException: got id " + id
+ ", expected lg(" + highestCloseFailBit +")");
}
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit);
}
checkClosedList(closedList, 3);
}
@@ -548,7 +548,7 @@
} catch (MyKindOfException e) {
if (failure == 0)
throw new AssertionError("Unexpected MyKindOfException");
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
if (failure == 1)
throw new AssertionError("Secondary exception suppression failed");
@@ -560,7 +560,7 @@
throw new AssertionError("CloseFailException: got id " + id
+ ", expected lg(" + highestCloseFailBit +")");
}
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit);
}
checkClosedList(closedList, 4);
}
@@ -586,7 +586,7 @@
} catch (MyKindOfException e) {
if (failure == 0)
throw new AssertionError("Unexpected MyKindOfException");
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
if (failure == 1)
throw new AssertionError("Secondary exception suppression failed");
@@ -598,7 +598,7 @@
throw new AssertionError("CloseFailException: got id " + id
+ ", expected lg(" + highestCloseFailBit +")");
}
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit);
}
checkClosedList(closedList, 4);
}
@@ -621,7 +621,7 @@
} catch (MyKindOfException e) {
if (failure == 0)
throw new AssertionError("Unexpected MyKindOfException");
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
if (failure == 1)
throw new AssertionError("Secondary exception suppression failed");
@@ -633,7 +633,7 @@
throw new AssertionError("CloseFailException: got id " + id
+ ", expected lg(" + highestCloseFailBit +")");
}
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit);
}
checkClosedList(closedList, 5);
}
@@ -660,7 +660,7 @@
} catch (MyKindOfException e) {
if (failure == 0)
throw new AssertionError("Unexpected MyKindOfException");
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap);
} catch (Resource.CloseFailException e) {
if (failure == 1)
throw new AssertionError("Secondary exception suppression failed");
@@ -672,7 +672,7 @@
throw new AssertionError("CloseFailException: got id " + id
+ ", expected lg(" + highestCloseFailBit +")");
}
- checkSuppressedExceptions(e.getSuppressedExceptions(), bitMap & ~highestCloseFailBit);
+ checkSuppressedExceptions(e.getSuppressed(), bitMap & ~highestCloseFailBit);
}
checkClosedList(closedList, 5);
}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/api/6598108/T6598108.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,71 @@
+/*
+ * Copyright (c) 2010, 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 6598108
+ * @summary com.sun.source.util.Trees.isAccessible incorrect
+ * @author Jan Lahoda
+ */
+
+import com.sun.source.tree.CompilationUnitTree;
+import com.sun.source.tree.Scope;
+import com.sun.source.util.JavacTask;
+import com.sun.source.util.TreePath;
+import com.sun.source.util.Trees;
+import java.net.URI;
+import java.util.Arrays;
+import javax.lang.model.element.TypeElement;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class T6598108 {
+ public static void main(String[] args) throws Exception {
+ final String bootPath = System.getProperty("sun.boot.class.path"); //NOI18N
+ final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+ assert tool != null;
+ final JavacTask ct = (JavacTask)tool.getTask(null, null, null, Arrays.asList("-bootclasspath", bootPath), null, Arrays.asList(new MyFileObject()));
+
+ CompilationUnitTree cut = ct.parse().iterator().next();
+ TreePath tp = new TreePath(new TreePath(cut), cut.getTypeDecls().get(0));
+ Scope s = Trees.instance(ct).getScope(tp);
+ TypeElement type = ct.getElements().getTypeElement("com.sun.java.util.jar.pack.Package.File");
+
+ if (Trees.instance(ct).isAccessible(s, type)) {
+ //com.sun.java.util.jar.pack.Package.File is a public innerclass inside a non-accessible class, so
+ //"false" would be expected here.
+ throw new IllegalStateException("");
+ }
+ }
+
+ static class MyFileObject extends SimpleJavaFileObject {
+ public MyFileObject() {
+ super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+ }
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ return "public class Test<TTT> { public void test() {TTT ttt;}}";
+ }
+ }
+}
--- a/langtools/test/tools/javac/api/T6412669.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/api/T6412669.java Tue Nov 30 14:51:07 2010 -0800
@@ -23,11 +23,12 @@
/*
* @test
- * @bug 6412669
+ * @bug 6412669 6997958
* @summary Should be able to get SourcePositions from 269 world
*/
import java.io.*;
+import java.net.*;
import java.util.*;
import javax.annotation.*;
import javax.annotation.processing.*;
@@ -39,28 +40,59 @@
@SupportedAnnotationTypes("*")
public class T6412669 extends AbstractProcessor {
- public static void main(String... args) throws IOException {
- String testSrc = System.getProperty("test.src", ".");
- String testClasses = System.getProperty("test.classes", ".");
+ public static void main(String... args) throws Exception {
+ File testSrc = new File(System.getProperty("test.src", "."));
+ File testClasses = new File(System.getProperty("test.classes", "."));
+
+ // Determine location of necessary tools classes. Assume all in one place.
+ // Likely candidates are typically tools.jar (when testing JDK build)
+ // or build/classes or dist/javac.jar (when testing langtools, using -Xbootclasspath/p:)
+ File toolsClasses;
+ URL u = T6412669.class.getClassLoader().getResource("com/sun/source/util/JavacTask.class");
+ switch (u.getProtocol()) {
+ case "file":
+ toolsClasses = new File(u.toURI());
+ break;
+ case "jar":
+ String s = u.getFile(); // will be file:path!/entry
+ int sep = s.indexOf("!");
+ toolsClasses = new File(new URI(s.substring(0, sep)));
+ break;
+ default:
+ throw new AssertionError("Cannot locate tools classes");
+ }
+ //System.err.println("toolsClasses: " + toolsClasses);
JavacTool tool = JavacTool.create();
StandardJavaFileManager fm = tool.getStandardFileManager(null, null, null);
- fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(new File(testClasses)));
+ fm.setLocation(StandardLocation.CLASS_PATH, Arrays.asList(testClasses, toolsClasses));
Iterable<? extends JavaFileObject> files =
fm.getJavaFileObjectsFromFiles(Arrays.asList(new File(testSrc, T6412669.class.getName()+".java")));
- String[] opts = { "-proc:only", "-processor", T6412669.class.getName(),
- "-classpath", new File(testClasses).getPath() };
- JavacTask task = tool.getTask(null, fm, null, Arrays.asList(opts), null, files);
- if (!task.call())
- throw new AssertionError("test failed");
+ String[] opts = { "-proc:only", "-processor", T6412669.class.getName()};
+ StringWriter sw = new StringWriter();
+ JavacTask task = tool.getTask(sw, fm, null, Arrays.asList(opts), null, files);
+ boolean ok = task.call();
+ String out = sw.toString();
+ if (!out.isEmpty())
+ System.err.println(out);
+ if (!ok)
+ throw new AssertionError("compilation of test program failed");
+ // verify we found an annotated element to exercise the SourcePositions API
+ if (!out.contains("processing element"))
+ throw new AssertionError("expected text not found in compilation output");
}
public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
Trees trees = Trees.instance(processingEnv);
SourcePositions sp = trees.getSourcePositions();
Messager m = processingEnv.getMessager();
+ m.printMessage(Diagnostic.Kind.NOTE, "processing annotations");
+ int count = 0;
for (TypeElement anno: annotations) {
+ count++;
+ m.printMessage(Diagnostic.Kind.NOTE, " processing annotation " + anno);
for (Element e: roundEnv.getElementsAnnotatedWith(anno)) {
+ m.printMessage(Diagnostic.Kind.NOTE, " processing element " + e);
TreePath p = trees.getPath(e);
long start = sp.getStartPosition(p.getCompilationUnit(), p.getLeaf());
long end = sp.getEndPosition(p.getCompilationUnit(), p.getLeaf());
@@ -69,6 +101,8 @@
m.printMessage(k, "test [" + start + "," + end + "]", e);
}
}
+ if (count == 0)
+ m.printMessage(Diagnostic.Kind.NOTE, "no annotations found");
return true;
}
--- a/langtools/test/tools/javac/cast/6467183/T6467183a.out Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/cast/6467183/T6467183a.out Tue Nov 30 14:51:07 2010 -0800
@@ -1,6 +1,4 @@
T6467183a.java:16:26: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), T6467183a<T>.B, T6467183a<T>.A<T>
-T6467183a.java:24:41: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), T6467183a<T>.A<java.lang.Integer>, T6467183a<T>.C<? extends java.lang.Number>
-T6467183a.java:28:42: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), T6467183a<T>.A<java.lang.Integer>, T6467183a<T>.C<? extends java.lang.Integer>
- compiler.err.warnings.and.werror
1 error
-3 warnings
+1 warning
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/6714835/T6714835.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,21 @@
+/*
+ * @test /nodynamiccopyright/
+ * @author mcimadamore
+ * @bug 6714835
+ * @summary Safe cast is rejected (with warning) by javac
+ * @compile/fail/ref=T6714835.out -Xlint:unchecked -Werror -XDrawDiagnostics T6714835.java
+ */
+
+import java.util.*;
+
+class T6714835 {
+ void cast1(Iterable<? extends Integer> x) {
+ Collection<? extends Number> x1 = (Collection<? extends Number>)x; //ok
+ Collection<? super Integer> x2 = (Collection<? super Integer>)x; //warn
+ }
+
+ void cast2(Iterable<? super Number> x) {
+ Collection<? super Integer> x1 = (Collection<? super Integer>)x; //ok
+ Collection<? extends Number> x2 = (Collection<? extends Number>)x; //warn
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/cast/6714835/T6714835.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,5 @@
+T6714835.java:14:71: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Iterable<compiler.misc.type.captureof: 1, ? extends java.lang.Integer>, java.util.Collection<? super java.lang.Integer>
+T6714835.java:19:73: compiler.warn.prob.found.req: (compiler.misc.unchecked.cast.to.type), java.lang.Iterable<compiler.misc.type.captureof: 1, ? super java.lang.Number>, java.util.Collection<? extends java.lang.Number>
+- compiler.err.warnings.and.werror
+1 error
+2 warnings
--- a/langtools/test/tools/javac/diags/examples/MulticatchMustBeFinal.java Tue Nov 30 10:35:55 2010 +0300
+++ /dev/null Thu Jan 01 00:00:00 1970 +0000
@@ -1,38 +0,0 @@
-/*
- * Copyright (c) 2010, 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.
- */
-
-// key: compiler.err.multicatch.param.must.be.final
-
-class MulticatchMustBeFinal {
- void e1() throws NullPointerException { }
- void e2() throws IllegalArgumentException { }
-
- void m() {
- try {
- e1();
- e2();
- } catch (NullPointerException | IllegalArgumentException e) {
- e.printStackTrace();
- }
- }
-}
--- a/langtools/test/tools/javac/diags/examples/ResourceClosed.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/diags/examples/ResourceClosed.java Tue Nov 30 14:51:07 2010 -0800
@@ -21,8 +21,8 @@
* questions.
*/
-// key: compiler.warn.twr.explicit.close.call
-// options: -Xlint:arm
+// key: compiler.warn.try.explicit.close.call
+// options: -Xlint:try
import java.io.*;
--- a/langtools/test/tools/javac/diags/examples/ResourceMayNotBeAssigned.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/diags/examples/ResourceMayNotBeAssigned.java Tue Nov 30 14:51:07 2010 -0800
@@ -21,7 +21,7 @@
* questions.
*/
-// key: compiler.err.twr.resource.may.not.be.assigned
+// key: compiler.err.try.resource.may.not.be.assigned
import java.io.*;
--- a/langtools/test/tools/javac/diags/examples/ResourceNotApplicableToType.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/diags/examples/ResourceNotApplicableToType.java Tue Nov 30 14:51:07 2010 -0800
@@ -21,7 +21,7 @@
* questions.
*/
-// key: compiler.misc.twr.not.applicable.to.type
+// key: compiler.misc.try.not.applicable.to.type
// key: compiler.err.prob.found.req
class ResourceNotApplicableToType {
--- a/langtools/test/tools/javac/diags/examples/ResourceNotReferenced.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/diags/examples/ResourceNotReferenced.java Tue Nov 30 14:51:07 2010 -0800
@@ -21,8 +21,8 @@
* questions.
*/
-// key: compiler.warn.automatic.resource.not.referenced
-// options: -Xlint:arm
+// key: compiler.warn.try.resource.not.referenced
+// options: -Xlint:try
import java.io.*;
--- a/langtools/test/tools/javac/diags/examples/TryResourceNotSupported.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/diags/examples/TryResourceNotSupported.java Tue Nov 30 14:51:07 2010 -0800
@@ -21,7 +21,7 @@
* questions.
*/
-// key: compiler.err.automatic.resource.management.not.supported.in.source
+// key: compiler.err.try.with.resources.not.supported.in.source
// options: -source 1.6
import java.io.*;
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719a.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6985719
+ * @summary Alike methods in interfaces (Inheritance and Overriding)
+ * @author mcimadamore
+ * @compile/fail/ref=T6985719a.out -XDrawDiagnostics T6985719a.java
+ */
+
+import java.util.List;
+
+class T6985719a {
+ interface A { void f(List<String> ls); }
+ interface B { void f(List<Integer> ls); }
+ interface C extends A,B {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719a.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+T6985719a.java:14:5: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719a.B, f(java.util.List<java.lang.String>), T6985719a.A
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719b.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6985719
+ * @summary Alike methods in interfaces (Inheritance and Overriding)
+ * @author mcimadamore
+ * @compile/fail/ref=T6985719b.out -XDrawDiagnostics T6985719b.java
+ */
+
+import java.util.List;
+
+class T6985719b {
+ abstract class A { abstract void f(List<String> ls); }
+ interface B { void f(List<Integer> ls); }
+ abstract class C extends A implements B {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719b.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+T6985719b.java:14:14: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719b.B, f(java.util.List<java.lang.String>), T6985719b.A
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719c.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6985719
+ * @summary Alike methods in interfaces (Inheritance and Overriding)
+ * @author mcimadamore
+ * @compile/fail/ref=T6985719c.out -XDrawDiagnostics T6985719c.java
+ */
+
+import java.util.List;
+
+class T6985719c {
+ interface A { void f(List<String> ls); }
+ interface B<X> { void f(List<X> ls); }
+ interface C extends A,B<Integer> {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719c.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+T6985719c.java:14:5: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<X>), T6985719c.B, f(java.util.List<java.lang.String>), T6985719c.A
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719d.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,15 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6985719
+ * @summary Alike methods in interfaces (Inheritance and Overriding)
+ * @author mcimadamore
+ * @compile/fail/ref=T6985719d.out -XDrawDiagnostics T6985719d.java
+ */
+
+import java.util.List;
+
+class T6985719d {
+ abstract class A { abstract void f(List<String> ls); }
+ interface B<X> { void f(List<X> ls); }
+ abstract class C extends A implements B<Integer> {}
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719d.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+T6985719d.java:14:14: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<X>), T6985719d.B, f(java.util.List<java.lang.String>), T6985719d.A
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719e.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6985719
+ * @summary Alike methods in interfaces (Inheritance and Overriding)
+ * @author mcimadamore
+ * @compile/fail/ref=T6985719e.out -XDrawDiagnostics T6985719e.java
+ */
+
+import java.util.List;
+
+class T6985719e {
+ interface A { void f(List<String> ls); }
+ interface B extends A { void f(List<Integer> ls); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719e.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+T6985719e.java:13:34: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719e.B, f(java.util.List<java.lang.String>), T6985719e.A
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719f.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6985719
+ * @summary Alike methods in interfaces (Inheritance and Overriding)
+ * @author mcimadamore
+ * @compile/fail/ref=T6985719f.out -XDrawDiagnostics T6985719f.java
+ */
+
+import java.util.List;
+
+class T6985719f {
+ abstract class A { abstract void f(List<String> ls); }
+ abstract class B extends A { void f(List<Integer> ls); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719f.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+T6985719f.java:13:39: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719f.B, f(java.util.List<java.lang.String>), T6985719f.A
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719g.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6985719
+ * @summary Alike methods in interfaces (Inheritance and Overriding)
+ * @author mcimadamore
+ * @compile/fail/ref=T6985719g.out -XDrawDiagnostics T6985719g.java
+ */
+
+import java.util.List;
+
+class T6985719g {
+ interface A<X> { void f(List<X> ls); }
+ interface B extends A<String> { void f(List<Integer> ls); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719g.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+T6985719g.java:13:42: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719g.B, f(java.util.List<X>), T6985719g.A
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719h.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,14 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6985719
+ * @summary Alike methods in interfaces (Inheritance and Overriding)
+ * @author mcimadamore
+ * @compile/fail/ref=T6985719h.out -XDrawDiagnostics T6985719h.java
+ */
+
+import java.util.List;
+
+class T6985719h {
+ abstract class A<X> { abstract void f(List<X> ls); }
+ abstract class B extends A<String> { abstract void f(List<Integer> ls); }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/6985719/T6985719h.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+T6985719h.java:13:56: compiler.err.name.clash.same.erasure.no.override: f(java.util.List<java.lang.Integer>), T6985719h.B, f(java.util.List<X>), T6985719h.A
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914a.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,171 @@
+/*
+ * Copyright (c) 2010, 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 6996914
+ * @summary Diamond inference: problem when accessing protected constructor
+ * @run main T6996914a
+ */
+
+import com.sun.source.util.JavacTask;
+import java.net.URI;
+import java.util.Arrays;
+import javax.tools.Diagnostic;
+import javax.tools.DiagnosticListener;
+import javax.tools.JavaCompiler;
+import javax.tools.JavaFileObject;
+import javax.tools.SimpleJavaFileObject;
+import javax.tools.ToolProvider;
+
+public class T6996914a {
+
+ enum PackageKind {
+ DEFAULT("", ""),
+ A("package a;", "import a.*;");
+
+ String pkgDecl;
+ String importDecl;
+
+ PackageKind(String pkgDecl, String importDecl) {
+ this.pkgDecl = pkgDecl;
+ this.importDecl = importDecl;
+ }
+ }
+
+ enum DiamondKind {
+ STANDARD("new Foo<>();"),
+ ANON("new Foo<>() {};");
+
+ String expr;
+
+ DiamondKind(String expr) {
+ this.expr = expr;
+ }
+ }
+
+ enum ConstructorKind {
+ PACKAGE(""),
+ PROTECTED("protected"),
+ PRIVATE("private"),
+ PUBLIC("public");
+
+ String mod;
+
+ ConstructorKind(String mod) {
+ this.mod = mod;
+ }
+ }
+
+ static class FooClass extends SimpleJavaFileObject {
+
+ final static String sourceStub =
+ "#P\n" +
+ "public class Foo<X> {\n" +
+ " #M Foo() {}\n" +
+ "}\n";
+
+ String source;
+
+ public FooClass(PackageKind pk, ConstructorKind ck) {
+ super(URI.create("myfo:/" + (pk != PackageKind.DEFAULT ? "a/Foo.java" : "Foo.java")),
+ JavaFileObject.Kind.SOURCE);
+ source = sourceStub.replace("#P", pk.pkgDecl).replace("#M", ck.mod);
+ }
+
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ return source;
+ }
+ }
+
+ static class ClientClass extends SimpleJavaFileObject {
+
+ final static String sourceStub =
+ "#I\n" +
+ "class Test {\n" +
+ " Foo<String> fs = #D\n" +
+ "}\n";
+
+ String source;
+
+ public ClientClass(PackageKind pk, DiamondKind dk) {
+ super(URI.create("myfo:/Test.java"), JavaFileObject.Kind.SOURCE);
+ source = sourceStub.replace("#I", pk.importDecl).replace("#D", dk.expr);
+ }
+
+ @Override
+ public CharSequence getCharContent(boolean ignoreEncodingErrors) {
+ return source;
+ }
+ }
+
+ public static void main(String... args) throws Exception {
+ for (PackageKind pk : PackageKind.values()) {
+ for (ConstructorKind ck : ConstructorKind.values()) {
+ for (DiamondKind dk : DiamondKind.values()) {
+ compileAndCheck(pk, ck, dk);
+ }
+ }
+ }
+ }
+
+ static void compileAndCheck(PackageKind pk, ConstructorKind ck, DiamondKind dk) throws Exception {
+ FooClass foo = new FooClass(pk, ck);
+ ClientClass client = new ClientClass(pk, dk);
+ final JavaCompiler tool = ToolProvider.getSystemJavaCompiler();
+ ErrorListener el = new ErrorListener();
+ JavacTask ct = (JavacTask)tool.getTask(null, null, el,
+ null, null, Arrays.asList(foo, client));
+ ct.analyze();
+ if (el.errors > 0 == check(pk, ck, dk)) {
+ String msg = el.errors > 0 ?
+ "Error compiling files" :
+ "No error when compiling files";
+ throw new AssertionError(msg + ": \n" + foo.source + "\n" + client.source);
+ }
+ }
+
+ static boolean check(PackageKind pk, ConstructorKind ck, DiamondKind dk) {
+ switch (pk) {
+ case A: return ck == ConstructorKind.PUBLIC ||
+ (ck == ConstructorKind.PROTECTED && dk == DiamondKind.ANON);
+ case DEFAULT: return ck != ConstructorKind.PRIVATE;
+ default: throw new AssertionError("Unknown package kind");
+ }
+ }
+
+ /**
+ * DiagnosticListener to count any errors that occur
+ */
+ private static class ErrorListener implements DiagnosticListener<JavaFileObject> {
+
+ public void report(Diagnostic<? extends JavaFileObject> diagnostic) {
+ switch (diagnostic.getKind()) {
+ case ERROR:
+ errors++;
+ }
+ }
+ int errors;
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/generics/diamond/6996914/T6996914b.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,39 @@
+/*
+ * Copyright (c) 2010, 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 6996914
+ * @summary Diamond inference: problem when accessing protected constructor
+ * @compile T6996914b.java
+ */
+
+class Super<X,Y> {
+ private Super(Integer i, Y y, X x) {}
+ public Super(Number n, X x, Y y) {}
+}
+
+class Test {
+ Super<String,Integer> ssi1 = new Super<>(1, "", 2);
+ Super<String,Integer> ssi2 = new Super<>(1, "", 2) {};
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/meth/XlintWarn.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,42 @@
+/*
+ * Copyright (c) 2008, 2010, 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 6999067
+ * @summary cast for invokeExact call gets redundant cast to <type> warnings
+ * @author mcimadamore
+ *
+ * @compile -Werror -Xlint:cast XlintWarn.java
+ */
+
+import java.dyn.*;
+
+class XlintWarn {
+ void test(MethodHandle mh) throws Throwable {
+ int i1 = (int)mh.invoke();
+ int i2 = (int)mh.invokeExact();
+ int i3 = (int)mh.invokeVarargs();
+ int i4 = (int)InvokeDynamic.test();
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Neg01eff_final.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,28 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6943289
+ *
+ * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch')
+ * @author darcy
+ * @compile/fail/ref=Neg01eff_final.out -XDrawDiagnostics Neg01eff_final.java
+ * @compile -source 6 -XDrawDiagnostics Neg01eff_final.java
+ *
+ */
+
+class Neg01eff_final {
+ static class A extends Exception {}
+ static class B1 extends A {}
+ static class B2 extends A {}
+
+ class Test {
+ void m() throws A {
+ try {
+ throw new B1();
+ } catch (A ex1) {
+ try {
+ throw ex1; // used to throw A, now throws B1!
+ } catch (B2 ex2) { }//unreachable
+ }
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Neg01eff_final.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+Neg01eff_final.java:24:19: compiler.err.except.never.thrown.in.try: Neg01eff_final.B2
+1 error
--- a/langtools/test/tools/javac/multicatch/Neg02.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/multicatch/Neg02.java Tue Nov 30 14:51:07 2010 -0800
@@ -20,6 +20,8 @@
else {
throw new B();
}
- } catch (A | B ex) { }
+ } catch (final A | B ex) {
+ ex = new B();
+ }
}
}
--- a/langtools/test/tools/javac/multicatch/Neg02.out Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/multicatch/Neg02.out Tue Nov 30 14:51:07 2010 -0800
@@ -1,2 +1,2 @@
-Neg02.java:23:24: compiler.err.multicatch.param.must.be.final: ex
+Neg02.java:24:13: compiler.err.multicatch.parameter.may.not.be.assigned: ex
1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Neg02eff_final.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6943289 6993963
+ *
+ * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch')
+ * @author mcimadamore
+ * @compile/fail/ref=Neg02eff_final.out -XDrawDiagnostics Neg02eff_final.java
+ *
+ */
+
+class Neg02eff_final {
+ static class A extends Exception {}
+ static class B extends Exception {}
+
+ void m() {
+ try {
+ if (true) {
+ throw new A();
+ }
+ else {
+ throw new B();
+ }
+ } catch (A | B ex) {
+ ex = new B();
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Neg02eff_final.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+Neg02eff_final.java:24:13: compiler.err.multicatch.parameter.may.not.be.assigned: ex
+1 error
--- a/langtools/test/tools/javac/multicatch/Neg03.java Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/multicatch/Neg03.java Tue Nov 30 14:51:07 2010 -0800
@@ -9,19 +9,22 @@
*/
class Neg03 {
- static class A extends Exception {}
- static class B extends Exception {}
- void m() {
+ static class A extends Exception { public void m() {}; public Object f;}
+ static class B1 extends A {}
+ static class B2 extends A {}
+
+ void m() throws B1, B2 {
try {
if (true) {
- throw new A();
+ throw new B1();
}
else {
- throw new B();
+ throw new B2();
}
- } catch (final A | B ex) {
- ex = new B();
+ } catch (Exception ex) {
+ ex = new B2(); //effectively final analysis disabled!
+ throw ex;
}
}
}
--- a/langtools/test/tools/javac/multicatch/Neg03.out Tue Nov 30 10:35:55 2010 +0300
+++ b/langtools/test/tools/javac/multicatch/Neg03.out Tue Nov 30 14:51:07 2010 -0800
@@ -1,2 +1,2 @@
-Neg03.java:24:13: compiler.err.multicatch.parameter.may.not.be.assigned: ex
+Neg03.java:27:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Neg04eff_final.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,31 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6943289
+ *
+ * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch')
+ * @author mcimadamore
+ * @compile/fail/ref=Neg04eff_final.out -XDrawDiagnostics Neg04eff_final.java
+ *
+ */
+
+class Neg04eff_final {
+ static class A extends Exception {}
+ static class B extends Exception {}
+
+ void test() throws B {
+ try {
+ if (true) {
+ throw new A();
+ } else if (false) {
+ throw new B();
+ } else {
+ throw (Throwable)new Exception();
+ }
+ }
+ catch (A e) {}
+ catch (Exception e) {
+ throw e;
+ }
+ catch (Throwable t) {}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Neg04eff_final.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+Neg04eff_final.java:27:13: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Exception
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Neg05.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,33 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6943289
+ *
+ * @summary Project Coin: Improved Exception Handling for Java (aka 'multicatch')
+ * @author mcimadamore
+ * @compile/fail/ref=Neg05.out -XDrawDiagnostics Neg05.java
+ *
+ */
+
+class Neg02 {
+
+ static class Foo<X> {
+ Foo(X x) {}
+ }
+
+ static interface Base<X> {}
+ static class A extends Exception implements Base<String> {}
+ static class B extends Exception implements Base<Integer> {}
+
+ void m() {
+ try {
+ if (true) {
+ throw new A();
+ }
+ else {
+ throw new B();
+ }
+ } catch (A | B ex) {
+ Foo<?> f = new Foo<>(ex);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Neg05.out Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,2 @@
+Neg05.java:30:31: compiler.err.cant.apply.diamond.1: (compiler.misc.diamond: Neg02.Foo), (compiler.misc.diamond.invalid.arg: java.lang.Exception&Neg02.Base<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<? extends java.lang.Object&java.io.Serializable&java.lang.Comparable<?>>>, (compiler.misc.diamond: Neg02.Foo))
+1 error
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Pos06.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,27 @@
+/*
+ * @test /nodynamiccopyright/
+ * @bug 6993963
+ *
+ * @summary Project Coin: Use precise exception analysis for effectively final catch parameters
+ * @author mcimadamore
+ * @compile Pos06.java
+ *
+ */
+
+class Pos06 {
+ static class A extends Exception {}
+ static class B extends Exception {}
+
+ void m() {
+ try {
+ if (true) {
+ throw new A();
+ }
+ else {
+ throw new B();
+ }
+ } catch (A | B ex) {
+ System.out.println(ex);
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Pos07.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,49 @@
+/*
+ * Copyright (c) 2010, 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 6993963
+ * @summary Project Coin: Use precise exception analysis for effectively final catch parameters
+ * @compile Pos07.java
+ */
+
+class Pos07 {
+
+ static class A extends Exception { public void m() {}; public Object f;}
+ static class B1 extends A {}
+ static class B2 extends A {}
+
+ void m() throws B1, B2 {
+ try {
+ if (true) {
+ throw new B1();
+ }
+ else {
+ throw new B2();
+ }
+ } catch (Exception ex) { //effectively final analysis
+ throw ex;
+ }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Pos08.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, 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 6993963
+ * @summary Multicatch: crash while compiling simple code with a multicatch parameter
+ * @compile Pos08.java
+ */
+
+class Pos08 {
+
+ interface Foo {}
+ static class X1 extends Exception implements Foo {}
+ static class X2 extends Exception implements Foo {}
+
+ void m(boolean cond) {
+ try {
+ if (cond)
+ throw new X1();
+ else
+ throw new X2();
+ }
+ catch (final X1 | X2 ex) {}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/Pos08eff_final.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,46 @@
+/*
+ * Copyright (c) 2010, 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 6993963
+ * @summary Multicatch: crash while compiling simple code with a multicatch parameter
+ * @compile Pos08eff_final.java
+ */
+
+class Pos08eff_final {
+
+ interface Foo {}
+ static class X1 extends Exception implements Foo {}
+ static class X2 extends Exception implements Foo {}
+
+ void m(boolean cond) {
+ try {
+ if (cond)
+ throw new X1();
+ else
+ throw new X2();
+ }
+ catch (X1 | X2 ex) {}
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/model/Check.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,27 @@
+/*
+ * Copyright (c) 2010, 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.
+ */
+
+/**
+ * Annotation used by ModelChecker to mark the class whose model is to be checked
+ */
+@interface Check {}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/model/Member.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,31 @@
+/*
+ * Copyright (c) 2010, 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.
+ */
+
+import javax.lang.model.element.ElementKind;
+
+/**
+ * Annotation used by ModelChecker to mark a member that is to be checked
+ */
+@interface Member {
+ ElementKind value();
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/model/Model01.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,48 @@
+/*
+ * Copyright (c) 2010, 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.
+ */
+
+import javax.lang.model.element.ElementKind;
+
+@Check
+class Test {
+
+ class A extends Exception {
+ @Member(ElementKind.METHOD)
+ public void m() {};
+ @Member(ElementKind.FIELD)
+ public Object f;
+ }
+
+ class B1 extends A {}
+ class B2 extends A {}
+
+ void test(){
+ try {
+ if (true)
+ throw new B1();
+ else
+ throw new B2();
+ }
+ catch(B1 | B2 ex) { }
+ }
+}
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/langtools/test/tools/javac/multicatch/model/ModelChecker.java Tue Nov 30 14:51:07 2010 -0800
@@ -0,0 +1,95 @@
+/*
+ * Copyright (c) 2010, 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 6993963
+ * @summary Project Coin: Use precise exception analysis for effectively final catch parameters
+ * @library ../../lib
+ * @build JavacTestingAbstractProcessor ModelChecker
+ * @compile -processor ModelChecker Model01.java
+ */
+
+import com.sun.source.tree.VariableTree;
+import com.sun.source.util.TreePathScanner;
+import com.sun.source.util.Trees;
+import com.sun.source.util.TreePath;
+
+import java.util.Set;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.ElementKind;
+import javax.lang.model.element.TypeElement;
+
+@SupportedAnnotationTypes("Check")
+public class ModelChecker extends JavacTestingAbstractProcessor {
+
+ @Override
+ public boolean process(Set<? extends TypeElement> annotations, RoundEnvironment roundEnv) {
+ if (roundEnv.processingOver())
+ return true;
+
+ Trees trees = Trees.instance(processingEnv);
+
+ TypeElement testAnno = elements.getTypeElement("Check");
+ for (Element elem: roundEnv.getElementsAnnotatedWith(testAnno)) {
+ TreePath p = trees.getPath(elem);
+ new MulticatchParamTester(trees).scan(p, null);
+ }
+ return true;
+ }
+
+ class MulticatchParamTester extends TreePathScanner<Void, Void> {
+ Trees trees;
+
+ public MulticatchParamTester(Trees trees) {
+ super();
+ this.trees = trees;
+ }
+
+ @Override
+ public Void visitVariable(VariableTree node, Void p) {
+ Element ex = trees.getElement(getCurrentPath());
+ if (ex.getSimpleName().contentEquals("ex")) {
+ assertTrue(ex.getKind() == ElementKind.EXCEPTION_PARAMETER, "Expected EXCEPTION_PARAMETER - found " + ex.getKind());
+ for (Element e : types.asElement(ex.asType()).getEnclosedElements()) {
+ Member m = e.getAnnotation(Member.class);
+ if (m != null) {
+ assertTrue(e.getKind() == m.value(), "Expected " + m.value() + " - found " + e.getKind());
+ }
+ }
+ assertTrue(assertionCount == 3, "Expected 3 assertions - found " + assertionCount);
+ }
+ return super.visitVariable(node, p);
+ }
+ }
+
+ private static void assertTrue(boolean cond, String msg) {
+ assertionCount++;
+ if (!cond)
+ throw new AssertionError(msg);
+ }
+
+ static int assertionCount = 0;
+}