# HG changeset patch # User lana # Date 1321643471 28800 # Node ID 41ce4af91010d259e95b5538ef25eb262bcf1234 # Parent d7f6c062c4549c9fa79cab5a983c11927ba03055# Parent 69c7122561ecf478f5fbf03e3ddfcff62f58c34a Merge diff -r d7f6c062c454 -r 41ce4af91010 .hgtags --- a/.hgtags Fri Nov 18 16:13:39 2011 +0800 +++ b/.hgtags Fri Nov 18 11:11:11 2011 -0800 @@ -133,3 +133,5 @@ fbf3cabc9e3bb1fcf710941d777cb0400505fbe6 jdk8-b09 f651ce87127980c58e3599daba964eba2f3b4026 jdk8-b10 cc1f5ce8e504d350e0b0c28c5f84333f8d540132 jdk8-b11 +86db042b3385c338e17f7664447fdc7d406dd19e jdk8-b12 +4cc0ef72c812943743ef4765f1100e2fbe2b1a08 jdk8-b13 diff -r d7f6c062c454 -r 41ce4af91010 .hgtags-top-repo --- a/.hgtags-top-repo Fri Nov 18 16:13:39 2011 +0800 +++ b/.hgtags-top-repo Fri Nov 18 11:11:11 2011 -0800 @@ -133,3 +133,5 @@ 8adb70647b5af5273dfe6a540f07be667cd50216 jdk8-b09 a6c4c248e8fa350c35014fa94bab5ac1a1ac3299 jdk8-b10 1defbc57940a56f0aa41e9dee87b71e8c8b71103 jdk8-b11 +8e2104d565baee473895d5eba20e39f85ab4bf9f jdk8-b12 +26fb81a1e9ceb9baffba216acd9ded62e9e9d5ab jdk8-b13 diff -r d7f6c062c454 -r 41ce4af91010 corba/.hgtags --- a/corba/.hgtags Fri Nov 18 16:13:39 2011 +0800 +++ b/corba/.hgtags Fri Nov 18 11:11:11 2011 -0800 @@ -133,3 +133,5 @@ a891732c1a83082177ff7a4cf1506068d9cc0a47 jdk8-b09 cda87f7fefcee3b89742a57ce5ad9b03a54c210d jdk8-b10 0199e4fef5cc2bd234c65b93220459ef7a3bb3b1 jdk8-b11 +31d70911b712c6b4e580a3110363d5f044cfed7a jdk8-b12 +5b9d9b839d3d7fe02347827221c97c6d242a6f96 jdk8-b13 diff -r d7f6c062c454 -r 41ce4af91010 corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java --- a/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java Fri Nov 18 16:13:39 2011 +0800 +++ b/corba/src/share/classes/com/sun/corba/se/impl/io/IIOPInputStream.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2243,6 +2243,10 @@ } try { + Class fieldCl = fields[i].getClazz(); + if (objectValue != null && !fieldCl.isInstance(objectValue)) { + throw new IllegalArgumentException(); + } bridge.putObject( o, fields[i].getFieldID(), objectValue ) ; // reflective code: fields[i].getField().set( o, objectValue ) ; } catch (IllegalArgumentException e) { @@ -2553,6 +2557,10 @@ { try { Field fld = c.getDeclaredField( fieldName ) ; + Class fieldCl = fld.getType(); + if(v != null && !fieldCl.isInstance(v)) { + throw new Exception(); + } long key = bridge.objectFieldOffset( fld ) ; bridge.putObject( o, key, v ) ; } catch (Exception e) { diff -r d7f6c062c454 -r 41ce4af91010 hotspot/.hgtags --- a/hotspot/.hgtags Fri Nov 18 16:13:39 2011 +0800 +++ b/hotspot/.hgtags Fri Nov 18 11:11:11 2011 -0800 @@ -195,3 +195,6 @@ 4d3850d9d326ac3a9bee2d867727e954322d014e hs23-b03 4538caeef7b6cbd4302bebced805d65e68ccf301 jdk8-b11 6534482ff68ad79066dfe15dfb6d8905f09681bd hs23-b04 +1d3900713a67a0a39faf4e12c9c158d55aebef87 jdk8-b12 +3e609627e780736f372eb14d29bb9b5e53b21fbf hs23-b05 +b92ca8e229d29004f840c67e620833d23a346761 jdk8-b13 diff -r d7f6c062c454 -r 41ce4af91010 hotspot/make/bsd/makefiles/buildtree.make --- a/hotspot/make/bsd/makefiles/buildtree.make Fri Nov 18 16:13:39 2011 +0800 +++ b/hotspot/make/bsd/makefiles/buildtree.make Fri Nov 18 11:11:11 2011 -0800 @@ -234,6 +234,8 @@ echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \ echo "$(call gamma-path,altsrc,share/vm) \\"; \ echo "$(call gamma-path,commonsrc,share/vm) \\"; \ + echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \ + echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \ echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \ echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \ echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ diff -r d7f6c062c454 -r 41ce4af91010 hotspot/make/bsd/makefiles/gcc.make --- a/hotspot/make/bsd/makefiles/gcc.make Fri Nov 18 16:13:39 2011 +0800 +++ b/hotspot/make/bsd/makefiles/gcc.make Fri Nov 18 11:11:11 2011 -0800 @@ -88,7 +88,7 @@ ifneq ($(USE_PRECOMPILED_HEADER),0) USE_PRECOMPILED_HEADER=1 PRECOMPILED_HEADER_DIR=. -PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp +PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch endif endif diff -r d7f6c062c454 -r 41ce4af91010 hotspot/make/hotspot_version --- a/hotspot/make/hotspot_version Fri Nov 18 16:13:39 2011 +0800 +++ b/hotspot/make/hotspot_version Fri Nov 18 11:11:11 2011 -0800 @@ -35,7 +35,7 @@ HS_MAJOR_VER=23 HS_MINOR_VER=0 -HS_BUILD_NUMBER=04 +HS_BUILD_NUMBER=05 JDK_MAJOR_VER=1 JDK_MINOR_VER=8 diff -r d7f6c062c454 -r 41ce4af91010 hotspot/make/linux/makefiles/buildtree.make --- a/hotspot/make/linux/makefiles/buildtree.make Fri Nov 18 16:13:39 2011 +0800 +++ b/hotspot/make/linux/makefiles/buildtree.make Fri Nov 18 11:11:11 2011 -0800 @@ -223,6 +223,8 @@ echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \ echo "$(call gamma-path,altsrc,share/vm) \\"; \ echo "$(call gamma-path,commonsrc,share/vm) \\"; \ + echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \ + echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \ echo "$(call gamma-path,altsrc,cpu/$(SRCARCH)/vm) \\"; \ echo "$(call gamma-path,commonsrc,cpu/$(SRCARCH)/vm) \\"; \ echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(SRCARCH)/vm) \\"; \ diff -r d7f6c062c454 -r 41ce4af91010 hotspot/make/linux/makefiles/gcc.make --- a/hotspot/make/linux/makefiles/gcc.make Fri Nov 18 16:13:39 2011 +0800 +++ b/hotspot/make/linux/makefiles/gcc.make Fri Nov 18 11:11:11 2011 -0800 @@ -52,7 +52,7 @@ ifneq ($(USE_PRECOMPILED_HEADER),0) USE_PRECOMPILED_HEADER=1 PRECOMPILED_HEADER_DIR=. -PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp +PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch endif endif diff -r d7f6c062c454 -r 41ce4af91010 hotspot/make/solaris/makefiles/buildtree.make --- a/hotspot/make/solaris/makefiles/buildtree.make Fri Nov 18 16:13:39 2011 +0800 +++ b/hotspot/make/solaris/makefiles/buildtree.make Fri Nov 18 11:11:11 2011 -0800 @@ -216,6 +216,8 @@ echo "$(call gamma-path,commonsrc,share/vm/prims) \\"; \ echo "$(call gamma-path,altsrc,share/vm) \\"; \ echo "$(call gamma-path,commonsrc,share/vm) \\"; \ + echo "$(call gamma-path,altsrc,share/vm/precompiled) \\"; \ + echo "$(call gamma-path,commonsrc,share/vm/precompiled) \\"; \ echo "$(call gamma-path,altsrc,cpu/$(ARCH)/vm) \\"; \ echo "$(call gamma-path,commonsrc,cpu/$(ARCH)/vm) \\"; \ echo "$(call gamma-path,altsrc,os_cpu/$(OS_FAMILY)_$(ARCH)/vm) \\"; \ diff -r d7f6c062c454 -r 41ce4af91010 hotspot/make/solaris/makefiles/gcc.make --- a/hotspot/make/solaris/makefiles/gcc.make Fri Nov 18 16:13:39 2011 +0800 +++ b/hotspot/make/solaris/makefiles/gcc.make Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 1998, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1998, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -51,7 +51,7 @@ ifneq ($(USE_PRECOMPILED_HEADER),0) USE_PRECOMPILED_HEADER=1 PRECOMPILED_HEADER_DIR=. -PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled.hpp +PRECOMPILED_HEADER_SRC=$(GAMMADIR)/src/share/vm/precompiled/precompiled.hpp PRECOMPILED_HEADER=$(PRECOMPILED_HEADER_DIR)/precompiled.hpp.gch endif endif diff -r d7f6c062c454 -r 41ce4af91010 hotspot/make/windows/makefiles/vm.make --- a/hotspot/make/windows/makefiles/vm.make Fri Nov 18 16:13:39 2011 +0800 +++ b/hotspot/make/windows/makefiles/vm.make Fri Nov 18 11:11:11 2011 -0800 @@ -134,6 +134,7 @@ CPP_INCLUDE_DIRS=$(CPP_INCLUDE_DIRS) \ /I "$(COMMONSRC)\share\vm" \ + /I "$(COMMONSRC)\share\vm\precompiled" \ /I "$(COMMONSRC)\share\vm\prims" \ /I "$(COMMONSRC)\os\windows\vm" \ /I "$(COMMONSRC)\os_cpu\windows_$(Platform_arch)\vm" \ diff -r d7f6c062c454 -r 41ce4af91010 hotspot/src/share/vm/precompiled.hpp --- a/hotspot/src/share/vm/precompiled.hpp Fri Nov 18 16:13:39 2011 +0800 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,330 +0,0 @@ -/* - * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - * - */ - -// Precompiled headers are turned off for Sun Studion, -// or if the user passes USE_PRECOMPILED_HEADER=0 to the makefiles. -#ifndef DONT_USE_PRECOMPILED_HEADER - -# include "asm/assembler.hpp" -# include "asm/assembler.inline.hpp" -# include "asm/codeBuffer.hpp" -# include "asm/register.hpp" -# include "ci/ciArray.hpp" -# include "ci/ciArrayKlass.hpp" -# include "ci/ciClassList.hpp" -# include "ci/ciConstant.hpp" -# include "ci/ciConstantPoolCache.hpp" -# include "ci/ciEnv.hpp" -# include "ci/ciExceptionHandler.hpp" -# include "ci/ciField.hpp" -# include "ci/ciFlags.hpp" -# include "ci/ciInstance.hpp" -# include "ci/ciInstanceKlass.hpp" -# include "ci/ciInstanceKlassKlass.hpp" -# include "ci/ciKlass.hpp" -# include "ci/ciKlassKlass.hpp" -# include "ci/ciMethod.hpp" -# include "ci/ciNullObject.hpp" -# include "ci/ciObjArrayKlass.hpp" -# include "ci/ciObject.hpp" -# include "ci/ciObjectFactory.hpp" -# include "ci/ciSignature.hpp" -# include "ci/ciStreams.hpp" -# include "ci/ciSymbol.hpp" -# include "ci/ciType.hpp" -# include "ci/ciTypeArrayKlass.hpp" -# include "ci/ciUtilities.hpp" -# include "ci/compilerInterface.hpp" -# include "classfile/classFileParser.hpp" -# include "classfile/classFileStream.hpp" -# include "classfile/classLoader.hpp" -# include "classfile/javaClasses.hpp" -# include "classfile/symbolTable.hpp" -# include "classfile/systemDictionary.hpp" -# include "classfile/vmSymbols.hpp" -# include "code/codeBlob.hpp" -# include "code/codeCache.hpp" -# include "code/compressedStream.hpp" -# include "code/debugInfo.hpp" -# include "code/debugInfoRec.hpp" -# include "code/dependencies.hpp" -# include "code/exceptionHandlerTable.hpp" -# include "code/jvmticmlr.h" -# include "code/location.hpp" -# include "code/nmethod.hpp" -# include "code/oopRecorder.hpp" -# include "code/pcDesc.hpp" -# include "code/relocInfo.hpp" -# include "code/stubs.hpp" -# include "code/vmreg.hpp" -# include "compiler/disassembler.hpp" -# include "compiler/methodLiveness.hpp" -# include "compiler/oopMap.hpp" -# include "gc_implementation/shared/adaptiveSizePolicy.hpp" -# include "gc_implementation/shared/ageTable.hpp" -# include "gc_implementation/shared/allocationStats.hpp" -# include "gc_implementation/shared/cSpaceCounters.hpp" -# include "gc_implementation/shared/collectorCounters.hpp" -# include "gc_implementation/shared/gSpaceCounters.hpp" -# include "gc_implementation/shared/gcStats.hpp" -# include "gc_implementation/shared/gcUtil.hpp" -# include "gc_implementation/shared/generationCounters.hpp" -# include "gc_implementation/shared/immutableSpace.hpp" -# include "gc_implementation/shared/markSweep.hpp" -# include "gc_implementation/shared/markSweep.inline.hpp" -# include "gc_implementation/shared/mutableSpace.hpp" -# include "gc_implementation/shared/spaceCounters.hpp" -# include "gc_implementation/shared/spaceDecorator.hpp" -# include "gc_interface/collectedHeap.hpp" -# include "gc_interface/collectedHeap.inline.hpp" -# include "gc_interface/gcCause.hpp" -# include "interpreter/abstractInterpreter.hpp" -# include "interpreter/bytecode.hpp" -# include "interpreter/bytecodeHistogram.hpp" -# include "interpreter/bytecodeInterpreter.hpp" -# include "interpreter/bytecodeInterpreter.inline.hpp" -# include "interpreter/bytecodeTracer.hpp" -# include "interpreter/bytecodes.hpp" -# include "interpreter/cppInterpreter.hpp" -# include "interpreter/interpreter.hpp" -# include "interpreter/invocationCounter.hpp" -# include "interpreter/linkResolver.hpp" -# include "interpreter/templateInterpreter.hpp" -# include "interpreter/templateTable.hpp" -# include "jvmtifiles/jvmti.h" -# include "memory/allocation.hpp" -# include "memory/allocation.inline.hpp" -# include "memory/barrierSet.hpp" -# include "memory/barrierSet.inline.hpp" -# include "memory/blockOffsetTable.hpp" -# include "memory/blockOffsetTable.inline.hpp" -# include "memory/cardTableModRefBS.hpp" -# include "memory/collectorPolicy.hpp" -# include "memory/compactingPermGenGen.hpp" -# include "memory/defNewGeneration.hpp" -# include "memory/gcLocker.hpp" -# include "memory/genCollectedHeap.hpp" -# include "memory/genOopClosures.hpp" -# include "memory/genRemSet.hpp" -# include "memory/generation.hpp" -# include "memory/generation.inline.hpp" -# include "memory/heap.hpp" -# include "memory/iterator.hpp" -# include "memory/memRegion.hpp" -# include "memory/modRefBarrierSet.hpp" -# include "memory/oopFactory.hpp" -# include "memory/permGen.hpp" -# include "memory/referencePolicy.hpp" -# include "memory/referenceProcessor.hpp" -# include "memory/resourceArea.hpp" -# include "memory/sharedHeap.hpp" -# include "memory/space.hpp" -# include "memory/space.inline.hpp" -# include "memory/specialized_oop_closures.hpp" -# include "memory/threadLocalAllocBuffer.hpp" -# include "memory/threadLocalAllocBuffer.inline.hpp" -# include "memory/universe.hpp" -# include "memory/universe.inline.hpp" -# include "memory/watermark.hpp" -# include "oops/arrayKlass.hpp" -# include "oops/arrayOop.hpp" -# include "oops/constMethodOop.hpp" -# include "oops/constantPoolOop.hpp" -# include "oops/cpCacheOop.hpp" -# include "oops/instanceKlass.hpp" -# include "oops/instanceOop.hpp" -# include "oops/instanceRefKlass.hpp" -# include "oops/klass.hpp" -# include "oops/klassOop.hpp" -# include "oops/klassPS.hpp" -# include "oops/klassVtable.hpp" -# include "oops/markOop.hpp" -# include "oops/markOop.inline.hpp" -# include "oops/methodDataOop.hpp" -# include "oops/methodOop.hpp" -# include "oops/objArrayKlass.hpp" -# include "oops/objArrayOop.hpp" -# include "oops/oop.hpp" -# include "oops/oop.inline.hpp" -# include "oops/oop.inline2.hpp" -# include "oops/oopsHierarchy.hpp" -# include "oops/symbol.hpp" -# include "oops/typeArrayKlass.hpp" -# include "oops/typeArrayOop.hpp" -# include "prims/jni.h" -# include "prims/jvm.h" -# include "prims/jvmtiExport.hpp" -# include "prims/methodHandles.hpp" -# include "runtime/arguments.hpp" -# include "runtime/atomic.hpp" -# include "runtime/deoptimization.hpp" -# include "runtime/extendedPC.hpp" -# include "runtime/fieldDescriptor.hpp" -# include "runtime/fieldType.hpp" -# include "runtime/frame.hpp" -# include "runtime/frame.inline.hpp" -# include "runtime/globals.hpp" -# include "runtime/globals_extension.hpp" -# include "runtime/handles.hpp" -# include "runtime/handles.inline.hpp" -# include "runtime/icache.hpp" -# include "runtime/init.hpp" -# include "runtime/interfaceSupport.hpp" -# include "runtime/java.hpp" -# include "runtime/javaCalls.hpp" -# include "runtime/javaFrameAnchor.hpp" -# include "runtime/jniHandles.hpp" -# include "runtime/monitorChunk.hpp" -# include "runtime/mutex.hpp" -# include "runtime/mutexLocker.hpp" -# include "runtime/objectMonitor.hpp" -# include "runtime/orderAccess.hpp" -# include "runtime/os.hpp" -# include "runtime/osThread.hpp" -# include "runtime/perfData.hpp" -# include "runtime/perfMemory.hpp" -# include "runtime/prefetch.hpp" -# include "runtime/reflection.hpp" -# include "runtime/reflectionUtils.hpp" -# include "runtime/registerMap.hpp" -# include "runtime/safepoint.hpp" -# include "runtime/sharedRuntime.hpp" -# include "runtime/signature.hpp" -# include "runtime/stackValue.hpp" -# include "runtime/stackValueCollection.hpp" -# include "runtime/stubCodeGenerator.hpp" -# include "runtime/stubRoutines.hpp" -# include "runtime/synchronizer.hpp" -# include "runtime/thread.hpp" -# include "runtime/threadLocalStorage.hpp" -# include "runtime/timer.hpp" -# include "runtime/unhandledOops.hpp" -# include "runtime/vframe.hpp" -# include "runtime/virtualspace.hpp" -# include "runtime/vmThread.hpp" -# include "runtime/vm_operations.hpp" -# include "runtime/vm_version.hpp" -# include "services/lowMemoryDetector.hpp" -# include "services/memoryPool.hpp" -# include "services/memoryService.hpp" -# include "services/memoryUsage.hpp" -# include "utilities/accessFlags.hpp" -# include "utilities/array.hpp" -# include "utilities/bitMap.hpp" -# include "utilities/bitMap.inline.hpp" -# include "utilities/constantTag.hpp" -# include "utilities/copy.hpp" -# include "utilities/debug.hpp" -# include "utilities/exceptions.hpp" -# include "utilities/globalDefinitions.hpp" -# include "utilities/growableArray.hpp" -# include "utilities/hashtable.hpp" -# include "utilities/histogram.hpp" -# include "utilities/macros.hpp" -# include "utilities/numberSeq.hpp" -# include "utilities/ostream.hpp" -# include "utilities/preserveException.hpp" -# include "utilities/sizes.hpp" -# include "utilities/taskqueue.hpp" -# include "utilities/top.hpp" -# include "utilities/utf8.hpp" -# include "utilities/workgroup.hpp" -# include "utilities/yieldingWorkgroup.hpp" -#ifdef COMPILER2 -# include "libadt/dict.hpp" -# include "libadt/port.hpp" -# include "libadt/set.hpp" -# include "libadt/vectset.hpp" -# include "opto/addnode.hpp" -# include "opto/adlcVMDeps.hpp" -# include "opto/block.hpp" -# include "opto/c2_globals.hpp" -# include "opto/callnode.hpp" -# include "opto/cfgnode.hpp" -# include "opto/compile.hpp" -# include "opto/connode.hpp" -# include "opto/idealGraphPrinter.hpp" -# include "opto/loopnode.hpp" -# include "opto/machnode.hpp" -# include "opto/matcher.hpp" -# include "opto/memnode.hpp" -# include "opto/mulnode.hpp" -# include "opto/multnode.hpp" -# include "opto/node.hpp" -# include "opto/opcodes.hpp" -# include "opto/optoreg.hpp" -# include "opto/phase.hpp" -# include "opto/phaseX.hpp" -# include "opto/regalloc.hpp" -# include "opto/regmask.hpp" -# include "opto/runtime.hpp" -# include "opto/subnode.hpp" -# include "opto/type.hpp" -# include "opto/vectornode.hpp" -#endif // COMPILER2 -#ifdef COMPILER1 -# include "c1/c1_Compilation.hpp" -# include "c1/c1_Defs.hpp" -# include "c1/c1_FrameMap.hpp" -# include "c1/c1_LIR.hpp" -# include "c1/c1_MacroAssembler.hpp" -# include "c1/c1_ValueType.hpp" -# include "c1/c1_globals.hpp" -#endif // COMPILER1 -#ifndef SERIALGC -# include "gc_implementation/concurrentMarkSweep/binaryTreeDictionary.hpp" -# include "gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp" -# include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp" -# include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp" -# include "gc_implementation/concurrentMarkSweep/freeBlockDictionary.hpp" -# include "gc_implementation/concurrentMarkSweep/freeChunk.hpp" -# include "gc_implementation/concurrentMarkSweep/freeList.hpp" -# include "gc_implementation/concurrentMarkSweep/promotionInfo.hpp" -# include "gc_implementation/g1/dirtyCardQueue.hpp" -# include "gc_implementation/g1/g1BlockOffsetTable.hpp" -# include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" -# include "gc_implementation/g1/g1OopClosures.hpp" -# include "gc_implementation/g1/g1_globals.hpp" -# include "gc_implementation/g1/g1_specialized_oop_closures.hpp" -# include "gc_implementation/g1/ptrQueue.hpp" -# include "gc_implementation/g1/satbQueue.hpp" -# include "gc_implementation/parNew/parGCAllocBuffer.hpp" -# include "gc_implementation/parNew/parOopClosures.hpp" -# include "gc_implementation/parallelScavenge/objectStartArray.hpp" -# include "gc_implementation/parallelScavenge/parMarkBitMap.hpp" -# include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" -# include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp" -# include "gc_implementation/parallelScavenge/psCompactionManager.hpp" -# include "gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp" -# include "gc_implementation/parallelScavenge/psGenerationCounters.hpp" -# include "gc_implementation/parallelScavenge/psOldGen.hpp" -# include "gc_implementation/parallelScavenge/psParallelCompact.hpp" -# include "gc_implementation/parallelScavenge/psPermGen.hpp" -# include "gc_implementation/parallelScavenge/psVirtualspace.hpp" -# include "gc_implementation/parallelScavenge/psYoungGen.hpp" -# include "gc_implementation/shared/gcAdaptivePolicyCounters.hpp" -# include "gc_implementation/shared/gcPolicyCounters.hpp" -#endif // SERIALGC - -#endif // !DONT_USE_PRECOMPILED_HEADER diff -r d7f6c062c454 -r 41ce4af91010 hotspot/src/share/vm/precompiled/precompiled.hpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/hotspot/src/share/vm/precompiled/precompiled.hpp Fri Nov 18 11:11:11 2011 -0800 @@ -0,0 +1,330 @@ +/* + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +// Precompiled headers are turned off for Sun Studion, +// or if the user passes USE_PRECOMPILED_HEADER=0 to the makefiles. +#ifndef DONT_USE_PRECOMPILED_HEADER + +# include "asm/assembler.hpp" +# include "asm/assembler.inline.hpp" +# include "asm/codeBuffer.hpp" +# include "asm/register.hpp" +# include "ci/ciArray.hpp" +# include "ci/ciArrayKlass.hpp" +# include "ci/ciClassList.hpp" +# include "ci/ciConstant.hpp" +# include "ci/ciConstantPoolCache.hpp" +# include "ci/ciEnv.hpp" +# include "ci/ciExceptionHandler.hpp" +# include "ci/ciField.hpp" +# include "ci/ciFlags.hpp" +# include "ci/ciInstance.hpp" +# include "ci/ciInstanceKlass.hpp" +# include "ci/ciInstanceKlassKlass.hpp" +# include "ci/ciKlass.hpp" +# include "ci/ciKlassKlass.hpp" +# include "ci/ciMethod.hpp" +# include "ci/ciNullObject.hpp" +# include "ci/ciObjArrayKlass.hpp" +# include "ci/ciObject.hpp" +# include "ci/ciObjectFactory.hpp" +# include "ci/ciSignature.hpp" +# include "ci/ciStreams.hpp" +# include "ci/ciSymbol.hpp" +# include "ci/ciType.hpp" +# include "ci/ciTypeArrayKlass.hpp" +# include "ci/ciUtilities.hpp" +# include "ci/compilerInterface.hpp" +# include "classfile/classFileParser.hpp" +# include "classfile/classFileStream.hpp" +# include "classfile/classLoader.hpp" +# include "classfile/javaClasses.hpp" +# include "classfile/symbolTable.hpp" +# include "classfile/systemDictionary.hpp" +# include "classfile/vmSymbols.hpp" +# include "code/codeBlob.hpp" +# include "code/codeCache.hpp" +# include "code/compressedStream.hpp" +# include "code/debugInfo.hpp" +# include "code/debugInfoRec.hpp" +# include "code/dependencies.hpp" +# include "code/exceptionHandlerTable.hpp" +# include "code/jvmticmlr.h" +# include "code/location.hpp" +# include "code/nmethod.hpp" +# include "code/oopRecorder.hpp" +# include "code/pcDesc.hpp" +# include "code/relocInfo.hpp" +# include "code/stubs.hpp" +# include "code/vmreg.hpp" +# include "compiler/disassembler.hpp" +# include "compiler/methodLiveness.hpp" +# include "compiler/oopMap.hpp" +# include "gc_implementation/shared/adaptiveSizePolicy.hpp" +# include "gc_implementation/shared/ageTable.hpp" +# include "gc_implementation/shared/allocationStats.hpp" +# include "gc_implementation/shared/cSpaceCounters.hpp" +# include "gc_implementation/shared/collectorCounters.hpp" +# include "gc_implementation/shared/gSpaceCounters.hpp" +# include "gc_implementation/shared/gcStats.hpp" +# include "gc_implementation/shared/gcUtil.hpp" +# include "gc_implementation/shared/generationCounters.hpp" +# include "gc_implementation/shared/immutableSpace.hpp" +# include "gc_implementation/shared/markSweep.hpp" +# include "gc_implementation/shared/markSweep.inline.hpp" +# include "gc_implementation/shared/mutableSpace.hpp" +# include "gc_implementation/shared/spaceCounters.hpp" +# include "gc_implementation/shared/spaceDecorator.hpp" +# include "gc_interface/collectedHeap.hpp" +# include "gc_interface/collectedHeap.inline.hpp" +# include "gc_interface/gcCause.hpp" +# include "interpreter/abstractInterpreter.hpp" +# include "interpreter/bytecode.hpp" +# include "interpreter/bytecodeHistogram.hpp" +# include "interpreter/bytecodeInterpreter.hpp" +# include "interpreter/bytecodeInterpreter.inline.hpp" +# include "interpreter/bytecodeTracer.hpp" +# include "interpreter/bytecodes.hpp" +# include "interpreter/cppInterpreter.hpp" +# include "interpreter/interpreter.hpp" +# include "interpreter/invocationCounter.hpp" +# include "interpreter/linkResolver.hpp" +# include "interpreter/templateInterpreter.hpp" +# include "interpreter/templateTable.hpp" +# include "jvmtifiles/jvmti.h" +# include "memory/allocation.hpp" +# include "memory/allocation.inline.hpp" +# include "memory/barrierSet.hpp" +# include "memory/barrierSet.inline.hpp" +# include "memory/blockOffsetTable.hpp" +# include "memory/blockOffsetTable.inline.hpp" +# include "memory/cardTableModRefBS.hpp" +# include "memory/collectorPolicy.hpp" +# include "memory/compactingPermGenGen.hpp" +# include "memory/defNewGeneration.hpp" +# include "memory/gcLocker.hpp" +# include "memory/genCollectedHeap.hpp" +# include "memory/genOopClosures.hpp" +# include "memory/genRemSet.hpp" +# include "memory/generation.hpp" +# include "memory/generation.inline.hpp" +# include "memory/heap.hpp" +# include "memory/iterator.hpp" +# include "memory/memRegion.hpp" +# include "memory/modRefBarrierSet.hpp" +# include "memory/oopFactory.hpp" +# include "memory/permGen.hpp" +# include "memory/referencePolicy.hpp" +# include "memory/referenceProcessor.hpp" +# include "memory/resourceArea.hpp" +# include "memory/sharedHeap.hpp" +# include "memory/space.hpp" +# include "memory/space.inline.hpp" +# include "memory/specialized_oop_closures.hpp" +# include "memory/threadLocalAllocBuffer.hpp" +# include "memory/threadLocalAllocBuffer.inline.hpp" +# include "memory/universe.hpp" +# include "memory/universe.inline.hpp" +# include "memory/watermark.hpp" +# include "oops/arrayKlass.hpp" +# include "oops/arrayOop.hpp" +# include "oops/constMethodOop.hpp" +# include "oops/constantPoolOop.hpp" +# include "oops/cpCacheOop.hpp" +# include "oops/instanceKlass.hpp" +# include "oops/instanceOop.hpp" +# include "oops/instanceRefKlass.hpp" +# include "oops/klass.hpp" +# include "oops/klassOop.hpp" +# include "oops/klassPS.hpp" +# include "oops/klassVtable.hpp" +# include "oops/markOop.hpp" +# include "oops/markOop.inline.hpp" +# include "oops/methodDataOop.hpp" +# include "oops/methodOop.hpp" +# include "oops/objArrayKlass.hpp" +# include "oops/objArrayOop.hpp" +# include "oops/oop.hpp" +# include "oops/oop.inline.hpp" +# include "oops/oop.inline2.hpp" +# include "oops/oopsHierarchy.hpp" +# include "oops/symbol.hpp" +# include "oops/typeArrayKlass.hpp" +# include "oops/typeArrayOop.hpp" +# include "prims/jni.h" +# include "prims/jvm.h" +# include "prims/jvmtiExport.hpp" +# include "prims/methodHandles.hpp" +# include "runtime/arguments.hpp" +# include "runtime/atomic.hpp" +# include "runtime/deoptimization.hpp" +# include "runtime/extendedPC.hpp" +# include "runtime/fieldDescriptor.hpp" +# include "runtime/fieldType.hpp" +# include "runtime/frame.hpp" +# include "runtime/frame.inline.hpp" +# include "runtime/globals.hpp" +# include "runtime/globals_extension.hpp" +# include "runtime/handles.hpp" +# include "runtime/handles.inline.hpp" +# include "runtime/icache.hpp" +# include "runtime/init.hpp" +# include "runtime/interfaceSupport.hpp" +# include "runtime/java.hpp" +# include "runtime/javaCalls.hpp" +# include "runtime/javaFrameAnchor.hpp" +# include "runtime/jniHandles.hpp" +# include "runtime/monitorChunk.hpp" +# include "runtime/mutex.hpp" +# include "runtime/mutexLocker.hpp" +# include "runtime/objectMonitor.hpp" +# include "runtime/orderAccess.hpp" +# include "runtime/os.hpp" +# include "runtime/osThread.hpp" +# include "runtime/perfData.hpp" +# include "runtime/perfMemory.hpp" +# include "runtime/prefetch.hpp" +# include "runtime/reflection.hpp" +# include "runtime/reflectionUtils.hpp" +# include "runtime/registerMap.hpp" +# include "runtime/safepoint.hpp" +# include "runtime/sharedRuntime.hpp" +# include "runtime/signature.hpp" +# include "runtime/stackValue.hpp" +# include "runtime/stackValueCollection.hpp" +# include "runtime/stubCodeGenerator.hpp" +# include "runtime/stubRoutines.hpp" +# include "runtime/synchronizer.hpp" +# include "runtime/thread.hpp" +# include "runtime/threadLocalStorage.hpp" +# include "runtime/timer.hpp" +# include "runtime/unhandledOops.hpp" +# include "runtime/vframe.hpp" +# include "runtime/virtualspace.hpp" +# include "runtime/vmThread.hpp" +# include "runtime/vm_operations.hpp" +# include "runtime/vm_version.hpp" +# include "services/lowMemoryDetector.hpp" +# include "services/memoryPool.hpp" +# include "services/memoryService.hpp" +# include "services/memoryUsage.hpp" +# include "utilities/accessFlags.hpp" +# include "utilities/array.hpp" +# include "utilities/bitMap.hpp" +# include "utilities/bitMap.inline.hpp" +# include "utilities/constantTag.hpp" +# include "utilities/copy.hpp" +# include "utilities/debug.hpp" +# include "utilities/exceptions.hpp" +# include "utilities/globalDefinitions.hpp" +# include "utilities/growableArray.hpp" +# include "utilities/hashtable.hpp" +# include "utilities/histogram.hpp" +# include "utilities/macros.hpp" +# include "utilities/numberSeq.hpp" +# include "utilities/ostream.hpp" +# include "utilities/preserveException.hpp" +# include "utilities/sizes.hpp" +# include "utilities/taskqueue.hpp" +# include "utilities/top.hpp" +# include "utilities/utf8.hpp" +# include "utilities/workgroup.hpp" +# include "utilities/yieldingWorkgroup.hpp" +#ifdef COMPILER2 +# include "libadt/dict.hpp" +# include "libadt/port.hpp" +# include "libadt/set.hpp" +# include "libadt/vectset.hpp" +# include "opto/addnode.hpp" +# include "opto/adlcVMDeps.hpp" +# include "opto/block.hpp" +# include "opto/c2_globals.hpp" +# include "opto/callnode.hpp" +# include "opto/cfgnode.hpp" +# include "opto/compile.hpp" +# include "opto/connode.hpp" +# include "opto/idealGraphPrinter.hpp" +# include "opto/loopnode.hpp" +# include "opto/machnode.hpp" +# include "opto/matcher.hpp" +# include "opto/memnode.hpp" +# include "opto/mulnode.hpp" +# include "opto/multnode.hpp" +# include "opto/node.hpp" +# include "opto/opcodes.hpp" +# include "opto/optoreg.hpp" +# include "opto/phase.hpp" +# include "opto/phaseX.hpp" +# include "opto/regalloc.hpp" +# include "opto/regmask.hpp" +# include "opto/runtime.hpp" +# include "opto/subnode.hpp" +# include "opto/type.hpp" +# include "opto/vectornode.hpp" +#endif // COMPILER2 +#ifdef COMPILER1 +# include "c1/c1_Compilation.hpp" +# include "c1/c1_Defs.hpp" +# include "c1/c1_FrameMap.hpp" +# include "c1/c1_LIR.hpp" +# include "c1/c1_MacroAssembler.hpp" +# include "c1/c1_ValueType.hpp" +# include "c1/c1_globals.hpp" +#endif // COMPILER1 +#ifndef SERIALGC +# include "gc_implementation/concurrentMarkSweep/binaryTreeDictionary.hpp" +# include "gc_implementation/concurrentMarkSweep/cmsOopClosures.hpp" +# include "gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.hpp" +# include "gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp" +# include "gc_implementation/concurrentMarkSweep/freeBlockDictionary.hpp" +# include "gc_implementation/concurrentMarkSweep/freeChunk.hpp" +# include "gc_implementation/concurrentMarkSweep/freeList.hpp" +# include "gc_implementation/concurrentMarkSweep/promotionInfo.hpp" +# include "gc_implementation/g1/dirtyCardQueue.hpp" +# include "gc_implementation/g1/g1BlockOffsetTable.hpp" +# include "gc_implementation/g1/g1BlockOffsetTable.inline.hpp" +# include "gc_implementation/g1/g1OopClosures.hpp" +# include "gc_implementation/g1/g1_globals.hpp" +# include "gc_implementation/g1/g1_specialized_oop_closures.hpp" +# include "gc_implementation/g1/ptrQueue.hpp" +# include "gc_implementation/g1/satbQueue.hpp" +# include "gc_implementation/parNew/parGCAllocBuffer.hpp" +# include "gc_implementation/parNew/parOopClosures.hpp" +# include "gc_implementation/parallelScavenge/objectStartArray.hpp" +# include "gc_implementation/parallelScavenge/parMarkBitMap.hpp" +# include "gc_implementation/parallelScavenge/parallelScavengeHeap.hpp" +# include "gc_implementation/parallelScavenge/psAdaptiveSizePolicy.hpp" +# include "gc_implementation/parallelScavenge/psCompactionManager.hpp" +# include "gc_implementation/parallelScavenge/psGCAdaptivePolicyCounters.hpp" +# include "gc_implementation/parallelScavenge/psGenerationCounters.hpp" +# include "gc_implementation/parallelScavenge/psOldGen.hpp" +# include "gc_implementation/parallelScavenge/psParallelCompact.hpp" +# include "gc_implementation/parallelScavenge/psPermGen.hpp" +# include "gc_implementation/parallelScavenge/psVirtualspace.hpp" +# include "gc_implementation/parallelScavenge/psYoungGen.hpp" +# include "gc_implementation/shared/gcAdaptivePolicyCounters.hpp" +# include "gc_implementation/shared/gcPolicyCounters.hpp" +#endif // SERIALGC + +#endif // !DONT_USE_PRECOMPILED_HEADER diff -r d7f6c062c454 -r 41ce4af91010 hotspot/src/share/vm/runtime/globals.hpp --- a/hotspot/src/share/vm/runtime/globals.hpp Fri Nov 18 16:13:39 2011 +0800 +++ b/hotspot/src/share/vm/runtime/globals.hpp Fri Nov 18 11:11:11 2011 -0800 @@ -2580,7 +2580,7 @@ diagnostic(bool, DebugInlinedCalls, true, \ "If false, restricts profiled locations to the root method only") \ \ - product(bool, PrintVMOptions, trueInDebug, \ + product(bool, PrintVMOptions, NOT_EMBEDDED(trueInDebug) EMBEDDED_ONLY(false),\ "Print flags that appeared on the command line") \ \ product(bool, IgnoreUnrecognizedVMOptions, false, \ diff -r d7f6c062c454 -r 41ce4af91010 jaxp/.hgtags --- a/jaxp/.hgtags Fri Nov 18 16:13:39 2011 +0800 +++ b/jaxp/.hgtags Fri Nov 18 11:11:11 2011 -0800 @@ -133,3 +133,5 @@ 93554324c014282571aeeb48552ad00d3fedb089 jdk8-b09 d21a4d5141c04bc9e88f2c0253121d449b66d667 jdk8-b10 d1b7a4f6dd2065fdeafbcdfd9dcc0072da8c6881 jdk8-b11 +ca977d167697a561c04894187fc1c4d927582ffa jdk8-b12 +bcc739229f6384786c7ac0b52c1822c85674dcf1 jdk8-b13 diff -r d7f6c062c454 -r 41ce4af91010 jaxws/.hgtags --- a/jaxws/.hgtags Fri Nov 18 16:13:39 2011 +0800 +++ b/jaxws/.hgtags Fri Nov 18 11:11:11 2011 -0800 @@ -133,3 +133,5 @@ 70172e57cf29efe271b068987eefb601c2a77780 jdk8-b09 8e7fdc8e3c758644ca6d0fd70bb255e9d2e64cda jdk8-b10 a12ab897a249feb7859a6e6cd84b49411f4c06ac jdk8-b11 +e6eed2ff5d5f62bdc815beb5276d23347600c760 jdk8-b12 +adf2a6b5fde14090beb9ebc40c4114132ddee731 jdk8-b13 diff -r d7f6c062c454 -r 41ce4af91010 jaxws/jaxws.properties --- a/jaxws/jaxws.properties Fri Nov 18 16:13:39 2011 +0800 +++ b/jaxws/jaxws.properties Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2010, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -25,15 +25,15 @@ drops.master.copy.base=${drops.dir} -jaxws_src.bundle.name=jdk7-jaxws2_2_4-b03-2011_05_27.zip -jaxws_src.bundle.md5.checksum=2f5b829ade70f67fe272d0b322e3e702 +jaxws_src.bundle.name=jdk8-jaxws2_2_4-b01-2011_07_22.zip +jaxws_src.bundle.md5.checksum=f64bedd3c512e6b1ca265fda2feb0905 jaxws_src.master.bundle.dir=${drops.master.copy.base} -jaxws_src.master.bundle.url.base=http://download.java.net/glassfish/components/jax-ws/openjdk/jdk7 +jaxws_src.master.bundle.url.base=http://download.java.net/glassfish/components/jax-ws/openjdk/jdk8 -jaf_src.bundle.name=jdk7-jaf-2010_08_19.zip +jaf_src.bundle.name=jdk8-jaf-2011_07_22.zip jaf_src.bundle.md5.checksum=18d15dfd71117daadb332af003d08212 jaf_src.master.bundle.dir=${drops.master.copy.base} -jaf_src.master.bundle.url.base=https://java.net/downloads/jax-ws/JDK7 +jaf_src.master.bundle.url.base=http://download.java.net/glassfish/components/jax-ws/openjdk/jdk8 #jaxws_tests.bundle.name=jdk7-jaxws-tests-2009_08_28.zip #jaxws_tests.master.bundle.dir=${drops.master.copy.base} diff -r d7f6c062c454 -r 41ce4af91010 jdk/.hgtags --- a/jdk/.hgtags Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/.hgtags Fri Nov 18 11:11:11 2011 -0800 @@ -134,3 +134,5 @@ 4788745572ef2bde34924ef34e7e4d55ba07e979 jdk8-b10 7ab0d613cd1a271a9763ffb894dc1f0a5b95a7e4 jdk8-b11 09fd2067f715e4505c44b01c301258a4e8f8964e jdk8-b12 +4cb2e8679b27432854690cb688ea06d3b2d8e008 jdk8-b13 +99632935785e2038b2fc836da9f2ede69dea294b jdk8-b14 diff -r d7f6c062c454 -r 41ce4af91010 jdk/make/common/Demo.gmk --- a/jdk/make/common/Demo.gmk Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/make/common/Demo.gmk Fri Nov 18 11:11:11 2011 -0800 @@ -158,6 +158,8 @@ # bit between them. LINK.demo = $(LINK.c) LDLIBS.demo = $(EXTRA_LIBS) $(LFLAGS_$(COMPILER_VERSION)) + DEMO_VERSION_INFO = $(OBJDIR)/$(LIBRARY).res + LDLIBS.demo += $(DEMO_VERSION_INFO) else ifneq ($(DEMO_NEEDS_CPP),) LINK.demo = $(LINK.cpp) @@ -288,6 +290,13 @@ $(install-file) endif +ifeq ($(PLATFORM),windows) +# JDK name required here +RC_FLAGS += /D "JDK_FNAME=$(LIBRARY).dll" \ + /D "JDK_INTERNAL_NAME=$(LIBRARY)" \ + /D "JDK_FTYPE=0x2L" +endif + # Native library building ifdef DEMO_LIBRARY @@ -308,6 +317,9 @@ # Actual creation of the native shared library (C++ and C are different) $(DEMO_LIBRARY): $(DEMO_FULL_OBJECTS) @$(prep-target) + ifeq ($(PLATFORM),windows) + $(RC) $(RC_FLAGS) $(CC_OBJECT_OUTPUT_FLAG)$(DEMO_VERSION_INFO) $(VERSIONINFO_RESOURCE) + endif $(LINK.demo) $(SHARED_LIBRARY_FLAG) $(CC_PROGRAM_OUTPUT_FLAG)$@ \ $(DEMO_FULL_OBJECTS) $(LDLIBS.demo) @$(call binary_file_verification,$@) diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/com/sun/net/ssl/HttpsURLConnection.java --- a/jdk/src/share/classes/com/sun/net/ssl/HttpsURLConnection.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/com/sun/net/ssl/HttpsURLConnection.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -179,6 +179,12 @@ throw new IllegalArgumentException( "no SSLSocketFactory specified"); } + + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkSetFactory(); + } + sslSocketFactory = sf; } diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/java/awt/AWTKeyStroke.java --- a/jdk/src/share/classes/java/awt/AWTKeyStroke.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/java/awt/AWTKeyStroke.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package java.awt; import java.awt.event.KeyEvent; +import sun.awt.AppContext; import java.awt.event.InputEvent; import java.util.Collections; import java.util.HashMap; @@ -66,9 +67,6 @@ public class AWTKeyStroke implements Serializable { static final long serialVersionUID = -6430539691155161871L; - private static Map cache; - private static AWTKeyStroke cacheKey; - private static Constructor ctor = getCtor(AWTKeyStroke.class); private static Map modifierKeywords; /** * Associates VK_XXX (as a String) with code (as Integer). This is @@ -77,6 +75,25 @@ */ private static VKCollection vks; + //A key for the collection of AWTKeyStrokes within AppContext. + private static Object APP_CONTEXT_CACHE_KEY = new Object(); + //A key withing the cache + private static AWTKeyStroke APP_CONTEXT_KEYSTROKE_KEY = new AWTKeyStroke(); + + /* + * Reads keystroke class from AppContext and if null, puts there the + * AWTKeyStroke class. + * Must be called under locked AWTKeyStro + */ + private static Class getAWTKeyStrokeClass() { + Class clazz = (Class)AppContext.getAppContext().get(AWTKeyStroke.class); + if (clazz == null) { + clazz = AWTKeyStroke.class; + AppContext.getAppContext().put(AWTKeyStroke.class, AWTKeyStroke.class); + } + return clazz; + } + private char keyChar = KeyEvent.CHAR_UNDEFINED; private int keyCode = KeyEvent.VK_UNDEFINED; private int modifiers; @@ -164,9 +181,12 @@ if (subclass == null) { throw new IllegalArgumentException("subclass cannot be null"); } - if (AWTKeyStroke.ctor.getDeclaringClass().equals(subclass)) { - // Already registered - return; + synchronized (AWTKeyStroke.class) { + Class keyStrokeClass = (Class)AppContext.getAppContext().get(AWTKeyStroke.class); + if (keyStrokeClass != null && keyStrokeClass.equals(subclass)){ + // Already registered + return; + } } if (!AWTKeyStroke.class.isAssignableFrom(subclass)) { throw new ClassCastException("subclass is not derived from AWTKeyStroke"); @@ -197,9 +217,9 @@ } synchronized (AWTKeyStroke.class) { - AWTKeyStroke.ctor = ctor; - cache = null; - cacheKey = null; + AppContext.getAppContext().put(AWTKeyStroke.class, subclass); + AppContext.getAppContext().remove(APP_CONTEXT_CACHE_KEY); + AppContext.getAppContext().remove(APP_CONTEXT_KEYSTROKE_KEY); } } @@ -229,13 +249,19 @@ private static synchronized AWTKeyStroke getCachedStroke (char keyChar, int keyCode, int modifiers, boolean onKeyRelease) { + Map cache = (Map)AppContext.getAppContext().get(APP_CONTEXT_CACHE_KEY); + AWTKeyStroke cacheKey = (AWTKeyStroke)AppContext.getAppContext().get(APP_CONTEXT_KEYSTROKE_KEY); + if (cache == null) { cache = new HashMap(); + AppContext.getAppContext().put(APP_CONTEXT_CACHE_KEY, cache); } if (cacheKey == null) { try { - cacheKey = (AWTKeyStroke)ctor.newInstance((Object[]) null); + Class clazz = getAWTKeyStrokeClass(); + cacheKey = (AWTKeyStroke)getCtor(clazz).newInstance((Object[]) null); + AppContext.getAppContext().put(APP_CONTEXT_KEYSTROKE_KEY, cacheKey); } catch (InstantiationException e) { assert(false); } catch (IllegalAccessException e) { @@ -253,9 +279,8 @@ if (stroke == null) { stroke = cacheKey; cache.put(stroke, stroke); - cacheKey = null; + AppContext.getAppContext().remove(APP_CONTEXT_KEYSTROKE_KEY); } - return stroke; } diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/java/io/InputStream.java --- a/jdk/src/share/classes/java/io/InputStream.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/java/io/InputStream.java Fri Nov 18 11:11:11 2011 -0800 @@ -44,10 +44,9 @@ */ public abstract class InputStream implements Closeable { - // SKIP_BUFFER_SIZE is used to determine the size of skipBuffer - private static final int SKIP_BUFFER_SIZE = 2048; - // skipBuffer is initialized in skip(long), if needed. - private static byte[] skipBuffer; + // MAX_SKIP_BUFFER_SIZE is used to determine the maximum buffer size to + // use when skipping. + private static final int MAX_SKIP_BUFFER_SIZE = 2048; /** * Reads the next byte of data from the input stream. The value byte is @@ -212,18 +211,15 @@ long remaining = n; int nr; - if (skipBuffer == null) - skipBuffer = new byte[SKIP_BUFFER_SIZE]; - - byte[] localSkipBuffer = skipBuffer; if (n <= 0) { return 0; } + int size = (int)Math.min(MAX_SKIP_BUFFER_SIZE, remaining); + byte[] skipBuffer = new byte[size]; while (remaining > 0) { - nr = read(localSkipBuffer, 0, - (int) Math.min(SKIP_BUFFER_SIZE, remaining)); + nr = read(skipBuffer, 0, (int)Math.min(size, remaining)); if (nr < 0) { break; } diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/java/util/CurrencyData.properties --- a/jdk/src/share/classes/java/util/CurrencyData.properties Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/java/util/CurrencyData.properties Fri Nov 18 11:11:11 2011 -0800 @@ -71,7 +71,7 @@ # # The table is based on the following web sites: # http://www.din.de/gremien/nas/nabd/iso3166ma/codlstp1/db_en.html -# http://www.bsi-global.com/iso4217currency +# http://www.currency-iso.org/iso_index/iso_tables.htm # http://www.cia.gov/cia/publications/factbook/indexgeo.html # AFGHANISTAN @@ -105,7 +105,7 @@ # AUSTRIA AT=EUR # AZERBAIJAN -AZ=AZM;2005-12-31-20-00-00;AZN +AZ=AZN # BAHAMAS BS=BSD # BAHRAIN @@ -378,7 +378,7 @@ # MOROCCO MA=MAD # MOZAMBIQUE -MZ=MZM;2006-06-30-22-00-00;MZN +MZ=MZN # MYANMAR MM=MMK # NAMIBIA @@ -440,7 +440,7 @@ # REUNION RE=EUR # ROMANIA -RO=ROL;2005-06-30-21-00-00;RON +RO=RON # RUSSIAN FEDERATION RU=RUB # RWANDA @@ -532,7 +532,7 @@ # TUNISIA TN=TND # TURKEY -TR=TRL;2004-12-31-22-00-00;TRY +TR=TRY # TURKMENISTAN TM=TMT # TURKS AND CAICOS ISLANDS @@ -558,7 +558,7 @@ # VANUATU VU=VUV # VENEZUELA -VE=VEB;2008-01-01-04-00-00;VEF +VE=VEF # VIET NAM VN=VND # VIRGIN ISLANDS, BRITISH diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/javax/net/ssl/HttpsURLConnection.java --- a/jdk/src/share/classes/javax/net/ssl/HttpsURLConnection.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/javax/net/ssl/HttpsURLConnection.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -347,6 +347,9 @@ * @param sf the SSL socket factory * @throws IllegalArgumentException if the SSLSocketFactory * parameter is null. + * @throws SecurityException if a security manager exists and its + * checkSetFactory method does not allow + * a socket factory to be specified. * @see #getSSLSocketFactory() */ public void setSSLSocketFactory(SSLSocketFactory sf) { @@ -355,6 +358,10 @@ "no SSLSocketFactory specified"); } + SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + sm.checkSetFactory(); + } sslSocketFactory = sf; } diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/javax/net/ssl/SSLEngine.java --- a/jdk/src/share/classes/javax/net/ssl/SSLEngine.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/javax/net/ssl/SSLEngine.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -538,7 +538,7 @@ * If this SSLEngine has not yet started its initial * handshake, this method will automatically start the handshake. *

- * This method will attempt to produce one SSL/TLS packet, and will + * This method will attempt to produce SSL/TLS records, and will * consume as much source data as possible, but will never consume * more than the sum of the bytes remaining in each buffer. Each * ByteBuffer's position is updated to reflect the diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/javax/swing/JTable.java --- a/jdk/src/share/classes/javax/swing/JTable.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/javax/swing/JTable.java Fri Nov 18 11:11:11 2011 -0800 @@ -1828,6 +1828,8 @@ * table. While the {@code autoCreateRowSorter} property remains * {@code true}, every time the model is changed, a new {@code * TableRowSorter} is created and set as the table's row sorter. + * The default value for the {@code autoCreateRowSorter} + * property is {@code false}. * * @param autoCreateRowSorter whether or not a {@code RowSorter} * should be automatically created diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/javax/swing/JTree.java --- a/jdk/src/share/classes/javax/swing/JTree.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/javax/swing/JTree.java Fri Nov 18 11:11:11 2011 -0800 @@ -1838,7 +1838,9 @@ * nodes, or null if nothing is currently selected */ public TreePath[] getSelectionPaths() { - return getSelectionModel().getSelectionPaths(); + TreePath[] selectionPaths = getSelectionModel().getSelectionPaths(); + + return (selectionPaths != null && selectionPaths.length > 0) ? selectionPaths : null; } /** diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/javax/swing/text/DefaultCaret.java --- a/jdk/src/share/classes/javax/swing/text/DefaultCaret.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/javax/swing/text/DefaultCaret.java Fri Nov 18 11:11:11 2011 -0800 @@ -1326,7 +1326,7 @@ if ( ! SwingUtilities2.canCurrentEventAccessSystemClipboard() ) { return; } - if (this.dot != this.mark && component != null) { + if (this.dot != this.mark && component != null && component.hasFocus()) { Clipboard clip = getSystemSelection(); if (clip != null) { String selectedText; diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/javax/swing/text/html/HTMLDocument.java --- a/jdk/src/share/classes/javax/swing/text/html/HTMLDocument.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/javax/swing/text/html/HTMLDocument.java Fri Nov 18 11:11:11 2011 -0800 @@ -1181,7 +1181,12 @@ public void insertAfterStart(Element elem, String htmlText) throws BadLocationException, IOException { verifyParser(); - if (elem != null && elem.isLeaf()) { + + if (elem == null || htmlText == null) { + return; + } + + if (elem.isLeaf()) { throw new IllegalArgumentException ("Can not insert HTML after start of a leaf"); } diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java --- a/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/awt/image/OffScreenImageSource.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -185,7 +185,7 @@ theConsumer.setDimensions(image.getWidth(), image.getHeight()); theConsumer.setProperties(properties); sendPixels(); - theConsumer.imageComplete(ImageConsumer.SINGLEFRAMEDONE); + theConsumer.imageComplete(ImageConsumer.STATICIMAGEDONE); } catch (NullPointerException e) { if (theConsumer != null) { theConsumer.imageComplete(ImageConsumer.IMAGEERROR); diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/net/ResourceManager.java --- a/jdk/src/share/classes/sun/net/ResourceManager.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/net/ResourceManager.java Fri Nov 18 11:11:11 2011 -0800 @@ -41,13 +41,14 @@ /* default maximum number of udp sockets per VM * when a security manager is enabled. - * The default is 1024 which is high enough to be useful + * The default is 25 which is high enough to be useful * but low enough to be well below the maximum number - * of port numbers actually available on all OSes for - * such sockets (5000 on some versions of windows) + * of port numbers actually available on all OSes + * when multiplied by the maximum feasible number of VM processes + * that could practically be spawned. */ - private static final int DEFAULT_MAX_SOCKETS = 1024; + private static final int DEFAULT_MAX_SOCKETS = 25; private static final int maxSockets; private static final AtomicInteger numSockets; diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/print/PSPrinterJob.java --- a/jdk/src/share/classes/sun/print/PSPrinterJob.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/print/PSPrinterJob.java Fri Nov 18 11:11:11 2011 -0800 @@ -68,14 +68,18 @@ import java.io.BufferedInputStream; import java.io.BufferedOutputStream; +import java.io.BufferedReader; import java.io.CharConversionException; import java.io.File; import java.io.InputStream; +import java.io.InputStreamReader; import java.io.IOException; import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.OutputStream; import java.io.PrintStream; +import java.io.PrintWriter; +import java.io.StringWriter; import java.util.ArrayList; import java.util.Enumeration; @@ -673,15 +677,38 @@ private class PrinterSpooler implements java.security.PrivilegedAction { PrinterException pex; + private void handleProcessFailure(final Process failedProcess, + final String[] execCmd, final int result) throws IOException { + try (StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw)) { + pw.append("error=").append(Integer.toString(result)); + pw.append(" running:"); + for (String arg: execCmd) { + pw.append(" '").append(arg).append("'"); + } + try (InputStream is = failedProcess.getErrorStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr)) { + while (br.ready()) { + pw.println(); + pw.append("\t\t").append(br.readLine()); + } + } finally { + pw.flush(); + throw new IOException(sw.toString()); + } + } + } + public Object run() { + if (spoolFile == null || !spoolFile.exists()) { + pex = new PrinterException("No spool file"); + return null; + } try { /** * Spool to the printer. */ - if (spoolFile == null || !spoolFile.exists()) { - pex = new PrinterException("No spool file"); - return null; - } String fileName = spoolFile.getAbsolutePath(); String execCmd[] = printExecCmd(mDestination, mOptions, mNoJobSheet, getJobNameInt(), @@ -689,12 +716,16 @@ Process process = Runtime.getRuntime().exec(execCmd); process.waitFor(); - spoolFile.delete(); - + final int result = process.exitValue(); + if (0 != result) { + handleProcessFailure(process, execCmd, result); + } } catch (IOException ex) { pex = new PrinterIOException(ex); } catch (InterruptedException ie) { pex = new PrinterException(ie.toString()); + } finally { + spoolFile.delete(); } return null; } diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java --- a/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/rmi/registry/RegistryImpl.java Fri Nov 18 11:11:11 2011 -0800 @@ -38,13 +38,23 @@ import java.rmi.registry.Registry; import java.rmi.server.RMIClientSocketFactory; import java.rmi.server.RMIServerSocketFactory; +import java.security.AccessControlContext; +import java.security.AccessController; +import java.security.CodeSource; +import java.security.Policy; import java.security.PrivilegedActionException; +import java.security.PrivilegedExceptionAction; +import java.security.PermissionCollection; +import java.security.Permissions; +import java.security.ProtectionDomain; import java.text.MessageFormat; +import sun.rmi.server.LoaderHandler; import sun.rmi.server.UnicastServerRef; import sun.rmi.server.UnicastServerRef2; import sun.rmi.transport.LiveRef; import sun.rmi.transport.ObjectTable; import sun.rmi.transport.Target; +import sun.security.action.GetPropertyAction; /** * A "registry" exists on every node that allows RMI connections to @@ -325,6 +335,19 @@ URL[] urls = sun.misc.URLClassPath.pathToURLs(envcp); ClassLoader cl = new URLClassLoader(urls); + String codebaseProperty = null; + String prop = java.security.AccessController.doPrivileged( + new GetPropertyAction("java.rmi.server.codebase")); + if (prop != null && prop.trim().length() > 0) { + codebaseProperty = prop; + } + URL[] codebaseURLs = null; + if (codebaseProperty != null) { + codebaseURLs = sun.misc.URLClassPath.pathToURLs(codebaseProperty); + } else { + codebaseURLs = new URL[0]; + } + /* * Fix bugid 4242317: Classes defined by this class loader should * be annotated with the value of the "java.rmi.server.codebase" @@ -334,11 +357,19 @@ Thread.currentThread().setContextClassLoader(cl); - int regPort = Registry.REGISTRY_PORT; - if (args.length >= 1) { - regPort = Integer.parseInt(args[0]); + final int regPort = (args.length >= 1) ? Integer.parseInt(args[0]) + : Registry.REGISTRY_PORT; + try { + registry = AccessController.doPrivileged( + new PrivilegedExceptionAction() { + public RegistryImpl run() throws RemoteException { + return new RegistryImpl(regPort); + } + }, getAccessControlContext(codebaseURLs)); + } catch (PrivilegedActionException ex) { + throw (RemoteException) ex.getException(); } - registry = new RegistryImpl(regPort); + // prevent registry from exiting while (true) { try { @@ -358,4 +389,48 @@ } System.exit(1); } + + /** + * Generates an AccessControlContext from several URLs. + * The approach used here is taken from the similar method + * getAccessControlContext() in the sun.applet.AppletPanel class. + */ + private static AccessControlContext getAccessControlContext(URL[] urls) { + // begin with permissions granted to all code in current policy + PermissionCollection perms = AccessController.doPrivileged( + new java.security.PrivilegedAction() { + public PermissionCollection run() { + CodeSource codesource = new CodeSource(null, + (java.security.cert.Certificate[]) null); + Policy p = java.security.Policy.getPolicy(); + if (p != null) { + return p.getPermissions(codesource); + } else { + return new Permissions(); + } + } + }); + + /* + * Anyone can connect to the registry and the registry can connect + * to and possibly download stubs from anywhere. Downloaded stubs and + * related classes themselves are more tightly limited by RMI. + */ + perms.add(new SocketPermission("*", "connect,accept")); + + perms.add(new RuntimePermission("accessClassInPackage.sun.*")); + + // add permissions required to load from codebase URL path + LoaderHandler.addPermissionsForURLs(urls, perms, false); + + /* + * Create an AccessControlContext that consists of a single + * protection domain with only the permissions calculated above. + */ + ProtectionDomain pd = new ProtectionDomain( + new CodeSource((urls.length > 0 ? urls[0] : null), + (java.security.cert.Certificate[]) null), + perms); + return new AccessControlContext(new ProtectionDomain[] { pd }); + } } diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/rmi/server/LoaderHandler.java --- a/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/rmi/server/LoaderHandler.java Fri Nov 18 11:11:11 2011 -0800 @@ -1031,9 +1031,9 @@ * loader. A given permission is only added to the collection if * it is not already implied by the collection. */ - private static void addPermissionsForURLs(URL[] urls, - PermissionCollection perms, - boolean forLoader) + public static void addPermissionsForURLs(URL[] urls, + PermissionCollection perms, + boolean forLoader) { for (int i = 0; i < urls.length; i++) { URL url = urls[i]; diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java --- a/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/rmi/server/UnicastServerRef.java Fri Nov 18 11:11:11 2011 -0800 @@ -390,6 +390,12 @@ ObjectInput in; try { in = call.getInputStream(); + try { + Class clazz = Class.forName("sun.rmi.transport.DGCImpl_Skel"); + if (clazz.isAssignableFrom(skel.getClass())) { + ((MarshalInputStream)in).useCodebaseOnly(); + } + } catch (ClassNotFoundException ignore) { } hash = in.readLong(); } catch (Exception readEx) { throw new UnmarshalException("error unmarshalling call header", diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/security/ssl/AppOutputStream.java --- a/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/security/ssl/AppOutputStream.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -69,12 +69,38 @@ // check if the Socket is invalid (error or closed) c.checkWrite(); + /* + * By default, we counter chosen plaintext issues on CBC mode + * ciphersuites in SSLv3/TLS1.0 by sending one byte of application + * data in the first record of every payload, and the rest in + * subsequent record(s). Note that the issues have been solved in + * TLS 1.1 or later. + * + * It is not necessary to split the very first application record of + * a freshly negotiated TLS session, as there is no previous + * application data to guess. To improve compatibility, we will not + * split such records. + * + * This avoids issues in the outbound direction. For a full fix, + * the peer must have similar protections. + */ + boolean isFirstRecordOfThePayload = true; + // Always flush at the end of each application level record. // This lets application synchronize read and write streams // however they like; if we buffered here, they couldn't. try { do { - int howmuch = Math.min(len, r.availableDataBytes()); + int howmuch; + if (isFirstRecordOfThePayload && c.needToSplitPayload()) { + howmuch = Math.min(0x01, r.availableDataBytes()); + } else { + howmuch = Math.min(len, r.availableDataBytes()); + } + + if (isFirstRecordOfThePayload && howmuch != 0) { + isFirstRecordOfThePayload = false; + } // NOTE: *must* call c.writeRecord() even for howmuch == 0 if (howmuch > 0) { diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/security/ssl/CipherBox.java --- a/jdk/src/share/classes/sun/security/ssl/CipherBox.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/security/ssl/CipherBox.java Fri Nov 18 11:11:11 2011 -0800 @@ -113,6 +113,11 @@ private SecureRandom random; /** + * Is the cipher of CBC mode? + */ + private final boolean isCBCMode; + + /** * Fixed masks of various block size, as the initial decryption IVs * for TLS 1.1 or later. * @@ -128,6 +133,7 @@ private CipherBox() { this.protocolVersion = ProtocolVersion.DEFAULT; this.cipher = null; + this.isCBCMode = false; } /** @@ -148,6 +154,7 @@ random = JsseJce.getSecureRandom(); } this.random = random; + this.isCBCMode = bulkCipher.isCBCMode; /* * RFC 4346 recommends two algorithms used to generated the @@ -694,4 +701,12 @@ } } + /* + * Does the cipher use CBC mode? + * + * @return true if the cipher use CBC mode, false otherwise. + */ + boolean isCBCMode() { + return isCBCMode; + } } diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/security/ssl/CipherSuite.java --- a/jdk/src/share/classes/sun/security/ssl/CipherSuite.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/security/ssl/CipherSuite.java Fri Nov 18 11:11:11 2011 -0800 @@ -420,10 +420,16 @@ // exportable under 512/40 bit rules final boolean exportable; + // Is the cipher algorithm of Cipher Block Chaining (CBC) mode? + final boolean isCBCMode; + BulkCipher(String transformation, int keySize, int expandedKeySize, int ivSize, boolean allowed) { this.transformation = transformation; - this.algorithm = transformation.split("/")[0]; + String[] splits = transformation.split("/"); + this.algorithm = splits[0]; + this.isCBCMode = + splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]); this.description = this.algorithm + "/" + (keySize << 3); this.keySize = keySize; this.ivSize = ivSize; @@ -436,7 +442,10 @@ BulkCipher(String transformation, int keySize, int ivSize, boolean allowed) { this.transformation = transformation; - this.algorithm = transformation.split("/")[0]; + String[] splits = transformation.split("/"); + this.algorithm = splits[0]; + this.isCBCMode = + splits.length <= 1 ? false : "CBC".equalsIgnoreCase(splits[1]); this.description = this.algorithm + "/" + (keySize << 3); this.keySize = keySize; this.ivSize = ivSize; diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java --- a/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/security/ssl/EngineOutputRecord.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -46,6 +46,7 @@ */ final class EngineOutputRecord extends OutputRecord { + private SSLEngineImpl engine; private EngineWriter writer; private boolean finishedMsg = false; @@ -62,6 +63,7 @@ */ EngineOutputRecord(byte type, SSLEngineImpl engine) { super(type, recordSize(type)); + this.engine = engine; writer = engine.writer; } @@ -227,12 +229,51 @@ * implementations are fragile and don't like to see empty * records, so this increases robustness. */ - int length = Math.min(ea.getAppRemaining(), maxDataSize); - if (length == 0) { + if (ea.getAppRemaining() == 0) { return; } /* + * By default, we counter chosen plaintext issues on CBC mode + * ciphersuites in SSLv3/TLS1.0 by sending one byte of application + * data in the first record of every payload, and the rest in + * subsequent record(s). Note that the issues have been solved in + * TLS 1.1 or later. + * + * It is not necessary to split the very first application record of + * a freshly negotiated TLS session, as there is no previous + * application data to guess. To improve compatibility, we will not + * split such records. + * + * Because of the compatibility, we'd better produce no more than + * SSLSession.getPacketBufferSize() net data for each wrap. As we + * need a one-byte record at first, the 2nd record size should be + * equal to or less than Record.maxDataSizeMinusOneByteRecord. + * + * This avoids issues in the outbound direction. For a full fix, + * the peer must have similar protections. + */ + int length; + if (engine.needToSplitPayload(writeCipher, protocolVersion)) { + write(ea, writeMAC, writeCipher, 0x01); + ea.resetLim(); // reset application data buffer limit + length = Math.min(ea.getAppRemaining(), + maxDataSizeMinusOneByteRecord); + } else { + length = Math.min(ea.getAppRemaining(), maxDataSize); + } + + // Don't bother to really write empty records. + if (length > 0) { + write(ea, writeMAC, writeCipher, length); + } + + return; + } + + void write(EngineArgs ea, MAC writeMAC, CipherBox writeCipher, + int length) throws IOException { + /* * Copy out existing buffer values. */ ByteBuffer dstBB = ea.netData; diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/security/ssl/Record.java --- a/jdk/src/share/classes/sun/security/ssl/Record.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/security/ssl/Record.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -67,6 +67,23 @@ + maxPadding // padding + trailerSize; // MAC + static final boolean enableCBCProtection = + Debug.getBooleanProperty("jsse.enableCBCProtection", true); + + /* + * For CBC protection in SSL3/TLS1, we break some plaintext into two + * packets. Max application data size for the second packet. + */ + static final int maxDataSizeMinusOneByteRecord = + maxDataSize // max data size + - ( // max one byte record size + headerSize // header + + maxIVLength // iv + + 1 // one byte data + + maxPadding // padding + + trailerSize // MAC + ); + /* * The maximum large record size. * diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java --- a/jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/security/ssl/SSLEngineImpl.java Fri Nov 18 11:11:11 2011 -0800 @@ -309,6 +309,11 @@ Object writeLock; /* + * Is it the first application record to write? + */ + private boolean isFirstAppOutputRecord = true; + + /* * Class and subclass dynamic debugging support */ private static final Debug debug = Debug.getInstance("ssl"); @@ -612,6 +617,9 @@ // See comment above. oldCipher.dispose(); + + // reset the flag of the first application record + isFirstAppOutputRecord = true; } /* @@ -1286,10 +1294,36 @@ } } + /* + * turn off the flag of the first application record if we really + * consumed at least byte. + */ + if (isFirstAppOutputRecord && ea.deltaApp() > 0) { + isFirstAppOutputRecord = false; + } + return hsStatus; } /* + * Need to split the payload except the following cases: + * + * 1. protocol version is TLS 1.1 or later; + * 2. bulk cipher does not use CBC mode, including null bulk cipher suites. + * 3. the payload is the first application record of a freshly + * negotiated TLS session. + * 4. the CBC protection is disabled; + * + * More details, please refer to + * EngineOutputRecord.write(EngineArgs, MAC, CipherBox). + */ + boolean needToSplitPayload(CipherBox cipher, ProtocolVersion protocol) { + return (protocol.v <= ProtocolVersion.TLS10.v) && + cipher.isCBCMode() && !isFirstAppOutputRecord && + Record.enableCBCProtection; + } + + /* * Non-application OutputRecords go through here. */ void writeRecord(EngineOutputRecord eor) throws IOException { diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java --- a/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/security/ssl/SSLSocketImpl.java Fri Nov 18 11:11:11 2011 -0800 @@ -369,6 +369,11 @@ /* Class and subclass dynamic debugging support */ private static final Debug debug = Debug.getInstance("ssl"); + /* + * Is it the first application record to write? + */ + private boolean isFirstAppOutputRecord = true; + // // CONSTRUCTORS AND INITIALIZATION CODE // @@ -802,8 +807,35 @@ if (connectionState < cs_ERROR) { checkSequenceNumber(writeMAC, r.contentType()); } + + // turn off the flag of the first application record + if (isFirstAppOutputRecord && + r.contentType() == Record.ct_application_data) { + isFirstAppOutputRecord = false; + } } + /* + * Need to split the payload except the following cases: + * + * 1. protocol version is TLS 1.1 or later; + * 2. bulk cipher does not use CBC mode, including null bulk cipher suites. + * 3. the payload is the first application record of a freshly + * negotiated TLS session. + * 4. the CBC protection is disabled; + * + * More details, please refer to AppOutputStream.write(byte[], int, int). + */ + boolean needToSplitPayload() { + writeLock.lock(); + try { + return (protocolVersion.v <= ProtocolVersion.TLS10.v) && + writeCipher.isCBCMode() && !isFirstAppOutputRecord && + Record.enableCBCProtection; + } finally { + writeLock.unlock(); + } + } /* * Read an application data record. Alerts and handshake @@ -2031,6 +2063,9 @@ // See comment above. oldCipher.dispose(); + + // reset the flag of the first application record + isFirstAppOutputRecord = true; } /* diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/swing/SwingUtilities2.java --- a/jdk/src/share/classes/sun/swing/SwingUtilities2.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/swing/SwingUtilities2.java Fri Nov 18 11:11:11 2011 -0800 @@ -524,56 +524,67 @@ } // If we get here we're not printing - AATextInfo info = drawTextAntialiased(c); - if (info != null && (g instanceof Graphics2D)) { + if (g instanceof Graphics2D) { + AATextInfo info = drawTextAntialiased(c); Graphics2D g2 = (Graphics2D)g; - Object oldContrast = null; - Object oldAAValue = g2.getRenderingHint(KEY_TEXT_ANTIALIASING); - if (info.aaHint != oldAAValue) { - g2.setRenderingHint(KEY_TEXT_ANTIALIASING, info.aaHint); - } else { - oldAAValue = null; - } - if (info.lcdContrastHint != null) { - oldContrast = g2.getRenderingHint(KEY_TEXT_LCD_CONTRAST); - if (info.lcdContrastHint.equals(oldContrast)) { - oldContrast = null; - } else { - g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, - info.lcdContrastHint); - } - } - boolean needsTextLayout = ((c != null) && (c.getClientProperty(TextAttribute.NUMERIC_SHAPING) != null)); + if (needsTextLayout) { synchronized(charsBufferLock) { int length = syncCharsBuffer(text); needsTextLayout = isComplexLayout(charsBuffer, 0, length); } } - if (needsTextLayout) { + + if (info != null) { + Object oldContrast = null; + Object oldAAValue = g2.getRenderingHint(KEY_TEXT_ANTIALIASING); + if (info.aaHint != oldAAValue) { + g2.setRenderingHint(KEY_TEXT_ANTIALIASING, info.aaHint); + } else { + oldAAValue = null; + } + if (info.lcdContrastHint != null) { + oldContrast = g2.getRenderingHint(KEY_TEXT_LCD_CONTRAST); + if (info.lcdContrastHint.equals(oldContrast)) { + oldContrast = null; + } else { + g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, + info.lcdContrastHint); + } + } + + if (needsTextLayout) { + TextLayout layout = createTextLayout(c, text, g2.getFont(), + g2.getFontRenderContext()); + layout.draw(g2, x, y); + } else { + g.drawString(text, x, y); + } + + if (oldAAValue != null) { + g2.setRenderingHint(KEY_TEXT_ANTIALIASING, oldAAValue); + } + if (oldContrast != null) { + g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, oldContrast); + } + + return; + } + + if (needsTextLayout){ TextLayout layout = createTextLayout(c, text, g2.getFont(), g2.getFontRenderContext()); layout.draw(g2, x, y); - } else { - g.drawString(text, x, y); - } - - if (oldAAValue != null) { - g2.setRenderingHint(KEY_TEXT_ANTIALIASING, oldAAValue); - } - if (oldContrast != null) { - g2.setRenderingHint(KEY_TEXT_LCD_CONTRAST, oldContrast); + return; } } - else { - g.drawString(text, x, y); - } + + g.drawString(text, x, y); } - /** * Draws the string at the specified location underlining the specified * character. diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/text/resources/CollationData_th.java --- a/jdk/src/share/classes/sun/text/resources/CollationData_th.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/text/resources/CollationData_th.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -103,18 +103,13 @@ // // Normal vowels // + + "< \u0E4D " // NIKHAHIT + "< \u0E30 " // SARA A + "< \u0E31 " // MAI HAN-AKAT + "< \u0E32 " // SARA AA - // Normalizer will decompose this character to \u0e4d\u0e32. This is - // a Bad Thing, because we want the separate characters to sort - // differently than this individual one. Since there's no public way to - // set the decomposition to be used when creating a collator, there's - // no way around this right now. - // It's best to go ahead and leave the character in, because it occurs - // this way a lot more often than it occurs as separate characters. - + "< \u0E33 " // SARA AM + // Normalizer will decompose this character to \u0e4d\u0e32. + + "< \u0E33 = \u0E4D\u0E32 " // SARA AM + "< \u0E34 " // SARA I @@ -133,62 +128,58 @@ + "< \u0E43 " // SARA AI MAIMUAN + "< \u0E44 " // SARA AI MAIMALAI - // - // Digits - // - + "< \u0E50 " // DIGIT ZERO - + "< \u0E51 " // DIGIT ONE - + "< \u0E52 " // DIGIT TWO - + "< \u0E53 " // DIGIT THREE - + "< \u0E54 " // DIGIT FOUR - + "< \u0E55 " // DIGIT FIVE - + "< \u0E56 " // DIGIT SIX - + "< \u0E57 " // DIGIT SEVEN - + "< \u0E58 " // DIGIT EIGHT - + "< \u0E59 " // DIGIT NINE + + //according to CLDR, it's after 0e44 + + "< \u0E3A " // PHINTHU + + - // Sorta tonal marks, but maybe not really - + "< \u0E4D " // NIKHAHIT + // This rare symbol comes after all characters. + + "< \u0E45 " // LAKKHANGYAO + + "& \u0E32 , \0E45 " // According to CLDR, 0E45 is after 0E32 in tertiary level + + + - // - // Thai symbols are supposed to sort "after white space". - // I'm treating this as making them sort just after the normal Latin-1 - // symbols, which are in turn after the white space. - // - + "&'\u007d'" // right-brace - + "< \u0E2F " // PAIYANNOI (ellipsis, abbreviation) - + "< \u0E46 " // MAIYAMOK - + "< \u0E4F " // FONGMAN - + "< \u0E5A " // ANGKHANKHU - + "< \u0E5B " // KHOMUT - + "< \u0E3F " // CURRENCY SYMBOL BAHT + // Below are thai puntuation marks and Tonal(Accent) marks. According to CLDR 1.9 and + // ISO/IEC 14651, Annex C, C.2.1 Thai ordering principles, 0E2F to 0E5B are punctuaion marks that need to be ignored + // in the first three leveles. 0E4E to 0E4B are tonal marks to be compared in secondary level. + // In real implmentation, set puncutation marks in tertiary as there is no fourth level in Java. + // Set all these special marks after \u0301, the accute accent. + + "& \u0301 " // acute accent - // These symbols are supposed to be "after all characters" - + "< \u0E4E " // YAMAKKAN + //puncutation marks + + ", \u0E2F " // PAIYANNOI (ellipsis, abbreviation) + + ", \u0E46 " // MAIYAMOK + + ", \u0E4F " // FONGMAN + + ", \u0E5A " // ANGKHANKHU + + ", \u0E5B " // KHOMUT - // This rare symbol also comes after all characters. But when it is - // used in combination with RU and LU, the combination is treated as - // a separate letter, ala "CH" sorting after "C" in traditional Spanish. - + "< \u0E45 " // LAKKHANGYAO - + "& \u0E24 < \u0E24\u0E45 " - + "& \u0E26 < \u0E26\u0E45 " - - // Tonal marks are primary ignorables but are treated as secondary - // differences - + "& \u0301 " // acute accent + //tonal marks + + "; \u0E4E " // YAMAKKAN + + "; \u0E4C " // THANTHAKHAT + "; \u0E47 " // MAITAIKHU + "; \u0E48 " // MAI EK + "; \u0E49 " // MAI THO + "; \u0E4A " // MAI TRI + "; \u0E4B " // MAI CHATTAWA - + "; \u0E4C " // THANTHAKHAT + + // + // Digits are equal to their corresponding Arabic digits in the first level + // + + "& 0 = \u0E50 " // DIGIT ZERO + + "& 1 = \u0E51 " // DIGIT ONE + + "& 2 = \u0E52 " // DIGIT TWO + + "& 3 = \u0E53 " // DIGIT THREE + + "& 4 = \u0E54 " // DIGIT FOUR + + "& 5 = \u0E55 " // DIGIT FIVE + + "& 6 = \u0E56 " // DIGIT SIX + + "& 7 = \u0E57 " // DIGIT SEVEN + + "& 8 = \u0E58 " // DIGIT EIGHT + + "& 9 = \u0E59 " // DIGIT NINE - // These are supposed to be ignored, so I'm treating them as controls - + "& \u0001 " - + "= \u0E3A " // PHINTHU - + "= '.' " // period - } + } }; } } diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/classes/sun/util/resources/CalendarData_lv.properties --- a/jdk/src/share/classes/sun/util/resources/CalendarData_lv.properties Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/classes/sun/util/resources/CalendarData_lv.properties Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ # -# Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -23,21 +23,45 @@ # questions. # -# (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved -# (C) Copyright IBM Corp. 1996 - 1999 - All Rights Reserved +# +# COPYRIGHT AND PERMISSION NOTICE +# +# Copyright (C) 1991-2011 Unicode, Inc. All rights reserved. +# Distributed under the Terms of Use in http://www.unicode.org/copyright.html. # -# The original version of this source code and documentation -# is copyrighted and owned by Taligent, Inc., a wholly-owned -# subsidiary of IBM. These materials are provided under terms -# of a License Agreement between Taligent and Sun. This technology -# is protected by multiple US and International patents. +# Permission is hereby granted, free of charge, to any person obtaining +# a copy of the Unicode data files and any associated documentation (the +# "Data Files") or Unicode software and any associated documentation +# (the "Software") to deal in the Data Files or Software without +# restriction, including without limitation the rights to use, copy, +# modify, merge, publish, distribute, and/or sell copies of the Data +# Files or Software, and to permit persons to whom the Data Files or +# Software are furnished to do so, provided that (a) the above copyright +# notice(s) and this permission notice appear with all copies of the +# Data Files or Software, (b) both the above copyright notice(s) and +# this permission notice appear in associated documentation, and (c) +# there is clear notice in each modified Data File or in the Software as +# well as in the documentation associated with the Data File(s) or +# Software that the data or software has been modified. # -# This notice and attribution to Taligent may not be removed. -# Taligent is a registered trademark of Taligent, Inc. - +# THE DATA FILES AND SOFTWARE ARE PROVIDED "AS IS", WITHOUT WARRANTY OF +# ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE +# WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND +# NONINFRINGEMENT OF THIRD PARTY RIGHTS. IN NO EVENT SHALL THE COPYRIGHT +# HOLDER OR HOLDERS INCLUDED IN THIS NOTICE BE LIABLE FOR ANY CLAIM, OR +# ANY SPECIAL INDIRECT OR CONSEQUENTIAL DAMAGES, OR ANY DAMAGES +# WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN +# ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT +# OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THE DATA FILES OR +# SOFTWARE. +# +# Except as contained in this notice, the name of a copyright holder +# shall not be used in advertising or otherwise to promote the sale, use +# or other dealings in these Data Files or Software without prior +# written authorization of the copyright holder. -# This bundle is empty because the data of the base bundle -# is adequate for this locale. -# The bundle is necessary to prevent the resource -# bundle lookup from falling back to the default -# locale. +# +# Generated automatically from the Common Locale Data Repository. DO NOT EDIT! +# +firstDayOfWeek=2 +minimalDaysInFirstWeek=4 diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/demo/jfc/TransparentRuler/README.txt --- a/jdk/src/share/demo/jfc/TransparentRuler/README.txt Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/demo/jfc/TransparentRuler/README.txt Fri Nov 18 11:11:11 2011 -0800 @@ -1,14 +1,10 @@ To run the Ruler demo: - java -jar Ruler.jar + java -jar TransparentRuler.jar These instructions assume that this installation's version of the java command is in your path. If it isn't, then you should either specify the complete path to the java command or update your PATH environment variable as described in the installation instructions for the Java(TM) SE Development Kit. - -KNOWN ISSUES: -Context menu is clipped with the window shape. The issues are: -CR 7027486 JPopupMenu doesn't take window shape into account diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp --- a/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/native/com/sun/java/util/jar/pack/unpack.cpp Fri Nov 18 11:11:11 2011 -0800 @@ -1112,11 +1112,14 @@ uint size3 = suffix * 3; if (suffix == 0) continue; // done with empty string chars.malloc(size3); + CHECK; byte* chp = chars.ptr; band saved_band = cp_Utf8_big_chars; cp_Utf8_big_chars.readData(suffix); + CHECK; for (int j = 0; j < suffix; j++) { unsigned short ch = cp_Utf8_big_chars.getInt(); + CHECK; chp = store_Utf8_char(chp, ch); } chars.realloc(chp - chars.ptr); @@ -1134,10 +1137,12 @@ CHECK; int prevlen = 0; // previous string length (in chars) tmallocs.add(bigbuf.ptr); // free after this block + CHECK; cp_Utf8_prefix.rewind(); for (i = 0; i < len; i++) { bytes& chars = allsuffixes[i]; int prefix = (i < PREFIX_SKIP_2)? 0: cp_Utf8_prefix.getInt(); + CHECK; int suffix = (int)chars.len; byte* fillp; // by induction, the buffer is already filled with the prefix diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp --- a/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/native/com/sun/java/util/jar/pack/utils.cpp Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,7 +52,7 @@ if (msize >= 0 && msize < sizeof(int)) msize = sizeof(int); // see 0xbaadf00d below #endif - void* ptr = (msize > PSIZE_MAX) ? null : malloc(msize); + void* ptr = (msize > PSIZE_MAX || msize <= 0) ? null : malloc(msize); if (ptr != null) { memset(ptr, 0, size); } else { diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/native/com/sun/java/util/jar/pack/utils.h --- a/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/native/com/sun/java/util/jar/pack/utils.h Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,7 +33,7 @@ #endif // overflow management -#define OVERFLOW ((size_t)-1) +#define OVERFLOW ((uint)-1) #define PSIZE_MAX (OVERFLOW/2) /* normal size limit */ inline size_t scale_size(size_t size, size_t scale) { diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/share/native/sun/java2d/loops/TransformHelper.c --- a/jdk/src/share/native/sun/java2d/loops/TransformHelper.c Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/share/native/sun/java2d/loops/TransformHelper.c Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -284,7 +284,7 @@ TransformHelperFunc *pHelperFunc; TransformInterpFunc *pInterpFunc; jdouble xorig, yorig; - jint numedges; + jlong numedges; jint *pEdges; jint edgebuf[2 + MAXEDGES * 2]; union { @@ -379,19 +379,44 @@ } Region_IntersectBounds(&clipInfo, &dstInfo.bounds); - numedges = (dstInfo.bounds.y2 - dstInfo.bounds.y1); - if (numedges > MAXEDGES) { - pEdges = malloc((2 + 2 * numedges) * sizeof (*pEdges)); - if (pEdges == NULL) { - SurfaceData_InvokeUnlock(env, dstOps, &dstInfo); - SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); - /* edgeArray should already contain zeros for min/maxy */ - return; - } + numedges = (((jlong) dstInfo.bounds.y2) - ((jlong) dstInfo.bounds.y1)); + if (numedges <= 0) { + pEdges = NULL; + } else if (!JNU_IsNull(env, edgeArray)) { + /* + * Ideally Java should allocate an array large enough, but if + * we ever have a miscommunication about the number of edge + * lines, or if the Java array calculation should overflow to + * a positive number and succeed in allocating an array that + * is too small, we need to verify that it can still hold the + * number of integers that we plan to store to be safe. + */ + jsize edgesize = (*env)->GetArrayLength(env, edgeArray); + /* (edgesize/2 - 1) should avoid any overflow or underflow. */ + pEdges = (((edgesize / 2) - 1) >= numedges) + ? (*env)->GetPrimitiveArrayCritical(env, edgeArray, NULL) + : NULL; + } else if (numedges > MAXEDGES) { + /* numedges variable (jlong) can be at most ((1<<32)-1) */ + /* memsize can overflow a jint, but not a jlong */ + jlong memsize = ((numedges * 2) + 2) * sizeof(*pEdges); + pEdges = (memsize == ((size_t) memsize)) + ? malloc((size_t) memsize) + : NULL; } else { pEdges = edgebuf; } + if (pEdges == NULL) { + if (numedges > 0) { + JNU_ThrowInternalError(env, "Unable to allocate edge list"); + } + SurfaceData_InvokeUnlock(env, dstOps, &dstInfo); + SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); + /* edgeArray should already contain zeros for min/maxy */ + return; + } + Transform_GetInfo(env, itxform, &itxInfo); if (!Region_IsEmpty(&clipInfo)) { @@ -500,14 +525,14 @@ } else { pEdges[0] = pEdges[1] = 0; } + + if (!JNU_IsNull(env, edgeArray)) { + (*env)->ReleasePrimitiveArrayCritical(env, edgeArray, pEdges, 0); + } else if (pEdges != edgebuf) { + free(pEdges); + } SurfaceData_InvokeUnlock(env, dstOps, &dstInfo); SurfaceData_InvokeUnlock(env, srcOps, &srcInfo); - if (!JNU_IsNull(env, edgeArray)) { - (*env)->SetIntArrayRegion(env, edgeArray, 0, 2+numedges*2, pEdges); - } - if (pEdges != edgebuf) { - free(pEdges); - } } static void diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java --- a/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/solaris/classes/sun/awt/X11/XComponentPeer.java Fri Nov 18 11:11:11 2011 -0800 @@ -466,12 +466,16 @@ if (true) { switch(e.getID()) { case PaintEvent.UPDATE: - log.finer("XCP coalescePaintEvent : UPDATE : add : x = " + + if (log.isLoggable(PlatformLogger.FINER)) { + log.finer("XCP coalescePaintEvent : UPDATE : add : x = " + r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height); + } return; case PaintEvent.PAINT: - log.finer("XCP coalescePaintEvent : PAINT : add : x = " + + if (log.isLoggable(PlatformLogger.FINER)) { + log.finer("XCP coalescePaintEvent : PAINT : add : x = " + r.x + ", y = " + r.y + ", width = " + r.width + ",height = " + r.height); + } return; } } @@ -1248,7 +1252,9 @@ * ButtonPress, ButtonRelease, KeyPress, KeyRelease, EnterNotify, LeaveNotify, MotionNotify */ protected boolean isEventDisabled(XEvent e) { - enableLog.finest("Component is {1}, checking for disabled event {0}", e, (isEnabled()?"enabled":"disable")); + if (enableLog.isLoggable(PlatformLogger.FINEST)) { + enableLog.finest("Component is {1}, checking for disabled event {0}", e, (isEnabled()?"enabled":"disable")); + } if (!isEnabled()) { switch (e.get_type()) { case XConstants.ButtonPress: @@ -1258,7 +1264,9 @@ case XConstants.EnterNotify: case XConstants.LeaveNotify: case XConstants.MotionNotify: - enableLog.finer("Event {0} is disable", e); + if (enableLog.isLoggable(PlatformLogger.FINER)) { + enableLog.finer("Event {0} is disable", e); + } return true; } } diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java --- a/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/solaris/classes/sun/awt/X11/generator/WrapperGenerator.java Fri Nov 18 11:11:11 2011 -0800 @@ -678,7 +678,7 @@ public void writeToString(StructType stp, PrintWriter pw) { int type; pw.println("\n\n\tString getName() {\n\t\treturn \"" + stp.getName()+ "\"; \n\t}"); - pw.println("\n\n\tString getFieldsAsString() {\n\t\tString ret=\"\";\n"); + pw.println("\n\n\tString getFieldsAsString() {\n\t\tStringBuilder ret = new StringBuilder(" + stp.getNumFields() * 40 + ");\n"); for (Enumeration e = stp.getMembers() ; e.hasMoreElements() ;) { AtomicType tp = (AtomicType) e.nextElement(); @@ -688,24 +688,24 @@ if ((name != null) && (name.length() > 0)) { if (type == AtomicType.TYPE_ATOM) { - pw.println("\t\tret += \"\"+\"" + name + " = \" + XAtom.get(get_" + name + "()) +\", \";"); + pw.println("\t\tret.append(\"" + name + " = \" ).append( XAtom.get(get_" + name + "()) ).append(\", \");"); } else if (name.equals("type")) { - pw.println("\t\tret += \"\"+\"type = \" + XlibWrapper.eventToString[get_type()] +\", \";"); + pw.println("\t\tret.append(\"type = \").append( XlibWrapper.eventToString[get_type()] ).append(\", \");"); } else if (name.equals("window")){ - pw.println("\t\tret += \"\"+\"window = \" + getWindow(get_window()) + \", \";"); + pw.println("\t\tret.append(\"window = \" ).append( getWindow(get_window()) ).append(\", \");"); } else if (type == AtomicType.TYPE_ARRAY) { - pw.print("\t\tret += \"{\""); + pw.print("\t\tret.append(\"{\")"); for (int i = 0; i < tp.getArrayLength(); i++) { - pw.print(" + get_" + name + "(" + i + ") + \" \""); + pw.print("\n\t\t.append( get_" + name + "(" + i + ") ).append(\" \")"); } - pw.println(" + \"}\";"); + pw.println(".append( \"}\");"); } else { - pw.println("\t\tret += \"\"+\"" + name +" = \" + get_"+ name+"() +\", \";"); + pw.println("\t\tret.append(\"" + name +" = \").append( get_"+ name+"() ).append(\", \");"); } } } - pw.println("\t\treturn ret;\n\t}\n\n"); + pw.println("\t\treturn ret.toString();\n\t}\n\n"); } public void writeStubs(StructType stp, PrintWriter pw) { diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/solaris/classes/sun/print/UnixPrintJob.java --- a/jdk/src/solaris/classes/sun/print/UnixPrintJob.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/solaris/classes/sun/print/UnixPrintJob.java Fri Nov 18 11:11:11 2011 -0800 @@ -38,7 +38,9 @@ import java.io.OutputStream; import java.io.OutputStreamWriter; import java.io.IOException; +import java.io.PrintWriter; import java.io.Reader; +import java.io.StringWriter; import java.io.UnsupportedEncodingException; import java.util.Vector; @@ -955,23 +957,49 @@ private class PrinterSpooler implements java.security.PrivilegedAction { PrintException pex; + private void handleProcessFailure(final Process failedProcess, + final String[] execCmd, final int result) throws IOException { + try (StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw)) { + pw.append("error=").append(Integer.toString(result)); + pw.append(" running:"); + for (String arg: execCmd) { + pw.append(" '").append(arg).append("'"); + } + try (InputStream is = failedProcess.getErrorStream(); + InputStreamReader isr = new InputStreamReader(is); + BufferedReader br = new BufferedReader(isr)) { + while (br.ready()) { + pw.println(); + pw.append("\t\t").append(br.readLine()); + } + } finally { + pw.flush(); + throw new IOException(sw.toString()); + } + } + } + public Object run() { + if (spoolFile == null || !spoolFile.exists()) { + pex = new PrintException("No spool file"); + notifyEvent(PrintJobEvent.JOB_FAILED); + return null; + } try { /** * Spool to the printer. */ - if (spoolFile == null || !spoolFile.exists()) { - pex = new PrintException("No spool file"); - notifyEvent(PrintJobEvent.JOB_FAILED); - return null; - } String fileName = spoolFile.getAbsolutePath(); String execCmd[] = printExecCmd(mDestination, mOptions, mNoJobSheet, jobName, copies, fileName); Process process = Runtime.getRuntime().exec(execCmd); process.waitFor(); - spoolFile.delete(); + final int result = process.exitValue(); + if (0 != result) { + handleProcessFailure(process, execCmd, result); + } notifyEvent(PrintJobEvent.DATA_TRANSFER_COMPLETE); } catch (IOException ex) { notifyEvent(PrintJobEvent.JOB_FAILED); @@ -981,6 +1009,7 @@ notifyEvent(PrintJobEvent.JOB_FAILED); pex = new PrintException(ie); } finally { + spoolFile.delete(); notifyEvent(PrintJobEvent.NO_MORE_EVENTS); } return null; diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_config.h --- a/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_config.h Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/solaris/native/sun/awt/splashscreen/splashscreen_config.h Fri Nov 18 11:11:11 2011 -0800 @@ -32,7 +32,7 @@ #include #include #include -#include +#include #include #include #include diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/windows/classes/java/lang/ProcessImpl.java --- a/jdk/src/windows/classes/java/lang/ProcessImpl.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/windows/classes/java/lang/ProcessImpl.java Fri Nov 18 11:11:11 2011 -0800 @@ -60,10 +60,11 @@ throws IOException { if (append) { + String path = f.getPath(); SecurityManager sm = System.getSecurityManager(); if (sm != null) - sm.checkWrite(f.getPath()); - long handle = openForAtomicAppend(f.getPath()); + sm.checkWrite(path); + long handle = openForAtomicAppend(path); final FileDescriptor fd = new FileDescriptor(); fdAccess.setHandle(fd, handle); return AccessController.doPrivileged( diff -r d7f6c062c454 -r 41ce4af91010 jdk/src/windows/native/sun/windows/awt_Window.cpp --- a/jdk/src/windows/native/sun/windows/awt_Window.cpp Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/src/windows/native/sun/windows/awt_Window.cpp Fri Nov 18 11:11:11 2011 -0800 @@ -355,7 +355,7 @@ RECT rect; CalculateWarningWindowBounds(env, &rect); - ::SetWindowPos(warningWindow, IsAlwaysOnTop() ? HWND_TOPMOST : GetHWnd(), + ::SetWindowPos(warningWindow, IsAlwaysOnTop() ? HWND_TOPMOST : HWND_NOTOPMOST, rect.left, rect.top, rect.right - rect.left, rect.bottom - rect.top, SWP_ASYNCWINDOWPOS | SWP_NOACTIVATE | @@ -835,7 +835,7 @@ if (securityAnimationKind == akShow) { ::SetWindowPos(warningWindow, - IsAlwaysOnTop() ? HWND_TOPMOST : GetHWnd(), + IsAlwaysOnTop() ? HWND_TOPMOST : HWND_NOTOPMOST, 0, 0, 0, 0, SWP_NOACTIVATE | SWP_NOSIZE | SWP_NOMOVE | SWP_SHOWWINDOW | SWP_NOOWNERZORDER); diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/java/util/Currency/CurrencyTest.java --- a/jdk/test/java/util/Currency/CurrencyTest.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/test/java/util/Currency/CurrencyTest.java Fri Nov 18 11:11:11 2011 -0800 @@ -128,18 +128,20 @@ checkCountryCurrency(country1[i], currency1[i]); } - // check currency changes - String[] switchOverCtry = {"DE", "FR", "ES", "IT", "NL", "BE", "TR", "RO", "AZ", "MZ", "GH", "VE"}; - String[] switchOverOld = {"DEM", "FRF", "ESP", "ITL", "NLG", "BEF", "TRL", "ROL", "AZM", "MZM", "GHC", "VEB"}; - String[] switchOverNew = {"EUR", "EUR", "EUR", "EUR", "EUR", "EUR", "TRY", "RON", "AZN", "MZN", "GHS", "VEF"}; - String[] switchOverTZ = {"Europe/Paris", "Europe/Paris", "Europe/Paris", "Europe/Paris", - "Europe/Paris", "Europe/Paris", "Asia/Istanbul", "Europe/Bucharest", - "Asia/Baku", "Africa/Maputo", "Africa/Accra", "America/Caracas"}; - int[] switchOverYear = {2002, 2002, 2002, 2002, 2002, 2002, 2005, 2005, 2006, 2006, 2007, 2008}; - int[] switchOverMonth = {Calendar.JANUARY, Calendar.JANUARY, Calendar.JANUARY, Calendar.JANUARY, - Calendar.JANUARY, Calendar.JANUARY, Calendar.JANUARY, Calendar.JULY, - Calendar.JANUARY, Calendar.JULY, Calendar.JULY, Calendar.JANUARY}; - int[] switchOverDay = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; + /* + * check currency changes + * In current implementation, there is no data of old currency and transition date at jdk/src/share/classes/java/util/CurrencyData.properties. + * So, all the switch data arrays are empty. In the future, if data of old currency and transition date are necessary for any country, the + * arrays here can be updated so that the program can check the currency switch. + */ + String[] switchOverCtry = {}; + String[] switchOverOld = {}; + String[] switchOverNew = {}; + String[] switchOverTZ = {}; + int[] switchOverYear = {}; + int[] switchOverMonth = {}; + int[] switchOverDay = {}; + for (int i = 0; i < switchOverCtry.length; i++) { TimeZone.setDefault(TimeZone.getTimeZone(switchOverTZ[i])); Calendar date = new GregorianCalendar(switchOverYear[i], switchOverMonth[i], switchOverDay[i]); diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/java/util/Currency/ValidateISO4217.java --- a/jdk/test/java/util/Currency/ValidateISO4217.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/test/java/util/Currency/ValidateISO4217.java Fri Nov 18 11:11:11 2011 -0800 @@ -92,7 +92,7 @@ /* Codes that are obsolete, do not have related country */ static final String otherCodes = - "ADP-AFA-ATS-AYM-BEF-BGL-BOV-BYB-CLF-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-NLG-PTE-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-USN-USS-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZWD-ZWN-ZWR"; + "ADP-AFA-ATS-AYM-AZM-BEF-BGL-BOV-BYB-CLF-CUC-CYP-DEM-EEK-ESP-FIM-FRF-GHC-GRD-GWP-IEP-ITL-LUF-MGF-MTL-MXV-MZM-NLG-PTE-ROL-RUR-SDD-SIT-SKK-SRG-TMM-TPE-TRL-VEF-USN-USS-VEB-XAG-XAU-XBA-XBB-XBC-XBD-XDR-XFO-XFU-XPD-XPT-XSU-XTS-XUA-XXX-YUM-ZWD-ZWN-ZWR"; static boolean err = false; diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/java/util/Currency/tablea1.txt --- a/jdk/test/java/util/Currency/tablea1.txt Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/test/java/util/Currency/tablea1.txt Fri Nov 18 11:11:11 2011 -0800 @@ -23,7 +23,7 @@ AU AUD 36 2 AT EUR 978 2 # MA 129 -AZ AZM 31 2 2005-12-31-20-00-00 AZN 944 2 +AZ AZN 944 2 BS BSD 44 2 BH BHD 48 3 BD BDT 50 2 @@ -96,7 +96,7 @@ GM GMD 270 2 GE GEL 981 2 DE EUR 978 2 -GH GHC 288 2 2007-07-01-00-00-00 GHS 936 2 +GH GHS 936 2 GI GIP 292 2 GR EUR 978 2 GL DKK 208 2 @@ -166,7 +166,7 @@ MS XCD 951 2 MA MAD 504 2 # MA 130 -MZ MZM 508 2 2006-06-30-22-00-00 MZN 943 2 +MZ MZN 943 2 MM MMK 104 2 # MA 134 ME EUR 978 2 @@ -200,7 +200,7 @@ PR USD 840 2 QA QAR 634 2 RE EUR 978 2 -RO ROL 946 2 2005-06-30-21-00-00 RON 946 2 +RO RON 946 2 RU RUB 643 2 RW RWF 646 0 SH SHP 654 2 @@ -266,7 +266,7 @@ UY UYU 858 2 UZ UZS 860 2 VU VUV 548 0 -VE VEB 862 2 2008-01-01-04-00-00 VEF 937 2 +VE VEF 937 2 VN VND 704 2 VG USD 840 2 VI USD 840 2 diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JEditorPane/4492274/bug4492274.java Fri Nov 18 11:11:11 2011 -0800 @@ -0,0 +1,111 @@ +/* + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* @test + * @bug 4492274 + * @summary Tests if JEditorPane.getPage() correctly returns anchor reference. + * @author Denis Sharypov + */ + +import sun.awt.SunToolkit; + +import javax.swing.*; +import javax.swing.text.html.HTMLEditorKit; +import java.awt.*; +import java.io.File; +import java.net.URL; + +public class bug4492274 { + + private static URL page; + + private static JEditorPane jep; + + public static void main(String args[]) throws Exception { + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + createAndShowGUI(); + } + }); + + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + page = new URL(page, "#linkname"); + jep.setPage(page); + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }); + + toolkit.realSync(); + + if (getPageAnchor() == null) { + throw new RuntimeException("JEditorPane.getPage() returns null anchor reference"); + } + + } + + private static String getPageAnchor() throws Exception { + final String[] result = new String[1]; + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + result[0] = jep.getPage().getRef(); + } + }); + + return result[0]; + } + + private static void createAndShowGUI() { + try { + File file = new File(System.getProperty("test.src", "."), "test.html"); + page = file.toURI().toURL(); + + JFrame f = new JFrame(); + + jep = new JEditorPane(); + jep.setEditorKit(new HTMLEditorKit()); + jep.setEditable(false); + jep.setPage(page); + + JScrollPane sp = new JScrollPane(jep); + + f.getContentPane().add(sp); + f.setSize(500, 500); + f.setVisible(true); + + } catch (Exception e) { + throw new RuntimeException(e); + } + } +} diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/javax/swing/JEditorPane/4492274/test.html --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JEditorPane/4492274/test.html Fri Nov 18 11:11:11 2011 -0800 @@ -0,0 +1,7 @@ + + +top + +bottom + + diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/javax/swing/JSlider/6348946/bug6348946.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JSlider/6348946/bug6348946.java Fri Nov 18 11:11:11 2011 -0800 @@ -0,0 +1,172 @@ +/* + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6348946 + * @summary Tests that JSlider's thumb moves in the right direction + * when it is used as a JTable cell editor. + * @author Mikhail Lapshin +*/ + +import sun.awt.SunToolkit; + +import java.awt.*; +import java.awt.event.InputEvent; +import javax.swing.*; +import javax.swing.event.*; +import javax.swing.table.*; + +public class bug6348946 { + + private static JFrame frame; + + private static JPanel panel; + + private static volatile boolean passed = false; + + public static void main(String[] args) throws Exception { + String lf = "javax.swing.plaf.metal.MetalLookAndFeel"; + UIManager.setLookAndFeel(lf); + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + try { + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + setupUI(); + } + }); + toolkit.realSync(); + clickOnSlider(); + toolkit.realSync(); + checkResult(); + } finally { + stopEDT(); + } + } + + private static void setupUI() { + frame = new JFrame(); + + panel = new JPanel(); + panel.setLayout(new BorderLayout()); + panel.add(new ParameterTable(), BorderLayout.CENTER); + frame.getContentPane().add(panel); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + } + + private static void clickOnSlider() throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(10); + + Rectangle rect = getPanelRectangle(); + + double clickX = rect.getX() + rect.getWidth() / 4; + double clickY = rect.getY() + rect.getHeight() / 2; + robot.mouseMove((int) clickX, (int) clickY); + + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + } + + private static void checkResult(){ + if (passed) { + System.out.println("Test passed"); + } else { + throw new RuntimeException("The thumb moved " + + "to the right instead of the left!"); + } + } + + private static void stopEDT() { + SwingUtilities.invokeLater(new Runnable() { + public void run() { + frame.dispose(); + } + }); + } + + private static class ParameterTable extends JTable { + public ParameterTable() { + super(new Object[][]{{5}}, new String[]{"Value"}); + getColumnModel().getColumn(0).setCellRenderer(new Renderer()); + getColumnModel().getColumn(0).setCellEditor(new Editor()); + } + } + + private static class Renderer implements TableCellRenderer { + private JSlider slider = new JSlider(0, 10); + + public Component getTableCellRendererComponent(JTable table, + Object value, + boolean isSelected, + boolean hasFocus, + int row, int col) { + int val = (Integer) value; + slider.setValue(val); + return slider; + } + } + + private static class Editor extends AbstractCellEditor implements TableCellEditor { + private JSlider slider = new JSlider(0, 10); + + public Component getTableCellEditorComponent(JTable table, Object value, + boolean isSelected, + int row, int col) { + int val = (Integer) value; + slider.setValue(val); + return slider; + } + + public Editor() { + slider.addChangeListener(new ChangeListener() { + public void stateChanged(ChangeEvent e) { + if (!slider.getValueIsAdjusting()) { + passed = slider.getValue() <= 5; + } + } + }); + } + + public Object getCellEditorValue() { + return slider.getValue(); + } + } + + private static Rectangle getPanelRectangle() throws Exception{ + final Rectangle[] result = new Rectangle[1]; + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + result[0] = new Rectangle(panel.getLocationOnScreen(), panel.getSize()); + } + }); + + return result[0]; + } +} diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/javax/swing/JTextArea/7049024/bug7049024.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/JTextArea/7049024/bug7049024.java Fri Nov 18 11:11:11 2011 -0800 @@ -0,0 +1,134 @@ +/* + * Copyright (c) 2011 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * Portions Copyright (c) 2011 IBM Corporation + */ + +/* @test + * @bug 7049024 + * @summary DnD fails with JTextArea and JTextField + * @author Sean Chou + */ + +import sun.awt.SunToolkit; + +import javax.swing.*; +import javax.swing.text.DefaultCaret; +import java.awt.*; +import java.awt.datatransfer.Clipboard; +import java.awt.datatransfer.DataFlavor; + +public class bug7049024 { + public static Clipboard clipboard = null; + + public static JTextField textField = null; + + // This button is used to move focus away from textField. + public static JButton button = null; + + public static JFrame frame = null; + + public static DefaultCaret caret = null; + + public static void main(String[] args) throws Exception { + + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + frame = new JFrame("Test"); + textField = new JTextField("test selection for textfield"); + button = new JButton("To compete the focus"); + + frame.setLayout(new FlowLayout()); + frame.getContentPane().add(textField); + frame.getContentPane().add(button); + + frame.pack(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setVisible(true); + } + }); + toolkit.realSync(); + + clipboard = textField.getToolkit().getSystemSelection(); + if (null == clipboard) { + return; + } + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + textField.requestFocusInWindow(); + } + }); + toolkit.realSync(); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + caret = (DefaultCaret) textField.getCaret(); + caret.setDot(2); + caret.moveDot(4); + } + }); + toolkit.realSync(); + + String oldSelection = (String) clipboard.getData(DataFlavor.stringFlavor); + System.out.println("oldSelection is " + oldSelection); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + button.requestFocusInWindow(); + } + }); + toolkit.realSync(); // So JTextField loses the focus. + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + caret.setDot(4); + caret.moveDot(6); + } + }); + toolkit.realSync(); + + String newSelection = (String) clipboard.getData(DataFlavor.stringFlavor); + System.out.println("newSelection is " + newSelection); + + boolean passed = newSelection.equals(oldSelection); + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + frame.dispose(); + } + }); + + if (!passed) { + throw new RuntimeException("The test for bug 7049024 failed"); + } + } +} diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/javax/swing/ToolTipManager/Test6256140.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/swing/ToolTipManager/Test6256140.java Fri Nov 18 11:11:11 2011 -0800 @@ -0,0 +1,143 @@ +/* + * Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6256140 + * @summary Esc key doesn't restore old value in JFormattedtextField when ToolTip is set + * @author Alexander Potochkin + * @run main Test6256140 + */ + +import sun.awt.SunToolkit; + +import javax.swing.*; +import java.awt.*; +import java.awt.event.KeyEvent; + +public class Test6256140 { + + private static volatile JFormattedTextField ft; + + private final static String initialText = "value"; + private final static JLabel toolTipLabel = new JLabel("tip"); + + public static void main(String[] args) throws Exception { + + Robot robot = new Robot(); + robot.setAutoDelay(10); + SunToolkit toolkit = (SunToolkit) Toolkit.getDefaultToolkit(); + + SwingUtilities.invokeAndWait(new Runnable() { + public void run() { + createAndShowGUI(); + } + }); + toolkit.realSync(); + + Point point = ft.getLocationOnScreen(); + robot.mouseMove(point.x, point.y); + robot.mouseMove(point.x + 3, point.y + 3); + + robot.keyPress(KeyEvent.VK_A); + robot.keyRelease(KeyEvent.VK_A); + toolkit.realSync(); + + if (!isTooltipShowning()) { + throw new RuntimeException("Tooltip is not shown"); + } + + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + toolkit.realSync(); + + if (isTooltipShowning()) { + throw new RuntimeException("Tooltip must be hidden now"); + } + + if (isTextEqual()) { + throw new RuntimeException("FormattedTextField must *not* cancel the updated value this time"); + } + + robot.keyPress(KeyEvent.VK_ESCAPE); + robot.keyRelease(KeyEvent.VK_ESCAPE); + toolkit.realSync(); + + if (!isTextEqual()) { + throw new RuntimeException("FormattedTextField must cancel the updated value"); + } + } + + private static boolean isTooltipShowning() throws Exception { + final boolean[] result = new boolean[1]; + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + result[0] = toolTipLabel.isShowing(); + } + }); + + return result[0]; + } + + private static boolean isTextEqual() throws Exception { + final boolean[] result = new boolean[1]; + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + result[0] = initialText.equals(ft.getText()); + } + }); + + return result[0]; + } + + private static void createAndShowGUI() { + ToolTipManager.sharedInstance().setDismissDelay(Integer.MAX_VALUE); + ToolTipManager.sharedInstance().setInitialDelay(0); + + final JFrame frame = new JFrame(); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + frame.setLayout(new FlowLayout()); + + ft = new JFormattedTextField() { + + public JToolTip createToolTip() { + JToolTip toolTip = super.createToolTip(); + toolTip.setLayout(new BorderLayout()); + toolTip.add(toolTipLabel); + return toolTip; + } + }; + ft.setToolTipText(" "); + ft.setValue(initialText); + frame.add(ft); + + frame.pack(); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + ft.requestFocus(); + } +} diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/main.java --- a/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/main.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/test/sun/security/ssl/com/sun/net/ssl/internal/ssl/GenSSLConfigs/main.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,10 +1,7 @@ /* * @test * @build TestThread Traffic Handler ServerHandler ServerThread ClientThread - * @run main/othervm/timeout=140 main - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. + * @run main/othervm/timeout=140 -Djsse.enableCBCProtection=false main * @summary Make sure that different configurations of SSL sockets work */ diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java --- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/CheckStatus.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,8 @@ * This is a simple hack to test a bunch of conditions and check * their return codes. * + * @run main/othervm -Djsse.enableCBCProtection=false CheckStatus + * * @author Brad Wetmore */ diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java --- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargeBufs.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2004, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2004, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -30,6 +30,8 @@ * This is to test larger buffer arrays, and make sure the maximum * is being passed. * + * @run main/othervm -Djsse.enableCBCProtection=false LargeBufs + * * @author Brad R. Wetmore */ diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargePacket.java --- a/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargePacket.java Fri Nov 18 16:13:39 2011 +0800 +++ b/jdk/test/sun/security/ssl/javax/net/ssl/NewAPIs/SSLEngine/LargePacket.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -27,10 +27,7 @@ * @bug 6388456 * @summary Need adjustable TLS max record size for interoperability * with non-compliant - * @run main/othervm LargePacket - * - * SunJSSE does not support dynamic system properties, no way to re-use - * system properties in samevm/agentvm mode. + * @run main/othervm -Djsse.enableCBCProtection=false LargePacket * * @author Xuelei Fan */ diff -r d7f6c062c454 -r 41ce4af91010 jdk/test/sun/text/resources/Collator/Bug6755060.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/sun/text/resources/Collator/Bug6755060.java Fri Nov 18 11:11:11 2011 -0800 @@ -0,0 +1,100 @@ +/* + * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * @test + * @bug 6755060 + * @summary updating collation tables for thai to make it consistent with CLDR 1.9 + */ + +import java.text.*; +import java.util.*; + +public class Bug6755060 { + + /******************************************************** + *********************************************************/ + public static void main (String[] args) { + + Locale reservedLocale = Locale.getDefault(); + + try{ + + int errors=0; + + Locale loc = new Locale ("th", "TH"); // Thai + + Locale.setDefault (loc); + Collator col = Collator.getInstance (); + + /* + * The original data "data" are the data to be sorted provided by the submitter of the CR. + * It's in correct order in accord with thai collation in CLDR 1.9. If we use old Java without this fix, + * the output order will be incorrect. Correct order will be turned into incorrect order. + + * If fix is there, "data" after sorting will be unchanged, same as "sortedData". If fix is lost (regression), + * "data" after sorting will be changed, not as "sortedData".(not correct anymore) + + * The submitter of the CR also gives a expected "sortedData" in the CR, but it's in accord with collation in CLDR 1.4. + * His data to be sorted are actually well sorted in accord with CLDR 1.9. + */ + + String[] data = {"\u0e01", "\u0e01\u0e2f", "\u0e01\u0e46", "\u0e01\u0e4f", "\u0e01\u0e5a", "\u0e01\u0e5b", "\u0e01\u0e4e", "\u0e01\u0e4c", "\u0e01\u0e48", "\u0e01\u0e01", "\u0e01\u0e4b\u0e01", "\u0e01\u0e4d", "\u0e01\u0e30", "\u0e01\u0e31\u0e01", "\u0e01\u0e32", "\u0e01\u0e33", "\u0e01\u0e34", "\u0e01\u0e35", "\u0e01\u0e36", "\u0e01\u0e37", "\u0e01\u0e38", "\u0e01\u0e39", "\u0e40\u0e01", "\u0e40\u0e01\u0e48", "\u0e40\u0e01\u0e49", "\u0e40\u0e01\u0e4b", "\u0e41\u0e01", "\u0e42\u0e01", "\u0e43\u0e01", "\u0e44\u0e01", "\u0e01\u0e3a", "\u0e24\u0e32", "\u0e24\u0e45", "\u0e40\u0e25", "\u0e44\u0e26"}; + + String[] sortedData = {"\u0e01", "\u0e01\u0e2f", "\u0e01\u0e46", "\u0e01\u0e4f", "\u0e01\u0e5a", "\u0e01\u0e5b", "\u0e01\u0e4e", "\u0e01\u0e4c", "\u0e01\u0e48", "\u0e01\u0e01", "\u0e01\u0e4b\u0e01", "\u0e01\u0e4d", "\u0e01\u0e30", "\u0e01\u0e31\u0e01", "\u0e01\u0e32", "\u0e01\u0e33", "\u0e01\u0e34", "\u0e01\u0e35", "\u0e01\u0e36", "\u0e01\u0e37", "\u0e01\u0e38", "\u0e01\u0e39", "\u0e40\u0e01", "\u0e40\u0e01\u0e48", "\u0e40\u0e01\u0e49", "\u0e40\u0e01\u0e4b", "\u0e41\u0e01", "\u0e42\u0e01", "\u0e43\u0e01", "\u0e44\u0e01", "\u0e01\u0e3a", "\u0e24\u0e32", "\u0e24\u0e45", "\u0e40\u0e25", "\u0e44\u0e26"}; + + Arrays.sort (data, col); + + System.out.println ("Using " + loc.getDisplayName()); + for (int i = 0; i < data.length; i++) { + System.out.println(data[i] + " : " + sortedData[i]); + if (sortedData[i].compareTo(data[i]) != 0) { + errors++; + } + }//end for + + if (errors > 0){ + StringBuffer expected = new StringBuffer(), actual = new StringBuffer(); + expected.append(sortedData[0]); + actual.append(data[0]); + + for (int i=1; i&' with an external RMI registry diff -r d7f6c062c454 -r 41ce4af91010 langtools/.hgtags --- a/langtools/.hgtags Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/.hgtags Fri Nov 18 11:11:11 2011 -0800 @@ -133,3 +133,5 @@ b7a7e47c8d3daf7822abf7c37e5179ccbbf53008 jdk8-b09 f6c783e18bdf4d46a0ab273868afebbf32600ff7 jdk8-b10 4bf01f1c4e3464f378959d10f3983a0469181d94 jdk8-b11 +f2d6ed25857dfa7f269ac66e13666d648cb988c6 jdk8-b12 +ae25163501bc7477cd907e26a006a6f1b05fdb6d jdk8-b13 diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTaskImpl.java Fri Nov 18 11:11:11 2011 -0800 @@ -325,7 +325,7 @@ ListBuffer elements = new ListBuffer(); for (JCCompilationUnit unit : units) { for (JCTree node : unit.defs) { - if (node.getTag() == JCTree.CLASSDEF) { + if (node.hasTag(JCTree.Tag.CLASSDEF)) { JCClassDecl cdef = (JCClassDecl) node; if (cdef.sym != null) // maybe null if errors in anno processing elements.append(cdef.sym); @@ -383,12 +383,12 @@ private void handleFlowResults(Queue> queue, ListBuffer elems) { for (Env env: queue) { switch (env.tree.getTag()) { - case JCTree.CLASSDEF: + case CLASSDEF: JCClassDecl cdef = (JCClassDecl) env.tree; if (cdef.sym != null) elems.append(cdef.sym); break; - case JCTree.TOPLEVEL: + case TOPLEVEL: JCCompilationUnit unit = (JCCompilationUnit) env.tree; if (unit.packge != null) elems.append(unit.packge); diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java --- a/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/api/JavacTrees.java Fri Nov 18 11:11:11 2011 -0800 @@ -207,7 +207,7 @@ if (sym == null && TreeInfo.isDeclaration(tree)) { for (TreePath p = path; p != null; p = p.getParentPath()) { JCTree t = (JCTree) p.getLeaf(); - if (t.getTag() == JCTree.CLASSDEF) { + if (t.hasTag(JCTree.Tag.CLASSDEF)) { JCClassDecl ct = (JCClassDecl) t; if (ct.sym != null) { if ((ct.sym.flags_field & Flags.UNATTRIBUTED) != 0) { diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,8 @@ import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; +import static com.sun.tools.javac.tree.JCTree.Tag.*; + /** Enter annotations on symbols. Annotations accumulate in a queue, * which is processed at the top level of any set of recursive calls * requesting it be processed. @@ -148,7 +150,7 @@ return new Attribute.Compound(a.type, List.>nil()); } List args = a.args; - if (args.length() == 1 && args.head.getTag() != JCTree.ASSIGN) { + if (args.length() == 1 && !args.head.hasTag(ASSIGN)) { // special case: elided "value=" assumed args.head = make.at(args.head.pos). Assign(make.Ident(names.value), args.head); @@ -157,12 +159,12 @@ new ListBuffer>(); for (List tl = args; tl.nonEmpty(); tl = tl.tail) { JCExpression t = tl.head; - if (t.getTag() != JCTree.ASSIGN) { + if (!t.hasTag(ASSIGN)) { log.error(t.pos(), "annotation.value.must.be.name.value"); continue; } JCAssign assign = (JCAssign)t; - if (assign.lhs.getTag() != JCTree.IDENT) { + if (!assign.lhs.hasTag(IDENT)) { log.error(t.pos(), "annotation.value.must.be.name.value"); continue; } @@ -222,14 +224,14 @@ (((JCFieldAccess) tree).selected).type); } if ((expected.tsym.flags() & Flags.ANNOTATION) != 0) { - if (tree.getTag() != JCTree.ANNOTATION) { + if (!tree.hasTag(ANNOTATION)) { log.error(tree.pos(), "annotation.value.must.be.annotation"); expected = syms.errorType; } return enterAnnotation((JCAnnotation)tree, expected, env); } if (expected.tag == TypeTags.ARRAY) { // should really be isArray() - if (tree.getTag() != JCTree.NEWARRAY) { + if (!tree.hasTag(NEWARRAY)) { tree = make.at(tree.pos). NewArray(null, List.nil(), List.of(tree)); } diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Attr.java Fri Nov 18 11:11:11 2011 -0800 @@ -49,8 +49,13 @@ import com.sun.source.util.SimpleTreeVisitor; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Flags.ANNOTATION; +import static com.sun.tools.javac.code.Flags.BLOCK; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.ERRONEOUS; import static com.sun.tools.javac.code.TypeTags.*; +import static com.sun.tools.javac.code.TypeTags.WILDCARD; +import static com.sun.tools.javac.tree.JCTree.Tag.*; /** This is the main context-dependent analysis phase in GJC. It * encompasses name resolution, type checking and constant folding as @@ -245,7 +250,7 @@ ((v.flags() & HASINIT) != 0 || !((base == null || - (base.getTag() == JCTree.IDENT && TreeInfo.name(base) == names._this)) && + (base.hasTag(IDENT) && TreeInfo.name(base) == names._this)) && isAssignableAsBlankFinal(v, env)))) { if (v.isResourceVariable()) { //TWR resource log.error(pos, "try.resource.may.not.be.assigned", v); @@ -263,7 +268,7 @@ * @param tree The candidate tree. */ boolean isStaticReference(JCTree tree) { - if (tree.getTag() == JCTree.SELECT) { + if (tree.hasTag(SELECT)) { Symbol lsym = TreeInfo.symbol(((JCFieldAccess) tree).selected); if (lsym == null || lsym.kind != TYP) { return false; @@ -693,7 +698,7 @@ // disable implicit outer instance from being passed. // (This would be an illegal access to "this before super"). if (env.info.isSelfCall && - env.tree.getTag() == JCTree.NEWCLASS && + env.tree.hasTag(NEWCLASS) && ((JCNewClass) env.tree).encl == null) { c.flags_field |= NOOUTERTHIS; @@ -863,7 +868,7 @@ chk.checkDeprecatedAnnotation(tree.pos(), v); if (tree.init != null) { - if ((v.flags_field & FINAL) != 0 && tree.init.getTag() != JCTree.NEWCLASS) { + if ((v.flags_field & FINAL) != 0 && !tree.init.hasTag(NEWCLASS)) { // In this case, `v' is final. Ensure that it's initializer is // evaluated. v.getConstValue(); // ensure initializer is evaluated @@ -971,8 +976,8 @@ public void visitLabelled(JCLabeledStatement tree) { // Check that label is not used in an enclosing statement Env env1 = env; - while (env1 != null && env1.tree.getTag() != JCTree.CLASSDEF) { - if (env1.tree.getTag() == JCTree.LABELLED && + while (env1 != null && !env1.tree.hasTag(CLASSDEF)) { + if (env1.tree.hasTag(LABELLED) && ((JCLabeledStatement) env1.tree).label == tree.label) { log.error(tree.pos(), "label.already.in.use", tree.label); @@ -1052,14 +1057,14 @@ private static void addVars(List stats, Scope switchScope) { for (;stats.nonEmpty(); stats = stats.tail) { JCTree stat = stats.head; - if (stat.getTag() == JCTree.VARDEF) + if (stat.hasTag(VARDEF)) switchScope.enter(((JCVariableDecl) stat).sym); } } // where /** Return the selected enumeration constant symbol, or null. */ private Symbol enumConstant(JCTree tree, Type enumType) { - if (tree.getTag() != JCTree.IDENT) { + if (!tree.hasTag(IDENT)) { log.error(tree.pos(), "enum.label.must.be.unqualified.enum"); return syms.errSymbol; } @@ -1094,7 +1099,7 @@ localEnv; // Attribute resource declarations for (JCTree resource : tree.resources) { - if (resource.getTag() == JCTree.VARDEF) { + if (resource.hasTag(VARDEF)) { attribStat(resource, tryEnv); chk.checkType(resource, resource.type, syms.autoCloseableType, "try.not.applicable.to.type"); @@ -1312,7 +1317,7 @@ * @param env The environment current at the jump statement. */ private JCTree findJumpTarget(DiagnosticPosition pos, - int tag, + JCTree.Tag tag, Name label, Env env) { // Search environments outwards from the point of jump. @@ -1320,15 +1325,15 @@ LOOP: while (env1 != null) { switch (env1.tree.getTag()) { - case JCTree.LABELLED: + case LABELLED: JCLabeledStatement labelled = (JCLabeledStatement)env1.tree; if (label == labelled.label) { // If jump is a continue, check that target is a loop. - if (tag == JCTree.CONTINUE) { - if (labelled.body.getTag() != JCTree.DOLOOP && - labelled.body.getTag() != JCTree.WHILELOOP && - labelled.body.getTag() != JCTree.FORLOOP && - labelled.body.getTag() != JCTree.FOREACHLOOP) + if (tag == CONTINUE) { + if (!labelled.body.hasTag(DOLOOP) && + !labelled.body.hasTag(WHILELOOP) && + !labelled.body.hasTag(FORLOOP) && + !labelled.body.hasTag(FOREACHLOOP)) log.error(pos, "not.loop.label", label); // Found labelled statement target, now go inwards // to next non-labelled tree. @@ -1338,17 +1343,17 @@ } } break; - case JCTree.DOLOOP: - case JCTree.WHILELOOP: - case JCTree.FORLOOP: - case JCTree.FOREACHLOOP: + case DOLOOP: + case WHILELOOP: + case FORLOOP: + case FOREACHLOOP: if (label == null) return env1.tree; break; - case JCTree.SWITCH: - if (label == null && tag == JCTree.BREAK) return env1.tree; + case SWITCH: + if (label == null && tag == BREAK) return env1.tree; break; - case JCTree.METHODDEF: - case JCTree.CLASSDEF: + case METHODDEF: + case CLASSDEF: break LOOP; default: } @@ -1356,7 +1361,7 @@ } if (label != null) log.error(pos, "undef.label", label); - else if (tag == JCTree.CONTINUE) + else if (tag == CONTINUE) log.error(pos, "cont.outside.loop"); else log.error(pos, "break.outside.switch.loop"); @@ -1452,7 +1457,7 @@ if (encl.tag == CLASS) { // we are calling a nested class - if (tree.meth.getTag() == JCTree.SELECT) { + if (tree.meth.hasTag(SELECT)) { JCTree qualifier = ((JCFieldAccess) tree.meth).selected; // We are seeing a prefixed call, of the form @@ -1468,7 +1473,7 @@ rs.resolveImplicitThis(tree.meth.pos(), localEnv, site, true); } - } else if (tree.meth.getTag() == JCTree.SELECT) { + } else if (tree.meth.hasTag(SELECT)) { log.error(tree.meth.pos(), "illegal.qual.not.icls", site.tsym); } @@ -1522,7 +1527,7 @@ // as a special case, array.clone() has a result that is // the same as static type of the array being cloned - if (tree.meth.getTag() == JCTree.SELECT && + if (tree.meth.hasTag(SELECT) && allowCovariantReturns && methName == names.clone && types.isArray(((JCFieldAccess) tree.meth).selected.type)) @@ -1531,7 +1536,7 @@ // as a special case, x.getClass() has type Class if (allowGenerics && methName == names.getClass && tree.args.isEmpty()) { - Type qualifier = (tree.meth.getTag() == JCTree.SELECT) + Type qualifier = (tree.meth.hasTag(SELECT)) ? ((JCFieldAccess) tree.meth).selected.type : env.enclClass.sym.type; restype = new @@ -1560,7 +1565,7 @@ JCMethodDecl enclMethod = env.enclMethod; if (enclMethod != null && enclMethod.name == names.init) { JCBlock body = enclMethod.body; - if (body.stats.head.getTag() == JCTree.EXEC && + if (body.stats.head.hasTag(EXEC) && ((JCExpressionStatement) body.stats.head).expr == tree) return true; } @@ -1591,7 +1596,7 @@ // complete class name to be fully qualified JCExpression clazz = tree.clazz; // Class field following new JCExpression clazzid = // Identifier in class field - (clazz.getTag() == JCTree.TYPEAPPLY) + (clazz.hasTag(TYPEAPPLY)) ? ((JCTypeApply) clazz).clazz : clazz; @@ -1610,7 +1615,7 @@ attribExpr(tree.encl, env)); clazzid1 = make.at(clazz.pos).Select(make.Type(encltype), ((JCIdent) clazzid).name); - if (clazz.getTag() == JCTree.TYPEAPPLY) + if (clazz.hasTag(TYPEAPPLY)) clazz = make.at(tree.pos). TypeApply(clazzid1, ((JCTypeApply) clazz).arguments); @@ -1689,7 +1694,7 @@ // Enums may not be instantiated except implicitly if (allowEnums && (clazztype.tsym.flags_field&Flags.ENUM) != 0 && - (env.tree.getTag() != JCTree.VARDEF || + (!env.tree.hasTag(VARDEF) || (((JCVariableDecl) env.tree).mods.flags&Flags.ENUM) == 0 || ((JCVariableDecl) env.tree).init != tree)) log.error(tree.pos(), "enum.cant.be.instantiated"); @@ -1930,7 +1935,7 @@ Name name = TreeInfo.name(arg); if (name == names._this || name == names._super) return arg; - int optag = JCTree.NULLCHK; + JCTree.Tag optag = NULLCHK; JCUnary tree = make.at(arg.pos).Unary(optag, arg); tree.operator = syms.nullcheck; tree.type = arg.type; @@ -1991,7 +1996,7 @@ Type operand = attribExpr(tree.rhs, env); // Find operator. Symbol operator = tree.operator = rs.resolveBinaryOperator( - tree.pos(), tree.getTag() - JCTree.ASGOffset, env, + tree.pos(), tree.getTag().noAssignOp(), env, owntype, operand); if (operator.kind == MTH && @@ -1999,7 +2004,7 @@ !operand.isErroneous()) { chk.checkOperator(tree.pos(), (OperatorSymbol)operator, - tree.getTag() - JCTree.ASGOffset, + tree.getTag().noAssignOp(), owntype, operand); chk.checkDivZero(tree.rhs.pos(), operator, operand); @@ -2012,7 +2017,7 @@ public void visitUnary(JCUnary tree) { // Attribute arguments. - Type argtype = (JCTree.PREINC <= tree.getTag() && tree.getTag() <= JCTree.POSTDEC) + Type argtype = (tree.getTag().isIncOrDecUnaryOp()) ? attribTree(tree.arg, env, VAR, Type.noType) : chk.checkNonVoid(tree.arg.pos(), attribExpr(tree.arg, env)); @@ -2023,7 +2028,7 @@ Type owntype = types.createErrorType(tree.type); if (operator.kind == MTH && !argtype.isErroneous()) { - owntype = (JCTree.PREINC <= tree.getTag() && tree.getTag() <= JCTree.POSTDEC) + owntype = (tree.getTag().isIncOrDecUnaryOp()) ? tree.arg.type : operator.type.getReturnType(); int opc = ((OperatorSymbol)operator).opcode; @@ -2621,7 +2626,7 @@ canOwnInitializer(env.info.scope.owner) && v.owner == env.info.scope.owner.enclClass() && ((v.flags() & STATIC) != 0) == Resolve.isStatic(env) && - (env.tree.getTag() != JCTree.ASSIGN || + (!env.tree.hasTag(ASSIGN) || TreeInfo.skipParens(((JCAssign) env.tree).lhs) != tree)) { String suffix = (env.info.enclVar == v) ? "self.ref" : "forward.ref"; @@ -2812,10 +2817,10 @@ } Type elemtype = types.elemtype(argtype); switch (tree.getTag()) { - case JCTree.APPLY: + case APPLY: ((JCMethodInvocation) tree).varargsElement = elemtype; break; - case JCTree.NEWCLASS: + case NEWCLASS: ((JCNewClass) tree).varargsElement = elemtype; break; default: @@ -2896,9 +2901,9 @@ if (clazzOuter.tag == CLASS) { Type site; JCExpression clazz = TreeInfo.typeIn(tree.clazz); - if (clazz.getTag() == JCTree.IDENT) { + if (clazz.hasTag(IDENT)) { site = env.enclClass.sym.type; - } else if (clazz.getTag() == JCTree.SELECT) { + } else if (clazz.hasTag(SELECT)) { site = ((JCFieldAccess) clazz).selected.type; } else throw new AssertionError(""+tree); if (clazzOuter.tag == CLASS && site != clazzOuter) { @@ -3068,7 +3073,7 @@ * Attribute an env for either a top level tree or class declaration. */ public void attrib(Env env) { - if (env.tree.getTag() == JCTree.TOPLEVEL) + if (env.tree.hasTag(TOPLEVEL)) attribTopLevel(env); else attribClass(env.tree.pos(), env.enclClass.sym); @@ -3245,7 +3250,7 @@ ((c.flags() & STATIC) == 0 || c.name == names.empty) && (TreeInfo.flags(l.head) & (STATIC | INTERFACE)) != 0) { Symbol sym = null; - if (l.head.getTag() == JCTree.VARDEF) sym = ((JCVariableDecl) l.head).sym; + if (l.head.hasTag(VARDEF)) sym = ((JCVariableDecl) l.head).sym; if (sym == null || sym.kind != VAR || ((VarSymbol) sym).getConstValue() == null) diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/comp/Check.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Check.java Fri Nov 18 11:11:11 2011 -0800 @@ -42,10 +42,14 @@ import com.sun.tools.javac.code.Symbol.*; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Flags.ANNOTATION; +import static com.sun.tools.javac.code.Flags.SYNCHRONIZED; import static com.sun.tools.javac.code.Kinds.*; import static com.sun.tools.javac.code.TypeTags.*; +import static com.sun.tools.javac.code.TypeTags.WILDCARD; import static com.sun.tools.javac.main.OptionName.*; +import static com.sun.tools.javac.tree.JCTree.Tag.*; /** Type checking helper class for the attribution phase. * @@ -987,7 +991,7 @@ * not final. */ private long implicitEnumFinalFlag(JCTree tree) { - if (tree.getTag() != JCTree.CLASSDEF) return 0; + if (!tree.hasTag(CLASSDEF)) return 0; class SpecialTreeVisitor extends JCTree.Visitor { boolean specialized; SpecialTreeVisitor() { @@ -1099,7 +1103,7 @@ // not parameterized at all. if (tree.type.getEnclosingType().isRaw()) log.error(tree.pos(), "improperly.formed.type.inner.raw.param"); - if (tree.clazz.getTag() == JCTree.SELECT) + if (tree.clazz.hasTag(SELECT)) visitSelectInternal((JCFieldAccess)tree.clazz); } } @@ -2413,7 +2417,7 @@ // count them off as they're annotated for (JCTree arg : a.args) { - if (arg.getTag() != JCTree.ASSIGN) continue; // recovery + if (!arg.hasTag(ASSIGN)) continue; // recovery JCAssign assign = (JCAssign) arg; Symbol m = TreeInfo.symbol(assign.lhs); if (m == null || m.type.isErroneous()) continue; @@ -2442,12 +2446,12 @@ a.args.tail == null) return; - if (a.args.head.getTag() != JCTree.ASSIGN) return; // error recovery + if (!a.args.head.hasTag(ASSIGN)) return; // error recovery JCAssign assign = (JCAssign) a.args.head; Symbol m = TreeInfo.symbol(assign.lhs); if (m.name != names.value) return; JCTree rhs = assign.rhs; - if (rhs.getTag() != JCTree.NEWARRAY) return; + if (!rhs.hasTag(NEWARRAY)) return; JCNewArray na = (JCNewArray) rhs; Set targets = new HashSet(); for (JCTree elem : na.elems) { @@ -2506,7 +2510,7 @@ try { tree.sym.flags_field |= LOCKED; for (JCTree def : tree.defs) { - if (def.getTag() != JCTree.METHODDEF) continue; + if (!def.hasTag(METHODDEF)) continue; JCMethodDecl meth = (JCMethodDecl)def; checkAnnotationResType(meth.pos(), meth.restype.type); } @@ -2614,7 +2618,7 @@ */ int checkOperator(DiagnosticPosition pos, OperatorSymbol operator, - int tag, + JCTree.Tag tag, Type left, Type right) { if (operator.opcode == ByteCodes.error) { @@ -2650,7 +2654,8 @@ * Check for empty statements after if */ void checkEmptyIf(JCIf tree) { - if (tree.thenpart.getTag() == JCTree.SKIP && tree.elsepart == null && lint.isEnabled(LintCategory.EMPTY)) + if (tree.thenpart.hasTag(SKIP) && tree.elsepart == null && + lint.isEnabled(LintCategory.EMPTY)) log.warning(LintCategory.EMPTY, tree.thenpart.pos(), "empty.if"); } @@ -2754,7 +2759,7 @@ } // where private boolean isCanonical(JCTree tree) { - while (tree.getTag() == JCTree.SELECT) { + while (tree.hasTag(SELECT)) { JCFieldAccess s = (JCFieldAccess) tree; if (s.sym.owner != TreeInfo.symbol(s.selected)) return false; diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Enter.java Fri Nov 18 11:11:11 2011 -0800 @@ -228,7 +228,7 @@ * only, and members go into the class member scope. */ Scope enterScope(Env env) { - return (env.tree.getTag() == JCTree.CLASSDEF) + return (env.tree.hasTag(JCTree.Tag.CLASSDEF)) ? ((JCClassDecl) env.tree).sym.members_field : env.info.scope; } diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/comp/Env.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Env.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Env.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -116,9 +116,9 @@ /** Return closest enclosing environment which points to a tree with given tag. */ - public Env enclosing(int tag) { + public Env enclosing(JCTree.Tag tag) { Env env1 = this; - while (env1 != null && env1.tree.getTag() != tag) env1 = env1.next; + while (env1 != null && !env1.tree.hasTag(tag)) env1 = env1.next; return env1; } diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Flow.java Fri Nov 18 11:11:11 2011 -0800 @@ -40,8 +40,10 @@ import com.sun.tools.javac.tree.JCTree.*; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Flags.BLOCK; import static com.sun.tools.javac.code.Kinds.*; import static com.sun.tools.javac.code.TypeTags.*; +import static com.sun.tools.javac.tree.JCTree.Tag.*; /** This pass implements dataflow analysis for Java programs. * Liveness analysis checks that every statement is reachable. @@ -321,7 +323,7 @@ log.error(exit.tree.pos(), "unreported.exception.default.constructor", exit.thrown); - } else if (exit.tree.getTag() == JCTree.VARDEF && + } else if (exit.tree.hasTag(VARDEF) && ((JCVariableDecl)exit.tree).sym.isResourceVariable()) { log.error(exit.tree.pos(), "unreported.exception.implicit.close", @@ -416,7 +418,7 @@ */ void letInit(JCTree tree) { tree = TreeInfo.skipParens(tree); - if (tree.getTag() == JCTree.IDENT || tree.getTag() == JCTree.SELECT) { + if (tree.hasTag(IDENT) || tree.hasTag(SELECT)) { Symbol sym = TreeInfo.symbol(tree); if (sym.kind == VAR) { letInit(tree.pos(), (VarSymbol)sym); @@ -452,7 +454,7 @@ pendingExits = oldPendingExits; for (; exits.nonEmpty(); exits = exits.tail) { PendingExit exit = exits.head; - if (exit.tree.getTag() == JCTree.BREAK && + if (exit.tree.hasTag(BREAK) && ((JCBreak) exit.tree).target == tree) { inits.andSet(exit.inits); uninits.andSet(exit.uninits); @@ -471,7 +473,7 @@ pendingExits = new ListBuffer(); for (; exits.nonEmpty(); exits = exits.tail) { PendingExit exit = exits.head; - if (exit.tree.getTag() == JCTree.CONTINUE && + if (exit.tree.hasTag(CONTINUE) && ((JCContinue) exit.tree).target == tree) { inits.andSet(exit.inits); uninits.andSet(exit.uninits); @@ -517,7 +519,7 @@ */ void scanDef(JCTree tree) { scanStat(tree); - if (tree != null && tree.getTag() == JCTree.BLOCK && !alive) { + if (tree != null && tree.hasTag(JCTree.Tag.BLOCK) && !alive) { log.error(tree.pos(), "initializer.must.be.able.to.complete.normally"); } @@ -528,7 +530,7 @@ void scanStat(JCTree tree) { if (!alive && tree != null) { log.error(tree.pos(), "unreachable.stmt"); - if (tree.getTag() != JCTree.SKIP) alive = true; + if (!tree.hasTag(SKIP)) alive = true; } scan(tree); } @@ -614,7 +616,7 @@ try { // define all the static fields for (List l = tree.defs; l.nonEmpty(); l = l.tail) { - if (l.head.getTag() == JCTree.VARDEF) { + if (l.head.hasTag(VARDEF)) { JCVariableDecl def = (JCVariableDecl)l.head; if ((def.mods.flags & STATIC) != 0) { VarSymbol sym = def.sym; @@ -626,7 +628,7 @@ // process all the static initializers for (List l = tree.defs; l.nonEmpty(); l = l.tail) { - if (l.head.getTag() != JCTree.METHODDEF && + if (!l.head.hasTag(METHODDEF) && (TreeInfo.flags(l.head) & STATIC) != 0) { scanDef(l.head); errorUncaught(); @@ -653,7 +655,7 @@ // define all the instance fields for (List l = tree.defs; l.nonEmpty(); l = l.tail) { - if (l.head.getTag() == JCTree.VARDEF) { + if (l.head.hasTag(VARDEF)) { JCVariableDecl def = (JCVariableDecl)l.head; if ((def.mods.flags & STATIC) == 0) { VarSymbol sym = def.sym; @@ -665,7 +667,7 @@ // process all the instance initializers for (List l = tree.defs; l.nonEmpty(); l = l.tail) { - if (l.head.getTag() != JCTree.METHODDEF && + if (!l.head.hasTag(METHODDEF) && (TreeInfo.flags(l.head) & STATIC) == 0) { scanDef(l.head); errorUncaught(); @@ -691,7 +693,7 @@ // process all the methods for (List l = tree.defs; l.nonEmpty(); l = l.tail) { - if (l.head.getTag() == JCTree.METHODDEF) { + if (l.head.hasTag(METHODDEF)) { scan(l.head); errorUncaught(); } @@ -760,7 +762,7 @@ PendingExit exit = exits.head; exits = exits.tail; if (exit.thrown == null) { - Assert.check(exit.tree.getTag() == JCTree.RETURN); + Assert.check(exit.tree.hasTag(RETURN)); if (isInitialConstructor) { inits = exit.inits; for (int i = firstadr; i < nextadr; i++) @@ -989,7 +991,7 @@ Bits uninits) { for (;stats.nonEmpty(); stats = stats.tail) { JCTree stat = stats.head; - if (stat.getTag() == JCTree.VARDEF) { + if (stat.hasTag(VARDEF)) { int adr = ((JCVariableDecl) stat).sym.adr; inits.excl(adr); uninits.incl(adr); @@ -1346,7 +1348,7 @@ public void visitUnary(JCUnary tree) { switch (tree.getTag()) { - case JCTree.NOT: + case NOT: scanCond(tree.arg); Bits t = initsWhenFalse; initsWhenFalse = initsWhenTrue; @@ -1355,8 +1357,8 @@ uninitsWhenFalse = uninitsWhenTrue; uninitsWhenTrue = t; break; - case JCTree.PREINC: case JCTree.POSTINC: - case JCTree.PREDEC: case JCTree.POSTDEC: + case PREINC: case POSTINC: + case PREDEC: case POSTDEC: scanExpr(tree.arg); letInit(tree.arg); break; @@ -1367,7 +1369,7 @@ public void visitBinary(JCBinary tree) { switch (tree.getTag()) { - case JCTree.AND: + case AND: scanCond(tree.lhs); Bits initsWhenFalseLeft = initsWhenFalse; Bits uninitsWhenFalseLeft = uninitsWhenFalse; @@ -1377,7 +1379,7 @@ initsWhenFalse.andSet(initsWhenFalseLeft); uninitsWhenFalse.andSet(uninitsWhenFalseLeft); break; - case JCTree.OR: + case OR: scanCond(tree.lhs); Bits initsWhenTrueLeft = initsWhenTrue; Bits uninitsWhenTrueLeft = uninitsWhenTrue; @@ -1418,7 +1420,7 @@ private boolean is292targetTypeCast(JCTypeCast tree) { boolean is292targetTypeCast = false; JCExpression expr = TreeInfo.skipParens(tree.expr); - if (expr.getTag() == JCTree.APPLY) { + if (expr.hasTag(APPLY)) { JCMethodInvocation apply = (JCMethodInvocation)expr; Symbol sym = TreeInfo.symbol(apply.meth); is292targetTypeCast = sym != null && diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Infer.java Fri Nov 18 11:11:11 2011 -0800 @@ -633,13 +633,13 @@ //the polymorphic signature call environment is nested. switch (env.next.tree.getTag()) { - case JCTree.TYPECAST: + case TYPECAST: JCTypeCast castTree = (JCTypeCast)env.next.tree; restype = (TreeInfo.skipParens(castTree.expr) == env.tree) ? castTree.clazz.type : syms.objectType; break; - case JCTree.EXEC: + case EXEC: JCTree.JCExpressionStatement execTree = (JCTree.JCExpressionStatement)env.next.tree; restype = (TreeInfo.skipParens(execTree.expr) == env.tree) ? diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Lower.java Fri Nov 18 11:11:11 2011 -0800 @@ -42,9 +42,11 @@ import com.sun.tools.javac.jvm.Target; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Flags.BLOCK; import static com.sun.tools.javac.code.Kinds.*; import static com.sun.tools.javac.code.TypeTags.*; import static com.sun.tools.javac.jvm.ByteCodes.*; +import static com.sun.tools.javac.tree.JCTree.Tag.*; /** This pass translates away some syntactic sugar: inner classes, * class literals, assertions, foreach loops, etc. @@ -303,7 +305,7 @@ Symbol constructor = TreeInfo.symbol(tree.meth); ClassSymbol c = (ClassSymbol)constructor.owner; if (c.hasOuterInstance() && - tree.meth.getTag() != JCTree.SELECT && + !tree.meth.hasTag(SELECT) && outerThisStack.head != null) visitSymbol(outerThisStack.head); } @@ -508,7 +510,7 @@ * @param optag The operators tree tag. * @param arg The operator's argument. */ - JCUnary makeUnary(int optag, JCExpression arg) { + JCUnary makeUnary(JCTree.Tag optag, JCExpression arg) { JCUnary tree = make.Unary(optag, arg); tree.operator = rs.resolveUnaryOperator( make_pos, optag, attrEnv, arg.type); @@ -521,7 +523,7 @@ * @param lhs The operator's left argument. * @param rhs The operator's right argument. */ - JCBinary makeBinary(int optag, JCExpression lhs, JCExpression rhs) { + JCBinary makeBinary(JCTree.Tag optag, JCExpression lhs, JCExpression rhs) { JCBinary tree = make.Binary(optag, lhs, rhs); tree.operator = rs.resolveBinaryOperator( make_pos, optag, attrEnv, lhs.type, rhs.type); @@ -534,10 +536,10 @@ * @param lhs The operator's left argument. * @param rhs The operator's right argument. */ - JCAssignOp makeAssignop(int optag, JCTree lhs, JCTree rhs) { + JCAssignOp makeAssignop(JCTree.Tag optag, JCTree lhs, JCTree rhs) { JCAssignOp tree = make.Assignop(optag, lhs, rhs); tree.operator = rs.resolveBinaryOperator( - make_pos, tree.getTag() - JCTree.ASGOffset, attrEnv, lhs.type, rhs.type); + make_pos, tree.getTag().noAssignOp(), attrEnv, lhs.type, rhs.type); tree.type = lhs.type; return tree; } @@ -720,7 +722,7 @@ // where private boolean isTranslatedClassAvailable(ClassSymbol c) { for (JCTree tree: translated) { - if (tree.getTag() == JCTree.CLASSDEF + if (tree.hasTag(CLASSDEF) && ((JCClassDecl) tree).sym == c) { return true; } @@ -802,13 +804,13 @@ private static int accessCode(JCTree tree, JCTree enclOp) { if (enclOp == null) return DEREFcode; - else if (enclOp.getTag() == JCTree.ASSIGN && + else if (enclOp.hasTag(ASSIGN) && tree == TreeInfo.skipParens(((JCAssign) enclOp).lhs)) return ASSIGNcode; - else if (JCTree.PREINC <= enclOp.getTag() && enclOp.getTag() <= JCTree.POSTDEC && + else if (enclOp.getTag().isIncOrDecUnaryOp() && tree == TreeInfo.skipParens(((JCUnary) enclOp).arg)) - return (enclOp.getTag() - JCTree.PREINC) * 2 + PREINCcode; - else if (JCTree.BITOR_ASG <= enclOp.getTag() && enclOp.getTag() <= JCTree.MOD_ASG && + return mapTagToUnaryOpCode(enclOp.getTag()); + else if (enclOp.getTag().isAssignop() && tree == TreeInfo.skipParens(((JCAssignOp) enclOp).lhs)) return accessCode(((OperatorSymbol) ((JCAssignOp) enclOp).operator).opcode); else @@ -832,39 +834,39 @@ /** Return tree tag for assignment operation corresponding * to given binary operator. */ - private static int treeTag(OperatorSymbol operator) { + private static JCTree.Tag treeTag(OperatorSymbol operator) { switch (operator.opcode) { case ByteCodes.ior: case ByteCodes.lor: - return JCTree.BITOR_ASG; + return BITOR_ASG; case ByteCodes.ixor: case ByteCodes.lxor: - return JCTree.BITXOR_ASG; + return BITXOR_ASG; case ByteCodes.iand: case ByteCodes.land: - return JCTree.BITAND_ASG; + return BITAND_ASG; case ByteCodes.ishl: case ByteCodes.lshl: case ByteCodes.ishll: case ByteCodes.lshll: - return JCTree.SL_ASG; + return SL_ASG; case ByteCodes.ishr: case ByteCodes.lshr: case ByteCodes.ishrl: case ByteCodes.lshrl: - return JCTree.SR_ASG; + return SR_ASG; case ByteCodes.iushr: case ByteCodes.lushr: case ByteCodes.iushrl: case ByteCodes.lushrl: - return JCTree.USR_ASG; + return USR_ASG; case ByteCodes.iadd: case ByteCodes.ladd: case ByteCodes.fadd: case ByteCodes.dadd: case ByteCodes.string_add: - return JCTree.PLUS_ASG; + return PLUS_ASG; case ByteCodes.isub: case ByteCodes.lsub: case ByteCodes.fsub: case ByteCodes.dsub: - return JCTree.MINUS_ASG; + return MINUS_ASG; case ByteCodes.imul: case ByteCodes.lmul: case ByteCodes.fmul: case ByteCodes.dmul: - return JCTree.MUL_ASG; + return MUL_ASG; case ByteCodes.idiv: case ByteCodes.ldiv: case ByteCodes.fdiv: case ByteCodes.ddiv: - return JCTree.DIV_ASG; + return DIV_ASG; case ByteCodes.imod: case ByteCodes.lmod: case ByteCodes.fmod: case ByteCodes.dmod: - return JCTree.MOD_ASG; + return MOD_ASG; default: throw new AssertionError(); } @@ -1003,7 +1005,7 @@ if (!currentClass.isSubClass(sym.owner, types)) return true; if ((sym.flags() & STATIC) != 0 || - tree.getTag() != JCTree.SELECT || + !tree.hasTag(SELECT) || TreeInfo.name(((JCFieldAccess) tree).selected) == names._super) return false; return !((JCFieldAccess) tree).selected.type.tsym.isSubClass(currentClass, types); @@ -1018,7 +1020,7 @@ if (protAccess) { Symbol qualifier = null; ClassSymbol c = currentClass; - if (tree.getTag() == JCTree.SELECT && (sym.flags() & STATIC) == 0) { + if (tree.hasTag(SELECT) && (sym.flags() & STATIC) == 0) { qualifier = ((JCFieldAccess) tree).selected.type.tsym; while (!qualifier.isSubClass(c, types)) { c = c.owner.enclClass(); @@ -1058,7 +1060,7 @@ Assert.check(sym != null && (sym.flags_field & FINAL) != 0); tree = make.at(tree.pos).Ident(sym); } - JCExpression base = (tree.getTag() == JCTree.SELECT) ? ((JCFieldAccess) tree).selected : null; + JCExpression base = (tree.hasTag(SELECT)) ? ((JCFieldAccess) tree).selected : null; switch (sym.kind) { case TYP: if (sym.owner.kind != PCK) { @@ -1068,11 +1070,11 @@ while (base != null && TreeInfo.symbol(base) != null && TreeInfo.symbol(base).kind != PCK) { - base = (base.getTag() == JCTree.SELECT) + base = (base.hasTag(SELECT)) ? ((JCFieldAccess) base).selected : null; } - if (tree.getTag() == JCTree.IDENT) { + if (tree.hasTag(IDENT)) { ((JCIdent) tree).name = flatname; } else if (base == null) { tree = make.at(tree.pos).Ident(sym); @@ -1220,6 +1222,42 @@ } } + /** Maps unary operator integer codes to JCTree.Tag objects + * @param unaryOpCode the unary operator code + */ + private static Tag mapUnaryOpCodeToTag(int unaryOpCode){ + switch (unaryOpCode){ + case PREINCcode: + return PREINC; + case PREDECcode: + return PREDEC; + case POSTINCcode: + return POSTINC; + case POSTDECcode: + return POSTDEC; + default: + return NO_TAG; + } + } + + /** Maps JCTree.Tag objects to unary operator integer codes + * @param tag the JCTree.Tag + */ + private static int mapTagToUnaryOpCode(Tag tag){ + switch (tag){ + case PREINC: + return PREINCcode; + case PREDEC: + return PREDECcode; + case POSTINC: + return POSTINCcode; + case POSTDEC: + return POSTDECcode; + default: + return -1; + } + } + /** Construct definition of an access method. * @param pos The source code position of the definition. * @param vsym The private or protected symbol. @@ -1259,8 +1297,7 @@ expr = make.Assign(ref, args.head); break; case PREINCcode: case POSTINCcode: case PREDECcode: case POSTDECcode: - expr = makeUnary( - ((acode1 - PREINCcode) >> 1) + JCTree.PREINC, ref); + expr = makeUnary(mapUnaryOpCodeToTag(acode1), ref); break; default: expr = make.Assignop( @@ -1576,7 +1613,7 @@ } private JCExpression makeNonNullCheck(JCExpression expression) { - return makeBinary(JCTree.NE, expression, makeNull()); + return makeBinary(NE, expression, makeNull()); } /** Construct a tree that represents the outer instance @@ -1808,7 +1845,7 @@ // $newcache.getClass().getComponentType().getClassLoader() : cl$" JCExpression clvalue = make.Conditional( - makeBinary(JCTree.EQ, make.Ident(clsym), makeNull()), + makeBinary(EQ, make.Ident(clsym), makeNull()), make.Assign( make.Ident(clsym), makeCall( @@ -1976,7 +2013,7 @@ writer.xClassName(type).toString().replace('/', '.'); Symbol cs = cacheSym(pos, sig); return make_at(pos).Conditional( - makeBinary(JCTree.EQ, make.Ident(cs), makeNull()), + makeBinary(EQ, make.Ident(cs), makeNull()), make.Assign( make.Ident(cs), make.App( @@ -2023,7 +2060,7 @@ List.nil()); JCClassDecl containerDef = classDef(container); make_at(containerDef.pos()); - JCExpression notStatus = makeUnary(JCTree.NOT, make.App(make.Select( + JCExpression notStatus = makeUnary(NOT, make.App(make.Select( classOfType(types.erasure(outermostClass.type), containerDef.pos()), desiredAssertionStatusSym))); @@ -2032,7 +2069,7 @@ containerDef.defs = containerDef.defs.prepend(assertDisabledDef); } make_at(pos); - return makeUnary(JCTree.NOT, make.Ident(assertDisabledSym)); + return makeUnary(NOT, make.Ident(assertDisabledSym)); } @@ -2062,9 +2099,9 @@ JCTree abstractRval(JCTree rval, Type type, TreeBuilder builder) { rval = TreeInfo.skipParens(rval); switch (rval.getTag()) { - case JCTree.LITERAL: + case LITERAL: return builder.build(rval); - case JCTree.IDENT: + case IDENT: JCIdent id = (JCIdent) rval; if ((id.sym.flags() & FINAL) != 0 && id.sym.owner.kind == MTH) return builder.build(rval); @@ -2097,9 +2134,9 @@ JCTree abstractLval(JCTree lval, final TreeBuilder builder) { lval = TreeInfo.skipParens(lval); switch (lval.getTag()) { - case JCTree.IDENT: + case IDENT: return builder.build(lval); - case JCTree.SELECT: { + case SELECT: { final JCFieldAccess s = (JCFieldAccess)lval; JCTree selected = TreeInfo.skipParens(s.selected); Symbol lid = TreeInfo.symbol(s.selected); @@ -2110,7 +2147,7 @@ } }); } - case JCTree.INDEXED: { + case INDEXED: { final JCArrayAccess i = (JCArrayAccess)lval; return abstractRval(i.indexed, new TreeBuilder() { public JCTree build(final JCTree indexed) { @@ -2125,7 +2162,7 @@ } }); } - case JCTree.TYPECAST: { + case TYPECAST: { return abstractLval(((JCTypeCast)lval).expr, builder); } } @@ -2345,7 +2382,7 @@ for (List defs = tree.defs; defs.nonEmpty(); defs=defs.tail) { - if (defs.head.getTag() == JCTree.VARDEF && (((JCVariableDecl) defs.head).mods.flags & ENUM) != 0) { + if (defs.head.hasTag(VARDEF) && (((JCVariableDecl) defs.head).mods.flags & ENUM) != 0) { JCVariableDecl var = (JCVariableDecl)defs.head; visitEnumConstantDef(var, nextOrdinal++); values.append(make.QualIdent(var.sym)); @@ -2757,9 +2794,9 @@ List.nil() : List.of(translate(tree.detail)); if (!tree.cond.type.isFalse()) { cond = makeBinary - (JCTree.AND, + (AND, cond, - makeUnary(JCTree.NOT, tree.cond)); + makeUnary(NOT, tree.cond)); } result = make.If(cond, @@ -2816,7 +2853,7 @@ // first argument. if (c.hasOuterInstance()) { JCExpression thisArg; - if (tree.meth.getTag() == JCTree.SELECT) { + if (tree.meth.hasTag(SELECT)) { thisArg = attr. makeNullCheck(translate(((JCFieldAccess) tree.meth).selected)); tree.meth = make.Ident(constructor); @@ -2837,7 +2874,7 @@ // If the translated method itself is an Apply tree, we are // seeing an access method invocation. In this case, append // the method arguments to the arguments of the access method. - if (tree.meth.getTag() == JCTree.APPLY) { + if (tree.meth.hasTag(APPLY)) { JCMethodInvocation app = (JCMethodInvocation)tree.meth; app.args = tree.args.prependList(app.args); result = app; @@ -2971,7 +3008,7 @@ // If translated left hand side is an Apply, we are // seeing an access method invocation. In this case, append // right hand side as last argument of the access method. - if (tree.lhs.getTag() == JCTree.APPLY) { + if (tree.lhs.hasTag(APPLY)) { JCMethodInvocation app = (JCMethodInvocation)tree.lhs; app.args = List.of(tree.rhs).prependList(app.args); result = app; @@ -2988,7 +3025,7 @@ // (but without recomputing x) JCTree newTree = abstractLval(tree.lhs, new TreeBuilder() { public JCTree build(final JCTree lhs) { - int newTag = tree.getTag() - JCTree.ASGOffset; + JCTree.Tag newTag = tree.getTag().noAssignOp(); // Erasure (TransTypes) can change the type of // tree.lhs. However, we can still get the // unerased type of tree.lhs as it is stored @@ -3018,7 +3055,7 @@ // If translated left hand side is an Apply, we are // seeing an access method invocation. In this case, append // right hand side as last argument of the access method. - if (tree.lhs.getTag() == JCTree.APPLY) { + if (tree.lhs.hasTag(APPLY)) { JCMethodInvocation app = (JCMethodInvocation)tree.lhs; // if operation is a += on strings, // make sure to convert argument to string @@ -3038,13 +3075,13 @@ // or // translate to tmp1=lval(e); tmp2=tmp1; (typeof tree)tmp1 OP 1; tmp2 // where OP is += or -= - final boolean cast = TreeInfo.skipParens(tree.arg).getTag() == JCTree.TYPECAST; + final boolean cast = TreeInfo.skipParens(tree.arg).hasTag(TYPECAST); return abstractLval(tree.arg, new TreeBuilder() { public JCTree build(final JCTree tmp1) { return abstractRval(tmp1, tree.arg.type, new TreeBuilder() { public JCTree build(final JCTree tmp2) { - int opcode = (tree.getTag() == JCTree.POSTINC) - ? JCTree.PLUS_ASG : JCTree.MINUS_ASG; + JCTree.Tag opcode = (tree.hasTag(POSTINC)) + ? PLUS_ASG : MINUS_ASG; JCTree lhs = cast ? make.TypeCast(tree.arg.type, (JCExpression)tmp1) : tmp1; @@ -3059,25 +3096,24 @@ } public void visitUnary(JCUnary tree) { - boolean isUpdateOperator = - JCTree.PREINC <= tree.getTag() && tree.getTag() <= JCTree.POSTDEC; + boolean isUpdateOperator = tree.getTag().isIncOrDecUnaryOp(); if (isUpdateOperator && !tree.arg.type.isPrimitive()) { switch(tree.getTag()) { - case JCTree.PREINC: // ++ e + case PREINC: // ++ e // translate to e += 1 - case JCTree.PREDEC: // -- e + case PREDEC: // -- e // translate to e -= 1 { - int opcode = (tree.getTag() == JCTree.PREINC) - ? JCTree.PLUS_ASG : JCTree.MINUS_ASG; + JCTree.Tag opcode = (tree.hasTag(PREINC)) + ? PLUS_ASG : MINUS_ASG; JCAssignOp newTree = makeAssignop(opcode, tree.arg, make.Literal(1)); result = translate(newTree, tree.type); return; } - case JCTree.POSTINC: // e ++ - case JCTree.POSTDEC: // e -- + case POSTINC: // e ++ + case POSTDEC: // e -- { result = translate(lowerBoxedPostop(tree), tree.type); return; @@ -3088,14 +3124,14 @@ tree.arg = boxIfNeeded(translate(tree.arg, tree), tree.type); - if (tree.getTag() == JCTree.NOT && tree.arg.type.constValue() != null) { + if (tree.hasTag(NOT) && tree.arg.type.constValue() != null) { tree.type = cfolder.fold1(bool_not, tree.arg.type); } // If translated left hand side is an Apply, we are // seeing an access method invocation. In this case, return // that access method invocation as result. - if (isUpdateOperator && tree.arg.getTag() == JCTree.APPLY) { + if (isUpdateOperator && tree.arg.hasTag(APPLY)) { result = tree.arg; } else { result = tree; @@ -3106,7 +3142,7 @@ List formals = tree.operator.type.getParameterTypes(); JCTree lhs = tree.lhs = translate(tree.lhs, formals.head); switch (tree.getTag()) { - case JCTree.OR: + case OR: if (lhs.type.isTrue()) { result = lhs; return; @@ -3116,7 +3152,7 @@ return; } break; - case JCTree.AND: + case AND: if (lhs.type.isFalse()) { result = lhs; return; @@ -3186,9 +3222,9 @@ indexdef.init.type = indexdef.type = syms.intType.constType(0); List loopinit = List.of(arraycachedef, lencachedef, indexdef); - JCBinary cond = makeBinary(JCTree.LT, make.Ident(index), make.Ident(lencache)); - - JCExpressionStatement step = make.Exec(makeUnary(JCTree.PREINC, make.Ident(index))); + JCBinary cond = makeBinary(LT, make.Ident(index), make.Ident(lencache)); + + JCExpressionStatement step = make.Exec(makeUnary(PREINC, make.Ident(index))); Type elemtype = types.elemtype(tree.expr.type); JCExpression loopvarinit = make.Indexed(make.Ident(arraycache), @@ -3592,7 +3628,7 @@ // need to special case-access of the form C.super.x // these will always need an access method. boolean qualifiedSuperAccess = - tree.selected.getTag() == JCTree.SELECT && + tree.selected.hasTag(SELECT) && TreeInfo.name(tree.selected) == names._super; tree.selected = translate(tree.selected); if (tree.name == names._class) @@ -3642,7 +3678,7 @@ endPositions = env.toplevel.endPositions; currentClass = null; currentMethodDef = null; - outermostClassDef = (cdef.getTag() == JCTree.CLASSDEF) ? (JCClassDecl)cdef : null; + outermostClassDef = (cdef.hasTag(CLASSDEF)) ? (JCClassDecl)cdef : null; outermostMemberDef = null; this.translated = new ListBuffer(); classdefs = new HashMap(); @@ -3838,7 +3874,7 @@ JCIdent fLocUsageId = make.Ident(otherVarSym); JCExpression sel = make.Select(fLocUsageId, ordinalSymbol); - JCBinary bin = makeBinary(JCTree.MINUS, id1, sel); + JCBinary bin = makeBinary(MINUS, id1, sel); JCReturn ret = make.Return(bin); blockStatements.append(ret); JCMethodDecl compareToMethod = make.MethodDef((MethodSymbol)compareToSym, diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/MemberEnter.java Fri Nov 18 11:11:11 2011 -0800 @@ -40,8 +40,10 @@ import com.sun.tools.javac.tree.JCTree.*; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Flags.ANNOTATION; import static com.sun.tools.javac.code.Kinds.*; import static com.sun.tools.javac.code.TypeTags.*; +import static com.sun.tools.javac.tree.JCTree.Tag.*; import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; /** This is the second phase of Enter, in which classes are completed @@ -644,7 +646,7 @@ tree.sym = v; if (tree.init != null) { v.flags_field |= HASINIT; - if ((v.flags_field & FINAL) != 0 && tree.init.getTag() != JCTree.NEWCLASS) { + if ((v.flags_field & FINAL) != 0 && !tree.init.hasTag(NEWCLASS)) { Env initEnv = getInitEnv(tree, env); initEnv.info.enclVar = v; v.setLazyConstValue(initEnv(tree, initEnv), attr, tree.init); @@ -868,7 +870,7 @@ // If this is a toplevel-class, make sure any preceding import // clauses have been seen. if (c.owner.kind == PCK) { - memberEnter(env.toplevel, env.enclosing(JCTree.TOPLEVEL)); + memberEnter(env.toplevel, env.enclosing(TOPLEVEL)); todo.append(env); } diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Resolve.java Fri Nov 18 11:11:11 2011 -0800 @@ -49,9 +49,12 @@ import javax.lang.model.element.ElementVisitor; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Flags.BLOCK; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.code.Kinds.ERRONEOUS; import static com.sun.tools.javac.code.TypeTags.*; import static com.sun.tools.javac.comp.Resolve.MethodResolutionPhase.*; +import static com.sun.tools.javac.tree.JCTree.Tag.*; /** Helper class for name resolution, used mostly by the attribution phase. * @@ -1269,7 +1272,7 @@ staticOnly = true; } - if (env.tree.getTag() != JCTree.IMPORT) { + if (!env.tree.hasTag(IMPORT)) { sym = findGlobalType(env, env.toplevel.namedImportScope, name); if (sym.exists()) return sym; else if (sym.kind < bestSoFar.kind) bestSoFar = sym; @@ -1796,7 +1799,7 @@ * @param env The environment current at the operation. * @param argtypes The types of the operands. */ - Symbol resolveOperator(DiagnosticPosition pos, int optag, + Symbol resolveOperator(DiagnosticPosition pos, JCTree.Tag optag, Env env, List argtypes) { startResolution(); Name name = treeinfo.operatorName(optag); @@ -1815,7 +1818,7 @@ * @param env The environment current at the operation. * @param arg The type of the operand. */ - Symbol resolveUnaryOperator(DiagnosticPosition pos, int optag, Env env, Type arg) { + Symbol resolveUnaryOperator(DiagnosticPosition pos, JCTree.Tag optag, Env env, Type arg) { return resolveOperator(pos, optag, env, List.of(arg)); } @@ -1827,7 +1830,7 @@ * @param right The types of the right operand. */ Symbol resolveBinaryOperator(DiagnosticPosition pos, - int optag, + JCTree.Tag optag, Env env, Type left, Type right) { diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/jvm/CRTable.java --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/CRTable.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/CRTable.java Fri Nov 18 11:11:11 2011 -0800 @@ -532,7 +532,7 @@ */ public int endPos(JCTree tree) { if (tree == null) return Position.NOPOS; - if (tree.getTag() == JCTree.BLOCK) + if (tree.hasTag(JCTree.Tag.BLOCK)) return ((JCBlock) tree).endpos; Integer endpos = endPositions.get(tree); if (endpos != null) diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/Gen.java Fri Nov 18 11:11:11 2011 -0800 @@ -47,6 +47,8 @@ import static com.sun.tools.javac.jvm.ByteCodes.*; import static com.sun.tools.javac.jvm.CRTFlags.*; import static com.sun.tools.javac.main.OptionName.*; +import static com.sun.tools.javac.tree.JCTree.Tag.*; +import static com.sun.tools.javac.tree.JCTree.Tag.BLOCK; /** This pass maps flat Java (i.e. without inner classes) to bytecodes. * @@ -433,7 +435,7 @@ */ boolean hasFinally(JCTree target, Env env) { while (env.tree != target) { - if (env.tree.getTag() == JCTree.TRY && env.info.finalize.hasFinalizer()) + if (env.tree.hasTag(TRY) && env.info.finalize.hasFinalizer()) return true; env = env.next; } @@ -460,17 +462,17 @@ for (List l = defs; l.nonEmpty(); l = l.tail) { JCTree def = l.head; switch (def.getTag()) { - case JCTree.BLOCK: + case BLOCK: JCBlock block = (JCBlock)def; if ((block.flags & STATIC) != 0) clinitCode.append(block); else initCode.append(block); break; - case JCTree.METHODDEF: + case METHODDEF: methodDefs.append(def); break; - case JCTree.VARDEF: + case VARDEF: JCVariableDecl vdef = (JCVariableDecl) def; VarSymbol sym = vdef.sym; checkDimension(vdef.pos(), sym.type); @@ -707,7 +709,7 @@ } int startpc = code.curPc(); genStat(tree, env); - if (tree.getTag() == JCTree.BLOCK) crtFlags |= CRT_BLOCK; + if (tree.hasTag(BLOCK)) crtFlags |= CRT_BLOCK; code.crt.put(tree, crtFlags, startpc, code.curPc()); } @@ -717,7 +719,7 @@ if (code.isAlive()) { code.statBegin(tree.pos); genDef(tree, env); - } else if (env.info.isSwitch && tree.getTag() == JCTree.VARDEF) { + } else if (env.info.isSwitch && tree.hasTag(VARDEF)) { // variables whose declarations are in a switch // can be used even if the decl is unreachable. code.newLocal(((JCVariableDecl) tree).sym); @@ -784,7 +786,7 @@ */ public CondItem genCond(JCTree _tree, boolean markBranches) { JCTree inner_tree = TreeInfo.skipParens(_tree); - if (inner_tree.getTag() == JCTree.CONDEXPR) { + if (inner_tree.hasTag(CONDEXPR)) { JCConditional tree = (JCConditional)inner_tree; CondItem cond = genCond(tree.cond, CRT_FLOW_CONTROLLER); if (cond.isTrue()) { @@ -1033,7 +1035,7 @@ Env localEnv = env.dup(tree, new GenContext()); genStats(tree.stats, localEnv); // End the scope of all block-local variables in variable info. - if (env.tree.getTag() != JCTree.METHODDEF) { + if (!env.tree.hasTag(METHODDEF)) { code.statBegin(tree.endpos); code.endScopes(limit); code.pendingStatPos = Position.NOPOS; @@ -1628,11 +1630,11 @@ // Optimize x++ to ++x and x-- to --x. JCExpression e = tree.expr; switch (e.getTag()) { - case JCTree.POSTINC: - ((JCUnary) e).setTag(JCTree.PREINC); + case POSTINC: + ((JCUnary) e).setTag(PREINC); break; - case JCTree.POSTDEC: - ((JCUnary) e).setTag(JCTree.PREDEC); + case POSTDEC: + ((JCUnary) e).setTag(PREDEC); break; } genExpr(tree.expr, tree.expr.type).drop(); @@ -1819,13 +1821,13 @@ // If we have an increment of -32768 to +32767 of a local // int variable we can use an incr instruction instead of // proceeding further. - if ((tree.getTag() == JCTree.PLUS_ASG || tree.getTag() == JCTree.MINUS_ASG) && + if ((tree.hasTag(PLUS_ASG) || tree.hasTag(MINUS_ASG)) && l instanceof LocalItem && tree.lhs.type.tag <= INT && tree.rhs.type.tag <= INT && tree.rhs.type.constValue() != null) { int ival = ((Number) tree.rhs.type.constValue()).intValue(); - if (tree.getTag() == JCTree.MINUS_ASG) ival = -ival; + if (tree.hasTag(MINUS_ASG)) ival = -ival; ((LocalItem)l).incr(ival); result = l; return; @@ -1841,29 +1843,29 @@ public void visitUnary(JCUnary tree) { OperatorSymbol operator = (OperatorSymbol)tree.operator; - if (tree.getTag() == JCTree.NOT) { + if (tree.hasTag(NOT)) { CondItem od = genCond(tree.arg, false); result = od.negate(); } else { Item od = genExpr(tree.arg, operator.type.getParameterTypes().head); switch (tree.getTag()) { - case JCTree.POS: + case POS: result = od.load(); break; - case JCTree.NEG: + case NEG: result = od.load(); code.emitop0(operator.opcode); break; - case JCTree.COMPL: + case COMPL: result = od.load(); emitMinusOne(od.typecode); code.emitop0(operator.opcode); break; - case JCTree.PREINC: case JCTree.PREDEC: + case PREINC: case PREDEC: od.duplicate(); if (od instanceof LocalItem && (operator.opcode == iadd || operator.opcode == isub)) { - ((LocalItem)od).incr(tree.getTag() == JCTree.PREINC ? 1 : -1); + ((LocalItem)od).incr(tree.hasTag(PREINC) ? 1 : -1); result = od; } else { od.load(); @@ -1877,12 +1879,12 @@ result = items.makeAssignItem(od); } break; - case JCTree.POSTINC: case JCTree.POSTDEC: + case POSTINC: case POSTDEC: od.duplicate(); if (od instanceof LocalItem && (operator.opcode == iadd || operator.opcode == isub)) { Item res = od.load(); - ((LocalItem)od).incr(tree.getTag() == JCTree.POSTINC ? 1 : -1); + ((LocalItem)od).incr(tree.hasTag(POSTINC) ? 1 : -1); result = res; } else { Item res = od.load(); @@ -1898,7 +1900,7 @@ result = res; } break; - case JCTree.NULLCHK: + case NULLCHK: result = od.load(); code.emitop0(dup); genNullCheck(tree.pos()); @@ -1926,7 +1928,7 @@ // Convert buffer to string. bufferToString(tree.pos()); result = items.makeStackItem(syms.stringType); - } else if (tree.getTag() == JCTree.AND) { + } else if (tree.hasTag(AND)) { CondItem lcond = genCond(tree.lhs, CRT_FLOW_CONTROLLER); if (!lcond.isFalse()) { Chain falseJumps = lcond.jumpFalse(); @@ -1940,7 +1942,7 @@ } else { result = lcond; } - } else if (tree.getTag() == JCTree.OR) { + } else if (tree.hasTag(OR)) { CondItem lcond = genCond(tree.lhs, CRT_FLOW_CONTROLLER); if (!lcond.isTrue()) { Chain trueJumps = lcond.jumpTrue(); @@ -1997,7 +1999,7 @@ */ void appendStrings(JCTree tree) { tree = TreeInfo.skipParens(tree); - if (tree.getTag() == JCTree.PLUS && tree.type.constValue() == null) { + if (tree.hasTag(PLUS) && tree.type.constValue() == null) { JCBinary op = (JCBinary) tree; if (op.operator.kind == MTH && ((OperatorSymbol) op.operator).opcode == string_add) { @@ -2240,7 +2242,7 @@ if (nerrs != 0) { // if errors, discard code for (List l = cdef.defs; l.nonEmpty(); l = l.tail) { - if (l.head.getTag() == JCTree.METHODDEF) + if (l.head.hasTag(METHODDEF)) ((JCMethodDecl) l.head).sym.code = null; } } diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java --- a/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/main/JavaCompiler.java Fri Nov 18 11:11:11 2011 -0800 @@ -1506,20 +1506,20 @@ for (List it = tree.defs; it.tail != null; it = it.tail) { JCTree t = it.head; switch (t.getTag()) { - case JCTree.CLASSDEF: + case CLASSDEF: if (isInterface || (((JCClassDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 || (((JCClassDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCClassDecl) t).sym.packge().getQualifiedName() == names.java_lang) newdefs.append(t); break; - case JCTree.METHODDEF: + case METHODDEF: if (isInterface || (((JCMethodDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 || ((JCMethodDecl) t).sym.name == names.init || (((JCMethodDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCMethodDecl) t).sym.packge().getQualifiedName() == names.java_lang) newdefs.append(t); break; - case JCTree.VARDEF: + case VARDEF: if (isInterface || (((JCVariableDecl) t).mods.flags & (Flags.PROTECTED|Flags.PUBLIC)) != 0 || (((JCVariableDecl) t).mods.flags & (Flags.PRIVATE)) == 0 && ((JCVariableDecl) t).sym.packge().getQualifiedName() == names.java_lang) newdefs.append(t); diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java --- a/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/model/JavacElements.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -48,6 +48,7 @@ import com.sun.tools.javac.util.*; import com.sun.tools.javac.util.Name; +import static com.sun.tools.javac.tree.JCTree.Tag.*; import static javax.lang.model.util.ElementFilter.methodsIn; /** @@ -288,7 +289,7 @@ } } public void visitArray(Attribute.Array array) { - if (tree.getTag() == JCTree.NEWARRAY && + if (tree.hasTag(NEWARRAY) && types.elemtype(array.type).tsym == findme.type.tsym) { List elems = ((JCNewArray) tree).elems; for (Attribute value : array.values) { @@ -327,7 +328,7 @@ scan(t.args); } public void visitAssign(JCAssign t) { - if (t.lhs.getTag() == JCTree.IDENT) { + if (t.lhs.hasTag(IDENT)) { JCIdent ident = (JCIdent) t.lhs; if (ident.sym == sym) result = t.rhs; diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavaTokenizer.java Fri Nov 18 11:11:11 2011 -0800 @@ -25,10 +25,11 @@ package com.sun.tools.javac.parser; -import java.nio.CharBuffer; import com.sun.tools.javac.code.Source; +import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; import com.sun.tools.javac.util.*; +import java.nio.CharBuffer; import static com.sun.tools.javac.parser.Tokens.*; import static com.sun.tools.javac.util.LayoutCharacters.*; @@ -65,9 +66,6 @@ */ private final Log log; - /** The name table. */ - private final Names names; - /** The token factory. */ private final Tokens tokens; @@ -87,17 +85,11 @@ */ protected int errPos = Position.NOPOS; - /** Has a @deprecated been encountered in last doc comment? - * this needs to be reset by client. + /** The Unicode reader (low-level stream reader). */ - protected boolean deprecatedFlag = false; + protected UnicodeReader reader; - /** A character buffer for saved chars. - */ - protected char[] sbuf = new char[128]; - protected int sp; - - protected UnicodeReader reader; + protected ScannerFactory fac; private static final boolean hexFloatsWork = hexFloatsWork(); private static boolean hexFloatsWork() { @@ -129,14 +121,14 @@ } protected JavaTokenizer(ScannerFactory fac, UnicodeReader reader) { - log = fac.log; - names = fac.names; - tokens = fac.tokens; - source = fac.source; + this.fac = fac; + this.log = fac.log; + this.tokens = fac.tokens; + this.source = fac.source; this.reader = reader; - allowBinaryLiterals = source.allowBinaryLiterals(); - allowHexFloats = source.allowHexFloats(); - allowUnderscoresInLiterals = source.allowUnderscoresInLiterals(); + this.allowBinaryLiterals = source.allowBinaryLiterals(); + this.allowHexFloats = source.allowHexFloats(); + this.allowUnderscoresInLiterals = source.allowUnderscoresInLiterals(); } /** Report an error at the given position using the provided arguments. @@ -147,38 +139,13 @@ errPos = pos; } - /** Read next character in comment, skipping over double '\' characters. - */ - protected void scanCommentChar() { - reader.scanChar(); - if (reader.ch == '\\') { - if (reader.peekChar() == '\\' && !reader.isUnicode()) { - reader.skipChar(); - } else { - reader.convertUnicode(); - } - } - } - - /** Append a character to sbuf. - */ - private void putChar(char ch) { - if (sp == sbuf.length) { - char[] newsbuf = new char[sbuf.length * 2]; - System.arraycopy(sbuf, 0, newsbuf, 0, sbuf.length); - sbuf = newsbuf; - } - sbuf[sp++] = ch; - } - /** Read next character in character or string literal and copy into sbuf. */ private void scanLitChar(int pos) { if (reader.ch == '\\') { if (reader.peekChar() == '\\' && !reader.isUnicode()) { reader.skipChar(); - putChar('\\'); - reader.scanChar(); + reader.putChar('\\', true); } else { reader.scanChar(); switch (reader.ch) { @@ -195,30 +162,30 @@ reader.scanChar(); } } - putChar((char)oct); + reader.putChar((char)oct); break; case 'b': - putChar('\b'); reader.scanChar(); break; + reader.putChar('\b', true); break; case 't': - putChar('\t'); reader.scanChar(); break; + reader.putChar('\t', true); break; case 'n': - putChar('\n'); reader.scanChar(); break; + reader.putChar('\n', true); break; case 'f': - putChar('\f'); reader.scanChar(); break; + reader.putChar('\f', true); break; case 'r': - putChar('\r'); reader.scanChar(); break; + reader.putChar('\r', true); break; case '\'': - putChar('\''); reader.scanChar(); break; + reader.putChar('\'', true); break; case '\"': - putChar('\"'); reader.scanChar(); break; + reader.putChar('\"', true); break; case '\\': - putChar('\\'); reader.scanChar(); break; + reader.putChar('\\', true); break; default: lexError(reader.bp, "illegal.esc.char"); } } } else if (reader.bp != reader.buflen) { - putChar(reader.ch); reader.scanChar(); + reader.putChar(true); } } @@ -227,7 +194,7 @@ int savePos; do { if (reader.ch != '_') { - putChar(reader.ch); + reader.putChar(false); } else { if (!allowUnderscoresInLiterals) { lexError(pos, "unsupported.underscore.lit", source.name); @@ -246,12 +213,10 @@ */ private void scanHexExponentAndSuffix(int pos) { if (reader.ch == 'p' || reader.ch == 'P') { - putChar(reader.ch); - reader.scanChar(); + reader.putChar(true); skipIllegalUnderscores(); if (reader.ch == '+' || reader.ch == '-') { - putChar(reader.ch); - reader.scanChar(); + reader.putChar(true); } skipIllegalUnderscores(); if ('0' <= reader.ch && reader.ch <= '9') { @@ -268,14 +233,12 @@ lexError(pos, "malformed.fp.lit"); } if (reader.ch == 'f' || reader.ch == 'F') { - putChar(reader.ch); - reader.scanChar(); + reader.putChar(true); tk = TokenKind.FLOATLITERAL; radix = 16; } else { if (reader.ch == 'd' || reader.ch == 'D') { - putChar(reader.ch); - reader.scanChar(); + reader.putChar(true); } tk = TokenKind.DOUBLELITERAL; radix = 16; @@ -289,14 +252,12 @@ if ('0' <= reader.ch && reader.ch <= '9') { scanDigits(pos, 10); } - int sp1 = sp; + int sp1 = reader.sp; if (reader.ch == 'e' || reader.ch == 'E') { - putChar(reader.ch); - reader.scanChar(); + reader.putChar(true); skipIllegalUnderscores(); if (reader.ch == '+' || reader.ch == '-') { - putChar(reader.ch); - reader.scanChar(); + reader.putChar(true); } skipIllegalUnderscores(); if ('0' <= reader.ch && reader.ch <= '9') { @@ -304,7 +265,7 @@ return; } lexError(pos, "malformed.fp.lit"); - sp = sp1; + reader.sp = sp1; } } @@ -314,13 +275,11 @@ radix = 10; scanFraction(pos); if (reader.ch == 'f' || reader.ch == 'F') { - putChar(reader.ch); - reader.scanChar(); + reader.putChar(true); tk = TokenKind.FLOATLITERAL; } else { if (reader.ch == 'd' || reader.ch == 'D') { - putChar(reader.ch); - reader.scanChar(); + reader.putChar(true); } tk = TokenKind.DOUBLELITERAL; } @@ -331,8 +290,7 @@ private void scanHexFractionAndSuffix(int pos, boolean seendigit) { radix = 16; Assert.check(reader.ch == '.'); - putChar(reader.ch); - reader.scanChar(); + reader.putChar(true); skipIllegalUnderscores(); if (reader.digit(pos, 16) >= 0) { seendigit = true; @@ -369,8 +327,7 @@ } else if (seendigit && radix == 16 && (reader.ch == 'p' || reader.ch == 'P')) { scanHexExponentAndSuffix(pos); } else if (digitRadix == 10 && reader.ch == '.') { - putChar(reader.ch); - reader.scanChar(); + reader.putChar(true); scanFractionAndSuffix(pos); } else if (digitRadix == 10 && (reader.ch == 'e' || reader.ch == 'E' || @@ -393,10 +350,7 @@ boolean isJavaIdentifierPart; char high; do { - if (sp == sbuf.length) putChar(reader.ch); else sbuf[sp++] = reader.ch; - // optimization, was: putChar(reader.ch); - - reader.scanChar(); + reader.putChar(true); switch (reader.ch) { case 'A': case 'B': case 'C': case 'D': case 'E': case 'F': case 'G': case 'H': case 'I': case 'J': @@ -423,7 +377,7 @@ break; case '\u001A': // EOI is also a legal identifier part if (reader.bp >= reader.buflen) { - name = names.fromChars(sbuf, 0, sp); + name = reader.name(); tk = tokens.lookupKind(name); return; } @@ -435,11 +389,7 @@ } else { high = reader.scanSurrogates(); if (high != 0) { - if (sp == sbuf.length) { - putChar(high); - } else { - sbuf[sp++] = high; - } + reader.putChar(high); isJavaIdentifierPart = Character.isJavaIdentifierPart( Character.toCodePoint(high, reader.ch)); } else { @@ -447,7 +397,7 @@ } } if (!isJavaIdentifierPart) { - name = names.fromChars(sbuf, 0, sp); + name = reader.name(); tk = tokens.lookupKind(name); return; } @@ -474,11 +424,11 @@ */ private void scanOperator() { while (true) { - putChar(reader.ch); - Name newname = names.fromChars(sbuf, 0, sp); + reader.putChar(false); + Name newname = reader.name(); TokenKind tk1 = tokens.lookupKind(newname); if (tk1 == TokenKind.IDENTIFIER) { - sp--; + reader.sp--; break; } tk = tk1; @@ -487,111 +437,17 @@ } } - /** - * Scan a documentation comment; determine if a deprecated tag is present. - * Called once the initial /, * have been skipped, positioned at the second * - * (which is treated as the beginning of the first line). - * Stops positioned at the closing '/'. - */ - @SuppressWarnings("fallthrough") - private void scanDocComment() { - boolean deprecatedPrefix = false; - - forEachLine: - while (reader.bp < reader.buflen) { - - // Skip optional WhiteSpace at beginning of line - while (reader.bp < reader.buflen && (reader.ch == ' ' || reader.ch == '\t' || reader.ch == FF)) { - scanCommentChar(); - } - - // Skip optional consecutive Stars - while (reader.bp < reader.buflen && reader.ch == '*') { - scanCommentChar(); - if (reader.ch == '/') { - return; - } - } - - // Skip optional WhiteSpace after Stars - while (reader.bp < reader.buflen && (reader.ch == ' ' || reader.ch == '\t' || reader.ch == FF)) { - scanCommentChar(); - } - - deprecatedPrefix = false; - // At beginning of line in the JavaDoc sense. - if (reader.bp < reader.buflen && reader.ch == '@' && !deprecatedFlag) { - scanCommentChar(); - if (reader.bp < reader.buflen && reader.ch == 'd') { - scanCommentChar(); - if (reader.bp < reader.buflen && reader.ch == 'e') { - scanCommentChar(); - if (reader.bp < reader.buflen && reader.ch == 'p') { - scanCommentChar(); - if (reader.bp < reader.buflen && reader.ch == 'r') { - scanCommentChar(); - if (reader.bp < reader.buflen && reader.ch == 'e') { - scanCommentChar(); - if (reader.bp < reader.buflen && reader.ch == 'c') { - scanCommentChar(); - if (reader.bp < reader.buflen && reader.ch == 'a') { - scanCommentChar(); - if (reader.bp < reader.buflen && reader.ch == 't') { - scanCommentChar(); - if (reader.bp < reader.buflen && reader.ch == 'e') { - scanCommentChar(); - if (reader.bp < reader.buflen && reader.ch == 'd') { - deprecatedPrefix = true; - scanCommentChar(); - }}}}}}}}}}} - if (deprecatedPrefix && reader.bp < reader.buflen) { - if (Character.isWhitespace(reader.ch)) { - deprecatedFlag = true; - } else if (reader.ch == '*') { - scanCommentChar(); - if (reader.ch == '/') { - deprecatedFlag = true; - return; - } - } - } - - // Skip rest of line - while (reader.bp < reader.buflen) { - switch (reader.ch) { - case '*': - scanCommentChar(); - if (reader.ch == '/') { - return; - } - break; - case CR: // (Spec 3.4) - scanCommentChar(); - if (reader.ch != LF) { - continue forEachLine; - } - /* fall through to LF case */ - case LF: // (Spec 3.4) - scanCommentChar(); - continue forEachLine; - default: - scanCommentChar(); - } - } // rest of line - } // forEachLine - return; - } - /** Read token. */ public Token readToken() { - sp = 0; + reader.sp = 0; name = null; - deprecatedFlag = false; radix = 0; + int pos = 0; int endPos = 0; + List comments = null; try { loop: while (true) { @@ -656,7 +512,7 @@ scanNumber(pos, 2); } } else { - putChar('0'); + reader.putChar('0'); if (reader.ch == '_') { int savePos = reader.bp; do { @@ -676,14 +532,13 @@ case '.': reader.scanChar(); if ('0' <= reader.ch && reader.ch <= '9') { - putChar('.'); + reader.putChar('.'); scanFractionAndSuffix(pos); } else if (reader.ch == '.') { - putChar('.'); putChar('.'); - reader.scanChar(); + reader.putChar('.'); reader.putChar('.', true); if (reader.ch == '.') { reader.scanChar(); - putChar('.'); + reader.putChar('.'); tk = TokenKind.ELLIPSIS; } else { lexError(pos, "malformed.fp.lit"); @@ -712,32 +567,36 @@ reader.scanChar(); if (reader.ch == '/') { do { - scanCommentChar(); + reader.scanCommentChar(); } while (reader.ch != CR && reader.ch != LF && reader.bp < reader.buflen); if (reader.bp < reader.buflen) { - processComment(pos, reader.bp, CommentStyle.LINE); + comments = addDocReader(comments, processComment(pos, reader.bp, CommentStyle.LINE)); } break; } else if (reader.ch == '*') { + boolean isEmpty = false; reader.scanChar(); CommentStyle style; if (reader.ch == '*') { style = CommentStyle.JAVADOC; - scanDocComment(); + reader.scanCommentChar(); + if (reader.ch == '/') { + isEmpty = true; + } } else { style = CommentStyle.BLOCK; - while (reader.bp < reader.buflen) { - if (reader.ch == '*') { - reader.scanChar(); - if (reader.ch == '/') break; - } else { - scanCommentChar(); - } + } + while (!isEmpty && reader.bp < reader.buflen) { + if (reader.ch == '*') { + reader.scanChar(); + if (reader.ch == '/') break; + } else { + reader.scanCommentChar(); } } if (reader.ch == '/') { reader.scanChar(); - processComment(pos, reader.bp, style); + comments = addDocReader(comments, processComment(pos, reader.bp, style)); break; } else { lexError(pos, "unclosed.comment"); @@ -789,11 +648,7 @@ } else { char high = reader.scanSurrogates(); if (high != 0) { - if (sp == sbuf.length) { - putChar(high); - } else { - sbuf[sp++] = high; - } + reader.putChar(high); isJavaIdentifierStart = Character.isJavaIdentifierStart( Character.toCodePoint(high, reader.ch)); @@ -816,10 +671,10 @@ } endPos = reader.bp; switch (tk.tag) { - case DEFAULT: return new Token(tk, pos, endPos, deprecatedFlag); - case NAMED: return new NamedToken(tk, pos, endPos, name, deprecatedFlag); - case STRING: return new StringToken(tk, pos, endPos, new String(sbuf, 0, sp), deprecatedFlag); - case NUMERIC: return new NumericToken(tk, pos, endPos, new String(sbuf, 0, sp), radix, deprecatedFlag); + case DEFAULT: return new Token(tk, pos, endPos, comments); + case NAMED: return new NamedToken(tk, pos, endPos, name, comments); + case STRING: return new StringToken(tk, pos, endPos, reader.chars(), comments); + case NUMERIC: return new NumericToken(tk, pos, endPos, reader.chars(), radix, comments); default: throw new AssertionError(); } } @@ -832,6 +687,12 @@ } } } + //where + List addDocReader(List docReaders, Comment docReader) { + return docReaders == null ? + List.of(docReader) : + docReaders.prepend(docReader); + } /** Return the position where a lexical error occurred; */ @@ -845,22 +706,18 @@ errPos = pos; } - public enum CommentStyle { - LINE, - BLOCK, - JAVADOC, - } - /** * Called when a complete comment has been scanned. pos and endPos * will mark the comment boundary. */ - protected void processComment(int pos, int endPos, CommentStyle style) { + protected Tokens.Comment processComment(int pos, int endPos, CommentStyle style) { if (scannerDebug) System.out.println("processComment(" + pos + "," + endPos + "," + style + ")=|" + new String(reader.getRawCharacters(pos, endPos)) + "|"); + char[] buf = reader.getRawCharacters(pos, endPos); + return new BasicComment(new UnicodeReader(fac, buf, buf.length), style); } /** @@ -893,4 +750,125 @@ public Position.LineMap getLineMap() { return Position.makeLineMap(reader.getRawCharacters(), reader.buflen, false); } + + + /** + * Scan a documentation comment; determine if a deprecated tag is present. + * Called once the initial /, * have been skipped, positioned at the second * + * (which is treated as the beginning of the first line). + * Stops positioned at the closing '/'. + */ + protected class BasicComment implements Comment { + + CommentStyle cs; + U comment_reader; + + protected boolean deprecatedFlag = false; + protected boolean scanned = false; + + protected BasicComment(U comment_reader, CommentStyle cs) { + this.comment_reader = comment_reader; + this.cs = cs; + } + + public String getText() { + return null; + } + + public CommentStyle getStyle() { + return cs; + } + + public boolean isDeprecated() { + if (!scanned && cs == CommentStyle.JAVADOC) { + scanDocComment(); + } + return deprecatedFlag; + } + + @SuppressWarnings("fallthrough") + protected void scanDocComment() { + try { + boolean deprecatedPrefix = false; + + comment_reader.bp += 3; // '/**' + comment_reader.ch = comment_reader.buf[comment_reader.bp]; + + forEachLine: + while (comment_reader.bp < comment_reader.buflen) { + + // Skip optional WhiteSpace at beginning of line + while (comment_reader.bp < comment_reader.buflen && (comment_reader.ch == ' ' || comment_reader.ch == '\t' || comment_reader.ch == FF)) { + comment_reader.scanCommentChar(); + } + + // Skip optional consecutive Stars + while (comment_reader.bp < comment_reader.buflen && comment_reader.ch == '*') { + comment_reader.scanCommentChar(); + if (comment_reader.ch == '/') { + return; + } + } + + // Skip optional WhiteSpace after Stars + while (comment_reader.bp < comment_reader.buflen && (comment_reader.ch == ' ' || comment_reader.ch == '\t' || comment_reader.ch == FF)) { + comment_reader.scanCommentChar(); + } + + deprecatedPrefix = false; + // At beginning of line in the JavaDoc sense. + if (!deprecatedFlag) { + String deprecated = "@deprecated"; + int i = 0; + while (comment_reader.bp < comment_reader.buflen && comment_reader.ch == deprecated.charAt(i)) { + comment_reader.scanCommentChar(); + i++; + if (i == deprecated.length()) { + deprecatedPrefix = true; + break; + } + } + } + + if (deprecatedPrefix && comment_reader.bp < comment_reader.buflen) { + if (Character.isWhitespace(comment_reader.ch)) { + deprecatedFlag = true; + } else if (comment_reader.ch == '*') { + comment_reader.scanCommentChar(); + if (comment_reader.ch == '/') { + deprecatedFlag = true; + return; + } + } + } + + // Skip rest of line + while (comment_reader.bp < comment_reader.buflen) { + switch (comment_reader.ch) { + case '*': + comment_reader.scanCommentChar(); + if (comment_reader.ch == '/') { + return; + } + break; + case CR: // (Spec 3.4) + comment_reader.scanCommentChar(); + if (comment_reader.ch != LF) { + continue forEachLine; + } + /* fall through to LF case */ + case LF: // (Spec 3.4) + comment_reader.scanCommentChar(); + continue forEachLine; + default: + comment_reader.scanCommentChar(); + } + } // rest of line + } // forEachLine + return; + } finally { + scanned = true; + } + } + } } diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java Fri Nov 18 11:11:11 2011 -0800 @@ -29,6 +29,7 @@ import com.sun.tools.javac.code.*; import com.sun.tools.javac.parser.Tokens.*; +import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; import com.sun.tools.javac.tree.*; import com.sun.tools.javac.tree.JCTree.*; import com.sun.tools.javac.util.*; @@ -36,8 +37,16 @@ import com.sun.tools.javac.util.JCDiagnostic.DiagnosticPosition; import com.sun.tools.javac.util.List; +import static com.sun.tools.javac.parser.Tokens.TokenKind.*; +import static com.sun.tools.javac.parser.Tokens.TokenKind.ASSERT; +import static com.sun.tools.javac.parser.Tokens.TokenKind.CASE; +import static com.sun.tools.javac.parser.Tokens.TokenKind.CATCH; +import static com.sun.tools.javac.parser.Tokens.TokenKind.EQ; +import static com.sun.tools.javac.parser.Tokens.TokenKind.GT; +import static com.sun.tools.javac.parser.Tokens.TokenKind.IMPORT; +import static com.sun.tools.javac.parser.Tokens.TokenKind.LT; import static com.sun.tools.javac.util.ListBuffer.lb; -import static com.sun.tools.javac.parser.Tokens.TokenKind.*; +import static com.sun.tools.javac.tree.JCTree.Tag.*; /** The parser maps a token sequence into an abstract syntax * tree. It operates by recursive descent, with code derived @@ -757,7 +766,7 @@ Assert.check(top == 0); t = odStack[0]; - if (t.getTag() == JCTree.PLUS) { + if (t.hasTag(JCTree.Tag.PLUS)) { StringBuffer buf = foldStrings(t); if (buf != null) { t = toP(F.at(startPos).Literal(TypeTags.CLASS, buf.toString())); @@ -790,7 +799,7 @@ return null; List buf = List.nil(); while (true) { - if (tree.getTag() == JCTree.LITERAL) { + if (tree.hasTag(LITERAL)) { JCLiteral lit = (JCLiteral) tree; if (lit.typetag == TypeTags.CLASS) { StringBuffer sbuf = @@ -801,9 +810,9 @@ } return sbuf; } - } else if (tree.getTag() == JCTree.PLUS) { + } else if (tree.hasTag(JCTree.Tag.PLUS)) { JCBinary op = (JCBinary)tree; - if (op.rhs.getTag() == JCTree.LITERAL) { + if (op.rhs.hasTag(LITERAL)) { JCLiteral lit = (JCLiteral) op.rhs; if (lit.typetag == TypeTags.CLASS) { buf = buf.prepend((String) lit.value); @@ -899,7 +908,7 @@ t = term3(); if ((mode & TYPE) != 0 && token.kind == LT) { // Could be a cast to a parameterized type - int op = JCTree.LT; + JCTree.Tag op = JCTree.Tag.LT; int pos1 = token.pos; nextToken(); mode &= (EXPR | TYPE); @@ -1153,7 +1162,7 @@ while ((token.kind == PLUSPLUS || token.kind == SUBSUB) && (mode & EXPR) != 0) { mode = EXPR; t = to(F.at(token.pos).Unary( - token.kind == PLUSPLUS ? JCTree.POSTINC : JCTree.POSTDEC, t)); + token.kind == PLUSPLUS ? POSTINC : POSTDEC, t)); nextToken(); } return toP(t); @@ -1584,7 +1593,7 @@ break; case MONKEYS_AT: case FINAL: { - String dc = token.docComment; + String dc = token.comment(CommentStyle.JAVADOC); JCModifiers mods = modifiersOpt(); if (token.kind == INTERFACE || token.kind == CLASS || @@ -1601,21 +1610,21 @@ break; } case ABSTRACT: case STRICTFP: { - String dc = token.docComment; + String dc = token.comment(CommentStyle.JAVADOC); JCModifiers mods = modifiersOpt(); stats.append(classOrInterfaceOrEnumDeclaration(mods, dc)); break; } case INTERFACE: case CLASS: - String dc = token.docComment; + String dc = token.comment(CommentStyle.JAVADOC); stats.append(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc)); break; case ENUM: case ASSERT: if (allowEnums && token.kind == ENUM) { error(token.pos, "local.enum"); - dc = token.docComment; + dc = token.comment(CommentStyle.JAVADOC); stats.append(classOrInterfaceOrEnumDeclaration(modifiersOpt(), dc)); break; } else if (allowAsserts && token.kind == ASSERT) { @@ -1626,7 +1635,7 @@ default: Token prevToken = token; JCExpression t = term(EXPR | TYPE); - if (token.kind == COLON && t.getTag() == JCTree.IDENT) { + if (token.kind == COLON && t.hasTag(IDENT)) { nextToken(); JCStatement stat = parseStatement(); stats.append(F.at(pos).Labelled(prevToken.name(), stat)); @@ -1701,7 +1710,7 @@ accept(LPAREN); List inits = token.kind == SEMI ? List.nil() : forInit(); if (inits.length() == 1 && - inits.head.getTag() == JCTree.VARDEF && + inits.head.hasTag(VARDEF) && ((JCVariableDecl) inits.head).init == null && token.kind == COLON) { checkForeach(); @@ -1834,7 +1843,7 @@ default: Token prevToken = token; JCExpression expr = parseExpression(); - if (token.kind == COLON && expr.getTag() == JCTree.IDENT) { + if (token.kind == COLON && expr.hasTag(IDENT)) { nextToken(); JCStatement stat = parseStatement(); return F.at(pos).Labelled(prevToken.name(), stat); @@ -1991,7 +2000,7 @@ annotations.appendList(partial.annotations); pos = partial.pos; } - if (token.deprecatedFlag) { + if (token.deprecatedFlag()) { flags |= Flags.DEPRECATED; } int lastPos = Position.NOPOS; @@ -2087,7 +2096,7 @@ if (token.kind == IDENTIFIER) { mode = EXPR; JCExpression t1 = term1(); - if (t1.getTag() == JCTree.IDENT && token.kind == EQ) { + if (t1.hasTag(IDENT) && token.kind == EQ) { int pos = token.pos; accept(EQ); JCExpression v = annotationValue(); @@ -2271,9 +2280,9 @@ seenImport = true; defs.append(importDeclaration()); } else { - String docComment = token.docComment; + String docComment = token.comment(CommentStyle.JAVADOC); if (firstTypeDecl && !seenImport && !seenPackage) { - docComment = firstToken.docComment; + docComment = firstToken.comment(CommentStyle.JAVADOC); consumedToplevelDoc = true; } JCTree def = typeDeclaration(mods, docComment); @@ -2288,7 +2297,7 @@ } JCTree.JCCompilationUnit toplevel = F.at(firstToken.pos).TopLevel(packageAnnotations, pid, defs.toList()); if (!consumedToplevelDoc) - attach(toplevel, firstToken.docComment); + attach(toplevel, firstToken.comment(CommentStyle.JAVADOC)); if (defs.elems.isEmpty()) storeEnd(toplevel, S.prevToken().endPos); if (keepDocComments) @@ -2498,9 +2507,9 @@ /** EnumeratorDeclaration = AnnotationsOpt [TypeArguments] IDENTIFIER [ Arguments ] [ "{" ClassBody "}" ] */ JCTree enumeratorDeclaration(Name enumName) { - String dc = token.docComment; + String dc = token.comment(CommentStyle.JAVADOC); int flags = Flags.PUBLIC|Flags.STATIC|Flags.FINAL|Flags.ENUM; - if (token.deprecatedFlag) { + if (token.deprecatedFlag()) { flags |= Flags.DEPRECATED; } int pos = token.pos; @@ -2587,7 +2596,7 @@ nextToken(); return List.nil(); } else { - String dc = token.docComment; + String dc = token.comment(CommentStyle.JAVADOC); int pos = token.pos; JCModifiers mods = modifiersOpt(); if (token.kind == CLASS || @@ -2617,7 +2626,7 @@ } else { type = parseType(); } - if (token.kind == LPAREN && !isInterface && type.getTag() == JCTree.IDENT) { + if (token.kind == LPAREN && !isInterface && type.hasTag(IDENT)) { if (isInterface || tk.name() != className) error(pos, "invalid.meth.decl.ret.type.req"); return List.of(methodDeclaratorRest( @@ -2814,15 +2823,15 @@ */ protected JCExpression checkExprStat(JCExpression t) { switch(t.getTag()) { - case JCTree.PREINC: case JCTree.PREDEC: - case JCTree.POSTINC: case JCTree.POSTDEC: - case JCTree.ASSIGN: - case JCTree.BITOR_ASG: case JCTree.BITXOR_ASG: case JCTree.BITAND_ASG: - case JCTree.SL_ASG: case JCTree.SR_ASG: case JCTree.USR_ASG: - case JCTree.PLUS_ASG: case JCTree.MINUS_ASG: - case JCTree.MUL_ASG: case JCTree.DIV_ASG: case JCTree.MOD_ASG: - case JCTree.APPLY: case JCTree.NEWCLASS: - case JCTree.ERRONEOUS: + case PREINC: case PREDEC: + case POSTINC: case POSTDEC: + case ASSIGN: + case BITOR_ASG: case BITXOR_ASG: case BITAND_ASG: + case SL_ASG: case SR_ASG: case USR_ASG: + case PLUS_ASG: case MINUS_ASG: + case MUL_ASG: case DIV_ASG: case MOD_ASG: + case APPLY: case NEWCLASS: + case ERRONEOUS: return t; default: JCExpression ret = F.at(t.pos).Erroneous(List.of(t)); @@ -2835,8 +2844,8 @@ * -1 if token is not a binary operator. @see TreeInfo.opPrec */ static int prec(TokenKind token) { - int oc = optag(token); - return (oc >= 0) ? TreeInfo.opPrec(oc) : -1; + JCTree.Tag oc = optag(token); + return (oc != NO_TAG) ? TreeInfo.opPrec(oc) : -1; } /** @@ -2852,96 +2861,96 @@ } /** Return operation tag of binary operator represented by token, - * -1 if token is not a binary operator. + * No_TAG if token is not a binary operator. */ - static int optag(TokenKind token) { + static JCTree.Tag optag(TokenKind token) { switch (token) { case BARBAR: - return JCTree.OR; + return OR; case AMPAMP: - return JCTree.AND; + return AND; case BAR: - return JCTree.BITOR; + return BITOR; case BAREQ: - return JCTree.BITOR_ASG; + return BITOR_ASG; case CARET: - return JCTree.BITXOR; + return BITXOR; case CARETEQ: - return JCTree.BITXOR_ASG; + return BITXOR_ASG; case AMP: - return JCTree.BITAND; + return BITAND; case AMPEQ: - return JCTree.BITAND_ASG; + return BITAND_ASG; case EQEQ: - return JCTree.EQ; + return JCTree.Tag.EQ; case BANGEQ: - return JCTree.NE; + return NE; case LT: - return JCTree.LT; + return JCTree.Tag.LT; case GT: - return JCTree.GT; + return JCTree.Tag.GT; case LTEQ: - return JCTree.LE; + return LE; case GTEQ: - return JCTree.GE; + return GE; case LTLT: - return JCTree.SL; + return SL; case LTLTEQ: - return JCTree.SL_ASG; + return SL_ASG; case GTGT: - return JCTree.SR; + return SR; case GTGTEQ: - return JCTree.SR_ASG; + return SR_ASG; case GTGTGT: - return JCTree.USR; + return USR; case GTGTGTEQ: - return JCTree.USR_ASG; + return USR_ASG; case PLUS: - return JCTree.PLUS; + return JCTree.Tag.PLUS; case PLUSEQ: - return JCTree.PLUS_ASG; + return PLUS_ASG; case SUB: - return JCTree.MINUS; + return MINUS; case SUBEQ: - return JCTree.MINUS_ASG; + return MINUS_ASG; case STAR: - return JCTree.MUL; + return MUL; case STAREQ: - return JCTree.MUL_ASG; + return MUL_ASG; case SLASH: - return JCTree.DIV; + return DIV; case SLASHEQ: - return JCTree.DIV_ASG; + return DIV_ASG; case PERCENT: - return JCTree.MOD; + return MOD; case PERCENTEQ: - return JCTree.MOD_ASG; + return MOD_ASG; case INSTANCEOF: - return JCTree.TYPETEST; + return TYPETEST; default: - return -1; + return NO_TAG; } } /** Return operation tag of unary operator represented by token, - * -1 if token is not a binary operator. + * No_TAG if token is not a binary operator. */ - static int unoptag(TokenKind token) { + static JCTree.Tag unoptag(TokenKind token) { switch (token) { case PLUS: - return JCTree.POS; + return POS; case SUB: - return JCTree.NEG; + return NEG; case BANG: - return JCTree.NOT; + return NOT; case TILDE: - return JCTree.COMPL; + return COMPL; case PLUSPLUS: - return JCTree.PREINC; + return PREINC; case SUBSUB: - return JCTree.PREDEC; + return PREDEC; default: - return -1; + return NO_TAG; } } diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavadocTokenizer.java Fri Nov 18 11:11:11 2011 -0800 @@ -25,8 +25,8 @@ package com.sun.tools.javac.parser; -import com.sun.tools.javac.file.JavacFileManager; -import com.sun.tools.javac.parser.Tokens.Token; +import com.sun.tools.javac.parser.Tokens.Comment; +import com.sun.tools.javac.parser.Tokens.Comment.CommentStyle; import com.sun.tools.javac.util.*; import java.nio.*; @@ -59,352 +59,295 @@ super(fac, input, inputLength); } - /** The comment input buffer, index of next chacter to be read, - * index of one past last character in buffer. - */ - private char[] buf; - private int bp; - private int buflen; - - /** The current character. - */ - private char ch; - - /** The column number position of the current character. - */ - private int col; - - /** The buffer index of the last converted Unicode character - */ - private int unicodeConversionBp = 0; - - /** - * Buffer for doc comment. - */ - private char[] docCommentBuffer = new char[1024]; - - /** - * Number of characters in doc comment buffer. - */ - private int docCommentCount; - - /** - * Translated and stripped contents of doc comment - */ - private String docComment = null; - - - /** Unconditionally expand the comment buffer. - */ - private void expandCommentBuffer() { - char[] newBuffer = new char[docCommentBuffer.length * 2]; - System.arraycopy(docCommentBuffer, 0, newBuffer, - 0, docCommentBuffer.length); - docCommentBuffer = newBuffer; - } - - /** Convert an ASCII digit from its base (8, 10, or 16) - * to its value. - */ - private int digit(int base) { - char c = ch; - int result = Character.digit(c, base); - if (result >= 0 && c > 0x7f) { - ch = "0123456789abcdef".charAt(result); - } - return result; - } - - /** Convert Unicode escape; bp points to initial '\' character - * (Spec 3.3). - */ - private void convertUnicode() { - if (ch == '\\' && unicodeConversionBp != bp) { - bp++; ch = buf[bp]; col++; - if (ch == 'u') { - do { - bp++; ch = buf[bp]; col++; - } while (ch == 'u'); - int limit = bp + 3; - if (limit < buflen) { - int d = digit(16); - int code = d; - while (bp < limit && d >= 0) { - bp++; ch = buf[bp]; col++; - d = digit(16); - code = (code << 4) + d; - } - if (d >= 0) { - ch = (char)code; - unicodeConversionBp = bp; - return; - } - } - // "illegal.Unicode.esc", reported by base scanner - } else { - bp--; - ch = '\\'; - col--; - } - } - } - - - /** Read next character. - */ - private void scanChar() { - bp++; - ch = buf[bp]; - switch (ch) { - case '\r': // return - col = 0; - break; - case '\n': // newline - if (bp == 0 || buf[bp-1] != '\r') { - col = 0; - } - break; - case '\t': // tab - col = (col / TabInc * TabInc) + TabInc; - break; - case '\\': // possible Unicode - col++; - convertUnicode(); - break; - default: - col++; - break; - } - } - @Override - public Token readToken() { - docComment = null; - Token tk = super.readToken(); - tk.docComment = docComment; - return tk; + protected Comment processComment(int pos, int endPos, CommentStyle style) { + char[] buf = reader.getRawCharacters(pos, endPos); + return new JavadocComment(new ColReader(fac, buf, buf.length), style); } /** - * Read next character in doc comment, skipping over double '\' characters. - * If a double '\' is skipped, put in the buffer and update buffer count. + * This is a specialized version of UnicodeReader that keeps track of the + * column position within a given character stream (used for Javadoc processing). */ - private void scanDocCommentChar() { - scanChar(); - if (ch == '\\') { - if (buf[bp+1] == '\\' && unicodeConversionBp != bp) { - if (docCommentCount == docCommentBuffer.length) - expandCommentBuffer(); - docCommentBuffer[docCommentCount++] = ch; - bp++; col++; - } else { - convertUnicode(); + static class ColReader extends UnicodeReader { + + int col; + + ColReader(ScannerFactory fac, char[] input, int inputLength) { + super(fac, input, inputLength); + } + + @Override + protected void convertUnicode() { + if (ch == '\\' && unicodeConversionBp != bp) { + bp++; ch = buf[bp]; col++; + if (ch == 'u') { + do { + bp++; ch = buf[bp]; col++; + } while (ch == 'u'); + int limit = bp + 3; + if (limit < buflen) { + int d = digit(bp, 16); + int code = d; + while (bp < limit && d >= 0) { + bp++; ch = buf[bp]; col++; + d = digit(bp, 16); + code = (code << 4) + d; + } + if (d >= 0) { + ch = (char)code; + unicodeConversionBp = bp; + return; + } + } + // "illegal.Unicode.esc", reported by base scanner + } else { + bp--; + ch = '\\'; + col--; + } + } + } + + @Override + protected void scanCommentChar() { + scanChar(); + if (ch == '\\') { + if (peekChar() == '\\' && !isUnicode()) { + putChar(ch, false); + bp++; col++; + } else { + convertUnicode(); + } + } + } + + @Override + protected void scanChar() { + bp++; + ch = buf[bp]; + switch (ch) { + case '\r': // return + col = 0; + break; + case '\n': // newline + if (bp == 0 || buf[bp-1] != '\r') { + col = 0; + } + break; + case '\t': // tab + col = (col / TabInc * TabInc) + TabInc; + break; + case '\\': // possible Unicode + col++; + convertUnicode(); + break; + default: + col++; + break; + } + } + } + + protected class JavadocComment extends JavaTokenizer.BasicComment { + + /** + * Translated and stripped contents of doc comment + */ + private String docComment = null; + + JavadocComment(ColReader comment_reader, CommentStyle cs) { + super(comment_reader, cs); + } + + public String getText() { + if (!scanned && cs == CommentStyle.JAVADOC) { + scanDocComment(); + } + return docComment; + } + + @Override + @SuppressWarnings("fallthrough") + protected void scanDocComment() { + try { + boolean firstLine = true; + + // Skip over first slash + comment_reader.scanCommentChar(); + // Skip over first star + comment_reader.scanCommentChar(); + + // consume any number of stars + while (comment_reader.bp < comment_reader.buflen && comment_reader.ch == '*') { + comment_reader.scanCommentChar(); + } + // is the comment in the form /**/, /***/, /****/, etc. ? + if (comment_reader.bp < comment_reader.buflen && comment_reader.ch == '/') { + docComment = ""; + return; + } + + // skip a newline on the first line of the comment. + if (comment_reader.bp < comment_reader.buflen) { + if (comment_reader.ch == LF) { + comment_reader.scanCommentChar(); + firstLine = false; + } else if (comment_reader.ch == CR) { + comment_reader.scanCommentChar(); + if (comment_reader.ch == LF) { + comment_reader.scanCommentChar(); + firstLine = false; + } + } + } + + outerLoop: + + // The outerLoop processes the doc comment, looping once + // for each line. For each line, it first strips off + // whitespace, then it consumes any stars, then it + // puts the rest of the line into our buffer. + while (comment_reader.bp < comment_reader.buflen) { + + // The wsLoop consumes whitespace from the beginning + // of each line. + wsLoop: + + while (comment_reader.bp < comment_reader.buflen) { + switch(comment_reader.ch) { + case ' ': + comment_reader.scanCommentChar(); + break; + case '\t': + comment_reader.col = ((comment_reader.col - 1) / TabInc * TabInc) + TabInc; + comment_reader.scanCommentChar(); + break; + case FF: + comment_reader.col = 0; + comment_reader.scanCommentChar(); + break; + // Treat newline at beginning of line (blank line, no star) + // as comment text. Old Javadoc compatibility requires this. + /*---------------------------------* + case CR: // (Spec 3.4) + doc_reader.scanCommentChar(); + if (ch == LF) { + col = 0; + doc_reader.scanCommentChar(); + } + break; + case LF: // (Spec 3.4) + doc_reader.scanCommentChar(); + break; + *---------------------------------*/ + default: + // we've seen something that isn't whitespace; + // jump out. + break wsLoop; + } + } + + // Are there stars here? If so, consume them all + // and check for the end of comment. + if (comment_reader.ch == '*') { + // skip all of the stars + do { + comment_reader.scanCommentChar(); + } while (comment_reader.ch == '*'); + + // check for the closing slash. + if (comment_reader.ch == '/') { + // We're done with the doc comment + // scanChar() and breakout. + break outerLoop; + } + } else if (! firstLine) { + //The current line does not begin with a '*' so we will indent it. + for (int i = 1; i < comment_reader.col; i++) { + comment_reader.putChar(' ', false); + } + } + // The textLoop processes the rest of the characters + // on the line, adding them to our buffer. + textLoop: + while (comment_reader.bp < comment_reader.buflen) { + switch (comment_reader.ch) { + case '*': + // Is this just a star? Or is this the + // end of a comment? + comment_reader.scanCommentChar(); + if (comment_reader.ch == '/') { + // This is the end of the comment, + // set ch and return our buffer. + break outerLoop; + } + // This is just an ordinary star. Add it to + // the buffer. + comment_reader.putChar('*', false); + break; + case ' ': + case '\t': + comment_reader.putChar(comment_reader.ch, false); + comment_reader.scanCommentChar(); + break; + case FF: + comment_reader.scanCommentChar(); + break textLoop; // treat as end of line + case CR: // (Spec 3.4) + comment_reader.scanCommentChar(); + if (comment_reader.ch != LF) { + // Canonicalize CR-only line terminator to LF + comment_reader.putChar((char)LF, false); + break textLoop; + } + /* fall through to LF case */ + case LF: // (Spec 3.4) + // We've seen a newline. Add it to our + // buffer and break out of this loop, + // starting fresh on a new line. + comment_reader.putChar(comment_reader.ch, false); + comment_reader.scanCommentChar(); + break textLoop; + default: + // Add the character to our buffer. + comment_reader.putChar(comment_reader.ch, false); + comment_reader.scanCommentChar(); + } + } // end textLoop + firstLine = false; + } // end outerLoop + + if (comment_reader.sp > 0) { + int i = comment_reader.sp - 1; + trailLoop: + while (i > -1) { + switch (comment_reader.sbuf[i]) { + case '*': + i--; + break; + default: + break trailLoop; + } + } + comment_reader.sp = i + 1; + + // Store the text of the doc comment + docComment = comment_reader.chars(); + } else { + docComment = ""; + } + } finally { + scanned = true; + if (docComment != null && + docComment.matches("(?sm).*^\\s*@deprecated( |$).*")) { + deprecatedFlag = true; + } } } } - /** - * Process a doc comment and make the string content available. - * Strips leading whitespace and stars. - */ - @SuppressWarnings("fallthrough") - protected void processComment(int pos, int endPos, CommentStyle style) { - if (style != CommentStyle.JAVADOC) { - return; - } - - buf = reader.getRawCharacters(pos, endPos); - buflen = buf.length; - bp = 0; - col = 0; - - docCommentCount = 0; - - boolean firstLine = true; - - // Skip over first slash - scanDocCommentChar(); - // Skip over first star - scanDocCommentChar(); - - // consume any number of stars - while (bp < buflen && ch == '*') { - scanDocCommentChar(); - } - // is the comment in the form /**/, /***/, /****/, etc. ? - if (bp < buflen && ch == '/') { - docComment = ""; - return; - } - - // skip a newline on the first line of the comment. - if (bp < buflen) { - if (ch == LF) { - scanDocCommentChar(); - firstLine = false; - } else if (ch == CR) { - scanDocCommentChar(); - if (ch == LF) { - scanDocCommentChar(); - firstLine = false; - } - } - } - - outerLoop: - - // The outerLoop processes the doc comment, looping once - // for each line. For each line, it first strips off - // whitespace, then it consumes any stars, then it - // puts the rest of the line into our buffer. - while (bp < buflen) { - - // The wsLoop consumes whitespace from the beginning - // of each line. - wsLoop: - - while (bp < buflen) { - switch(ch) { - case ' ': - scanDocCommentChar(); - break; - case '\t': - col = ((col - 1) / TabInc * TabInc) + TabInc; - scanDocCommentChar(); - break; - case FF: - col = 0; - scanDocCommentChar(); - break; -// Treat newline at beginning of line (blank line, no star) -// as comment text. Old Javadoc compatibility requires this. -/*---------------------------------* - case CR: // (Spec 3.4) - scanDocCommentChar(); - if (ch == LF) { - col = 0; - scanDocCommentChar(); - } - break; - case LF: // (Spec 3.4) - scanDocCommentChar(); - break; -*---------------------------------*/ - default: - // we've seen something that isn't whitespace; - // jump out. - break wsLoop; - } - } - - // Are there stars here? If so, consume them all - // and check for the end of comment. - if (ch == '*') { - // skip all of the stars - do { - scanDocCommentChar(); - } while (ch == '*'); - - // check for the closing slash. - if (ch == '/') { - // We're done with the doc comment - // scanChar() and breakout. - break outerLoop; - } - } else if (! firstLine) { - //The current line does not begin with a '*' so we will indent it. - for (int i = 1; i < col; i++) { - if (docCommentCount == docCommentBuffer.length) - expandCommentBuffer(); - docCommentBuffer[docCommentCount++] = ' '; - } - } - - // The textLoop processes the rest of the characters - // on the line, adding them to our buffer. - textLoop: - while (bp < buflen) { - switch (ch) { - case '*': - // Is this just a star? Or is this the - // end of a comment? - scanDocCommentChar(); - if (ch == '/') { - // This is the end of the comment, - // set ch and return our buffer. - break outerLoop; - } - // This is just an ordinary star. Add it to - // the buffer. - if (docCommentCount == docCommentBuffer.length) - expandCommentBuffer(); - docCommentBuffer[docCommentCount++] = '*'; - break; - case ' ': - case '\t': - if (docCommentCount == docCommentBuffer.length) - expandCommentBuffer(); - docCommentBuffer[docCommentCount++] = ch; - scanDocCommentChar(); - break; - case FF: - scanDocCommentChar(); - break textLoop; // treat as end of line - case CR: // (Spec 3.4) - scanDocCommentChar(); - if (ch != LF) { - // Canonicalize CR-only line terminator to LF - if (docCommentCount == docCommentBuffer.length) - expandCommentBuffer(); - docCommentBuffer[docCommentCount++] = (char)LF; - break textLoop; - } - /* fall through to LF case */ - case LF: // (Spec 3.4) - // We've seen a newline. Add it to our - // buffer and break out of this loop, - // starting fresh on a new line. - if (docCommentCount == docCommentBuffer.length) - expandCommentBuffer(); - docCommentBuffer[docCommentCount++] = ch; - scanDocCommentChar(); - break textLoop; - default: - // Add the character to our buffer. - if (docCommentCount == docCommentBuffer.length) - expandCommentBuffer(); - docCommentBuffer[docCommentCount++] = ch; - scanDocCommentChar(); - } - } // end textLoop - firstLine = false; - } // end outerLoop - - if (docCommentCount > 0) { - int i = docCommentCount - 1; - trailLoop: - while (i > -1) { - switch (docCommentBuffer[i]) { - case '*': - i--; - break; - default: - break trailLoop; - } - } - docCommentCount = i + 1; - - // Store the text of the doc comment - docComment = new String(docCommentBuffer, 0 , docCommentCount); - } else { - docComment = ""; - } - } - - /** Build a map for translating between line numbers and - * positions in the input. - * - * @return a LineMap */ + @Override public Position.LineMap getLineMap() { char[] buf = reader.getRawCharacters(); return Position.makeLineMap(buf, buf.length, true); diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/parser/Tokens.java --- a/langtools/src/share/classes/com/sun/tools/javac/parser/Tokens.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/Tokens.java Fri Nov 18 11:11:11 2011 -0800 @@ -30,8 +30,10 @@ import com.sun.tools.javac.api.Formattable; import com.sun.tools.javac.api.Messages; import com.sun.tools.javac.parser.Tokens.Token.Tag; +import com.sun.tools.javac.util.List; import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Context; +import com.sun.tools.javac.util.ListBuffer; import com.sun.tools.javac.util.Names; /** A class that defines codes/utilities for Java source tokens @@ -281,6 +283,19 @@ } } + public interface Comment { + + enum CommentStyle { + LINE, + BLOCK, + JAVADOC, + } + + String getText(); + CommentStyle getStyle(); + boolean isDeprecated(); + } + /** * This is the class representing a javac token. Each token has several fields * that are set by the javac lexer (i.e. start/end position, string value, etc). @@ -304,18 +319,14 @@ /** The end position of this token */ public final int endPos; - /** Is this token preceeded by a deprecated comment? */ - public final boolean deprecatedFlag; + /** Comment reader associated with this token */ + public final List comments; - /** Is this token preceeded by a deprecated comment? */ - public String docComment; - - Token(TokenKind kind, int pos, int endPos, - boolean deprecatedFlag) { + Token(TokenKind kind, int pos, int endPos, List comments) { this.kind = kind; this.pos = pos; this.endPos = endPos; - this.deprecatedFlag = deprecatedFlag; + this.comments = comments; checkKind(); } @@ -331,8 +342,8 @@ throw new AssertionError("Cant split - bad subtokens"); } return new Token[] { - new Token(t1, pos, pos + t1.name.length(), deprecatedFlag), - new Token(t2, pos + t1.name.length(), endPos, false) + new Token(t1, pos, pos + t1.name.length(), comments), + new Token(t2, pos + t1.name.length(), endPos, null) }; } @@ -353,14 +364,52 @@ public int radix() { throw new UnsupportedOperationException(); } + + /** + * Preserve classic semantics - if multiple javadocs are found on the token + * the last one is returned + */ + public String comment(Comment.CommentStyle style) { + List readers = getReaders(Comment.CommentStyle.JAVADOC); + return readers.isEmpty() ? + null : + readers.head.getText(); + } + + /** + * Preserve classic semantics - deprecated should be set if at least one + * javadoc comment attached to this token contains the '@deprecated' string + */ + public boolean deprecatedFlag() { + for (Comment r : getReaders(Comment.CommentStyle.JAVADOC)) { + if (r.isDeprecated()) { + return true; + } + } + return false; + } + + private List getReaders(Comment.CommentStyle style) { + if (comments == null) { + return List.nil(); + } else { + ListBuffer buf = ListBuffer.lb(); + for (Comment r : comments) { + if (r.getStyle() == style) { + buf.add(r); + } + } + return buf.toList(); + } + } } final static class NamedToken extends Token { /** The name of this token */ public final Name name; - public NamedToken(TokenKind kind, int pos, int endPos, Name name, boolean deprecatedFlag) { - super(kind, pos, endPos, deprecatedFlag); + public NamedToken(TokenKind kind, int pos, int endPos, Name name, List comments) { + super(kind, pos, endPos, comments); this.name = name; } @@ -380,8 +429,8 @@ /** The string value of this token */ public final String stringVal; - public StringToken(TokenKind kind, int pos, int endPos, String stringVal, boolean deprecatedFlag) { - super(kind, pos, endPos, deprecatedFlag); + public StringToken(TokenKind kind, int pos, int endPos, String stringVal, List comments) { + super(kind, pos, endPos, comments); this.stringVal = stringVal; } @@ -401,8 +450,8 @@ /** The 'radix' value of this token */ public final int radix; - public NumericToken(TokenKind kind, int pos, int endPos, String stringVal, int radix, boolean deprecatedFlag) { - super(kind, pos, endPos, stringVal, deprecatedFlag); + public NumericToken(TokenKind kind, int pos, int endPos, String stringVal, int radix, List comments) { + super(kind, pos, endPos, stringVal, comments); this.radix = radix; } @@ -419,5 +468,5 @@ } public static final Token DUMMY = - new Token(TokenKind.ERROR, 0, 0, false); + new Token(TokenKind.ERROR, 0, 0, null); } diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java --- a/langtools/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/UnicodeReader.java Fri Nov 18 11:11:11 2011 -0800 @@ -26,8 +26,12 @@ package com.sun.tools.javac.parser; import com.sun.tools.javac.file.JavacFileManager; +import com.sun.tools.javac.util.Log; +import com.sun.tools.javac.util.Name; +import com.sun.tools.javac.util.Names; + import java.nio.CharBuffer; -import com.sun.tools.javac.util.Log; + import static com.sun.tools.javac.util.LayoutCharacters.*; /** The char reader used by the javac lexer/tokenizer. Returns the sequence of @@ -58,6 +62,12 @@ protected int unicodeConversionBp = -1; protected Log log; + protected Names names; + + /** A character buffer for saved chars. + */ + protected char[] sbuf = new char[128]; + protected int sp; /** * Create a scanner from the input array. This method might @@ -76,6 +86,7 @@ protected UnicodeReader(ScannerFactory sf, char[] input, int inputLength) { log = sf.log; + names = sf.names; if (inputLength == input.length) { if (input.length > 0 && Character.isWhitespace(input[input.length - 1])) { inputLength--; @@ -103,6 +114,48 @@ } } + /** Read next character in comment, skipping over double '\' characters. + */ + protected void scanCommentChar() { + scanChar(); + if (ch == '\\') { + if (peekChar() == '\\' && !isUnicode()) { + skipChar(); + } else { + convertUnicode(); + } + } + } + + /** Append a character to sbuf. + */ + protected void putChar(char ch, boolean scan) { + if (sp == sbuf.length) { + char[] newsbuf = new char[sbuf.length * 2]; + System.arraycopy(sbuf, 0, newsbuf, 0, sbuf.length); + sbuf = newsbuf; + } + sbuf[sp++] = ch; + if (scan) + scanChar(); + } + + protected void putChar(char ch) { + putChar(ch, false); + } + + protected void putChar(boolean scan) { + putChar(ch, scan); + } + + Name name() { + return names.fromChars(sbuf, 0, sp); + } + + String chars() { + return new String(sbuf, 0, sp); + } + /** Convert unicode escape; bp points to initial '\' character * (Spec 3.3). */ diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java --- a/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/processing/JavacProcessingEnvironment.java Fri Nov 18 11:11:11 2011 -0800 @@ -1222,7 +1222,7 @@ List classes = List.nil(); for (JCCompilationUnit unit : units) { for (JCTree node : unit.defs) { - if (node.getTag() == JCTree.CLASSDEF) { + if (node.hasTag(JCTree.Tag.CLASSDEF)) { ClassSymbol sym = ((JCClassDecl) node).sym; Assert.checkNonNull(sym); classes = classes.prepend(sym); diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java --- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java Fri Nov 18 11:11:11 2011 -0800 @@ -42,6 +42,7 @@ import com.sun.source.tree.*; import static com.sun.tools.javac.code.BoundKind.*; +import static com.sun.tools.javac.tree.JCTree.Tag.*; /** * Root class for abstract syntax tree nodes. It provides definitions @@ -79,253 +80,289 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { /* Tree tag values, identifying kinds of trees */ + public enum Tag{ + /** For methods that return an invalid tag if a given condition is not met + */ + NO_TAG, - /** Toplevel nodes, of type TopLevel, representing entire source files. - */ - public static final int TOPLEVEL = 1; + /** Toplevel nodes, of type TopLevel, representing entire source files. + */ + TOPLEVEL, - /** Import clauses, of type Import. - */ - public static final int IMPORT = TOPLEVEL + 1; + /** Import clauses, of type Import. + */ + IMPORT, - /** Class definitions, of type ClassDef. - */ - public static final int CLASSDEF = IMPORT + 1; + /** Class definitions, of type ClassDef. + */ + CLASSDEF, - /** Method definitions, of type MethodDef. - */ - public static final int METHODDEF = CLASSDEF + 1; + /** Method definitions, of type MethodDef. + */ + METHODDEF, - /** Variable definitions, of type VarDef. - */ - public static final int VARDEF = METHODDEF + 1; + /** Variable definitions, of type VarDef. + */ + VARDEF, - /** The no-op statement ";", of type Skip - */ - public static final int SKIP = VARDEF + 1; + /** The no-op statement ";", of type Skip + */ + SKIP, + + /** Blocks, of type Block. + */ + BLOCK, - /** Blocks, of type Block. - */ - public static final int BLOCK = SKIP + 1; + /** Do-while loops, of type DoLoop. + */ + DOLOOP, - /** Do-while loops, of type DoLoop. - */ - public static final int DOLOOP = BLOCK + 1; + /** While-loops, of type WhileLoop. + */ + WHILELOOP, - /** While-loops, of type WhileLoop. - */ - public static final int WHILELOOP = DOLOOP + 1; + /** For-loops, of type ForLoop. + */ + FORLOOP, - /** For-loops, of type ForLoop. - */ - public static final int FORLOOP = WHILELOOP + 1; + /** Foreach-loops, of type ForeachLoop. + */ + FOREACHLOOP, - /** Foreach-loops, of type ForeachLoop. - */ - public static final int FOREACHLOOP = FORLOOP + 1; + /** Labelled statements, of type Labelled. + */ + LABELLED, - /** Labelled statements, of type Labelled. - */ - public static final int LABELLED = FOREACHLOOP + 1; + /** Switch statements, of type Switch. + */ + SWITCH, - /** Switch statements, of type Switch. - */ - public static final int SWITCH = LABELLED + 1; + /** Case parts in switch statements, of type Case. + */ + CASE, - /** Case parts in switch statements, of type Case. - */ - public static final int CASE = SWITCH + 1; + /** Synchronized statements, of type Synchonized. + */ + SYNCHRONIZED, + + /** Try statements, of type Try. + */ + TRY, - /** Synchronized statements, of type Synchonized. - */ - public static final int SYNCHRONIZED = CASE + 1; + /** Catch clauses in try statements, of type Catch. + */ + CATCH, - /** Try statements, of type Try. - */ - public static final int TRY = SYNCHRONIZED + 1; + /** Conditional expressions, of type Conditional. + */ + CONDEXPR, - /** Catch clauses in try statements, of type Catch. - */ - public static final int CATCH = TRY + 1; + /** Conditional statements, of type If. + */ + IF, - /** Conditional expressions, of type Conditional. - */ - public static final int CONDEXPR = CATCH + 1; + /** Expression statements, of type Exec. + */ + EXEC, - /** Conditional statements, of type If. - */ - public static final int IF = CONDEXPR + 1; + /** Break statements, of type Break. + */ + BREAK, - /** Expression statements, of type Exec. - */ - public static final int EXEC = IF + 1; + /** Continue statements, of type Continue. + */ + CONTINUE, - /** Break statements, of type Break. - */ - public static final int BREAK = EXEC + 1; + /** Return statements, of type Return. + */ + RETURN, - /** Continue statements, of type Continue. - */ - public static final int CONTINUE = BREAK + 1; + /** Throw statements, of type Throw. + */ + THROW, + + /** Assert statements, of type Assert. + */ + ASSERT, - /** Return statements, of type Return. - */ - public static final int RETURN = CONTINUE + 1; + /** Method invocation expressions, of type Apply. + */ + APPLY, - /** Throw statements, of type Throw. - */ - public static final int THROW = RETURN + 1; + /** Class instance creation expressions, of type NewClass. + */ + NEWCLASS, - /** Assert statements, of type Assert. - */ - public static final int ASSERT = THROW + 1; + /** Array creation expressions, of type NewArray. + */ + NEWARRAY, - /** Method invocation expressions, of type Apply. - */ - public static final int APPLY = ASSERT + 1; + /** Parenthesized subexpressions, of type Parens. + */ + PARENS, - /** Class instance creation expressions, of type NewClass. - */ - public static final int NEWCLASS = APPLY + 1; + /** Assignment expressions, of type Assign. + */ + ASSIGN, - /** Array creation expressions, of type NewArray. - */ - public static final int NEWARRAY = NEWCLASS + 1; + /** Type cast expressions, of type TypeCast. + */ + TYPECAST, - /** Parenthesized subexpressions, of type Parens. - */ - public static final int PARENS = NEWARRAY + 1; + /** Type test expressions, of type TypeTest. + */ + TYPETEST, - /** Assignment expressions, of type Assign. - */ - public static final int ASSIGN = PARENS + 1; + /** Indexed array expressions, of type Indexed. + */ + INDEXED, + + /** Selections, of type Select. + */ + SELECT, - /** Type cast expressions, of type TypeCast. - */ - public static final int TYPECAST = ASSIGN + 1; + /** Simple identifiers, of type Ident. + */ + IDENT, + + /** Literals, of type Literal. + */ + LITERAL, - /** Type test expressions, of type TypeTest. - */ - public static final int TYPETEST = TYPECAST + 1; + /** Basic type identifiers, of type TypeIdent. + */ + TYPEIDENT, - /** Indexed array expressions, of type Indexed. - */ - public static final int INDEXED = TYPETEST + 1; + /** Array types, of type TypeArray. + */ + TYPEARRAY, - /** Selections, of type Select. - */ - public static final int SELECT = INDEXED + 1; + /** Parameterized types, of type TypeApply. + */ + TYPEAPPLY, - /** Simple identifiers, of type Ident. - */ - public static final int IDENT = SELECT + 1; + /** Union types, of type TypeUnion + */ + TYPEUNION, - /** Literals, of type Literal. - */ - public static final int LITERAL = IDENT + 1; + /** Formal type parameters, of type TypeParameter. + */ + TYPEPARAMETER, - /** Basic type identifiers, of type TypeIdent. - */ - public static final int TYPEIDENT = LITERAL + 1; + /** Type argument. + */ + WILDCARD, - /** Array types, of type TypeArray. - */ - public static final int TYPEARRAY = TYPEIDENT + 1; - - /** Parameterized types, of type TypeApply. - */ - public static final int TYPEAPPLY = TYPEARRAY + 1; + /** Bound kind: extends, super, exact, or unbound + */ + TYPEBOUNDKIND, - /** Union types, of type TypeUnion - */ - public static final int TYPEUNION = TYPEAPPLY + 1; + /** metadata: Annotation. + */ + ANNOTATION, - /** Formal type parameters, of type TypeParameter. - */ - public static final int TYPEPARAMETER = TYPEUNION + 1; + /** metadata: Modifiers + */ + MODIFIERS, + + ANNOTATED_TYPE, - /** Type argument. - */ - public static final int WILDCARD = TYPEPARAMETER + 1; - - /** Bound kind: extends, super, exact, or unbound - */ - public static final int TYPEBOUNDKIND = WILDCARD + 1; + /** Error trees, of type Erroneous. + */ + ERRONEOUS, - /** metadata: Annotation. - */ - public static final int ANNOTATION = TYPEBOUNDKIND + 1; + /** Unary operators, of type Unary. + */ + POS, // + + NEG, // - + NOT, // ! + COMPL, // ~ + PREINC, // ++ _ + PREDEC, // -- _ + POSTINC, // _ ++ + POSTDEC, // _ -- - /** metadata: Modifiers - */ - public static final int MODIFIERS = ANNOTATION + 1; - - public static final int ANNOTATED_TYPE = MODIFIERS + 1; + /** unary operator for null reference checks, only used internally. + */ + NULLCHK, - /** Error trees, of type Erroneous. - */ - public static final int ERRONEOUS = ANNOTATED_TYPE + 1; + /** Binary operators, of type Binary. + */ + OR, // || + AND, // && + BITOR, // | + BITXOR, // ^ + BITAND, // & + EQ, // == + NE, // != + LT, // < + GT, // > + LE, // <= + GE, // >= + SL, // << + SR, // >> + USR, // >>> + PLUS, // + + MINUS, // - + MUL, // * + DIV, // / + MOD, // % - /** Unary operators, of type Unary. - */ - public static final int POS = ERRONEOUS + 1; // + - public static final int NEG = POS + 1; // - - public static final int NOT = NEG + 1; // ! - public static final int COMPL = NOT + 1; // ~ - public static final int PREINC = COMPL + 1; // ++ _ - public static final int PREDEC = PREINC + 1; // -- _ - public static final int POSTINC = PREDEC + 1; // _ ++ - public static final int POSTDEC = POSTINC + 1; // _ -- + /** Assignment operators, of type Assignop. + */ + BITOR_ASG(BITOR), // |= + BITXOR_ASG(BITXOR), // ^= + BITAND_ASG(BITAND), // &= - /** unary operator for null reference checks, only used internally. - */ - public static final int NULLCHK = POSTDEC + 1; + SL_ASG(SL), // <<= + SR_ASG(SR), // >>= + USR_ASG(USR), // >>>= + PLUS_ASG(PLUS), // += + MINUS_ASG(MINUS), // -= + MUL_ASG(MUL), // *= + DIV_ASG(DIV), // /= + MOD_ASG(MOD), // %= - /** Binary operators, of type Binary. - */ - public static final int OR = NULLCHK + 1; // || - public static final int AND = OR + 1; // && - public static final int BITOR = AND + 1; // | - public static final int BITXOR = BITOR + 1; // ^ - public static final int BITAND = BITXOR + 1; // & - public static final int EQ = BITAND + 1; // == - public static final int NE = EQ + 1; // != - public static final int LT = NE + 1; // < - public static final int GT = LT + 1; // > - public static final int LE = GT + 1; // <= - public static final int GE = LE + 1; // >= - public static final int SL = GE + 1; // << - public static final int SR = SL + 1; // >> - public static final int USR = SR + 1; // >>> - public static final int PLUS = USR + 1; // + - public static final int MINUS = PLUS + 1; // - - public static final int MUL = MINUS + 1; // * - public static final int DIV = MUL + 1; // / - public static final int MOD = DIV + 1; // % + /** A synthetic let expression, of type LetExpr. + */ + LETEXPR; // ala scheme + + private Tag noAssignTag; + + private static int numberOfOperators = MOD.ordinal() - POS.ordinal() + 1; + + private Tag(Tag noAssignTag) { + this.noAssignTag = noAssignTag; + } + + private Tag() { } + + public static int getNumberOfOperators() { + return numberOfOperators; + } - /** Assignment operators, of type Assignop. - */ - public static final int BITOR_ASG = MOD + 1; // |= - public static final int BITXOR_ASG = BITOR_ASG + 1; // ^= - public static final int BITAND_ASG = BITXOR_ASG + 1; // &= + public Tag noAssignOp() { + if (noAssignTag != null) + return noAssignTag; + throw new AssertionError("noAssignOp() method is not available for non assignment tags"); + } + + public boolean isPostUnaryOp() { + return (this == POSTINC || this == POSTDEC); + } - public static final int SL_ASG = SL + BITOR_ASG - BITOR; // <<= - public static final int SR_ASG = SL_ASG + 1; // >>= - public static final int USR_ASG = SR_ASG + 1; // >>>= - public static final int PLUS_ASG = USR_ASG + 1; // += - public static final int MINUS_ASG = PLUS_ASG + 1; // -= - public static final int MUL_ASG = MINUS_ASG + 1; // *= - public static final int DIV_ASG = MUL_ASG + 1; // /= - public static final int MOD_ASG = DIV_ASG + 1; // %= + public boolean isIncOrDecUnaryOp() { + return (this == PREINC || this == PREDEC || this == POSTINC || this == POSTDEC); + } - /** A synthetic let expression, of type LetExpr. - */ - public static final int LETEXPR = MOD_ASG + 1; // ala scheme + public boolean isAssignop() { + return noAssignTag != null; + } - - /** The offset between assignment operators and normal operators. - */ - public static final int ASGOffset = BITOR_ASG - BITOR; + public int operatorIndex() { + return (this.ordinal() - POS.ordinal()); + } + } /* The (encoded) position in the source file. @see util.Position. */ @@ -337,7 +374,13 @@ /* The tag of this node -- one of the constants declared above. */ - public abstract int getTag(); + public abstract Tag getTag(); + + /* Returns true if the tag of this node is equals to tag. + */ + public boolean hasTag(Tag tag) { + return tag == getTag(); + } /** Convert a tree to a pretty-printed string. */ @Override @@ -464,10 +507,9 @@ public List getImports() { ListBuffer imports = new ListBuffer(); for (JCTree tree : defs) { - int tag = tree.getTag(); - if (tag == IMPORT) + if (tree.hasTag(IMPORT)) imports.append((JCImport)tree); - else if (tag != SKIP) + else if (!tree.hasTag(SKIP)) break; } return imports.toList(); @@ -482,7 +524,7 @@ public List getTypeDecls() { List typeDefs; for (typeDefs = defs; !typeDefs.isEmpty(); typeDefs = typeDefs.tail) - if (typeDefs.head.getTag() != IMPORT) + if (!typeDefs.head.hasTag(IMPORT)) break; return typeDefs; } @@ -492,7 +534,7 @@ } @Override - public int getTag() { + public Tag getTag() { return TOPLEVEL; } } @@ -521,7 +563,7 @@ } @Override - public int getTag() { + public Tag getTag() { return IMPORT; } } @@ -618,7 +660,7 @@ } @Override - public int getTag() { + public Tag getTag() { return CLASSDEF; } } @@ -690,7 +732,7 @@ } @Override - public int getTag() { + public Tag getTag() { return METHODDEF; } } @@ -736,7 +778,7 @@ } @Override - public int getTag() { + public Tag getTag() { return VARDEF; } } @@ -757,7 +799,7 @@ } @Override - public int getTag() { + public Tag getTag() { return SKIP; } } @@ -790,7 +832,7 @@ } @Override - public int getTag() { + public Tag getTag() { return BLOCK; } } @@ -817,7 +859,7 @@ } @Override - public int getTag() { + public Tag getTag() { return DOLOOP; } } @@ -844,7 +886,7 @@ } @Override - public int getTag() { + public Tag getTag() { return WHILELOOP; } } @@ -885,7 +927,7 @@ } @Override - public int getTag() { + public Tag getTag() { return FORLOOP; } } @@ -914,7 +956,7 @@ return v.visitEnhancedForLoop(this, d); } @Override - public int getTag() { + public Tag getTag() { return FOREACHLOOP; } } @@ -939,7 +981,7 @@ return v.visitLabeledStatement(this, d); } @Override - public int getTag() { + public Tag getTag() { return LABELLED; } } @@ -965,7 +1007,7 @@ return v.visitSwitch(this, d); } @Override - public int getTag() { + public Tag getTag() { return SWITCH; } } @@ -991,7 +1033,7 @@ return v.visitCase(this, d); } @Override - public int getTag() { + public Tag getTag() { return CASE; } } @@ -1017,7 +1059,7 @@ return v.visitSynchronized(this, d); } @Override - public int getTag() { + public Tag getTag() { return SYNCHRONIZED; } } @@ -1057,7 +1099,7 @@ return resources; } @Override - public int getTag() { + public Tag getTag() { return TRY; } } @@ -1083,7 +1125,7 @@ return v.visitCatch(this, d); } @Override - public int getTag() { + public Tag getTag() { return CATCH; } } @@ -1115,7 +1157,7 @@ return v.visitConditionalExpression(this, d); } @Override - public int getTag() { + public Tag getTag() { return CONDEXPR; } } @@ -1147,7 +1189,7 @@ return v.visitIf(this, d); } @Override - public int getTag() { + public Tag getTag() { return IF; } } @@ -1172,7 +1214,7 @@ return v.visitExpressionStatement(this, d); } @Override - public int getTag() { + public Tag getTag() { return EXEC; } @@ -1212,7 +1254,7 @@ return v.visitBreak(this, d); } @Override - public int getTag() { + public Tag getTag() { return BREAK; } } @@ -1237,7 +1279,7 @@ return v.visitContinue(this, d); } @Override - public int getTag() { + public Tag getTag() { return CONTINUE; } } @@ -1260,7 +1302,7 @@ return v.visitReturn(this, d); } @Override - public int getTag() { + public Tag getTag() { return RETURN; } } @@ -1283,7 +1325,7 @@ return v.visitThrow(this, d); } @Override - public int getTag() { + public Tag getTag() { return THROW; } } @@ -1309,7 +1351,7 @@ return v.visitAssert(this, d); } @Override - public int getTag() { + public Tag getTag() { return ASSERT; } } @@ -1352,7 +1394,7 @@ return this; } @Override - public int getTag() { + public Tag getTag() { return(APPLY); } } @@ -1402,7 +1444,7 @@ return v.visitNewClass(this, d); } @Override - public int getTag() { + public Tag getTag() { return NEWCLASS; } } @@ -1438,7 +1480,7 @@ return v.visitNewArray(this, d); } @Override - public int getTag() { + public Tag getTag() { return NEWARRAY; } } @@ -1461,7 +1503,7 @@ return v.visitParenthesized(this, d); } @Override - public int getTag() { + public Tag getTag() { return PARENS; } } @@ -1487,7 +1529,7 @@ return v.visitAssignment(this, d); } @Override - public int getTag() { + public Tag getTag() { return ASSIGN; } } @@ -1496,11 +1538,11 @@ * An assignment with "+=", "|=" ... */ public static class JCAssignOp extends JCExpression implements CompoundAssignmentTree { - private int opcode; + private Tag opcode; public JCExpression lhs; public JCExpression rhs; public Symbol operator; - protected JCAssignOp(int opcode, JCTree lhs, JCTree rhs, Symbol operator) { + protected JCAssignOp(Tag opcode, JCTree lhs, JCTree rhs, Symbol operator) { this.opcode = opcode; this.lhs = (JCExpression)lhs; this.rhs = (JCExpression)rhs; @@ -1520,7 +1562,7 @@ return v.visitCompoundAssignment(this, d); } @Override - public int getTag() { + public Tag getTag() { return opcode; } } @@ -1529,10 +1571,10 @@ * A unary operation. */ public static class JCUnary extends JCExpression implements UnaryTree { - private int opcode; + private Tag opcode; public JCExpression arg; public Symbol operator; - protected JCUnary(int opcode, JCExpression arg) { + protected JCUnary(Tag opcode, JCExpression arg) { this.opcode = opcode; this.arg = arg; } @@ -1549,11 +1591,11 @@ return v.visitUnary(this, d); } @Override - public int getTag() { + public Tag getTag() { return opcode; } - public void setTag(int tag) { + public void setTag(Tag tag) { opcode = tag; } } @@ -1562,11 +1604,11 @@ * A binary operation. */ public static class JCBinary extends JCExpression implements BinaryTree { - private int opcode; + private Tag opcode; public JCExpression lhs; public JCExpression rhs; public Symbol operator; - protected JCBinary(int opcode, + protected JCBinary(Tag opcode, JCExpression lhs, JCExpression rhs, Symbol operator) { @@ -1589,7 +1631,7 @@ return v.visitBinary(this, d); } @Override - public int getTag() { + public Tag getTag() { return opcode; } } @@ -1615,7 +1657,7 @@ return v.visitTypeCast(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPECAST; } } @@ -1641,7 +1683,7 @@ return v.visitInstanceOf(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPETEST; } } @@ -1667,7 +1709,7 @@ return v.visitArrayAccess(this, d); } @Override - public int getTag() { + public Tag getTag() { return INDEXED; } } @@ -1698,7 +1740,7 @@ } public Name getIdentifier() { return name; } @Override - public int getTag() { + public Tag getTag() { return SELECT; } } @@ -1724,7 +1766,8 @@ public R accept(TreeVisitor v, D d) { return v.visitIdentifier(this, d); } - public int getTag() { + @Override + public Tag getTag() { return IDENT; } } @@ -1790,7 +1833,7 @@ return this; } @Override - public int getTag() { + public Tag getTag() { return LITERAL; } } @@ -1838,7 +1881,7 @@ return v.visitPrimitiveType(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPEIDENT; } } @@ -1861,7 +1904,7 @@ return v.visitArrayType(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPEARRAY; } } @@ -1889,7 +1932,7 @@ return v.visitParameterizedType(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPEAPPLY; } } @@ -1917,7 +1960,7 @@ return v.visitUnionType(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPEUNION; } } @@ -1947,7 +1990,7 @@ return v.visitTypeParameter(this, d); } @Override - public int getTag() { + public Tag getTag() { return TYPEPARAMETER; } } @@ -1981,7 +2024,7 @@ return v.visitWildcard(this, d); } @Override - public int getTag() { + public Tag getTag() { return WILDCARD; } } @@ -2002,7 +2045,7 @@ throw new AssertionError("TypeBoundKind is not part of a public API"); } @Override - public int getTag() { + public Tag getTag() { return TYPEBOUNDKIND; } } @@ -2027,7 +2070,7 @@ return v.visitAnnotation(this, d); } @Override - public int getTag() { + public Tag getTag() { return ANNOTATION; } } @@ -2054,7 +2097,7 @@ return v.visitModifiers(this, d); } @Override - public int getTag() { + public Tag getTag() { return MODIFIERS; } } @@ -2079,7 +2122,7 @@ return v.visitErroneous(this, d); } @Override - public int getTag() { + public Tag getTag() { return ERRONEOUS; } } @@ -2103,7 +2146,7 @@ throw new AssertionError("LetExpr is not part of a public API"); } @Override - public int getTag() { + public Tag getTag() { return LETEXPR; } } @@ -2175,9 +2218,9 @@ List elems); JCParens Parens(JCExpression expr); JCAssign Assign(JCExpression lhs, JCExpression rhs); - JCAssignOp Assignop(int opcode, JCTree lhs, JCTree rhs); - JCUnary Unary(int opcode, JCExpression arg); - JCBinary Binary(int opcode, JCExpression lhs, JCExpression rhs); + JCAssignOp Assignop(Tag opcode, JCTree lhs, JCTree rhs); + JCUnary Unary(Tag opcode, JCExpression arg); + JCBinary Binary(Tag opcode, JCExpression lhs, JCExpression rhs); JCTypeCast TypeCast(JCTree expr, JCExpression type); JCInstanceOf TypeTest(JCExpression expr, JCTree clazz); JCArrayAccess Indexed(JCExpression indexed, JCExpression index); diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java --- a/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/Pretty.java Fri Nov 18 11:11:11 2011 -0800 @@ -36,6 +36,8 @@ import com.sun.tools.javac.tree.JCTree.*; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.code.Flags.ANNOTATION; +import static com.sun.tools.javac.tree.JCTree.Tag.*; /** Prints out a tree as an indented Java source program. * @@ -310,7 +312,7 @@ /** Is the given tree an enumerator definition? */ boolean isEnumerator(JCTree t) { - return t.getTag() == JCTree.VARDEF && (((JCVariableDecl) t).mods.flags & ENUM) != 0; + return t.hasTag(VARDEF) && (((JCVariableDecl) t).mods.flags & ENUM) != 0; } /** Print unit consisting of package clause and import statements in toplevel, @@ -331,9 +333,9 @@ } boolean firstImport = true; for (List l = tree.defs; - l.nonEmpty() && (cdef == null || l.head.getTag() == JCTree.IMPORT); + l.nonEmpty() && (cdef == null || l.head.hasTag(IMPORT)); l = l.tail) { - if (l.head.getTag() == JCTree.IMPORT) { + if (l.head.hasTag(IMPORT)) { JCImport imp = (JCImport)l.head; Name name = TreeInfo.name(imp.qualid); if (name == name.table.names.asterisk || @@ -484,7 +486,7 @@ print("/*public static final*/ "); print(tree.name); if (tree.init != null) { - if (sourceOutput && tree.init.getTag() == JCTree.NEWCLASS) { + if (sourceOutput && tree.init.hasTag(NEWCLASS)) { print(" /*enum*/ "); JCNewClass init = (JCNewClass) tree.init; if (init.args != null && init.args.nonEmpty()) { @@ -545,7 +547,7 @@ printStat(tree.body); align(); print(" while "); - if (tree.cond.getTag() == JCTree.PARENS) { + if (tree.cond.hasTag(PARENS)) { printExpr(tree.cond); } else { print("("); @@ -561,7 +563,7 @@ public void visitWhileLoop(JCWhileLoop tree) { try { print("while "); - if (tree.cond.getTag() == JCTree.PARENS) { + if (tree.cond.hasTag(PARENS)) { printExpr(tree.cond); } else { print("("); @@ -579,7 +581,7 @@ try { print("for ("); if (tree.init.nonEmpty()) { - if (tree.init.head.getTag() == JCTree.VARDEF) { + if (tree.init.head.hasTag(VARDEF)) { printExpr(tree.init.head); for (List l = tree.init.tail; l.nonEmpty(); l = l.tail) { JCVariableDecl vdef = (JCVariableDecl)l.head; @@ -626,7 +628,7 @@ public void visitSwitch(JCSwitch tree) { try { print("switch "); - if (tree.selector.getTag() == JCTree.PARENS) { + if (tree.selector.hasTag(PARENS)) { printExpr(tree.selector); } else { print("("); @@ -665,7 +667,7 @@ public void visitSynchronized(JCSynchronized tree) { try { print("synchronized "); - if (tree.lock.getTag() == JCTree.PARENS) { + if (tree.lock.hasTag(PARENS)) { printExpr(tree.lock); } else { print("("); @@ -736,7 +738,7 @@ public void visitIf(JCIf tree) { try { print("if "); - if (tree.cond.getTag() == JCTree.PARENS) { + if (tree.cond.hasTag(PARENS)) { printExpr(tree.cond); } else { print("("); @@ -823,7 +825,7 @@ public void visitApply(JCMethodInvocation tree) { try { if (!tree.typeargs.isEmpty()) { - if (tree.meth.getTag() == JCTree.SELECT) { + if (tree.meth.hasTag(SELECT)) { JCFieldAccess left = (JCFieldAccess)tree.meth; printExpr(left.selected); print(".<"); @@ -882,7 +884,7 @@ if (tree.elemtype != null) { print("new "); JCTree elem = tree.elemtype; - if (elem.getTag() == JCTree.TYPEARRAY) + if (elem.hasTag(TYPEARRAY)) printBaseElementType((JCArrayTypeTree) elem); else printExpr(elem); @@ -927,36 +929,36 @@ } } - public String operatorName(int tag) { + public String operatorName(JCTree.Tag tag) { switch(tag) { - case JCTree.POS: return "+"; - case JCTree.NEG: return "-"; - case JCTree.NOT: return "!"; - case JCTree.COMPL: return "~"; - case JCTree.PREINC: return "++"; - case JCTree.PREDEC: return "--"; - case JCTree.POSTINC: return "++"; - case JCTree.POSTDEC: return "--"; - case JCTree.NULLCHK: return "<*nullchk*>"; - case JCTree.OR: return "||"; - case JCTree.AND: return "&&"; - case JCTree.EQ: return "=="; - case JCTree.NE: return "!="; - case JCTree.LT: return "<"; - case JCTree.GT: return ">"; - case JCTree.LE: return "<="; - case JCTree.GE: return ">="; - case JCTree.BITOR: return "|"; - case JCTree.BITXOR: return "^"; - case JCTree.BITAND: return "&"; - case JCTree.SL: return "<<"; - case JCTree.SR: return ">>"; - case JCTree.USR: return ">>>"; - case JCTree.PLUS: return "+"; - case JCTree.MINUS: return "-"; - case JCTree.MUL: return "*"; - case JCTree.DIV: return "/"; - case JCTree.MOD: return "%"; + case POS: return "+"; + case NEG: return "-"; + case NOT: return "!"; + case COMPL: return "~"; + case PREINC: return "++"; + case PREDEC: return "--"; + case POSTINC: return "++"; + case POSTDEC: return "--"; + case NULLCHK: return "<*nullchk*>"; + case OR: return "||"; + case AND: return "&&"; + case EQ: return "=="; + case NE: return "!="; + case LT: return "<"; + case GT: return ">"; + case LE: return "<="; + case GE: return ">="; + case BITOR: return "|"; + case BITXOR: return "^"; + case BITAND: return "&"; + case SL: return "<<"; + case SR: return ">>"; + case USR: return ">>>"; + case PLUS: return "+"; + case MINUS: return "-"; + case MUL: return "*"; + case DIV: return "/"; + case MOD: return "%"; default: throw new Error(); } } @@ -965,7 +967,7 @@ try { open(prec, TreeInfo.assignopPrec); printExpr(tree.lhs, TreeInfo.assignopPrec + 1); - print(" " + operatorName(tree.getTag() - JCTree.ASGOffset) + "= "); + print(" " + operatorName(tree.getTag().noAssignOp()) + "= "); printExpr(tree.rhs, TreeInfo.assignopPrec); close(prec, TreeInfo.assignopPrec); } catch (IOException e) { @@ -978,7 +980,7 @@ int ownprec = TreeInfo.opPrec(tree.getTag()); String opname = operatorName(tree.getTag()); open(prec, ownprec); - if (tree.getTag() <= JCTree.PREDEC) { + if (!tree.getTag().isPostUnaryOp()) { print(opname); printExpr(tree.arg, ownprec); } else { @@ -1153,7 +1155,7 @@ while (true) { elem = tree.elemtype; print("[]"); - if (elem.getTag() != JCTree.TYPEARRAY) break; + if (!elem.hasTag(TYPEARRAY)) break; tree = (JCArrayTypeTree) elem; } } diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeCopier.java Fri Nov 18 11:11:11 2011 -0800 @@ -406,7 +406,7 @@ public JCTree visitOther(Tree node, P p) { JCTree tree = (JCTree) node; switch (tree.getTag()) { - case JCTree.LETEXPR: { + case LETEXPR: { LetExpr t = (LetExpr) node; List defs = copy(t.defs, p); JCTree expr = copy(t.expr, p); diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeInfo.java Fri Nov 18 11:11:11 2011 -0800 @@ -35,6 +35,9 @@ import com.sun.tools.javac.tree.JCTree.*; import static com.sun.tools.javac.code.Flags.*; +import static com.sun.tools.javac.tree.JCTree.Tag.*; +import static com.sun.tools.javac.tree.JCTree.Tag.BLOCK; +import static com.sun.tools.javac.tree.JCTree.Tag.SYNCHRONIZED; /** Utility class containing inspector methods for trees. * @@ -56,53 +59,60 @@ /** The names of all operators. */ - private Name[] opname = new Name[JCTree.MOD - JCTree.POS + 1]; + private Name[] opname = new Name[Tag.getNumberOfOperators()]; + + private void setOpname(Tag tag, String name, Names names) { + setOpname(tag, names.fromString(name)); + } + private void setOpname(Tag tag, Name name) { + opname[tag.operatorIndex()] = name; + } private TreeInfo(Context context) { context.put(treeInfoKey, this); Names names = Names.instance(context); - opname[JCTree.POS - JCTree.POS] = names.fromString("+"); - opname[JCTree.NEG - JCTree.POS] = names.hyphen; - opname[JCTree.NOT - JCTree.POS] = names.fromString("!"); - opname[JCTree.COMPL - JCTree.POS] = names.fromString("~"); - opname[JCTree.PREINC - JCTree.POS] = names.fromString("++"); - opname[JCTree.PREDEC - JCTree.POS] = names.fromString("--"); - opname[JCTree.POSTINC - JCTree.POS] = names.fromString("++"); - opname[JCTree.POSTDEC - JCTree.POS] = names.fromString("--"); - opname[JCTree.NULLCHK - JCTree.POS] = names.fromString("<*nullchk*>"); - opname[JCTree.OR - JCTree.POS] = names.fromString("||"); - opname[JCTree.AND - JCTree.POS] = names.fromString("&&"); - opname[JCTree.EQ - JCTree.POS] = names.fromString("=="); - opname[JCTree.NE - JCTree.POS] = names.fromString("!="); - opname[JCTree.LT - JCTree.POS] = names.fromString("<"); - opname[JCTree.GT - JCTree.POS] = names.fromString(">"); - opname[JCTree.LE - JCTree.POS] = names.fromString("<="); - opname[JCTree.GE - JCTree.POS] = names.fromString(">="); - opname[JCTree.BITOR - JCTree.POS] = names.fromString("|"); - opname[JCTree.BITXOR - JCTree.POS] = names.fromString("^"); - opname[JCTree.BITAND - JCTree.POS] = names.fromString("&"); - opname[JCTree.SL - JCTree.POS] = names.fromString("<<"); - opname[JCTree.SR - JCTree.POS] = names.fromString(">>"); - opname[JCTree.USR - JCTree.POS] = names.fromString(">>>"); - opname[JCTree.PLUS - JCTree.POS] = names.fromString("+"); - opname[JCTree.MINUS - JCTree.POS] = names.hyphen; - opname[JCTree.MUL - JCTree.POS] = names.asterisk; - opname[JCTree.DIV - JCTree.POS] = names.slash; - opname[JCTree.MOD - JCTree.POS] = names.fromString("%"); + setOpname(POS, "+", names); + setOpname(NEG, names.hyphen); + setOpname(NOT, "!", names); + setOpname(COMPL, "~", names); + setOpname(PREINC, "++", names); + setOpname(PREDEC, "--", names); + setOpname(POSTINC, "++", names); + setOpname(POSTDEC, "--", names); + setOpname(NULLCHK, "<*nullchk*>", names); + setOpname(OR, "||", names); + setOpname(AND, "&&", names); + setOpname(EQ, "==", names); + setOpname(NE, "!=", names); + setOpname(LT, "<", names); + setOpname(GT, ">", names); + setOpname(LE, "<=", names); + setOpname(GE, ">=", names); + setOpname(BITOR, "|", names); + setOpname(BITXOR, "^", names); + setOpname(BITAND, "&", names); + setOpname(SL, "<<", names); + setOpname(SR, ">>", names); + setOpname(USR, ">>>", names); + setOpname(PLUS, "+", names); + setOpname(MINUS, names.hyphen); + setOpname(MUL, names.asterisk); + setOpname(DIV, names.slash); + setOpname(MOD, "%", names); } /** Return name of operator with given tree tag. */ - public Name operatorName(int tag) { - return opname[tag - JCTree.POS]; + public Name operatorName(JCTree.Tag tag) { + return opname[tag.operatorIndex()]; } /** Is tree a constructor declaration? */ public static boolean isConstructor(JCTree tree) { - if (tree.getTag() == JCTree.METHODDEF) { + if (tree.hasTag(METHODDEF)) { Name name = ((JCMethodDecl) tree).name; return name == name.table.names.init; } else { @@ -119,17 +129,17 @@ } public static boolean isMultiCatch(JCCatch catchClause) { - return catchClause.param.vartype.getTag() == JCTree.TYPEUNION; + return catchClause.param.vartype.hasTag(TYPEUNION); } /** Is statement an initializer for a synthetic field? */ public static boolean isSyntheticInit(JCTree stat) { - if (stat.getTag() == JCTree.EXEC) { + if (stat.hasTag(EXEC)) { JCExpressionStatement exec = (JCExpressionStatement)stat; - if (exec.expr.getTag() == JCTree.ASSIGN) { + if (exec.expr.hasTag(ASSIGN)) { JCAssign assign = (JCAssign)exec.expr; - if (assign.lhs.getTag() == JCTree.SELECT) { + if (assign.lhs.hasTag(SELECT)) { JCFieldAccess select = (JCFieldAccess)assign.lhs; if (select.sym != null && (select.sym.flags() & SYNTHETIC) != 0) { @@ -146,9 +156,9 @@ /** If the expression is a method call, return the method name, null * otherwise. */ public static Name calledMethodName(JCTree tree) { - if (tree.getTag() == JCTree.EXEC) { + if (tree.hasTag(EXEC)) { JCExpressionStatement exec = (JCExpressionStatement)tree; - if (exec.expr.getTag() == JCTree.APPLY) { + if (exec.expr.hasTag(APPLY)) { Name mname = TreeInfo.name(((JCMethodInvocation) exec.expr).meth); return mname; } @@ -192,7 +202,7 @@ /** Return the first call in a constructor definition. */ public static JCMethodInvocation firstConstructorCall(JCTree tree) { - if (tree.getTag() != JCTree.METHODDEF) return null; + if (!tree.hasTag(METHODDEF)) return null; JCMethodDecl md = (JCMethodDecl) tree; Names names = md.name.table.names; if (md.name != names.init) return null; @@ -202,24 +212,24 @@ while (stats.nonEmpty() && isSyntheticInit(stats.head)) stats = stats.tail; if (stats.isEmpty()) return null; - if (stats.head.getTag() != JCTree.EXEC) return null; + if (!stats.head.hasTag(EXEC)) return null; JCExpressionStatement exec = (JCExpressionStatement) stats.head; - if (exec.expr.getTag() != JCTree.APPLY) return null; + if (!exec.expr.hasTag(APPLY)) return null; return (JCMethodInvocation)exec.expr; } /** Return true if a tree represents a diamond new expr. */ public static boolean isDiamond(JCTree tree) { switch(tree.getTag()) { - case JCTree.TYPEAPPLY: return ((JCTypeApply)tree).getTypeArguments().isEmpty(); - case JCTree.NEWCLASS: return isDiamond(((JCNewClass)tree).clazz); + case TYPEAPPLY: return ((JCTypeApply)tree).getTypeArguments().isEmpty(); + case NEWCLASS: return isDiamond(((JCNewClass)tree).clazz); default: return false; } } /** Return true if a tree represents the null literal. */ public static boolean isNull(JCTree tree) { - if (tree.getTag() != JCTree.LITERAL) + if (!tree.hasTag(LITERAL)) return false; JCLiteral lit = (JCLiteral) tree; return (lit.typetag == TypeTags.BOT); @@ -229,7 +239,7 @@ * the block itself if it is empty. */ public static int firstStatPos(JCTree tree) { - if (tree.getTag() == JCTree.BLOCK && ((JCBlock) tree).stats.nonEmpty()) + if (tree.hasTag(BLOCK) && ((JCBlock) tree).stats.nonEmpty()) return ((JCBlock) tree).stats.head.pos; else return tree.pos; @@ -239,11 +249,11 @@ * defined endpos. */ public static int endPos(JCTree tree) { - if (tree.getTag() == JCTree.BLOCK && ((JCBlock) tree).endpos != Position.NOPOS) + if (tree.hasTag(BLOCK) && ((JCBlock) tree).endpos != Position.NOPOS) return ((JCBlock) tree).endpos; - else if (tree.getTag() == JCTree.SYNCHRONIZED) + else if (tree.hasTag(SYNCHRONIZED)) return endPos(((JCSynchronized) tree).body); - else if (tree.getTag() == JCTree.TRY) { + else if (tree.hasTag(TRY)) { JCTry t = (JCTry) tree; return endPos((t.finalizer != null) ? t.finalizer @@ -263,73 +273,73 @@ return Position.NOPOS; switch(tree.getTag()) { - case(JCTree.APPLY): - return getStartPos(((JCMethodInvocation) tree).meth); - case(JCTree.ASSIGN): - return getStartPos(((JCAssign) tree).lhs); - case(JCTree.BITOR_ASG): case(JCTree.BITXOR_ASG): case(JCTree.BITAND_ASG): - case(JCTree.SL_ASG): case(JCTree.SR_ASG): case(JCTree.USR_ASG): - case(JCTree.PLUS_ASG): case(JCTree.MINUS_ASG): case(JCTree.MUL_ASG): - case(JCTree.DIV_ASG): case(JCTree.MOD_ASG): - return getStartPos(((JCAssignOp) tree).lhs); - case(JCTree.OR): case(JCTree.AND): case(JCTree.BITOR): - case(JCTree.BITXOR): case(JCTree.BITAND): case(JCTree.EQ): - case(JCTree.NE): case(JCTree.LT): case(JCTree.GT): - case(JCTree.LE): case(JCTree.GE): case(JCTree.SL): - case(JCTree.SR): case(JCTree.USR): case(JCTree.PLUS): - case(JCTree.MINUS): case(JCTree.MUL): case(JCTree.DIV): - case(JCTree.MOD): - return getStartPos(((JCBinary) tree).lhs); - case(JCTree.CLASSDEF): { - JCClassDecl node = (JCClassDecl)tree; - if (node.mods.pos != Position.NOPOS) - return node.mods.pos; - break; - } - case(JCTree.CONDEXPR): - return getStartPos(((JCConditional) tree).cond); - case(JCTree.EXEC): - return getStartPos(((JCExpressionStatement) tree).expr); - case(JCTree.INDEXED): - return getStartPos(((JCArrayAccess) tree).indexed); - case(JCTree.METHODDEF): { - JCMethodDecl node = (JCMethodDecl)tree; - if (node.mods.pos != Position.NOPOS) - return node.mods.pos; - if (node.typarams.nonEmpty()) // List.nil() used for no typarams - return getStartPos(node.typarams.head); - return node.restype == null ? node.pos : getStartPos(node.restype); - } - case(JCTree.SELECT): - return getStartPos(((JCFieldAccess) tree).selected); - case(JCTree.TYPEAPPLY): - return getStartPos(((JCTypeApply) tree).clazz); - case(JCTree.TYPEARRAY): - return getStartPos(((JCArrayTypeTree) tree).elemtype); - case(JCTree.TYPETEST): - return getStartPos(((JCInstanceOf) tree).expr); - case(JCTree.POSTINC): - case(JCTree.POSTDEC): - return getStartPos(((JCUnary) tree).arg); - case(JCTree.NEWCLASS): { - JCNewClass node = (JCNewClass)tree; - if (node.encl != null) - return getStartPos(node.encl); - break; - } - case(JCTree.VARDEF): { - JCVariableDecl node = (JCVariableDecl)tree; - if (node.mods.pos != Position.NOPOS) { - return node.mods.pos; - } else { - return getStartPos(node.vartype); + case APPLY: + return getStartPos(((JCMethodInvocation) tree).meth); + case ASSIGN: + return getStartPos(((JCAssign) tree).lhs); + case BITOR_ASG: case BITXOR_ASG: case BITAND_ASG: + case SL_ASG: case SR_ASG: case USR_ASG: + case PLUS_ASG: case MINUS_ASG: case MUL_ASG: + case DIV_ASG: case MOD_ASG: + return getStartPos(((JCAssignOp) tree).lhs); + case OR: case AND: case BITOR: + case BITXOR: case BITAND: case EQ: + case NE: case LT: case GT: + case LE: case GE: case SL: + case SR: case USR: case PLUS: + case MINUS: case MUL: case DIV: + case MOD: + return getStartPos(((JCBinary) tree).lhs); + case CLASSDEF: { + JCClassDecl node = (JCClassDecl)tree; + if (node.mods.pos != Position.NOPOS) + return node.mods.pos; + break; } - } - case(JCTree.ERRONEOUS): { - JCErroneous node = (JCErroneous)tree; - if (node.errs != null && node.errs.nonEmpty()) - return getStartPos(node.errs.head); - } + case CONDEXPR: + return getStartPos(((JCConditional) tree).cond); + case EXEC: + return getStartPos(((JCExpressionStatement) tree).expr); + case INDEXED: + return getStartPos(((JCArrayAccess) tree).indexed); + case METHODDEF: { + JCMethodDecl node = (JCMethodDecl)tree; + if (node.mods.pos != Position.NOPOS) + return node.mods.pos; + if (node.typarams.nonEmpty()) // List.nil() used for no typarams + return getStartPos(node.typarams.head); + return node.restype == null ? node.pos : getStartPos(node.restype); + } + case SELECT: + return getStartPos(((JCFieldAccess) tree).selected); + case TYPEAPPLY: + return getStartPos(((JCTypeApply) tree).clazz); + case TYPEARRAY: + return getStartPos(((JCArrayTypeTree) tree).elemtype); + case TYPETEST: + return getStartPos(((JCInstanceOf) tree).expr); + case POSTINC: + case POSTDEC: + return getStartPos(((JCUnary) tree).arg); + case NEWCLASS: { + JCNewClass node = (JCNewClass)tree; + if (node.encl != null) + return getStartPos(node.encl); + break; + } + case VARDEF: { + JCVariableDecl node = (JCVariableDecl)tree; + if (node.mods.pos != Position.NOPOS) { + return node.mods.pos; + } else { + return getStartPos(node.vartype); + } + } + case ERRONEOUS: { + JCErroneous node = (JCErroneous)tree; + if (node.errs != null && node.errs.nonEmpty()) + return getStartPos(node.errs.head); + } } return tree.pos; } @@ -350,75 +360,75 @@ return mapPos; switch(tree.getTag()) { - case(JCTree.BITOR_ASG): case(JCTree.BITXOR_ASG): case(JCTree.BITAND_ASG): - case(JCTree.SL_ASG): case(JCTree.SR_ASG): case(JCTree.USR_ASG): - case(JCTree.PLUS_ASG): case(JCTree.MINUS_ASG): case(JCTree.MUL_ASG): - case(JCTree.DIV_ASG): case(JCTree.MOD_ASG): - return getEndPos(((JCAssignOp) tree).rhs, endPositions); - case(JCTree.OR): case(JCTree.AND): case(JCTree.BITOR): - case(JCTree.BITXOR): case(JCTree.BITAND): case(JCTree.EQ): - case(JCTree.NE): case(JCTree.LT): case(JCTree.GT): - case(JCTree.LE): case(JCTree.GE): case(JCTree.SL): - case(JCTree.SR): case(JCTree.USR): case(JCTree.PLUS): - case(JCTree.MINUS): case(JCTree.MUL): case(JCTree.DIV): - case(JCTree.MOD): - return getEndPos(((JCBinary) tree).rhs, endPositions); - case(JCTree.CASE): - return getEndPos(((JCCase) tree).stats.last(), endPositions); - case(JCTree.CATCH): - return getEndPos(((JCCatch) tree).body, endPositions); - case(JCTree.CONDEXPR): - return getEndPos(((JCConditional) tree).falsepart, endPositions); - case(JCTree.FORLOOP): - return getEndPos(((JCForLoop) tree).body, endPositions); - case(JCTree.FOREACHLOOP): - return getEndPos(((JCEnhancedForLoop) tree).body, endPositions); - case(JCTree.IF): { - JCIf node = (JCIf)tree; - if (node.elsepart == null) { - return getEndPos(node.thenpart, endPositions); - } else { - return getEndPos(node.elsepart, endPositions); + case BITOR_ASG: case BITXOR_ASG: case BITAND_ASG: + case SL_ASG: case SR_ASG: case USR_ASG: + case PLUS_ASG: case MINUS_ASG: case MUL_ASG: + case DIV_ASG: case MOD_ASG: + return getEndPos(((JCAssignOp) tree).rhs, endPositions); + case OR: case AND: case BITOR: + case BITXOR: case BITAND: case EQ: + case NE: case LT: case GT: + case LE: case GE: case SL: + case SR: case USR: case PLUS: + case MINUS: case MUL: case DIV: + case MOD: + return getEndPos(((JCBinary) tree).rhs, endPositions); + case CASE: + return getEndPos(((JCCase) tree).stats.last(), endPositions); + case CATCH: + return getEndPos(((JCCatch) tree).body, endPositions); + case CONDEXPR: + return getEndPos(((JCConditional) tree).falsepart, endPositions); + case FORLOOP: + return getEndPos(((JCForLoop) tree).body, endPositions); + case FOREACHLOOP: + return getEndPos(((JCEnhancedForLoop) tree).body, endPositions); + case IF: { + JCIf node = (JCIf)tree; + if (node.elsepart == null) { + return getEndPos(node.thenpart, endPositions); + } else { + return getEndPos(node.elsepart, endPositions); + } } - } - case(JCTree.LABELLED): - return getEndPos(((JCLabeledStatement) tree).body, endPositions); - case(JCTree.MODIFIERS): - return getEndPos(((JCModifiers) tree).annotations.last(), endPositions); - case(JCTree.SYNCHRONIZED): - return getEndPos(((JCSynchronized) tree).body, endPositions); - case(JCTree.TOPLEVEL): - return getEndPos(((JCCompilationUnit) tree).defs.last(), endPositions); - case(JCTree.TRY): { - JCTry node = (JCTry)tree; - if (node.finalizer != null) { - return getEndPos(node.finalizer, endPositions); - } else if (!node.catchers.isEmpty()) { - return getEndPos(node.catchers.last(), endPositions); - } else { - return getEndPos(node.body, endPositions); + case LABELLED: + return getEndPos(((JCLabeledStatement) tree).body, endPositions); + case MODIFIERS: + return getEndPos(((JCModifiers) tree).annotations.last(), endPositions); + case SYNCHRONIZED: + return getEndPos(((JCSynchronized) tree).body, endPositions); + case TOPLEVEL: + return getEndPos(((JCCompilationUnit) tree).defs.last(), endPositions); + case TRY: { + JCTry node = (JCTry)tree; + if (node.finalizer != null) { + return getEndPos(node.finalizer, endPositions); + } else if (!node.catchers.isEmpty()) { + return getEndPos(node.catchers.last(), endPositions); + } else { + return getEndPos(node.body, endPositions); + } } - } - case(JCTree.WILDCARD): - return getEndPos(((JCWildcard) tree).inner, endPositions); - case(JCTree.TYPECAST): - return getEndPos(((JCTypeCast) tree).expr, endPositions); - case(JCTree.TYPETEST): - return getEndPos(((JCInstanceOf) tree).clazz, endPositions); - case(JCTree.POS): - case(JCTree.NEG): - case(JCTree.NOT): - case(JCTree.COMPL): - case(JCTree.PREINC): - case(JCTree.PREDEC): - return getEndPos(((JCUnary) tree).arg, endPositions); - case(JCTree.WHILELOOP): - return getEndPos(((JCWhileLoop) tree).body, endPositions); - case(JCTree.ERRONEOUS): { - JCErroneous node = (JCErroneous)tree; - if (node.errs != null && node.errs.nonEmpty()) - return getEndPos(node.errs.last(), endPositions); - } + case WILDCARD: + return getEndPos(((JCWildcard) tree).inner, endPositions); + case TYPECAST: + return getEndPos(((JCTypeCast) tree).expr, endPositions); + case TYPETEST: + return getEndPos(((JCInstanceOf) tree).clazz, endPositions); + case POS: + case NEG: + case NOT: + case COMPL: + case PREINC: + case PREDEC: + return getEndPos(((JCUnary) tree).arg, endPositions); + case WHILELOOP: + return getEndPos(((JCWhileLoop) tree).body, endPositions); + case ERRONEOUS: { + JCErroneous node = (JCErroneous)tree; + if (node.errs != null && node.errs.nonEmpty()) + return getEndPos(node.errs.last(), endPositions); + } } return Position.NOPOS; } @@ -443,11 +453,11 @@ /** The position of the finalizer of given try/synchronized statement. */ public static int finalizerPos(JCTree tree) { - if (tree.getTag() == JCTree.TRY) { + if (tree.hasTag(TRY)) { JCTry t = (JCTry) tree; Assert.checkNonNull(t.finalizer); return firstStatPos(t.finalizer); - } else if (tree.getTag() == JCTree.SYNCHRONIZED) { + } else if (tree.hasTag(SYNCHRONIZED)) { return endPos(((JCSynchronized) tree).body); } else { throw new AssertionError(); @@ -547,9 +557,9 @@ public static JCTree referencedStatement(JCLabeledStatement tree) { JCTree t = tree; do t = ((JCLabeledStatement) t).body; - while (t.getTag() == JCTree.LABELLED); + while (t.hasTag(LABELLED)); switch (t.getTag()) { - case JCTree.DOLOOP: case JCTree.WHILELOOP: case JCTree.FORLOOP: case JCTree.FOREACHLOOP: case JCTree.SWITCH: + case DOLOOP: case WHILELOOP: case FORLOOP: case FOREACHLOOP: case SWITCH: return t; default: return tree; @@ -559,7 +569,7 @@ /** Skip parens and return the enclosed expression */ public static JCExpression skipParens(JCExpression tree) { - while (tree.getTag() == JCTree.PARENS) { + while (tree.hasTag(PARENS)) { tree = ((JCParens) tree).expr; } return tree; @@ -568,7 +578,7 @@ /** Skip parens and return the enclosed expression */ public static JCTree skipParens(JCTree tree) { - if (tree.getTag() == JCTree.PARENS) + if (tree.hasTag(PARENS)) return skipParens((JCParens)tree); else return tree; @@ -588,11 +598,11 @@ */ public static Name name(JCTree tree) { switch (tree.getTag()) { - case JCTree.IDENT: + case IDENT: return ((JCIdent) tree).name; - case JCTree.SELECT: + case SELECT: return ((JCFieldAccess) tree).name; - case JCTree.TYPEAPPLY: + case TYPEAPPLY: return name(((JCTypeApply) tree).clazz); default: return null; @@ -605,9 +615,9 @@ public static Name fullName(JCTree tree) { tree = skipParens(tree); switch (tree.getTag()) { - case JCTree.IDENT: + case IDENT: return ((JCIdent) tree).name; - case JCTree.SELECT: + case SELECT: Name sname = fullName(((JCFieldAccess) tree).selected); return sname == null ? null : sname.append('.', name(tree)); default: @@ -618,11 +628,11 @@ public static Symbol symbolFor(JCTree node) { node = skipParens(node); switch (node.getTag()) { - case JCTree.CLASSDEF: + case CLASSDEF: return ((JCClassDecl) node).sym; - case JCTree.METHODDEF: + case METHODDEF: return ((JCMethodDecl) node).sym; - case JCTree.VARDEF: + case VARDEF: return ((JCVariableDecl) node).sym; default: return null; @@ -632,9 +642,9 @@ public static boolean isDeclaration(JCTree node) { node = skipParens(node); switch (node.getTag()) { - case JCTree.CLASSDEF: - case JCTree.METHODDEF: - case JCTree.VARDEF: + case CLASSDEF: + case METHODDEF: + case VARDEF: return true; default: return false; @@ -647,11 +657,11 @@ public static Symbol symbol(JCTree tree) { tree = skipParens(tree); switch (tree.getTag()) { - case JCTree.IDENT: + case IDENT: return ((JCIdent) tree).sym; - case JCTree.SELECT: + case SELECT: return ((JCFieldAccess) tree).sym; - case JCTree.TYPEAPPLY: + case TYPEAPPLY: return symbol(((JCTypeApply) tree).clazz); default: return null; @@ -661,7 +671,7 @@ /** Return true if this is a nonstatic selection. */ public static boolean nonstaticSelect(JCTree tree) { tree = skipParens(tree); - if (tree.getTag() != JCTree.SELECT) return false; + if (!tree.hasTag(SELECT)) return false; JCFieldAccess s = (JCFieldAccess) tree; Symbol e = symbol(s.selected); return e == null || (e.kind != Kinds.PCK && e.kind != Kinds.TYP); @@ -672,9 +682,9 @@ public static void setSymbol(JCTree tree, Symbol sym) { tree = skipParens(tree); switch (tree.getTag()) { - case JCTree.IDENT: + case IDENT: ((JCIdent) tree).sym = sym; break; - case JCTree.SELECT: + case SELECT: ((JCFieldAccess) tree).sym = sym; break; default: } @@ -685,13 +695,13 @@ */ public static long flags(JCTree tree) { switch (tree.getTag()) { - case JCTree.VARDEF: + case VARDEF: return ((JCVariableDecl) tree).mods.flags; - case JCTree.METHODDEF: + case METHODDEF: return ((JCMethodDecl) tree).mods.flags; - case JCTree.CLASSDEF: + case CLASSDEF: return ((JCClassDecl) tree).mods.flags; - case JCTree.BLOCK: + case BLOCK: return ((JCBlock) tree).flags; default: return 0; @@ -739,155 +749,155 @@ /** Map operators to their precedence levels. */ - public static int opPrec(int op) { + public static int opPrec(JCTree.Tag op) { switch(op) { - case JCTree.POS: - case JCTree.NEG: - case JCTree.NOT: - case JCTree.COMPL: - case JCTree.PREINC: - case JCTree.PREDEC: return prefixPrec; - case JCTree.POSTINC: - case JCTree.POSTDEC: - case JCTree.NULLCHK: return postfixPrec; - case JCTree.ASSIGN: return assignPrec; - case JCTree.BITOR_ASG: - case JCTree.BITXOR_ASG: - case JCTree.BITAND_ASG: - case JCTree.SL_ASG: - case JCTree.SR_ASG: - case JCTree.USR_ASG: - case JCTree.PLUS_ASG: - case JCTree.MINUS_ASG: - case JCTree.MUL_ASG: - case JCTree.DIV_ASG: - case JCTree.MOD_ASG: return assignopPrec; - case JCTree.OR: return orPrec; - case JCTree.AND: return andPrec; - case JCTree.EQ: - case JCTree.NE: return eqPrec; - case JCTree.LT: - case JCTree.GT: - case JCTree.LE: - case JCTree.GE: return ordPrec; - case JCTree.BITOR: return bitorPrec; - case JCTree.BITXOR: return bitxorPrec; - case JCTree.BITAND: return bitandPrec; - case JCTree.SL: - case JCTree.SR: - case JCTree.USR: return shiftPrec; - case JCTree.PLUS: - case JCTree.MINUS: return addPrec; - case JCTree.MUL: - case JCTree.DIV: - case JCTree.MOD: return mulPrec; - case JCTree.TYPETEST: return ordPrec; + case POS: + case NEG: + case NOT: + case COMPL: + case PREINC: + case PREDEC: return prefixPrec; + case POSTINC: + case POSTDEC: + case NULLCHK: return postfixPrec; + case ASSIGN: return assignPrec; + case BITOR_ASG: + case BITXOR_ASG: + case BITAND_ASG: + case SL_ASG: + case SR_ASG: + case USR_ASG: + case PLUS_ASG: + case MINUS_ASG: + case MUL_ASG: + case DIV_ASG: + case MOD_ASG: return assignopPrec; + case OR: return orPrec; + case AND: return andPrec; + case EQ: + case NE: return eqPrec; + case LT: + case GT: + case LE: + case GE: return ordPrec; + case BITOR: return bitorPrec; + case BITXOR: return bitxorPrec; + case BITAND: return bitandPrec; + case SL: + case SR: + case USR: return shiftPrec; + case PLUS: + case MINUS: return addPrec; + case MUL: + case DIV: + case MOD: return mulPrec; + case TYPETEST: return ordPrec; default: throw new AssertionError(); } } - static Tree.Kind tagToKind(int tag) { + static Tree.Kind tagToKind(JCTree.Tag tag) { switch (tag) { // Postfix expressions - case JCTree.POSTINC: // _ ++ + case POSTINC: // _ ++ return Tree.Kind.POSTFIX_INCREMENT; - case JCTree.POSTDEC: // _ -- + case POSTDEC: // _ -- return Tree.Kind.POSTFIX_DECREMENT; // Unary operators - case JCTree.PREINC: // ++ _ + case PREINC: // ++ _ return Tree.Kind.PREFIX_INCREMENT; - case JCTree.PREDEC: // -- _ + case PREDEC: // -- _ return Tree.Kind.PREFIX_DECREMENT; - case JCTree.POS: // + + case POS: // + return Tree.Kind.UNARY_PLUS; - case JCTree.NEG: // - + case NEG: // - return Tree.Kind.UNARY_MINUS; - case JCTree.COMPL: // ~ + case COMPL: // ~ return Tree.Kind.BITWISE_COMPLEMENT; - case JCTree.NOT: // ! + case NOT: // ! return Tree.Kind.LOGICAL_COMPLEMENT; // Binary operators // Multiplicative operators - case JCTree.MUL: // * + case MUL: // * return Tree.Kind.MULTIPLY; - case JCTree.DIV: // / + case DIV: // / return Tree.Kind.DIVIDE; - case JCTree.MOD: // % + case MOD: // % return Tree.Kind.REMAINDER; // Additive operators - case JCTree.PLUS: // + + case PLUS: // + return Tree.Kind.PLUS; - case JCTree.MINUS: // - + case MINUS: // - return Tree.Kind.MINUS; // Shift operators - case JCTree.SL: // << + case SL: // << return Tree.Kind.LEFT_SHIFT; - case JCTree.SR: // >> + case SR: // >> return Tree.Kind.RIGHT_SHIFT; - case JCTree.USR: // >>> + case USR: // >>> return Tree.Kind.UNSIGNED_RIGHT_SHIFT; // Relational operators - case JCTree.LT: // < + case LT: // < return Tree.Kind.LESS_THAN; - case JCTree.GT: // > + case GT: // > return Tree.Kind.GREATER_THAN; - case JCTree.LE: // <= + case LE: // <= return Tree.Kind.LESS_THAN_EQUAL; - case JCTree.GE: // >= + case GE: // >= return Tree.Kind.GREATER_THAN_EQUAL; // Equality operators - case JCTree.EQ: // == + case EQ: // == return Tree.Kind.EQUAL_TO; - case JCTree.NE: // != + case NE: // != return Tree.Kind.NOT_EQUAL_TO; // Bitwise and logical operators - case JCTree.BITAND: // & + case BITAND: // & return Tree.Kind.AND; - case JCTree.BITXOR: // ^ + case BITXOR: // ^ return Tree.Kind.XOR; - case JCTree.BITOR: // | + case BITOR: // | return Tree.Kind.OR; // Conditional operators - case JCTree.AND: // && + case AND: // && return Tree.Kind.CONDITIONAL_AND; - case JCTree.OR: // || + case OR: // || return Tree.Kind.CONDITIONAL_OR; // Assignment operators - case JCTree.MUL_ASG: // *= + case MUL_ASG: // *= return Tree.Kind.MULTIPLY_ASSIGNMENT; - case JCTree.DIV_ASG: // /= + case DIV_ASG: // /= return Tree.Kind.DIVIDE_ASSIGNMENT; - case JCTree.MOD_ASG: // %= + case MOD_ASG: // %= return Tree.Kind.REMAINDER_ASSIGNMENT; - case JCTree.PLUS_ASG: // += + case PLUS_ASG: // += return Tree.Kind.PLUS_ASSIGNMENT; - case JCTree.MINUS_ASG: // -= + case MINUS_ASG: // -= return Tree.Kind.MINUS_ASSIGNMENT; - case JCTree.SL_ASG: // <<= + case SL_ASG: // <<= return Tree.Kind.LEFT_SHIFT_ASSIGNMENT; - case JCTree.SR_ASG: // >>= + case SR_ASG: // >>= return Tree.Kind.RIGHT_SHIFT_ASSIGNMENT; - case JCTree.USR_ASG: // >>>= + case USR_ASG: // >>>= return Tree.Kind.UNSIGNED_RIGHT_SHIFT_ASSIGNMENT; - case JCTree.BITAND_ASG: // &= + case BITAND_ASG: // &= return Tree.Kind.AND_ASSIGNMENT; - case JCTree.BITXOR_ASG: // ^= + case BITXOR_ASG: // ^= return Tree.Kind.XOR_ASSIGNMENT; - case JCTree.BITOR_ASG: // |= + case BITOR_ASG: // |= return Tree.Kind.OR_ASSIGNMENT; // Null check (implementation detail), for example, __.getClass() - case JCTree.NULLCHK: + case NULLCHK: return Tree.Kind.OTHER; default: @@ -901,13 +911,13 @@ */ public static JCExpression typeIn(JCExpression tree) { switch (tree.getTag()) { - case JCTree.IDENT: /* simple names */ - case JCTree.TYPEIDENT: /* primitive name */ - case JCTree.SELECT: /* qualified name */ - case JCTree.TYPEARRAY: /* array types */ - case JCTree.WILDCARD: /* wild cards */ - case JCTree.TYPEPARAMETER: /* type parameters */ - case JCTree.TYPEAPPLY: /* parameterized types */ + case IDENT: /* simple names */ + case TYPEIDENT: /* primitive name */ + case SELECT: /* qualified name */ + case TYPEARRAY: /* array types */ + case WILDCARD: /* wild cards */ + case TYPEPARAMETER: /* type parameters */ + case TYPEAPPLY: /* parameterized types */ return tree; default: throw new AssertionError("Unexpected type tree: " + tree); @@ -916,9 +926,9 @@ public static JCTree innermostType(JCTree type) { switch (type.getTag()) { - case JCTree.TYPEARRAY: + case TYPEARRAY: return innermostType(((JCArrayTypeTree)type).elemtype); - case JCTree.WILDCARD: + case WILDCARD: return innermostType(((JCWildcard)type).inner); default: return type; diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Fri Nov 18 11:11:11 2011 -0800 @@ -363,19 +363,19 @@ return tree; } - public JCAssignOp Assignop(int opcode, JCTree lhs, JCTree rhs) { + public JCAssignOp Assignop(JCTree.Tag opcode, JCTree lhs, JCTree rhs) { JCAssignOp tree = new JCAssignOp(opcode, lhs, rhs, null); tree.pos = pos; return tree; } - public JCUnary Unary(int opcode, JCExpression arg) { + public JCUnary Unary(JCTree.Tag opcode, JCExpression arg) { JCUnary tree = new JCUnary(opcode, arg); tree.pos = pos; return tree; } - public JCBinary Binary(int opcode, JCExpression lhs, JCExpression rhs) { + public JCBinary Binary(JCTree.Tag opcode, JCExpression lhs, JCExpression rhs) { JCBinary tree = new JCBinary(opcode, lhs, rhs, null); tree.pos = pos; return tree; diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java --- a/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javadoc/ClassDocImpl.java Fri Nov 18 11:11:11 2011 -0800 @@ -65,6 +65,7 @@ import com.sun.tools.javac.util.Position; import static com.sun.tools.javac.code.Kinds.*; +import static com.sun.tools.javac.tree.JCTree.Tag.*; /** * Represents a java class and provides access to information @@ -1083,7 +1084,7 @@ Name asterisk = tsym.name.table.names.asterisk; for (JCTree t : compenv.toplevel.defs) { - if (t.getTag() == JCTree.IMPORT) { + if (t.hasTag(IMPORT)) { JCTree imp = ((JCImport) t).qualid; if ((TreeInfo.name(imp) != asterisk) && (imp.type.tsym.kind & Kinds.TYP) != 0) { @@ -1124,7 +1125,7 @@ if (compenv == null) return new PackageDocImpl[0]; for (JCTree t : compenv.toplevel.defs) { - if (t.getTag() == JCTree.IMPORT) { + if (t.hasTag(IMPORT)) { JCTree imp = ((JCImport) t).qualid; if (TreeInfo.name(imp) == names.asterisk) { JCFieldAccess sel = (JCFieldAccess)imp; diff -r d7f6c062c454 -r 41ce4af91010 langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java --- a/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/src/share/classes/com/sun/tools/javadoc/JavadocTool.java Fri Nov 18 11:11:11 2011 -0800 @@ -419,7 +419,7 @@ ListBuffer result = new ListBuffer(); for (JCCompilationUnit t : trees) { for (JCTree def : t.defs) { - if (def.getTag() == JCTree.CLASSDEF) + if (def.hasTag(JCTree.Tag.CLASSDEF)) result.append((JCClassDecl)def); } } diff -r d7f6c062c454 -r 41ce4af91010 langtools/test/Makefile --- a/langtools/test/Makefile Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/test/Makefile Fri Nov 18 11:11:11 2011 -0800 @@ -19,6 +19,7 @@ # Get OS/ARCH specifics OSNAME = $(shell uname -s) ifeq ($(OSNAME), SunOS) + SLASH_JAVA = /java PLATFORM = solaris JT_PLATFORM = solaris ARCH = $(shell uname -p) @@ -27,6 +28,7 @@ endif endif ifeq ($(OSNAME), Linux) + SLASH_JAVA = /java PLATFORM = linux JT_PLATFORM = linux ARCH = $(shell uname -m) @@ -35,7 +37,16 @@ endif endif ifeq ($(OSNAME), Windows_NT) + # MKS + PLATFORM=windows +endif +ifeq ($(PLATFORM),) PLATFORM = windows + CYGPATH = | cygpath -m -s -f - +endif + +ifeq ($(PLATFORM), windows) + SLASH_JAVA = J: JT_PLATFORM = win32 ifeq ($(word 1, $(PROCESSOR_IDENTIFIER)),ia64) ARCH=ia64 @@ -54,7 +65,7 @@ endif # Root of this test area (important to use full paths in some places) -TEST_ROOT := $(shell pwd) +TEST_ROOT := $(shell pwd $(CYGPATH) ) # Default bundle of all test results (passed or not) (JPRT only) ifdef JPRT_JOB_ID @@ -72,7 +83,7 @@ ifdef JPRT_JTREG_HOME JTREG_HOME = $(JPRT_JTREG_HOME) else - JTREG_HOME = $(SLASH_JAVA)/re/jtreg/4.0/promoted/latest/binaries/jtreg + JTREG_HOME = $(SLASH_JAVA)/re/jtreg/4.1/promoted/latest/binaries/jtreg endif JTREG = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtreg JTDIFF = $(JTREG_HOME)/$(JT_PLATFORM)/bin/jtdiff @@ -81,7 +92,7 @@ ifdef JPRT_JCK_HOME JCK_HOME = $(JPRT_JCK_HOME) else - JCK_HOME = $(SLASH_JAVA)/re/jck/7/promoted/latest/binaries + JCK_HOME = $(SLASH_JAVA)/re/jck/8/promoted/latest/binaries endif # Default JDK for JTREG and JCK @@ -93,7 +104,7 @@ ifdef JPRT_JAVA_HOME JT_JAVA = $(JPRT_JAVA_HOME) else - JT_JAVA = $(SLASH_JAVA)/re/jdk/1.6.0/archive/fcs/binaries/$(PLATFORM)-$(ARCH) + JT_JAVA = $(SLASH_JAVA)/re/jdk/1.7.0/archive/fcs/binaries/$(PLATFORM)-$(ARCH) endif # Default JDK to test @@ -195,7 +206,7 @@ ABS_TEST_OUTPUT_DIR := \ $(shell mkdir -p $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools; \ cd $(TEST_ROOT)/../build/$(PLATFORM)-$(ARCH)/test/langtools; \ - pwd ) + pwd $(CYGPATH)) # Subdirectories for different test runs JTREG_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jtreg JCK_COMPILER_OUTPUT_DIR = $(ABS_TEST_OUTPUT_DIR)/jck-compiler @@ -272,15 +283,17 @@ fi # Check to make sure these directories exist -check-jtreg: $(JT_HOME) $(PRODUCT_HOME) $(JTREG) +check-jtreg: $(PRODUCT_HOME) $(JTREG) # Run JCK-compiler tests # # JCK_HOME # Installed location of JCK: should include JCK-compiler, and JCK-extras +# Default is JCK 8. # JT_JAVA # Version of java used to run JCK. Should normally be the same as TESTJAVA +# Default is JDK 7 # TESTJAVA # Version of java to be tested. # JCK_COMPILER_OPTIONS @@ -297,7 +310,7 @@ $(JCK_COMPILER_OUTPUT_DIR)/diff.html $(JCK_COMPILER_OUTPUT_DIR)/status.txt @mkdir -p $(JCK_COMPILER_OUTPUT_DIR) $(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \ - -jar $(JCK_HOME)/JCK-compiler-7/lib/jtjck.jar \ + -jar $(JCK_HOME)/JCK-compiler-8/lib/jtjck.jar \ -v:non-pass \ -r:$(JCK_COMPILER_OUTPUT_DIR)/report \ -w:$(JCK_COMPILER_OUTPUT_DIR)/work \ @@ -346,7 +359,7 @@ $(JCK_RUNTIME_OUTPUT_DIR)/diff.html $(JCK_RUNTIME_OUTPUT_DIR)/status.txt @mkdir -p $(JCK_RUNTIME_OUTPUT_DIR) $(JT_JAVA)/bin/java -XX:MaxPermSize=256m -Xmx512m \ - -jar $(JCK_HOME)/JCK-runtime-7/lib/jtjck.jar \ + -jar $(JCK_HOME)/JCK-runtime-8/lib/jtjck.jar \ -v:non-pass \ -r:$(JCK_RUNTIME_OUTPUT_DIR)/report \ -w:$(JCK_RUNTIME_OUTPUT_DIR)/work \ @@ -373,7 +386,7 @@ fi # Check to make sure these directories exist -check-jck: $(JT_HOME) $(JCK_HOME) $(PRODUCT_HOME) +check-jck: $(JCK_HOME) $(PRODUCT_HOME) all-summary: FRC if [ -n "`find $(TEST_OUTPUT_DIR) -name status.txt`" ]; then diff -r d7f6c062c454 -r 41ce4af91010 langtools/test/tools/javac/depDocComment/DeprecatedDocComment4.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/depDocComment/DeprecatedDocComment4.java Fri Nov 18 11:11:11 2011 -0800 @@ -0,0 +1,20 @@ +/** + * @test /nodynamiccopyright/ + * @bug 7104201 + * @summary Refactor DocCommentScanner + * @compile/fail/ref=DeprecatedDocComment4.out -XDrawDiagnostics -Werror -Xlint:dep-ann DeprecatedDocComment4.java + */ + +class DeprecatedDocComment4 { + /** @deprecated **/ + /* block */ + void test1() {}; + + /** @deprecated **/ + /** double javadoc */ + void test2() {}; + + /** @deprecated **/ + //line comment + void test3() {}; +} diff -r d7f6c062c454 -r 41ce4af91010 langtools/test/tools/javac/depDocComment/DeprecatedDocComment4.out --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/langtools/test/tools/javac/depDocComment/DeprecatedDocComment4.out Fri Nov 18 11:11:11 2011 -0800 @@ -0,0 +1,6 @@ +DeprecatedDocComment4.java:11:10: compiler.warn.missing.deprecated.annotation +DeprecatedDocComment4.java:15:10: compiler.warn.missing.deprecated.annotation +DeprecatedDocComment4.java:19:10: compiler.warn.missing.deprecated.annotation +- compiler.err.warnings.and.werror +1 error +3 warnings diff -r d7f6c062c454 -r 41ce4af91010 langtools/test/tools/javac/failover/CheckAttributedTree.java --- a/langtools/test/tools/javac/failover/CheckAttributedTree.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/test/tools/javac/failover/CheckAttributedTree.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -85,6 +85,8 @@ import java.util.Set; import javax.lang.model.element.Element; +import static com.sun.tools.javac.tree.JCTree.Tag.*; + /** * Utility and test program to check validity of tree positions for tree nodes. * The program can be run standalone, or as a jtreg test. In standalone mode, @@ -289,7 +291,7 @@ for (CompilationUnitTree t : trees) { JCCompilationUnit cu = (JCCompilationUnit)t; for (JCTree def : cu.defs) { - if (def.getTag() == JCTree.CLASSDEF && + if (def.hasTag(CLASSDEF) && analyzedElems.contains(((JCTree.JCClassDecl)def).sym)) { //System.out.println("Adding pair..."); res.add(new Pair<>(cu, def)); @@ -373,9 +375,9 @@ private boolean mandatoryType(JCTree that) { return that instanceof JCTree.JCExpression || - that.getTag() == JCTree.VARDEF || - that.getTag() == JCTree.METHODDEF || - that.getTag() == JCTree.CLASSDEF; + that.hasTag(VARDEF) || + that.hasTag(METHODDEF) || + that.hasTag(CLASSDEF); } private final List excludedFields = Arrays.asList("varargsElement"); @@ -429,7 +431,7 @@ private class Info { Info() { tree = null; - tag = JCTree.ERRONEOUS; + tag = ERRONEOUS; start = 0; pos = 0; end = Integer.MAX_VALUE; @@ -449,7 +451,7 @@ } final JCTree tree; - final int tag; + final JCTree.Tag tag; final int start; final int pos; final int end; @@ -457,27 +459,10 @@ /** * Names for tree tags. - * javac does not provide an API to convert tag values to strings, so this class uses - * reflection to determine names of public static final int values in JCTree. */ private static class TreeUtil { - String nameFromTag(int tag) { - if (names == null) { - names = new HashMap(); - Class c = JCTree.class; - for (Field f : c.getDeclaredFields()) { - if (f.getType().equals(int.class)) { - int mods = f.getModifiers(); - if (Modifier.isPublic(mods) && Modifier.isStatic(mods) && Modifier.isFinal(mods)) { - try { - names.put(f.getInt(null), f.getName()); - } catch (IllegalAccessException e) { - } - } - } - } - } - String name = names.get(tag); + String nameFromTag(JCTree.Tag tag) { + String name = tag.name(); return (name == null) ? "??" : name; } @@ -496,8 +481,6 @@ } return buf; } - - private Map names; } /** diff -r d7f6c062c454 -r 41ce4af91010 langtools/test/tools/javac/tree/AbstractTreeScannerTest.java --- a/langtools/test/tools/javac/tree/AbstractTreeScannerTest.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/test/tools/javac/tree/AbstractTreeScannerTest.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -274,7 +274,7 @@ return fields; } // where - Map> map = new HashMap>(); + Map> map = new HashMap>(); /** Get the line number for the primary position for a tree. * The code is intended to be simple, although not necessarily efficient. diff -r d7f6c062c454 -r 41ce4af91010 langtools/test/tools/javac/tree/TreePosTest.java --- a/langtools/test/tools/javac/tree/TreePosTest.java Fri Nov 18 16:13:39 2011 +0800 +++ b/langtools/test/tools/javac/tree/TreePosTest.java Fri Nov 18 11:11:11 2011 -0800 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2011, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -80,6 +80,7 @@ import com.sun.tools.javac.tree.TreeInfo; import com.sun.tools.javac.tree.TreeScanner; +import static com.sun.tools.javac.tree.JCTree.Tag.*; import static com.sun.tools.javac.util.Position.NOPOS; /** @@ -291,6 +292,14 @@ errors++; } + /** + * Names for tree tags. + */ + private static String getTagName(JCTree.Tag tag) { + String name = tag.name(); + return (name == null) ? "??" : name; + } + /** Number of files that have been analyzed. */ int fileCount; /** Number of errors reported. */ @@ -312,8 +321,6 @@ Set excludeFiles = new HashSet(); /** Set of tag names to be excluded from analysis. */ Set excludeTags = new HashSet(); - /** Table of printable names for tree tag values. */ - TagNames tagNames = new TagNames(); /** * Main class for testing assertions concerning tree positions for tree nodes. @@ -337,7 +344,7 @@ // there is no corresponding source text. // Redundant semicolons in a class definition can cause empty // initializer blocks with no positions. - if ((self.tag == JCTree.MODIFIERS || self.tag == JCTree.BLOCK) + if ((self.tag == MODIFIERS || self.tag == BLOCK) && self.pos == NOPOS) { // If pos is NOPOS, so should be the start and end positions check("start == NOPOS", encl, self, self.start == NOPOS); @@ -359,15 +366,15 @@ // e.g. int[][] a = new int[2][]; check("encl.start <= start", encl, self, encl.start <= self.start); check("start <= pos", encl, self, self.start <= self.pos); - if (!(self.tag == JCTree.TYPEARRAY - && (encl.tag == JCTree.VARDEF || - encl.tag == JCTree.METHODDEF || - encl.tag == JCTree.TYPEARRAY))) { + if (!(self.tag == TYPEARRAY + && (encl.tag == VARDEF || + encl.tag == METHODDEF || + encl.tag == TYPEARRAY))) { check("encl.pos <= start || end <= encl.pos", encl, self, encl.pos <= self.start || self.end <= encl.pos); } check("pos <= end", encl, self, self.pos <= self.end); - if (!(self.tag == JCTree.TYPEARRAY && encl.tag == JCTree.TYPEARRAY)) { + if (!(self.tag == TYPEARRAY && encl.tag == TYPEARRAY)) { check("end <= encl.end", encl, self, self.end <= encl.end); } } @@ -388,7 +395,7 @@ if ((tree.mods.flags & Flags.ENUM) != 0) { scan(tree.mods); if (tree.init != null) { - if (tree.init.getTag() == JCTree.NEWCLASS) { + if (tree.init.hasTag(NEWCLASS)) { JCNewClass init = (JCNewClass) tree.init; if (init.args != null && init.args.nonEmpty()) { scan(init.args); @@ -404,11 +411,11 @@ boolean check(Info encl, Info self) { if (excludeTags.size() > 0) { - if (encl != null && excludeTags.contains(tagNames.get(encl.tag)) - || excludeTags.contains(tagNames.get(self.tag))) + if (encl != null && excludeTags.contains(getTagName(encl.tag)) + || excludeTags.contains(getTagName(self.tag))) return false; } - return tags.size() == 0 || tags.contains(tagNames.get(self.tag)); + return tags.size() == 0 || tags.contains(getTagName(self.tag)); } void check(String label, Info encl, Info self, boolean ok) { @@ -439,7 +446,7 @@ private class Info { Info() { tree = null; - tag = JCTree.ERRONEOUS; + tag = ERRONEOUS; start = 0; pos = 0; end = Integer.MAX_VALUE; @@ -455,46 +462,17 @@ @Override public String toString() { - return tagNames.get(tree.getTag()) + "[start:" + start + ",pos:" + pos + ",end:" + end + "]"; + return getTagName(tree.getTag()) + "[start:" + start + ",pos:" + pos + ",end:" + end + "]"; } final JCTree tree; - final int tag; + final JCTree.Tag tag; final int start; final int pos; final int end; } /** - * Names for tree tags. - * javac does not provide an API to convert tag values to strings, so this class uses - * reflection to determine names of public static final int values in JCTree. - */ - private static class TagNames { - String get(int tag) { - if (map == null) { - map = new HashMap(); - Class c = JCTree.class; - for (Field f : c.getDeclaredFields()) { - if (f.getType().equals(int.class)) { - int mods = f.getModifiers(); - if (Modifier.isPublic(mods) && Modifier.isStatic(mods) && Modifier.isFinal(mods)) { - try { - map.put(f.getInt(null), f.getName()); - } catch (IllegalAccessException e) { - } - } - } - } - } - String name = map.get(tag); - return (name == null) ? "??" : name; - } - - private Map map; - } - - /** * Thrown when errors are found parsing a java file. */ private static class ParseException extends Exception { @@ -719,7 +697,7 @@ void setInfo(Info info) { this.info = info; - tagName.setText(tagNames.get(info.tag)); + tagName.setText(getTagName(info.tag)); start.setText(String.valueOf(info.start)); pos.setText(String.valueOf(info.pos)); end.setText(String.valueOf(info.end));