From 9224d25f96ad206d23827945b73d8f8b56d37e9d Mon Sep 17 00:00:00 2001 From: Miroslav Kos Date: Sun, 30 Dec 2012 00:00:00 +0100 Subject: [PATCH 001/159] 8029237: Update copyright year to match last edit in jaxws repository for 2012 Reviewed-by: chegar --- jaxws/build.properties | 2 +- jaxws/build.xml | 2 +- .../jaf_classes/com/sun/activation/registries/LogSupport.java | 2 +- .../jaf_classes/com/sun/activation/registries/MailcapFile.java | 2 +- .../com/sun/activation/registries/MailcapParseException.java | 2 +- .../com/sun/activation/registries/MailcapTokenizer.java | 2 +- .../com/sun/activation/registries/MimeTypeEntry.java | 2 +- .../jaf_classes/com/sun/activation/registries/MimeTypeFile.java | 2 +- .../jaf_classes/javax/activation/ActivationDataFlavor.java | 2 +- jaxws/src/share/jaf_classes/javax/activation/CommandInfo.java | 2 +- jaxws/src/share/jaf_classes/javax/activation/CommandMap.java | 2 +- jaxws/src/share/jaf_classes/javax/activation/CommandObject.java | 2 +- .../share/jaf_classes/javax/activation/DataContentHandler.java | 2 +- .../jaf_classes/javax/activation/DataContentHandlerFactory.java | 2 +- jaxws/src/share/jaf_classes/javax/activation/DataHandler.java | 2 +- jaxws/src/share/jaf_classes/javax/activation/DataSource.java | 2 +- .../src/share/jaf_classes/javax/activation/FileDataSource.java | 2 +- jaxws/src/share/jaf_classes/javax/activation/FileTypeMap.java | 2 +- .../share/jaf_classes/javax/activation/MailcapCommandMap.java | 2 +- jaxws/src/share/jaf_classes/javax/activation/MimeType.java | 2 +- .../jaf_classes/javax/activation/MimeTypeParameterList.java | 2 +- .../jaf_classes/javax/activation/MimeTypeParseException.java | 2 +- .../jaf_classes/javax/activation/MimetypesFileTypeMap.java | 2 +- .../src/share/jaf_classes/javax/activation/SecuritySupport.java | 2 +- jaxws/src/share/jaf_classes/javax/activation/URLDataSource.java | 2 +- .../javax/activation/UnsupportedDataTypeException.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/ClassType.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/CodeWriter.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JAnnotatable.java | 2 +- .../com/sun/codemodel/internal/JAnnotationArrayMember.java | 2 +- .../com/sun/codemodel/internal/JAnnotationStringValue.java | 2 +- .../com/sun/codemodel/internal/JAnnotationUse.java | 2 +- .../com/sun/codemodel/internal/JAnnotationValue.java | 2 +- .../com/sun/codemodel/internal/JAnnotationWriter.java | 2 +- .../com/sun/codemodel/internal/JAnonymousClass.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JArray.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JArrayClass.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JArrayCompRef.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JAssignment.java | 2 +- .../com/sun/codemodel/internal/JAssignmentTarget.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JAtom.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JBlock.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JBreak.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JCase.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JCast.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JCatchBlock.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JClass.java | 2 +- .../sun/codemodel/internal/JClassAlreadyExistsException.java | 2 +- .../com/sun/codemodel/internal/JClassContainer.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JCodeModel.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JCommentPart.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JConditional.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JContinue.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JDeclaration.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JDefinedClass.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JDirectClass.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JDoLoop.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JDocComment.java | 2 +- .../com/sun/codemodel/internal/JDocCommentable.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JEnumConstant.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JExpr.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JExpression.java | 2 +- .../com/sun/codemodel/internal/JExpressionImpl.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JFieldRef.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JFieldVar.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JForEach.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JForLoop.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JFormatter.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JGenerable.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JGenerifiable.java | 2 +- .../com/sun/codemodel/internal/JGenerifiableImpl.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JInvocation.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JJavaName.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JLabel.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JMethod.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JMod.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JMods.java | 2 +- .../com/sun/codemodel/internal/JNarrowedClass.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JNullType.java | 2 +- .../src/share/jaxws_classes/com/sun/codemodel/internal/JOp.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JPackage.java | 2 +- .../com/sun/codemodel/internal/JPrimitiveType.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JResourceFile.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JReturn.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JStatement.java | 2 +- .../com/sun/codemodel/internal/JStringLiteral.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JSwitch.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JThrow.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JTryBlock.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JType.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JTypeVar.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JTypeWildcard.java | 2 +- .../share/jaxws_classes/com/sun/codemodel/internal/JVar.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/JWhileLoop.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/SecureLoader.java | 2 +- .../com/sun/codemodel/internal/TypedAnnotationWriter.java | 2 +- .../com/sun/codemodel/internal/fmt/JBinaryFile.java | 2 +- .../com/sun/codemodel/internal/fmt/JPropertyFile.java | 2 +- .../com/sun/codemodel/internal/fmt/JSerializedObject.java | 2 +- .../com/sun/codemodel/internal/fmt/JStaticFile.java | 2 +- .../com/sun/codemodel/internal/fmt/JStaticJavaFile.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/fmt/JTextFile.java | 2 +- .../com/sun/codemodel/internal/fmt/SecureLoader.java | 2 +- .../jaxws_classes/com/sun/codemodel/internal/package-info.java | 2 +- .../com/sun/codemodel/internal/util/ClassNameComparator.java | 2 +- .../com/sun/codemodel/internal/util/EncoderFactory.java | 2 +- .../com/sun/codemodel/internal/util/JavadocEscapeWriter.java | 2 +- .../com/sun/codemodel/internal/util/MS1252Encoder.java | 2 +- .../com/sun/codemodel/internal/util/SingleByteEncoder.java | 2 +- .../com/sun/codemodel/internal/util/Surrogate.java | 2 +- .../com/sun/codemodel/internal/util/UnicodeEscapeWriter.java | 2 +- .../com/sun/codemodel/internal/writer/FileCodeWriter.java | 2 +- .../com/sun/codemodel/internal/writer/FilterCodeWriter.java | 2 +- .../com/sun/codemodel/internal/writer/ProgressCodeWriter.java | 2 +- .../com/sun/codemodel/internal/writer/PrologCodeWriter.java | 2 +- .../sun/codemodel/internal/writer/SingleStreamCodeWriter.java | 2 +- .../com/sun/codemodel/internal/writer/ZipCodeWriter.java | 2 +- .../jaxws_classes/com/sun/org/glassfish/gmbal/AMXClient.java | 2 +- .../com/sun/org/glassfish/gmbal/AMXMBeanInterface.java | 2 +- .../jaxws_classes/com/sun/org/glassfish/gmbal/AMXMetadata.java | 2 +- .../jaxws_classes/com/sun/org/glassfish/gmbal/Description.java | 2 +- .../com/sun/org/glassfish/gmbal/DescriptorFields.java | 2 +- .../com/sun/org/glassfish/gmbal/DescriptorKey.java | 2 +- .../com/sun/org/glassfish/gmbal/GmbalException.java | 2 +- .../jaxws_classes/com/sun/org/glassfish/gmbal/GmbalMBean.java | 2 +- .../com/sun/org/glassfish/gmbal/GmbalMBeanNOPImpl.java | 2 +- .../share/jaxws_classes/com/sun/org/glassfish/gmbal/Impact.java | 2 +- .../com/sun/org/glassfish/gmbal/IncludeSubclass.java | 2 +- .../com/sun/org/glassfish/gmbal/InheritedAttribute.java | 2 +- .../com/sun/org/glassfish/gmbal/InheritedAttributes.java | 2 +- .../com/sun/org/glassfish/gmbal/ManagedAttribute.java | 2 +- .../jaxws_classes/com/sun/org/glassfish/gmbal/ManagedData.java | 2 +- .../com/sun/org/glassfish/gmbal/ManagedObject.java | 2 +- .../com/sun/org/glassfish/gmbal/ManagedObjectManager.java | 2 +- .../sun/org/glassfish/gmbal/ManagedObjectManagerFactory.java | 2 +- .../sun/org/glassfish/gmbal/ManagedObjectManagerNOPImpl.java | 2 +- .../com/sun/org/glassfish/gmbal/ManagedOperation.java | 2 +- .../jaxws_classes/com/sun/org/glassfish/gmbal/NameValue.java | 2 +- .../com/sun/org/glassfish/gmbal/ParameterNames.java | 2 +- .../com/sun/org/glassfish/gmbal/util/GenericConstructor.java | 2 +- .../jaxws_classes/com/sun/tools/internal/jxc/Messages.java | 2 +- .../jaxws_classes/com/sun/tools/internal/jxc/ap/Const.java | 2 +- .../com/sun/tools/internal/jxc/ap/ErrorReceiverImpl.java | 2 +- .../sun/tools/internal/jxc/ap/InlineAnnotationReaderImpl.java | 2 +- .../com/sun/tools/internal/jxc/ap/MessageBundle.properties | 2 +- .../jaxws_classes/com/sun/tools/internal/jxc/ap/Messages.java | 2 +- .../jaxws_classes/com/sun/tools/internal/jxc/ap/package.html | 2 +- .../com/sun/tools/internal/jxc/gen/config/config.rng | 2 +- .../com/sun/tools/internal/jxc/gen/config/config.xsd | 2 +- .../com/sun/tools/internal/xjc/AbortException.java | 2 +- .../com/sun/tools/internal/xjc/BadCommandLineException.java | 2 +- .../com/sun/tools/internal/xjc/ConsoleErrorReporter.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/ErrorReceiver.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/Language.java | 2 +- .../share/jaxws_classes/com/sun/tools/internal/xjc/Plugin.java | 2 +- .../com/sun/tools/internal/xjc/ProgressCodeWriter.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/XJCListener.java | 2 +- .../com/sun/tools/internal/xjc/addon/accessors/PluginImpl.java | 2 +- .../sun/tools/internal/xjc/addon/at_generated/PluginImpl.java | 2 +- .../com/sun/tools/internal/xjc/addon/code_injector/Const.java | 2 +- .../sun/tools/internal/xjc/addon/code_injector/PluginImpl.java | 2 +- .../com/sun/tools/internal/xjc/addon/episode/PluginImpl.java | 2 +- .../com/sun/tools/internal/xjc/addon/episode/package-info.java | 2 +- .../tools/internal/xjc/addon/locator/SourceLocationAddOn.java | 2 +- .../tools/internal/xjc/addon/sync/SynchronizedMethodAddOn.java | 2 +- .../com/sun/tools/internal/xjc/api/ClassNameAllocator.java | 2 +- .../com/sun/tools/internal/xjc/api/ErrorListener.java | 2 +- .../com/sun/tools/internal/xjc/api/J2SJAXBModel.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/api/JAXBModel.java | 2 +- .../com/sun/tools/internal/xjc/api/JavaCompiler.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/api/Mapping.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/api/Property.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/api/Reference.java | 2 +- .../com/sun/tools/internal/xjc/api/S2JJAXBModel.java | 2 +- .../com/sun/tools/internal/xjc/api/SchemaCompiler.java | 2 +- .../com/sun/tools/internal/xjc/api/SpecVersion.java | 2 +- .../com/sun/tools/internal/xjc/api/TypeAndAnnotation.java | 2 +- .../tools/internal/xjc/api/impl/s2j/AbstractMappingImpl.java | 2 +- .../sun/tools/internal/xjc/api/impl/s2j/BeanMappingImpl.java | 2 +- .../internal/xjc/api/impl/s2j/DowngradingErrorHandler.java | 2 +- .../com/sun/tools/internal/xjc/api/impl/s2j/ElementAdapter.java | 2 +- .../internal/xjc/api/impl/s2j/ElementCollectionAdapter.java | 2 +- .../sun/tools/internal/xjc/api/impl/s2j/ElementMappingImpl.java | 2 +- .../tools/internal/xjc/api/impl/s2j/ElementSingleAdapter.java | 2 +- .../com/sun/tools/internal/xjc/api/impl/s2j/JAXBModelImpl.java | 2 +- .../com/sun/tools/internal/xjc/api/impl/s2j/PropertyImpl.java | 2 +- .../com/sun/tools/internal/xjc/api/impl/s2j/package.html | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/api/package.html | 2 +- .../com/sun/tools/internal/xjc/api/util/ApClassLoader.java | 2 +- .../com/sun/tools/internal/xjc/api/util/FilerCodeWriter.java | 2 +- .../com/sun/tools/internal/xjc/api/util/Messages.java | 2 +- .../com/sun/tools/internal/xjc/api/util/Messages.properties | 2 +- .../tools/internal/xjc/api/util/ToolsJarNotFoundException.java | 2 +- .../com/sun/tools/internal/xjc/api/util/package.html | 2 +- .../sun/tools/internal/xjc/generator/bean/ClassOutlineImpl.java | 2 +- .../tools/internal/xjc/generator/bean/ElementOutlineImpl.java | 2 +- .../internal/xjc/generator/bean/ImplStructureStrategy.java | 2 +- .../com/sun/tools/internal/xjc/generator/bean/Messages.java | 2 +- .../com/sun/tools/internal/xjc/generator/bean/MethodWriter.java | 2 +- .../internal/xjc/generator/bean/ObjectFactoryGenerator.java | 2 +- .../internal/xjc/generator/bean/ObjectFactoryGeneratorImpl.java | 2 +- .../tools/internal/xjc/generator/bean/PackageOutlineImpl.java | 2 +- .../xjc/generator/bean/PrivateObjectFactoryGenerator.java | 2 +- .../xjc/generator/bean/PublicObjectFactoryGenerator.java | 2 +- .../tools/internal/xjc/generator/bean/field/AbstractField.java | 2 +- .../internal/xjc/generator/bean/field/AbstractListField.java | 2 +- .../sun/tools/internal/xjc/generator/bean/field/ArrayField.java | 2 +- .../sun/tools/internal/xjc/generator/bean/field/ConstField.java | 2 +- .../internal/xjc/generator/bean/field/ConstFieldRenderer.java | 2 +- .../internal/xjc/generator/bean/field/ContentListField.java | 2 +- .../internal/xjc/generator/bean/field/DefaultFieldRenderer.java | 2 +- .../tools/internal/xjc/generator/bean/field/DummyListField.java | 2 +- .../tools/internal/xjc/generator/bean/field/FieldRenderer.java | 2 +- .../internal/xjc/generator/bean/field/FieldRendererFactory.java | 2 +- .../internal/xjc/generator/bean/field/GenericFieldRenderer.java | 2 +- .../sun/tools/internal/xjc/generator/bean/field/IsSetField.java | 2 +- .../internal/xjc/generator/bean/field/IsSetFieldRenderer.java | 2 +- .../internal/xjc/generator/bean/field/MessageBundle.properties | 2 +- .../sun/tools/internal/xjc/generator/bean/field/Messages.java | 2 +- .../xjc/generator/bean/field/NoExtendedContentField.java | 2 +- .../tools/internal/xjc/generator/bean/field/SingleField.java | 2 +- .../xjc/generator/bean/field/SinglePrimitiveAccessField.java | 2 +- .../tools/internal/xjc/generator/bean/field/UnboxedField.java | 2 +- .../internal/xjc/generator/bean/field/UntypedListField.java | 2 +- .../xjc/generator/bean/field/UntypedListFieldRenderer.java | 2 +- .../sun/tools/internal/xjc/generator/bean/field/package.html | 2 +- .../com/sun/tools/internal/xjc/generator/package-info.java | 2 +- .../sun/tools/internal/xjc/generator/util/BlockReference.java | 2 +- .../internal/xjc/generator/util/ExistingBlockReference.java | 2 +- .../tools/internal/xjc/generator/util/LazyBlockReference.java | 2 +- .../tools/internal/xjc/generator/util/WhitespaceNormalizer.java | 2 +- .../com/sun/tools/internal/xjc/model/AbstractCElement.java | 2 +- .../com/sun/tools/internal/xjc/model/AbstractCTypeInfoImpl.java | 2 +- .../sun/tools/internal/xjc/model/AutoClassNameAllocator.java | 2 +- .../com/sun/tools/internal/xjc/model/CAdapter.java | 2 +- .../sun/tools/internal/xjc/model/CAttributePropertyInfo.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/model/CClass.java | 2 +- .../com/sun/tools/internal/xjc/model/CClassInfo.java | 2 +- .../com/sun/tools/internal/xjc/model/CClassInfoParent.java | 2 +- .../com/sun/tools/internal/xjc/model/CClassRef.java | 2 +- .../com/sun/tools/internal/xjc/model/CCustomizable.java | 2 +- .../com/sun/tools/internal/xjc/model/CCustomizations.java | 2 +- .../com/sun/tools/internal/xjc/model/CDefaultValue.java | 2 +- .../com/sun/tools/internal/xjc/model/CElement.java | 2 +- .../com/sun/tools/internal/xjc/model/CElementInfo.java | 2 +- .../com/sun/tools/internal/xjc/model/CElementPropertyInfo.java | 2 +- .../com/sun/tools/internal/xjc/model/CEnumConstant.java | 2 +- .../com/sun/tools/internal/xjc/model/CEnumLeafInfo.java | 2 +- .../com/sun/tools/internal/xjc/model/CNonElement.java | 2 +- .../com/sun/tools/internal/xjc/model/CPluginCustomization.java | 2 +- .../com/sun/tools/internal/xjc/model/CPropertyVisitor.java | 2 +- .../sun/tools/internal/xjc/model/CReferencePropertyInfo.java | 2 +- .../sun/tools/internal/xjc/model/CSingleTypePropertyInfo.java | 2 +- .../com/sun/tools/internal/xjc/model/CValuePropertyInfo.java | 2 +- .../com/sun/tools/internal/xjc/model/CWildcardTypeInfo.java | 2 +- .../sun/tools/internal/xjc/model/ClassNameAllocatorWrapper.java | 2 +- .../com/sun/tools/internal/xjc/model/Constructor.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/model/Model.java | 2 +- .../com/sun/tools/internal/xjc/model/Multiplicity.java | 2 +- .../com/sun/tools/internal/xjc/model/Populatable.java | 2 +- .../com/sun/tools/internal/xjc/model/SymbolSpace.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/model/TypeUse.java | 2 +- .../com/sun/tools/internal/xjc/model/TypeUseFactory.java | 2 +- .../com/sun/tools/internal/xjc/model/TypeUseImpl.java | 2 +- .../com/sun/tools/internal/xjc/model/nav/EagerNClass.java | 2 +- .../com/sun/tools/internal/xjc/model/nav/NClass.java | 2 +- .../com/sun/tools/internal/xjc/model/nav/NClassByJClass.java | 2 +- .../sun/tools/internal/xjc/model/nav/NParameterizedType.java | 2 +- .../com/sun/tools/internal/xjc/model/nav/NType.java | 2 +- .../com/sun/tools/internal/xjc/model/nav/package.html | 2 +- .../com/sun/tools/internal/xjc/outline/Aspect.java | 2 +- .../com/sun/tools/internal/xjc/outline/ClassOutline.java | 2 +- .../com/sun/tools/internal/xjc/outline/ElementOutline.java | 2 +- .../com/sun/tools/internal/xjc/outline/EnumConstantOutline.java | 2 +- .../com/sun/tools/internal/xjc/outline/EnumOutline.java | 2 +- .../com/sun/tools/internal/xjc/outline/FieldAccessor.java | 2 +- .../com/sun/tools/internal/xjc/outline/FieldOutline.java | 2 +- .../com/sun/tools/internal/xjc/outline/Outline.java | 2 +- .../com/sun/tools/internal/xjc/outline/PackageOutline.java | 2 +- .../com/sun/tools/internal/xjc/outline/package.html | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/package-info.java | 2 +- .../internal/xjc/reader/AbstractExtensionBindingChecker.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/reader/Const.java | 2 +- .../sun/tools/internal/xjc/reader/ExtensionBindingChecker.java | 2 +- .../com/sun/tools/internal/xjc/reader/MessageBundle.properties | 2 +- .../com/sun/tools/internal/xjc/reader/Messages.java | 2 +- .../com/sun/tools/internal/xjc/reader/ModelChecker.java | 2 +- .../com/sun/tools/internal/xjc/reader/RawTypeSet.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/reader/Ring.java | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/reader/Util.java | 2 +- .../com/sun/tools/internal/xjc/reader/dtd/Block.java | 2 +- .../com/sun/tools/internal/xjc/reader/dtd/Element.java | 2 +- .../sun/tools/internal/xjc/reader/dtd/MessageBundle.properties | 2 +- .../com/sun/tools/internal/xjc/reader/dtd/Messages.java | 2 +- .../com/sun/tools/internal/xjc/reader/dtd/ModelGroup.java | 2 +- .../com/sun/tools/internal/xjc/reader/dtd/Occurence.java | 2 +- .../com/sun/tools/internal/xjc/reader/dtd/TDTDReader.java | 2 +- .../com/sun/tools/internal/xjc/reader/dtd/Term.java | 2 +- .../sun/tools/internal/xjc/reader/dtd/bindinfo/BIAttribute.java | 2 +- .../tools/internal/xjc/reader/dtd/bindinfo/BIConstructor.java | 2 +- .../sun/tools/internal/xjc/reader/dtd/bindinfo/BIContent.java | 2 +- .../tools/internal/xjc/reader/dtd/bindinfo/BIConversion.java | 2 +- .../sun/tools/internal/xjc/reader/dtd/bindinfo/BIElement.java | 2 +- .../tools/internal/xjc/reader/dtd/bindinfo/BIEnumeration.java | 2 +- .../sun/tools/internal/xjc/reader/dtd/bindinfo/BIInterface.java | 2 +- .../sun/tools/internal/xjc/reader/dtd/bindinfo/DOMLocator.java | 2 +- .../com/sun/tools/internal/xjc/reader/dtd/bindinfo/DOMUtil.java | 2 +- .../xjc/reader/dtd/bindinfo/DTDExtensionBindingChecker.java | 2 +- .../internal/xjc/reader/dtd/bindinfo/MessageBundle.properties | 2 +- .../sun/tools/internal/xjc/reader/dtd/bindinfo/Messages.java | 2 +- .../sun/tools/internal/xjc/reader/dtd/bindinfo/bindingfile.rng | 2 +- .../sun/tools/internal/xjc/reader/dtd/bindinfo/bindingfile.xsd | 2 +- .../com/sun/tools/internal/xjc/reader/dtd/bindinfo/package.html | 2 +- .../com/sun/tools/internal/xjc/reader/dtd/bindinfo/xjc.xsd | 2 +- .../com/sun/tools/internal/xjc/reader/gbind/Choice.java | 2 +- .../sun/tools/internal/xjc/reader/gbind/ConnectedComponent.java | 2 +- .../com/sun/tools/internal/xjc/reader/gbind/Element.java | 2 +- .../com/sun/tools/internal/xjc/reader/gbind/ElementSet.java | 2 +- .../com/sun/tools/internal/xjc/reader/gbind/ElementSets.java | 2 +- .../com/sun/tools/internal/xjc/reader/gbind/Expression.java | 2 +- .../com/sun/tools/internal/xjc/reader/gbind/Graph.java | 2 +- .../com/sun/tools/internal/xjc/reader/gbind/OneOrMore.java | 2 +- .../com/sun/tools/internal/xjc/reader/gbind/Sequence.java | 2 +- .../com/sun/tools/internal/xjc/reader/gbind/SinkNode.java | 2 +- .../com/sun/tools/internal/xjc/reader/gbind/SourceNode.java | 2 +- .../com/sun/tools/internal/xjc/reader/gbind/package.html | 2 +- .../internalizer/ContentHandlerNamespacePrefixAdapter.java | 2 +- .../sun/tools/internal/xjc/reader/internalizer/DOMBuilder.java | 2 +- .../tools/internal/xjc/reader/internalizer/DOMForestParser.java | 2 +- .../internal/xjc/reader/internalizer/DOMForestScanner.java | 2 +- .../internal/xjc/reader/internalizer/InternalizationLogic.java | 2 +- .../tools/internal/xjc/reader/internalizer/LocatorTable.java | 2 +- .../internal/xjc/reader/internalizer/MessageBundle.properties | 2 +- .../sun/tools/internal/xjc/reader/internalizer/Messages.java | 2 +- .../internal/xjc/reader/internalizer/NamespaceContextImpl.java | 2 +- .../tools/internal/xjc/reader/internalizer/VersionChecker.java | 2 +- .../internal/xjc/reader/internalizer/WhitespaceStripper.java | 2 +- .../com/sun/tools/internal/xjc/reader/internalizer/package.html | 2 +- .../com/sun/tools/internal/xjc/reader/package.html | 2 +- .../com/sun/tools/internal/xjc/reader/relaxng/BindStyle.java | 2 +- .../tools/internal/xjc/reader/relaxng/ContentModelBinder.java | 2 +- .../com/sun/tools/internal/xjc/reader/relaxng/DatatypeLib.java | 2 +- .../com/sun/tools/internal/xjc/reader/relaxng/DefineFinder.java | 2 +- .../sun/tools/internal/xjc/reader/relaxng/NameCalculator.java | 2 +- .../sun/tools/internal/xjc/reader/relaxng/RELAXNGCompiler.java | 2 +- .../xjc/reader/relaxng/RELAXNGInternalizationLogic.java | 2 +- .../tools/internal/xjc/reader/relaxng/RawTypeSetBuilder.java | 2 +- .../tools/internal/xjc/reader/relaxng/TypePatternBinder.java | 2 +- .../sun/tools/internal/xjc/reader/relaxng/TypeUseBinder.java | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/Abstractifier.java | 2 +- .../com/sun/tools/internal/xjc/reader/xmlschema/BindBlue.java | 2 +- .../com/sun/tools/internal/xjc/reader/xmlschema/BindGreen.java | 2 +- .../com/sun/tools/internal/xjc/reader/xmlschema/BindPurple.java | 2 +- .../com/sun/tools/internal/xjc/reader/xmlschema/BindRed.java | 2 +- .../com/sun/tools/internal/xjc/reader/xmlschema/BindYellow.java | 2 +- .../tools/internal/xjc/reader/xmlschema/BindingComponent.java | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/ClassBinder.java | 2 +- .../tools/internal/xjc/reader/xmlschema/ClassBinderFilter.java | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/ClassSelector.java | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/CollisionInfo.java | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/ColorBinder.java | 2 +- .../tools/internal/xjc/reader/xmlschema/DefaultClassBinder.java | 2 +- .../internal/xjc/reader/xmlschema/DefaultParticleBinder.java | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/ErrorReporter.java | 2 +- .../tools/internal/xjc/reader/xmlschema/ExpressionBuilder.java | 2 +- .../internal/xjc/reader/xmlschema/ExpressionParticleBinder.java | 2 +- .../com/sun/tools/internal/xjc/reader/xmlschema/GElement.java | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/GElementImpl.java | 2 +- .../tools/internal/xjc/reader/xmlschema/GWildcardElement.java | 2 +- .../internal/xjc/reader/xmlschema/MessageBundle.properties | 2 +- .../com/sun/tools/internal/xjc/reader/xmlschema/Messages.java | 2 +- .../internal/xjc/reader/xmlschema/MultiplicityCounter.java | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/ParticleBinder.java | 2 +- .../tools/internal/xjc/reader/xmlschema/RawTypeSetBuilder.java | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/RefererFinder.java | 2 +- .../xjc/reader/xmlschema/UnusedCustomizationChecker.java | 2 +- .../internal/xjc/reader/xmlschema/WildcardNameClassBuilder.java | 2 +- .../xjc/reader/xmlschema/bindinfo/AbstractDeclarationImpl.java | 2 +- .../tools/internal/xjc/reader/xmlschema/bindinfo/BIClass.java | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/BIConversion.java | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/BIDeclaration.java | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/bindinfo/BIDom.java | 2 +- .../tools/internal/xjc/reader/xmlschema/bindinfo/BIEnum.java | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/BIEnumMember.java | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/BIFactoryMethod.java | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/BIGlobalBinding.java | 2 +- .../xjc/reader/xmlschema/bindinfo/BIInlineBinaryData.java | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/BIProperty.java | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/BISchemaBinding.java | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/BISerializable.java | 2 +- .../tools/internal/xjc/reader/xmlschema/bindinfo/BIXDom.java | 2 +- .../xjc/reader/xmlschema/bindinfo/BIXPluginCustomization.java | 2 +- .../xjc/reader/xmlschema/bindinfo/BIXSubstitutable.java | 2 +- .../xjc/reader/xmlschema/bindinfo/CollectionTypeAttribute.java | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/EnumMemberMode.java | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/ForkingFilter.java | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/LocalScoping.java | 2 +- .../xjc/reader/xmlschema/bindinfo/MessageBundle.properties | 2 +- .../tools/internal/xjc/reader/xmlschema/bindinfo/Messages.java | 2 +- .../xjc/reader/xmlschema/bindinfo/OptionalPropertyMode.java | 2 +- .../tools/internal/xjc/reader/xmlschema/bindinfo/binding.rng | 2 +- .../tools/internal/xjc/reader/xmlschema/bindinfo/binding.xsd | 2 +- .../internal/xjc/reader/xmlschema/bindinfo/package-info.java | 2 +- .../tools/internal/xjc/reader/xmlschema/bindinfo/package.html | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/bindinfo/xjc.xsd | 2 +- .../com/sun/tools/internal/xjc/reader/xmlschema/bindinfo/xs.xsd | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/ct/CTBuilder.java | 2 +- .../reader/xmlschema/ct/ChoiceContentComplexTypeBuilder.java | 2 +- .../xjc/reader/xmlschema/ct/ComplexTypeBindingMode.java | 2 +- .../xjc/reader/xmlschema/ct/ComplexTypeFieldBuilder.java | 2 +- .../xjc/reader/xmlschema/ct/ExtendedComplexTypeBuilder.java | 2 +- .../xjc/reader/xmlschema/ct/FreshComplexTypeBuilder.java | 2 +- .../internal/xjc/reader/xmlschema/ct/MessageBundle.properties | 2 +- .../sun/tools/internal/xjc/reader/xmlschema/ct/Messages.java | 2 +- .../xjc/reader/xmlschema/ct/MixedComplexTypeBuilder.java | 2 +- .../reader/xmlschema/ct/MixedExtendedComplexTypeBuilder.java | 2 +- .../reader/xmlschema/ct/MultiWildcardComplexTypeBuilder.java | 2 +- .../xjc/reader/xmlschema/ct/RestrictedComplexTypeBuilder.java | 2 +- .../xjc/reader/xmlschema/ct/STDerivedComplexTypeBuilder.java | 2 +- .../reader/xmlschema/parser/CustomizationContextChecker.java | 2 +- .../reader/xmlschema/parser/IncorrectNamespaceURIChecker.java | 2 +- .../internal/xjc/reader/xmlschema/parser/LSInputSAXWrapper.java | 2 +- .../xjc/reader/xmlschema/parser/MessageBundle.properties | 2 +- .../tools/internal/xjc/reader/xmlschema/parser/Messages.java | 2 +- .../reader/xmlschema/parser/XMLSchemaInternalizationLogic.java | 2 +- .../com/sun/tools/internal/xjc/runtime/JAXBContextFactory.java | 2 +- .../sun/tools/internal/xjc/runtime/ZeroOneBooleanAdapter.java | 2 +- .../com/sun/tools/internal/xjc/runtime/package.html | 2 +- .../com/sun/tools/internal/xjc/util/CodeModelClassFactory.java | 2 +- .../com/sun/tools/internal/xjc/util/ErrorReceiverFilter.java | 2 +- .../com/sun/tools/internal/xjc/util/ForkContentHandler.java | 2 +- .../com/sun/tools/internal/xjc/util/ForkEntityResolver.java | 2 +- .../com/sun/tools/internal/xjc/util/MessageBundle.properties | 2 +- .../jaxws_classes/com/sun/tools/internal/xjc/util/Messages.java | 2 +- .../com/sun/tools/internal/xjc/util/MimeTypeRange.java | 2 +- .../sun/tools/internal/xjc/util/NamespaceContextAdapter.java | 2 +- .../com/sun/tools/internal/xjc/util/NullStream.java | 2 +- .../com/sun/tools/internal/xjc/util/ReadOnlyAdapter.java | 2 +- .../com/sun/tools/internal/xjc/util/StringCutter.java | 2 +- .../com/sun/tools/internal/xjc/util/SubtreeCutter.java | 2 +- .../com/sun/tools/internal/xjc/writer/SignatureWriter.java | 2 +- .../com/sun/xml/internal/bind/AccessorFactory.java | 2 +- .../com/sun/xml/internal/bind/AccessorFactoryImpl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/bind/AnyTypeAdapter.java | 2 +- .../com/sun/xml/internal/bind/CycleRecoverable.java | 2 +- .../jaxws_classes/com/sun/xml/internal/bind/IDResolver.java | 2 +- .../jaxws_classes/com/sun/xml/internal/bind/Locatable.java | 2 +- .../com/sun/xml/internal/bind/ValidationEventLocatorEx.java | 2 +- .../com/sun/xml/internal/bind/XmlAccessorFactory.java | 2 +- .../sun/xml/internal/bind/annotation/OverrideAnnotationOf.java | 2 +- .../com/sun/xml/internal/bind/annotation/XmlIsSet.java | 2 +- .../com/sun/xml/internal/bind/annotation/XmlLocation.java | 2 +- .../com/sun/xml/internal/bind/api/AccessorException.java | 2 +- .../jaxws_classes/com/sun/xml/internal/bind/api/Bridge.java | 2 +- .../com/sun/xml/internal/bind/api/BridgeContext.java | 2 +- .../com/sun/xml/internal/bind/api/ClassResolver.java | 2 +- .../com/sun/xml/internal/bind/api/CompositeStructure.java | 2 +- .../com/sun/xml/internal/bind/api/ErrorListener.java | 2 +- .../jaxws_classes/com/sun/xml/internal/bind/api/Messages.java | 2 +- .../com/sun/xml/internal/bind/api/Messages.properties | 2 +- .../com/sun/xml/internal/bind/api/RawAccessor.java | 2 +- .../com/sun/xml/internal/bind/api/package-info.java | 2 +- .../xml/internal/bind/marshaller/CharacterEscapeHandler.java | 2 +- .../com/sun/xml/internal/bind/marshaller/DataWriter.java | 2 +- .../com/sun/xml/internal/bind/marshaller/DumbEscapeHandler.java | 2 +- .../com/sun/xml/internal/bind/marshaller/Messages.java | 2 +- .../com/sun/xml/internal/bind/marshaller/Messages.properties | 2 +- .../sun/xml/internal/bind/marshaller/MinimumEscapeHandler.java | 2 +- .../sun/xml/internal/bind/marshaller/NamespacePrefixMapper.java | 2 +- .../com/sun/xml/internal/bind/marshaller/NioEscapeHandler.java | 2 +- .../com/sun/xml/internal/bind/marshaller/XMLWriter.java | 2 +- .../com/sun/xml/internal/bind/unmarshaller/DOMScanner.java | 2 +- .../com/sun/xml/internal/bind/unmarshaller/InfosetScanner.java | 2 +- .../com/sun/xml/internal/bind/unmarshaller/Messages.java | 2 +- .../com/sun/xml/internal/bind/unmarshaller/Messages.properties | 2 +- .../com/sun/xml/internal/bind/unmarshaller/Patcher.java | 2 +- .../com/sun/xml/internal/bind/util/AttributesImpl.java | 2 +- .../xml/internal/bind/util/ValidationEventLocatorExImpl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/bind/util/Which.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/bind/v2/TODO.java | 2 +- .../com/sun/xml/internal/bind/v2/WellKnownNamespace.java | 2 +- .../com/sun/xml/internal/bind/v2/bytecode/ClassTailor.java | 2 +- .../com/sun/xml/internal/bind/v2/bytecode/SecureLoader.java | 2 +- .../com/sun/xml/internal/bind/v2/bytecode/package.html | 2 +- .../v2/model/annotation/AbstractInlineAnnotationReaderImpl.java | 2 +- .../xml/internal/bind/v2/model/annotation/AnnotationReader.java | 2 +- .../xml/internal/bind/v2/model/annotation/AnnotationSource.java | 2 +- .../xml/internal/bind/v2/model/annotation/ClassLocatable.java | 2 +- .../xml/internal/bind/v2/model/annotation/FieldLocatable.java | 2 +- .../sun/xml/internal/bind/v2/model/annotation/Locatable.java | 2 +- .../internal/bind/v2/model/annotation/LocatableAnnotation.java | 2 +- .../com/sun/xml/internal/bind/v2/model/annotation/Messages.java | 2 +- .../xml/internal/bind/v2/model/annotation/Messages.properties | 2 +- .../xml/internal/bind/v2/model/annotation/MethodLocatable.java | 2 +- .../com/sun/xml/internal/bind/v2/model/annotation/Quick.java | 2 +- .../bind/v2/model/annotation/RuntimeAnnotationReader.java | 2 +- .../bind/v2/model/annotation/RuntimeInlineAnnotationReader.java | 2 +- .../sun/xml/internal/bind/v2/model/annotation/SecureLoader.java | 2 +- .../com/sun/xml/internal/bind/v2/model/annotation/package.html | 2 +- .../com/sun/xml/internal/bind/v2/model/core/Adapter.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/ArrayInfo.java | 2 +- .../xml/internal/bind/v2/model/core/AttributePropertyInfo.java | 2 +- .../sun/xml/internal/bind/v2/model/core/BuiltinLeafInfo.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/ClassInfo.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/Element.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/ElementInfo.java | 2 +- .../xml/internal/bind/v2/model/core/ElementPropertyInfo.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/EnumConstant.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/EnumLeafInfo.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/ID.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/LeafInfo.java | 2 +- .../sun/xml/internal/bind/v2/model/core/MapPropertyInfo.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/MaybeElement.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/NonElement.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/NonElementRef.java | 2 +- .../xml/internal/bind/v2/model/core/ReferencePropertyInfo.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/TypeInfo.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/TypeInfoSet.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/TypeRef.java | 2 +- .../sun/xml/internal/bind/v2/model/core/ValuePropertyInfo.java | 2 +- .../com/sun/xml/internal/bind/v2/model/core/WildcardMode.java | 2 +- .../sun/xml/internal/bind/v2/model/core/WildcardTypeInfo.java | 2 +- .../com/sun/xml/internal/bind/v2/model/impl/AnyTypeImpl.java | 2 +- .../internal/bind/v2/model/impl/AttributePropertyInfoImpl.java | 2 +- .../xml/internal/bind/v2/model/impl/BuiltinLeafInfoImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/model/impl/ClassInfoImpl.java | 2 +- .../sun/xml/internal/bind/v2/model/impl/DummyPropertyInfo.java | 2 +- .../sun/xml/internal/bind/v2/model/impl/ERPropertyInfoImpl.java | 2 +- .../sun/xml/internal/bind/v2/model/impl/ElementInfoImpl.java | 2 +- .../internal/bind/v2/model/impl/ElementPropertyInfoImpl.java | 2 +- .../sun/xml/internal/bind/v2/model/impl/EnumConstantImpl.java | 2 +- .../sun/xml/internal/bind/v2/model/impl/EnumLeafInfoImpl.java | 2 +- .../sun/xml/internal/bind/v2/model/impl/FieldPropertySeed.java | 2 +- .../internal/bind/v2/model/impl/GetterSetterPropertySeed.java | 2 +- .../com/sun/xml/internal/bind/v2/model/impl/LeafInfoImpl.java | 2 +- .../xml/internal/bind/v2/model/impl/MapPropertyInfoImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/model/impl/Messages.java | 2 +- .../com/sun/xml/internal/bind/v2/model/impl/Messages.properties | 2 +- .../sun/xml/internal/bind/v2/model/impl/PropertyInfoImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/model/impl/PropertySeed.java | 2 +- .../sun/xml/internal/bind/v2/model/impl/RegistryInfoImpl.java | 2 +- .../xml/internal/bind/v2/model/impl/RuntimeArrayInfoImpl.java | 2 +- .../bind/v2/model/impl/RuntimeAttributePropertyInfoImpl.java | 2 +- .../xml/internal/bind/v2/model/impl/RuntimeClassInfoImpl.java | 2 +- .../bind/v2/model/impl/RuntimeElementPropertyInfoImpl.java | 2 +- .../internal/bind/v2/model/impl/RuntimeEnumConstantImpl.java | 2 +- .../internal/bind/v2/model/impl/RuntimeEnumLeafInfoImpl.java | 2 +- .../internal/bind/v2/model/impl/RuntimeMapPropertyInfoImpl.java | 2 +- .../bind/v2/model/impl/RuntimeReferencePropertyInfoImpl.java | 2 +- .../sun/xml/internal/bind/v2/model/impl/RuntimeTypeRefImpl.java | 2 +- .../bind/v2/model/impl/RuntimeValuePropertyInfoImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/model/impl/SecureLoader.java | 2 +- .../internal/bind/v2/model/impl/SingleTypePropertyInfoImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/model/impl/TypeInfoImpl.java | 2 +- .../sun/xml/internal/bind/v2/model/impl/TypeInfoSetImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/model/impl/TypeRefImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/model/impl/Util.java | 2 +- .../xml/internal/bind/v2/model/impl/ValuePropertyInfoImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/model/impl/package.html | 2 +- .../xml/internal/bind/v2/model/nav/GenericArrayTypeImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/model/nav/TypeVisitor.java | 2 +- .../sun/xml/internal/bind/v2/model/nav/WildcardTypeImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/model/nav/package.html | 2 +- .../xml/internal/bind/v2/model/runtime/RuntimeArrayInfo.java | 2 +- .../bind/v2/model/runtime/RuntimeAttributePropertyInfo.java | 2 +- .../internal/bind/v2/model/runtime/RuntimeBuiltinLeafInfo.java | 2 +- .../xml/internal/bind/v2/model/runtime/RuntimeClassInfo.java | 2 +- .../sun/xml/internal/bind/v2/model/runtime/RuntimeElement.java | 2 +- .../xml/internal/bind/v2/model/runtime/RuntimeElementInfo.java | 2 +- .../bind/v2/model/runtime/RuntimeElementPropertyInfo.java | 2 +- .../xml/internal/bind/v2/model/runtime/RuntimeEnumLeafInfo.java | 2 +- .../sun/xml/internal/bind/v2/model/runtime/RuntimeLeafInfo.java | 2 +- .../internal/bind/v2/model/runtime/RuntimeMapPropertyInfo.java | 2 +- .../internal/bind/v2/model/runtime/RuntimeNonElementRef.java | 2 +- .../xml/internal/bind/v2/model/runtime/RuntimePropertyInfo.java | 2 +- .../bind/v2/model/runtime/RuntimeReferencePropertyInfo.java | 2 +- .../sun/xml/internal/bind/v2/model/runtime/RuntimeTypeInfo.java | 2 +- .../sun/xml/internal/bind/v2/model/runtime/RuntimeTypeRef.java | 2 +- .../bind/v2/model/runtime/RuntimeValuePropertyInfo.java | 2 +- .../sun/xml/internal/bind/v2/model/runtime/package-info.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/AnyTypeBeanInfo.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/ArrayBeanInfoImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/AssociationMap.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/AttributeAccessor.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/BinderImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/BridgeContextImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/BridgeImpl.java | 2 +- .../internal/bind/v2/runtime/CompositeStructureBeanInfo.java | 2 +- .../sun/xml/internal/bind/v2/runtime/ContentHandlerAdaptor.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/DomPostInitAction.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/FilterTransducer.java | 2 +- .../internal/bind/v2/runtime/IllegalAnnotationException.java | 2 +- .../internal/bind/v2/runtime/IllegalAnnotationsException.java | 2 +- .../xml/internal/bind/v2/runtime/InlineBinaryTransducer.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/InternalBridge.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/JaxBeanInfo.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/LifecycleMethods.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/Location.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/Messages.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/Messages.properties | 2 +- .../sun/xml/internal/bind/v2/runtime/MimeTypedTransducer.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/Name.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/NameBuilder.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/NameList.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/NamespaceContext2.java | 2 +- .../sun/xml/internal/bind/v2/runtime/SchemaTypeTransducer.java | 2 +- .../sun/xml/internal/bind/v2/runtime/StAXPostInitAction.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/SwaRefAdapter.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/Transducer.java | 2 +- .../sun/xml/internal/bind/v2/runtime/ValueListBeanInfoImpl.java | 2 +- .../sun/xml/internal/bind/v2/runtime/output/C14nXmlOutput.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/output/DOMOutput.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/output/Encoded.java | 2 +- .../bind/v2/runtime/output/FastInfosetStreamWriterOutput.java | 2 +- .../sun/xml/internal/bind/v2/runtime/output/ForkXmlOutput.java | 2 +- .../internal/bind/v2/runtime/output/IndentingUTF8XmlOutput.java | 2 +- .../sun/xml/internal/bind/v2/runtime/output/MTOMXmlOutput.java | 2 +- .../internal/bind/v2/runtime/output/NamespaceContextImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/output/Pcdata.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/output/SAXOutput.java | 2 +- .../sun/xml/internal/bind/v2/runtime/output/SecureLoader.java | 2 +- .../bind/v2/runtime/output/StAXExStreamWriterOutput.java | 2 +- .../sun/xml/internal/bind/v2/runtime/output/UTF8XmlOutput.java | 2 +- .../internal/bind/v2/runtime/output/XMLEventWriterOutput.java | 2 +- .../internal/bind/v2/runtime/output/XMLStreamWriterOutput.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/output/XmlOutput.java | 2 +- .../internal/bind/v2/runtime/output/XmlOutputAbstractImpl.java | 2 +- .../sun/xml/internal/bind/v2/runtime/output/package-info.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/package.html | 2 +- .../xml/internal/bind/v2/runtime/property/ArrayERProperty.java | 2 +- .../bind/v2/runtime/property/ArrayElementLeafProperty.java | 2 +- .../bind/v2/runtime/property/ArrayElementNodeProperty.java | 2 +- .../internal/bind/v2/runtime/property/ArrayElementProperty.java | 2 +- .../bind/v2/runtime/property/ArrayReferenceNodeProperty.java | 2 +- .../internal/bind/v2/runtime/property/AttributeProperty.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/property/Messages.java | 2 +- .../xml/internal/bind/v2/runtime/property/Messages.properties | 2 +- .../com/sun/xml/internal/bind/v2/runtime/property/Property.java | 2 +- .../xml/internal/bind/v2/runtime/property/PropertyFactory.java | 2 +- .../sun/xml/internal/bind/v2/runtime/property/PropertyImpl.java | 2 +- .../bind/v2/runtime/property/SingleElementNodeProperty.java | 2 +- .../bind/v2/runtime/property/SingleReferenceNodeProperty.java | 2 +- .../bind/v2/runtime/property/StructureLoaderBuilder.java | 2 +- .../sun/xml/internal/bind/v2/runtime/property/TagAndType.java | 2 +- .../internal/bind/v2/runtime/property/UnmarshallerChain.java | 2 +- .../xml/internal/bind/v2/runtime/property/ValueProperty.java | 2 +- .../xml/internal/bind/v2/runtime/reflect/AdaptedAccessor.java | 2 +- .../sun/xml/internal/bind/v2/runtime/reflect/AdaptedLister.java | 2 +- .../bind/v2/runtime/reflect/DefaultTransducedAccessor.java | 2 +- .../sun/xml/internal/bind/v2/runtime/reflect/ListIterator.java | 2 +- .../bind/v2/runtime/reflect/ListTransducedAccessorImpl.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/reflect/Messages.java | 2 +- .../xml/internal/bind/v2/runtime/reflect/Messages.properties | 2 +- .../xml/internal/bind/v2/runtime/reflect/NullSafeAccessor.java | 2 +- .../bind/v2/runtime/reflect/PrimitiveArrayListerByte.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/reflect/opt/Bean.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/reflect/opt/Const.java | 2 +- .../bind/v2/runtime/reflect/opt/FieldAccessor_Byte.java | 2 +- .../internal/bind/v2/runtime/reflect/opt/FieldAccessor_Ref.java | 2 +- .../bind/v2/runtime/reflect/opt/MethodAccessor_Byte.java | 2 +- .../bind/v2/runtime/reflect/opt/MethodAccessor_Ref.java | 2 +- .../runtime/reflect/opt/OptimizedTransducedAccessorFactory.java | 2 +- .../com/sun/xml/internal/bind/v2/runtime/reflect/opt/Ref.java | 2 +- .../xml/internal/bind/v2/runtime/reflect/opt/SecureLoader.java | 2 +- .../runtime/reflect/opt/TransducedAccessor_field_Boolean.java | 2 +- .../v2/runtime/reflect/opt/TransducedAccessor_field_Byte.java | 2 +- .../runtime/reflect/opt/TransducedAccessor_field_Integer.java | 2 +- .../v2/runtime/reflect/opt/TransducedAccessor_method_Byte.java | 2 +- .../runtime/reflect/opt/TransducedAccessor_method_Integer.java | 2 +- .../sun/xml/internal/bind/v2/runtime/reflect/opt/package.html | 2 +- .../com/sun/xml/internal/bind/v2/runtime/reflect/package.html | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/AttributesEx.java | 2 +- .../internal/bind/v2/runtime/unmarshaller/AttributesExImpl.java | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/Base64Data.java | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/ChildLoader.java | 2 +- .../bind/v2/runtime/unmarshaller/DefaultIDResolver.java | 2 +- .../v2/runtime/unmarshaller/DefaultValueLoaderDecorator.java | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/Discarder.java | 2 +- .../bind/v2/runtime/unmarshaller/FastInfosetConnector.java | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/IntArrayData.java | 2 +- .../sun/xml/internal/bind/v2/runtime/unmarshaller/IntData.java | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/Intercepter.java | 2 +- .../bind/v2/runtime/unmarshaller/InterningXmlVisitor.java | 2 +- .../bind/v2/runtime/unmarshaller/LeafPropertyLoader.java | 2 +- .../bind/v2/runtime/unmarshaller/LeafPropertyXsiLoader.java | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/LocatorEx.java | 2 +- .../internal/bind/v2/runtime/unmarshaller/LocatorExWrapper.java | 2 +- .../internal/bind/v2/runtime/unmarshaller/MTOMDecorator.java | 2 +- .../sun/xml/internal/bind/v2/runtime/unmarshaller/Patcher.java | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/ProxyLoader.java | 2 +- .../sun/xml/internal/bind/v2/runtime/unmarshaller/Receiver.java | 2 +- .../sun/xml/internal/bind/v2/runtime/unmarshaller/Scope.java | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/SecureLoader.java | 2 +- .../internal/bind/v2/runtime/unmarshaller/StAXConnector.java | 2 +- .../bind/v2/runtime/unmarshaller/StAXEventConnector.java | 2 +- .../internal/bind/v2/runtime/unmarshaller/StAXExConnector.java | 2 +- .../bind/v2/runtime/unmarshaller/StAXStreamConnector.java | 2 +- .../internal/bind/v2/runtime/unmarshaller/StructureLoader.java | 2 +- .../sun/xml/internal/bind/v2/runtime/unmarshaller/TagName.java | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/TextLoader.java | 2 +- .../bind/v2/runtime/unmarshaller/ValidatingUnmarshaller.java | 2 +- .../bind/v2/runtime/unmarshaller/ValuePropertyLoader.java | 2 +- .../internal/bind/v2/runtime/unmarshaller/WildcardLoader.java | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/XmlVisitor.java | 2 +- .../xml/internal/bind/v2/runtime/unmarshaller/XsiNilLoader.java | 2 +- .../sun/xml/internal/bind/v2/schemagen/FoolProofResolver.java | 2 +- .../com/sun/xml/internal/bind/v2/schemagen/Form.java | 2 +- .../com/sun/xml/internal/bind/v2/schemagen/GroupKind.java | 2 +- .../com/sun/xml/internal/bind/v2/schemagen/Messages.java | 2 +- .../com/sun/xml/internal/bind/v2/schemagen/Messages.properties | 2 +- .../com/sun/xml/internal/bind/v2/schemagen/MultiMap.java | 2 +- .../com/sun/xml/internal/bind/v2/schemagen/Tree.java | 2 +- .../com/sun/xml/internal/bind/v2/schemagen/Util.java | 2 +- .../sun/xml/internal/bind/v2/schemagen/episode/Bindings.java | 2 +- .../com/sun/xml/internal/bind/v2/schemagen/episode/Klass.java | 2 +- .../com/sun/xml/internal/bind/v2/schemagen/episode/Package.java | 2 +- .../xml/internal/bind/v2/schemagen/episode/SchemaBindings.java | 2 +- .../xml/internal/bind/v2/schemagen/episode/package-info.java | 2 +- .../com/sun/xml/internal/bind/v2/schemagen/package-info.java | 2 +- .../bind/v2/schemagen/xmlschema/ContentModelContainer.java | 2 +- .../sun/xml/internal/bind/v2/schemagen/xmlschema/Particle.java | 2 +- .../sun/xml/internal/bind/v2/schemagen/xmlschema/package.html | 2 +- .../internal/bind/v2/schemagen/xmlschema/xmlschema-for-jaxb.rng | 2 +- .../sun/xml/internal/bind/v2/util/ByteArrayOutputStreamEx.java | 2 +- .../com/sun/xml/internal/bind/v2/util/CollisionCheckStack.java | 2 +- .../com/sun/xml/internal/bind/v2/util/DataSourceSource.java | 2 +- .../com/sun/xml/internal/bind/v2/util/FatalAdapter.java | 2 +- .../com/sun/xml/internal/bind/v2/util/FlattenIterator.java | 2 +- .../com/sun/xml/internal/bind/v2/util/QNameMap.java | 2 +- .../com/sun/xml/internal/bind/v2/util/StackRecorder.java | 2 +- .../com/sun/xml/internal/bind/v2/util/TypeCast.java | 2 +- .../sun/xml/internal/fastinfoset/AbstractResourceBundle.java | 2 +- .../com/sun/xml/internal/fastinfoset/DecoderStateTables.java | 2 +- .../jaxws_classes/com/sun/xml/internal/fastinfoset/Encoder.java | 2 +- .../com/sun/xml/internal/fastinfoset/EncodingConstants.java | 2 +- .../com/sun/xml/internal/fastinfoset/Notation.java | 2 +- .../com/sun/xml/internal/fastinfoset/OctetBufferListener.java | 2 +- .../com/sun/xml/internal/fastinfoset/QualifiedName.java | 2 +- .../com/sun/xml/internal/fastinfoset/UnparsedEntity.java | 2 +- .../fastinfoset/algorithm/BuiltInEncodingAlgorithmFactory.java | 2 +- .../fastinfoset/algorithm/BuiltInEncodingAlgorithmState.java | 2 +- .../internal/fastinfoset/algorithm/DoubleEncodingAlgorithm.java | 2 +- .../algorithm/IEEE754FloatingPointEncodingAlgorithm.java | 2 +- .../internal/fastinfoset/algorithm/IntEncodingAlgorithm.java | 2 +- .../fastinfoset/algorithm/IntegerEncodingAlgorithm.java | 2 +- .../internal/fastinfoset/algorithm/LongEncodingAlgorithm.java | 2 +- .../internal/fastinfoset/algorithm/ShortEncodingAlgorithm.java | 2 +- .../internal/fastinfoset/algorithm/UUIDEncodingAlgorithm.java | 2 +- .../fastinfoset/alphabet/BuiltInRestrictedAlphabets.java | 2 +- .../sun/xml/internal/fastinfoset/dom/DOMDocumentSerializer.java | 2 +- .../internal/fastinfoset/org/apache/xerces/util/XMLChar.java | 2 +- .../com/sun/xml/internal/fastinfoset/sax/Features.java | 2 +- .../com/sun/xml/internal/fastinfoset/sax/Properties.java | 2 +- .../sun/xml/internal/fastinfoset/sax/SAXDocumentSerializer.java | 2 +- .../fastinfoset/sax/SAXDocumentSerializerWithPrefixMapping.java | 2 +- .../com/sun/xml/internal/fastinfoset/sax/SystemIdResolver.java | 2 +- .../com/sun/xml/internal/fastinfoset/stax/EventLocation.java | 2 +- .../xml/internal/fastinfoset/stax/StAXDocumentSerializer.java | 2 +- .../com/sun/xml/internal/fastinfoset/stax/StAXManager.java | 2 +- .../sun/xml/internal/fastinfoset/stax/events/AttributeBase.java | 2 +- .../xml/internal/fastinfoset/stax/events/CharactersEvent.java | 2 +- .../sun/xml/internal/fastinfoset/stax/events/CommentEvent.java | 2 +- .../com/sun/xml/internal/fastinfoset/stax/events/DTDEvent.java | 2 +- .../sun/xml/internal/fastinfoset/stax/events/EmptyIterator.java | 2 +- .../xml/internal/fastinfoset/stax/events/EndDocumentEvent.java | 2 +- .../xml/internal/fastinfoset/stax/events/EndElementEvent.java | 2 +- .../internal/fastinfoset/stax/events/EntityDeclarationImpl.java | 2 +- .../internal/fastinfoset/stax/events/EntityReferenceEvent.java | 2 +- .../com/sun/xml/internal/fastinfoset/stax/events/EventBase.java | 2 +- .../sun/xml/internal/fastinfoset/stax/events/NamespaceBase.java | 2 +- .../fastinfoset/stax/events/ProcessingInstructionEvent.java | 2 +- .../sun/xml/internal/fastinfoset/stax/events/ReadIterator.java | 2 +- .../fastinfoset/stax/events/StAXEventAllocatorBase.java | 2 +- .../xml/internal/fastinfoset/stax/events/StAXEventReader.java | 2 +- .../xml/internal/fastinfoset/stax/events/StAXEventWriter.java | 2 +- .../xml/internal/fastinfoset/stax/events/StAXFilteredEvent.java | 2 +- .../internal/fastinfoset/stax/events/StartDocumentEvent.java | 2 +- .../com/sun/xml/internal/fastinfoset/stax/events/Util.java | 2 +- .../sun/xml/internal/fastinfoset/stax/events/XMLConstants.java | 2 +- .../xml/internal/fastinfoset/stax/factory/StAXEventFactory.java | 2 +- .../xml/internal/fastinfoset/stax/factory/StAXInputFactory.java | 2 +- .../xml/internal/fastinfoset/stax/util/StAXFilteredParser.java | 2 +- .../xml/internal/fastinfoset/stax/util/StAXParserWrapper.java | 2 +- .../fastinfoset/tools/FI_DOM_Or_XML_DOM_SAX_SAXEvent.java | 2 +- .../fastinfoset/tools/FI_SAX_Or_XML_SAX_DOM_SAX_SAXEvent.java | 2 +- .../internal/fastinfoset/tools/FI_SAX_Or_XML_SAX_SAXEvent.java | 2 +- .../com/sun/xml/internal/fastinfoset/tools/FI_SAX_XML.java | 2 +- .../fastinfoset/tools/FI_StAX_SAX_Or_XML_SAX_SAXEvent.java | 2 +- .../com/sun/xml/internal/fastinfoset/tools/PrintTable.java | 2 +- .../com/sun/xml/internal/fastinfoset/tools/SAX2StAXWriter.java | 2 +- .../com/sun/xml/internal/fastinfoset/tools/StAX2SAXReader.java | 2 +- .../sun/xml/internal/fastinfoset/tools/VocabularyGenerator.java | 2 +- .../com/sun/xml/internal/fastinfoset/tools/XML_DOM_FI.java | 2 +- .../com/sun/xml/internal/fastinfoset/tools/XML_DOM_SAX_FI.java | 2 +- .../com/sun/xml/internal/fastinfoset/tools/XML_SAX_FI.java | 2 +- .../com/sun/xml/internal/fastinfoset/tools/XML_SAX_StAX_FI.java | 2 +- .../com/sun/xml/internal/fastinfoset/util/CharArray.java | 2 +- .../com/sun/xml/internal/fastinfoset/util/CharArrayArray.java | 2 +- .../com/sun/xml/internal/fastinfoset/util/CharArrayIntMap.java | 2 +- .../com/sun/xml/internal/fastinfoset/util/CharArrayString.java | 2 +- .../xml/internal/fastinfoset/util/ContiguousCharArrayArray.java | 2 +- .../internal/fastinfoset/util/DuplicateAttributeVerifier.java | 2 +- .../xml/internal/fastinfoset/util/FixedEntryStringIntMap.java | 2 +- .../com/sun/xml/internal/fastinfoset/util/KeyIntMap.java | 2 +- .../internal/fastinfoset/util/LocalNameQualifiedNamesMap.java | 2 +- .../fastinfoset/util/NamespaceContextImplementation.java | 2 +- .../com/sun/xml/internal/fastinfoset/util/PrefixArray.java | 2 +- .../sun/xml/internal/fastinfoset/util/QualifiedNameArray.java | 2 +- .../com/sun/xml/internal/fastinfoset/util/StringArray.java | 2 +- .../com/sun/xml/internal/fastinfoset/util/StringIntMap.java | 2 +- .../com/sun/xml/internal/fastinfoset/util/ValueArray.java | 2 +- .../internal/fastinfoset/util/ValueArrayResourceException.java | 2 +- .../sun/xml/internal/fastinfoset/vocab/ParserVocabulary.java | 2 +- .../xml/internal/fastinfoset/vocab/SerializerVocabulary.java | 2 +- .../com/sun/xml/internal/fastinfoset/vocab/Vocabulary.java | 2 +- .../xml/internal/org/jvnet/fastinfoset/EncodingAlgorithm.java | 2 +- .../org/jvnet/fastinfoset/EncodingAlgorithmException.java | 2 +- .../org/jvnet/fastinfoset/EncodingAlgorithmIndexes.java | 2 +- .../xml/internal/org/jvnet/fastinfoset/ExternalVocabulary.java | 2 +- .../internal/org/jvnet/fastinfoset/FastInfosetException.java | 2 +- .../xml/internal/org/jvnet/fastinfoset/FastInfosetParser.java | 2 +- .../xml/internal/org/jvnet/fastinfoset/FastInfosetResult.java | 2 +- .../internal/org/jvnet/fastinfoset/FastInfosetSerializer.java | 2 +- .../xml/internal/org/jvnet/fastinfoset/FastInfosetSource.java | 2 +- .../xml/internal/org/jvnet/fastinfoset/RestrictedAlphabet.java | 2 +- .../com/sun/xml/internal/org/jvnet/fastinfoset/Vocabulary.java | 2 +- .../org/jvnet/fastinfoset/VocabularyApplicationData.java | 2 +- .../org/jvnet/fastinfoset/sax/EncodingAlgorithmAttributes.java | 2 +- .../jvnet/fastinfoset/sax/EncodingAlgorithmContentHandler.java | 2 +- .../org/jvnet/fastinfoset/sax/ExtendedContentHandler.java | 2 +- .../internal/org/jvnet/fastinfoset/sax/FastInfosetReader.java | 2 +- .../internal/org/jvnet/fastinfoset/sax/FastInfosetWriter.java | 2 +- .../org/jvnet/fastinfoset/sax/PrimitiveTypeContentHandler.java | 2 +- .../jvnet/fastinfoset/sax/RestrictedAlphabetContentHandler.java | 2 +- .../sax/helpers/EncodingAlgorithmAttributesImpl.java | 2 +- .../fastinfoset/sax/helpers/FastInfosetDefaultHandler.java | 2 +- .../org/jvnet/fastinfoset/stax/FastInfosetStreamReader.java | 2 +- .../jvnet/fastinfoset/stax/LowLevelFastInfosetStreamWriter.java | 2 +- .../com/sun/xml/internal/rngom/ast/builder/Annotations.java | 2 +- .../com/sun/xml/internal/rngom/ast/builder/BuildException.java | 2 +- .../com/sun/xml/internal/rngom/ast/builder/CommentList.java | 2 +- .../sun/xml/internal/rngom/ast/builder/DataPatternBuilder.java | 2 +- .../com/sun/xml/internal/rngom/ast/builder/Div.java | 2 +- .../internal/rngom/ast/builder/ElementAnnotationBuilder.java | 2 +- .../com/sun/xml/internal/rngom/ast/builder/Grammar.java | 2 +- .../com/sun/xml/internal/rngom/ast/builder/GrammarSection.java | 2 +- .../com/sun/xml/internal/rngom/ast/builder/Include.java | 2 +- .../com/sun/xml/internal/rngom/ast/builder/IncludedGrammar.java | 2 +- .../sun/xml/internal/rngom/ast/builder/NameClassBuilder.java | 2 +- .../com/sun/xml/internal/rngom/ast/builder/SchemaBuilder.java | 2 +- .../com/sun/xml/internal/rngom/ast/builder/Scope.java | 2 +- .../com/sun/xml/internal/rngom/ast/om/Location.java | 2 +- .../sun/xml/internal/rngom/ast/om/ParsedElementAnnotation.java | 2 +- .../com/sun/xml/internal/rngom/ast/om/ParsedNameClass.java | 2 +- .../com/sun/xml/internal/rngom/ast/om/ParsedPattern.java | 2 +- .../sun/xml/internal/rngom/ast/util/CheckingSchemaBuilder.java | 2 +- .../com/sun/xml/internal/rngom/ast/util/LocatorImpl.java | 2 +- .../com/sun/xml/internal/rngom/ast/util/package.html | 2 +- .../com/sun/xml/internal/rngom/binary/AfterPattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/Alphabet.java | 2 +- .../com/sun/xml/internal/rngom/binary/AttributePattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/BinaryPattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/ChoicePattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/DataExceptPattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/DataPattern.java | 2 +- .../xml/internal/rngom/binary/DuplicateAttributeDetector.java | 2 +- .../com/sun/xml/internal/rngom/binary/ElementPattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/EmptyPattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/ErrorPattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/GroupPattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/InterleavePattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/ListPattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/Messages.properties | 2 +- .../com/sun/xml/internal/rngom/binary/NotAllowedPattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/OneOrMorePattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/Pattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/PatternBuilder.java | 2 +- .../com/sun/xml/internal/rngom/binary/PatternInterner.java | 2 +- .../com/sun/xml/internal/rngom/binary/RefPattern.java | 2 +- .../internal/rngom/binary/RestrictionViolationException.java | 2 +- .../com/sun/xml/internal/rngom/binary/SchemaPatternBuilder.java | 2 +- .../com/sun/xml/internal/rngom/binary/StringPattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/TextPattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/ValuePattern.java | 2 +- .../com/sun/xml/internal/rngom/binary/package.html | 2 +- .../xml/internal/rngom/binary/visitor/ChildElementFinder.java | 2 +- .../sun/xml/internal/rngom/binary/visitor/PatternFunction.java | 2 +- .../sun/xml/internal/rngom/binary/visitor/PatternVisitor.java | 2 +- .../sun/xml/internal/rngom/binary/visitor/PatternWalker.java | 2 +- .../com/sun/xml/internal/rngom/digested/Annotation.java | 2 +- .../com/sun/xml/internal/rngom/digested/CommentListImpl.java | 2 +- .../com/sun/xml/internal/rngom/digested/DAnnotation.java | 2 +- .../com/sun/xml/internal/rngom/digested/DAttributePattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DChoicePattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DContainerPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DDefine.java | 2 +- .../com/sun/xml/internal/rngom/digested/DElementPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DEmptyPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DGrammarPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DGroupPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DInterleavePattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DListPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DMixedPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DNotAllowedPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DOMPrinter.java | 2 +- .../com/sun/xml/internal/rngom/digested/DOneOrMorePattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DOptionalPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DPatternVisitor.java | 2 +- .../com/sun/xml/internal/rngom/digested/DPatternWalker.java | 2 +- .../com/sun/xml/internal/rngom/digested/DRefPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DSchemaBuilderImpl.java | 2 +- .../com/sun/xml/internal/rngom/digested/DTextPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DUnaryPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DValuePattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DXmlTokenPattern.java | 2 +- .../com/sun/xml/internal/rngom/digested/DZeroOrMorePattern.java | 2 +- .../internal/rngom/digested/ElementAnnotationBuilderImpl.java | 2 +- .../com/sun/xml/internal/rngom/digested/ElementWrapper.java | 2 +- .../com/sun/xml/internal/rngom/digested/IncludeImpl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/rngom/digested/Main.java | 2 +- .../com/sun/xml/internal/rngom/digested/PatternParseable.java | 2 +- .../com/sun/xml/internal/rngom/digested/package.html | 2 +- .../sun/xml/internal/rngom/dt/CachedDatatypeLibraryFactory.java | 2 +- .../xml/internal/rngom/dt/CascadingDatatypeLibraryFactory.java | 2 +- .../internal/rngom/dt/DoNothingDatatypeLibraryFactoryImpl.java | 2 +- .../xml/internal/rngom/dt/builtin/BuiltinDatatypeBuilder.java | 2 +- .../xml/internal/rngom/dt/builtin/BuiltinDatatypeLibrary.java | 2 +- .../rngom/dt/builtin/BuiltinDatatypeLibraryFactory.java | 2 +- .../internal/rngom/dt/builtin/CompatibilityDatatypeLibrary.java | 2 +- .../com/sun/xml/internal/rngom/dt/builtin/Messages.properties | 2 +- .../com/sun/xml/internal/rngom/dt/builtin/package.html | 2 +- .../com/sun/xml/internal/rngom/nc/AnyNameExceptNameClass.java | 2 +- .../com/sun/xml/internal/rngom/nc/ChoiceNameClass.java | 2 +- .../jaxws_classes/com/sun/xml/internal/rngom/nc/NameClass.java | 2 +- .../com/sun/xml/internal/rngom/nc/NameClassVisitor.java | 2 +- .../com/sun/xml/internal/rngom/nc/NameClassWalker.java | 2 +- .../com/sun/xml/internal/rngom/nc/NsNameClass.java | 2 +- .../com/sun/xml/internal/rngom/nc/NsNameExceptNameClass.java | 2 +- .../com/sun/xml/internal/rngom/nc/NullNameClass.java | 2 +- .../com/sun/xml/internal/rngom/nc/OverlapDetector.java | 2 +- .../jaxws_classes/com/sun/xml/internal/rngom/nc/package.html | 2 +- .../jaxws_classes/com/sun/xml/internal/rngom/parse/Context.java | 2 +- .../sun/xml/internal/rngom/parse/IllegalSchemaException.java | 2 +- .../com/sun/xml/internal/rngom/parse/Messages.properties | 2 +- .../com/sun/xml/internal/rngom/parse/Parseable.java | 2 +- .../sun/xml/internal/rngom/parse/compact/CompactParseable.java | 2 +- .../com/sun/xml/internal/rngom/parse/compact/CompactSyntax.java | 2 +- .../internal/rngom/parse/compact/CompactSyntaxConstants.java | 2 +- .../internal/rngom/parse/compact/CompactSyntaxTokenManager.java | 2 +- .../com/sun/xml/internal/rngom/parse/compact/EOFException.java | 2 +- .../xml/internal/rngom/parse/compact/EscapeSyntaxException.java | 2 +- .../sun/xml/internal/rngom/parse/compact/JavaCharStream.java | 2 +- .../sun/xml/internal/rngom/parse/compact/Messages.properties | 2 +- .../sun/xml/internal/rngom/parse/compact/ParseException.java | 2 +- .../com/sun/xml/internal/rngom/parse/compact/Token.java | 2 +- .../com/sun/xml/internal/rngom/parse/compact/TokenMgrError.java | 2 +- .../com/sun/xml/internal/rngom/parse/host/AnnotationsHost.java | 2 +- .../com/sun/xml/internal/rngom/parse/host/Base.java | 2 +- .../com/sun/xml/internal/rngom/parse/host/CommentListHost.java | 2 +- .../xml/internal/rngom/parse/host/DataPatternBuilderHost.java | 2 +- .../com/sun/xml/internal/rngom/parse/host/DivHost.java | 2 +- .../internal/rngom/parse/host/ElementAnnotationBuilderHost.java | 2 +- .../com/sun/xml/internal/rngom/parse/host/GrammarHost.java | 2 +- .../sun/xml/internal/rngom/parse/host/GrammarSectionHost.java | 2 +- .../com/sun/xml/internal/rngom/parse/host/IncludeHost.java | 2 +- .../com/sun/xml/internal/rngom/parse/host/LocationHost.java | 2 +- .../sun/xml/internal/rngom/parse/host/NameClassBuilderHost.java | 2 +- .../internal/rngom/parse/host/ParsedElementAnnotationHost.java | 2 +- .../sun/xml/internal/rngom/parse/host/ParsedNameClassHost.java | 2 +- .../sun/xml/internal/rngom/parse/host/ParsedPatternHost.java | 2 +- .../sun/xml/internal/rngom/parse/host/SchemaBuilderHost.java | 2 +- .../com/sun/xml/internal/rngom/parse/host/ScopeHost.java | 2 +- .../com/sun/xml/internal/rngom/parse/host/package.html | 2 +- .../com/sun/xml/internal/rngom/parse/xml/DtdContext.java | 2 +- .../com/sun/xml/internal/rngom/parse/xml/Messages.properties | 2 +- .../com/sun/xml/internal/rngom/parse/xml/SAXParseable.java | 2 +- .../com/sun/xml/internal/rngom/util/Localizer.java | 2 +- .../jaxws_classes/com/sun/xml/internal/rngom/util/Uri.java | 2 +- .../jaxws_classes/com/sun/xml/internal/rngom/util/Utf16.java | 2 +- .../sun/xml/internal/rngom/xml/sax/AbstractLexicalHandler.java | 2 +- .../com/sun/xml/internal/rngom/xml/sax/XMLReaderCreator.java | 2 +- .../com/sun/xml/internal/rngom/xml/sax/XmlBaseHandler.java | 2 +- .../com/sun/xml/internal/rngom/xml/util/EncodingMap.java | 2 +- .../com/sun/xml/internal/rngom/xml/util/Naming.java | 2 +- .../sun/xml/internal/rngom/xml/util/WellKnownNamespaces.java | 2 +- .../jaxws_classes/com/sun/xml/internal/txw2/Attribute.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/txw2/Cdata.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/txw2/Comment.java | 2 +- .../com/sun/xml/internal/txw2/ContainerElement.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/txw2/Content.java | 2 +- .../jaxws_classes/com/sun/xml/internal/txw2/ContentVisitor.java | 2 +- .../jaxws_classes/com/sun/xml/internal/txw2/DatatypeWriter.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/txw2/Document.java | 2 +- .../jaxws_classes/com/sun/xml/internal/txw2/EndDocument.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/txw2/EndTag.java | 2 +- .../com/sun/xml/internal/txw2/IllegalAnnotationException.java | 2 +- .../com/sun/xml/internal/txw2/IllegalSignatureException.java | 2 +- .../jaxws_classes/com/sun/xml/internal/txw2/NamespaceDecl.java | 2 +- .../com/sun/xml/internal/txw2/NamespaceResolver.java | 2 +- .../com/sun/xml/internal/txw2/NamespaceSupport.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/txw2/Pcdata.java | 2 +- .../jaxws_classes/com/sun/xml/internal/txw2/StartDocument.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/txw2/StartTag.java | 2 +- .../src/share/jaxws_classes/com/sun/xml/internal/txw2/TXW.java | 2 +- .../src/share/jaxws_classes/com/sun/xml/internal/txw2/Text.java | 2 +- .../jaxws_classes/com/sun/xml/internal/txw2/TxwException.java | 2 +- .../jaxws_classes/com/sun/xml/internal/txw2/TypedXmlWriter.java | 2 +- .../com/sun/xml/internal/txw2/annotation/XmlAttribute.java | 2 +- .../com/sun/xml/internal/txw2/annotation/XmlCDATA.java | 2 +- .../com/sun/xml/internal/txw2/annotation/XmlElement.java | 2 +- .../com/sun/xml/internal/txw2/annotation/XmlNamespace.java | 2 +- .../com/sun/xml/internal/txw2/annotation/XmlValue.java | 2 +- .../com/sun/xml/internal/txw2/annotation/package.html | 2 +- .../sun/xml/internal/txw2/output/CharacterEscapeHandler.java | 2 +- .../com/sun/xml/internal/txw2/output/DataWriter.java | 2 +- .../sun/xml/internal/txw2/output/DelegatingXMLStreamWriter.java | 2 +- .../com/sun/xml/internal/txw2/output/DomSerializer.java | 2 +- .../com/sun/xml/internal/txw2/output/DumbEscapeHandler.java | 2 +- .../com/sun/xml/internal/txw2/output/DumpSerializer.java | 2 +- .../com/sun/xml/internal/txw2/output/IndentingXMLFilter.java | 2 +- .../sun/xml/internal/txw2/output/IndentingXMLStreamWriter.java | 2 +- .../com/sun/xml/internal/txw2/output/ResultFactory.java | 2 +- .../com/sun/xml/internal/txw2/output/SaxSerializer.java | 2 +- .../com/sun/xml/internal/txw2/output/StaxSerializer.java | 2 +- .../com/sun/xml/internal/txw2/output/StreamSerializer.java | 2 +- .../com/sun/xml/internal/txw2/output/TXWResult.java | 2 +- .../com/sun/xml/internal/txw2/output/TXWSerializer.java | 2 +- .../com/sun/xml/internal/txw2/output/XmlSerializer.java | 2 +- .../jaxws_classes/com/sun/xml/internal/txw2/output/package.html | 2 +- .../share/jaxws_classes/com/sun/xml/internal/txw2/package.html | 2 +- .../xml/internal/ws/org/objectweb/asm/AnnotationVisitor.java | 2 +- .../sun/xml/internal/ws/org/objectweb/asm/AnnotationWriter.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/Attribute.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/ByteVector.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/ClassReader.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/ClassVisitor.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/ClassWriter.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/Edge.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/FieldVisitor.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/FieldWriter.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/Frame.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/Handler.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/Item.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/Label.java | 2 +- .../sun/xml/internal/ws/org/objectweb/asm/MethodVisitor.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/MethodWriter.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/Opcodes.java | 2 +- .../com/sun/xml/internal/ws/org/objectweb/asm/Type.java | 2 +- .../com/sun/xml/internal/ws/policy/AssertionSet.java | 2 +- .../xml/internal/ws/policy/AssertionValidationProcessor.java | 2 +- .../com/sun/xml/internal/ws/policy/ComplexAssertion.java | 2 +- .../xml/internal/ws/policy/EffectiveAlternativeSelector.java | 2 +- .../com/sun/xml/internal/ws/policy/EffectivePolicyModifier.java | 2 +- .../com/sun/xml/internal/ws/policy/NestedPolicy.java | 2 +- .../jaxws_classes/com/sun/xml/internal/ws/policy/Policy.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicyAssertion.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicyConstants.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicyException.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicyIntersector.java | 2 +- .../jaxws_classes/com/sun/xml/internal/ws/policy/PolicyMap.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicyMapExtender.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicyMapKey.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicyMapKeyHandler.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicyMapMutator.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicyMapUtil.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicyMerger.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicyScope.java | 2 +- .../com/sun/xml/internal/ws/policy/PolicySubject.java | 2 +- .../com/sun/xml/internal/ws/policy/SimpleAssertion.java | 2 +- .../com/sun/xml/internal/ws/policy/package-info.java | 2 +- .../xml/internal/ws/policy/privateutil/Localization.properties | 2 +- .../internal/ws/policy/privateutil/LocalizationMessages.java | 2 +- .../sun/xml/internal/ws/policy/privateutil/PolicyLogger.java | 2 +- .../ws/policy/privateutil/RuntimePolicyUtilsException.java | 2 +- .../ws/policy/privateutil/ServiceConfigurationError.java | 2 +- .../sun/xml/internal/ws/policy/privateutil/ServiceFinder.java | 2 +- .../sun/xml/internal/ws/policy/privateutil/package-info.java | 2 +- .../sun/xml/internal/ws/policy/sourcemodel/AssertionData.java | 2 +- .../internal/ws/policy/sourcemodel/CompactModelGenerator.java | 2 +- .../ws/policy/sourcemodel/DefaultPolicyAssertionCreator.java | 2 +- .../com/sun/xml/internal/ws/policy/sourcemodel/ModelNode.java | 2 +- .../ws/policy/sourcemodel/NormalizedModelGenerator.java | 2 +- .../internal/ws/policy/sourcemodel/PolicyModelGenerator.java | 2 +- .../internal/ws/policy/sourcemodel/PolicyModelMarshaller.java | 2 +- .../internal/ws/policy/sourcemodel/PolicyModelTranslator.java | 2 +- .../internal/ws/policy/sourcemodel/PolicyModelUnmarshaller.java | 2 +- .../xml/internal/ws/policy/sourcemodel/PolicyReferenceData.java | 2 +- .../xml/internal/ws/policy/sourcemodel/PolicySourceModel.java | 2 +- .../ws/policy/sourcemodel/PolicySourceModelContext.java | 2 +- .../ws/policy/sourcemodel/XmlPolicyModelMarshaller.java | 2 +- .../ws/policy/sourcemodel/XmlPolicyModelUnmarshaller.java | 2 +- .../sourcemodel/attach/ExternalAttachmentsUnmarshaller.java | 2 +- .../xml/internal/ws/policy/sourcemodel/attach/package-info.java | 2 +- .../sun/xml/internal/ws/policy/sourcemodel/package-info.java | 2 +- .../ws/policy/sourcemodel/wspolicy/NamespaceVersion.java | 2 +- .../xml/internal/ws/policy/sourcemodel/wspolicy/XmlToken.java | 2 +- .../sun/xml/internal/ws/policy/spi/AbstractQNameValidator.java | 2 +- .../xml/internal/ws/policy/spi/AssertionCreationException.java | 2 +- .../sun/xml/internal/ws/policy/spi/PolicyAssertionCreator.java | 2 +- .../xml/internal/ws/policy/spi/PolicyAssertionValidator.java | 2 +- .../com/sun/xml/internal/ws/policy/spi/PrefixMapper.java | 2 +- .../com/sun/xml/internal/ws/policy/spi/package-info.java | 2 +- .../xml/internal/ws/policy/subject/PolicyMapKeyConverter.java | 2 +- .../sun/xml/internal/ws/policy/subject/WsdlBindingSubject.java | 2 +- .../com/sun/xml/internal/ws/policy/subject/package-info.java | 2 +- .../com/sun/xml/internal/xsom/ForeignAttributes.java | 2 +- .../src/share/jaxws_classes/com/sun/xml/internal/xsom/SCD.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSAnnotation.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSAttContainer.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSAttGroupDecl.java | 2 +- .../com/sun/xml/internal/xsom/XSAttributeDecl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSAttributeUse.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSComplexType.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSComponent.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSContentType.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSDeclaration.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSElementDecl.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/xsom/XSFacet.java | 2 +- .../com/sun/xml/internal/xsom/XSIdentityConstraint.java | 2 +- .../com/sun/xml/internal/xsom/XSListSimpleType.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSModelGroup.java | 2 +- .../com/sun/xml/internal/xsom/XSModelGroupDecl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSNotation.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSParticle.java | 2 +- .../com/sun/xml/internal/xsom/XSRestrictionSimpleType.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/xsom/XSSchema.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSSchemaSet.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSSimpleType.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/xsom/XSTerm.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/xsom/XSType.java | 2 +- .../com/sun/xml/internal/xsom/XSUnionSimpleType.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSVariety.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XSWildcard.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/xsom/XSXPath.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/XmlString.java | 2 +- .../com/sun/xml/internal/xsom/impl/AnnotationImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/AttGroupDeclImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/AttributeDeclImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/AttributeUseImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/AttributesHolder.java | 2 +- .../com/sun/xml/internal/xsom/impl/ComplexTypeImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/ComponentImpl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/impl/Const.java | 2 +- .../com/sun/xml/internal/xsom/impl/ContentTypeImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/DeclarationImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/ElementDecl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/impl/EmptyImpl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/impl/FacetImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/ForeignAttributesImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/IdentityConstraintImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/ListSimpleTypeImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/ModelGroupDeclImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/ModelGroupImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/NotationImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/ParticleImpl.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/xsom/impl/Ref.java | 2 +- .../sun/xml/internal/xsom/impl/RestrictionSimpleTypeImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/SchemaImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/SchemaSetImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/SimpleTypeImpl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/impl/UName.java | 2 +- .../com/sun/xml/internal/xsom/impl/UnionSimpleTypeImpl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/impl/Util.java | 2 +- .../com/sun/xml/internal/xsom/impl/WildcardImpl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/impl/XPathImpl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/impl/package.html | 2 +- .../com/sun/xml/internal/xsom/impl/parser/BaseContentRef.java | 2 +- .../xml/internal/xsom/impl/parser/DefaultAnnotationParser.java | 2 +- .../com/sun/xml/internal/xsom/impl/parser/DelayedRef.java | 2 +- .../sun/xml/internal/xsom/impl/parser/Messages_ja.properties | 2 +- .../com/sun/xml/internal/xsom/impl/parser/NGCCRuntimeEx.java | 2 +- .../com/sun/xml/internal/xsom/impl/parser/ParserContext.java | 2 +- .../com/sun/xml/internal/xsom/impl/parser/Patch.java | 2 +- .../com/sun/xml/internal/xsom/impl/parser/PatcherManager.java | 2 +- .../sun/xml/internal/xsom/impl/parser/SchemaDocumentImpl.java | 2 +- .../xml/internal/xsom/impl/parser/SubstGroupBaseTypeRef.java | 2 +- .../com/sun/xml/internal/xsom/impl/parser/datatypes.xsd | 2 +- .../com/sun/xml/internal/xsom/impl/parser/package.html | 2 +- .../sun/xml/internal/xsom/impl/parser/state/AttributesImpl.java | 2 +- .../xml/internal/xsom/impl/parser/state/NGCCEventReceiver.java | 2 +- .../xml/internal/xsom/impl/parser/state/NGCCEventSource.java | 2 +- .../sun/xml/internal/xsom/impl/parser/state/NGCCHandler.java | 2 +- .../internal/xsom/impl/parser/state/NGCCInterleaveFilter.java | 2 +- .../sun/xml/internal/xsom/impl/parser/state/NGCCRuntime.java | 2 +- .../xml/internal/xsom/impl/parser/state/foreignAttributes.java | 2 +- .../sun/xml/internal/xsom/impl/parser/state/qualification.java | 2 +- .../com/sun/xml/internal/xsom/impl/scd/AbstractAxisImpl.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/impl/scd/Axis.java | 2 +- .../com/sun/xml/internal/xsom/impl/scd/Iterators.java | 2 +- .../com/sun/xml/internal/xsom/impl/scd/ParseException.java | 2 +- .../com/sun/xml/internal/xsom/impl/scd/SCDImpl.java | 2 +- .../com/sun/xml/internal/xsom/impl/scd/SCDParser.java | 2 +- .../com/sun/xml/internal/xsom/impl/scd/SCDParserConstants.java | 2 +- .../sun/xml/internal/xsom/impl/scd/SCDParserTokenManager.java | 2 +- .../com/sun/xml/internal/xsom/impl/scd/SimpleCharStream.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/impl/scd/Step.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/impl/scd/Token.java | 2 +- .../com/sun/xml/internal/xsom/impl/scd/TokenMgrError.java | 2 +- .../sun/xml/internal/xsom/impl/util/DraconianErrorHandler.java | 2 +- .../sun/xml/internal/xsom/impl/util/ResourceEntityResolver.java | 2 +- .../sun/xml/internal/xsom/impl/util/SchemaTreeTraverser.java | 2 +- .../com/sun/xml/internal/xsom/impl/util/SchemaWriter.java | 2 +- .../share/jaxws_classes/com/sun/xml/internal/xsom/package.html | 2 +- .../com/sun/xml/internal/xsom/parser/AnnotationContext.java | 2 +- .../com/sun/xml/internal/xsom/parser/AnnotationParser.java | 2 +- .../sun/xml/internal/xsom/parser/AnnotationParserFactory.java | 2 +- .../com/sun/xml/internal/xsom/parser/SchemaDocument.java | 2 +- .../com/sun/xml/internal/xsom/parser/XMLParser.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/parser/package.html | 2 +- .../com/sun/xml/internal/xsom/util/ComponentNameFunction.java | 2 +- .../com/sun/xml/internal/xsom/util/DeferedCollection.java | 2 +- .../com/sun/xml/internal/xsom/util/NameGetter.java | 2 +- .../com/sun/xml/internal/xsom/util/NameGetter.properties | 2 +- .../com/sun/xml/internal/xsom/util/SimpleTypeSet.java | 2 +- .../com/sun/xml/internal/xsom/util/TypeClosure.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/util/TypeSet.java | 2 +- .../jaxws_classes/com/sun/xml/internal/xsom/util/XSFinder.java | 2 +- .../com/sun/xml/internal/xsom/util/XSFunctionFilter.java | 2 +- .../sun/xml/internal/xsom/visitor/XSContentTypeFunction.java | 2 +- .../com/sun/xml/internal/xsom/visitor/XSContentTypeVisitor.java | 2 +- .../com/sun/xml/internal/xsom/visitor/XSFunction.java | 2 +- .../com/sun/xml/internal/xsom/visitor/XSSimpleTypeFunction.java | 2 +- .../com/sun/xml/internal/xsom/visitor/XSSimpleTypeVisitor.java | 2 +- .../com/sun/xml/internal/xsom/visitor/XSTermFunction.java | 2 +- .../sun/xml/internal/xsom/visitor/XSTermFunctionWithParam.java | 2 +- .../com/sun/xml/internal/xsom/visitor/XSTermVisitor.java | 2 +- .../com/sun/xml/internal/xsom/visitor/XSVisitor.java | 2 +- .../com/sun/xml/internal/xsom/visitor/XSWildcardFunction.java | 2 +- .../com/sun/xml/internal/xsom/visitor/XSWildcardVisitor.java | 2 +- .../com/sun/xml/internal/xsom/visitor/package.html | 2 +- jaxws/src/share/jaxws_classes/javax/jws/HandlerChain.java | 2 +- jaxws/src/share/jaxws_classes/javax/jws/Oneway.java | 2 +- jaxws/src/share/jaxws_classes/javax/jws/WebMethod.java | 2 +- jaxws/src/share/jaxws_classes/javax/jws/WebParam.java | 2 +- jaxws/src/share/jaxws_classes/javax/jws/WebResult.java | 2 +- jaxws/src/share/jaxws_classes/javax/jws/WebService.java | 2 +- jaxws/src/share/jaxws_classes/javax/jws/soap/InitParam.java | 2 +- jaxws/src/share/jaxws_classes/javax/jws/soap/SOAPBinding.java | 2 +- .../share/jaxws_classes/javax/jws/soap/SOAPMessageHandler.java | 2 +- .../share/jaxws_classes/javax/jws/soap/SOAPMessageHandlers.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/soap/package.html | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/Action.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/AsyncHandler.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/Binding.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/BindingProvider.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/BindingType.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/Dispatch.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/Endpoint.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/EndpointContext.java | 2 +- .../src/share/jaxws_classes/javax/xml/ws/EndpointReference.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/FaultAction.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/Holder.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/LogicalMessage.java | 2 +- .../src/share/jaxws_classes/javax/xml/ws/ProtocolException.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/Provider.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/RequestWrapper.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/RespectBinding.java | 2 +- .../share/jaxws_classes/javax/xml/ws/RespectBindingFeature.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/Response.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/ResponseWrapper.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/Service.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/ServiceMode.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/WebEndpoint.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/WebFault.java | 2 +- .../src/share/jaxws_classes/javax/xml/ws/WebServiceClient.java | 2 +- .../src/share/jaxws_classes/javax/xml/ws/WebServiceContext.java | 2 +- .../share/jaxws_classes/javax/xml/ws/WebServiceException.java | 2 +- .../src/share/jaxws_classes/javax/xml/ws/WebServiceFeature.java | 2 +- .../share/jaxws_classes/javax/xml/ws/WebServicePermission.java | 2 +- .../share/jaxws_classes/javax/xml/ws/WebServiceProvider.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/WebServiceRef.java | 2 +- .../jaxws_classes/javax/xml/ws/handler/HandlerResolver.java | 2 +- .../jaxws_classes/javax/xml/ws/handler/LogicalHandler.java | 2 +- .../javax/xml/ws/handler/LogicalMessageContext.java | 2 +- .../jaxws_classes/javax/xml/ws/handler/MessageContext.java | 2 +- .../src/share/jaxws_classes/javax/xml/ws/handler/PortInfo.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/handler/package.html | 2 +- .../jaxws_classes/javax/xml/ws/handler/soap/SOAPHandler.java | 2 +- .../javax/xml/ws/handler/soap/SOAPMessageContext.java | 2 +- .../share/jaxws_classes/javax/xml/ws/handler/soap/package.html | 2 +- .../src/share/jaxws_classes/javax/xml/ws/http/HTTPBinding.java | 2 +- .../share/jaxws_classes/javax/xml/ws/http/HTTPException.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/http/package.html | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/package.html | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/soap/Addressing.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/soap/MTOM.java | 2 +- .../src/share/jaxws_classes/javax/xml/ws/soap/SOAPBinding.java | 2 +- .../jaxws_classes/javax/xml/ws/soap/SOAPFaultException.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/soap/package.html | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Invoker.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/spi/Provider.java | 2 +- .../share/jaxws_classes/javax/xml/ws/spi/ServiceDelegate.java | 2 +- .../javax/xml/ws/spi/WebServiceFeatureAnnotation.java | 2 +- .../share/jaxws_classes/javax/xml/ws/spi/http/HttpContext.java | 2 +- .../share/jaxws_classes/javax/xml/ws/spi/http/HttpExchange.java | 2 +- .../share/jaxws_classes/javax/xml/ws/spi/http/HttpHandler.java | 2 +- .../share/jaxws_classes/javax/xml/ws/spi/http/package-info.java | 2 +- jaxws/src/share/jaxws_classes/javax/xml/ws/spi/package.html | 2 +- .../javax/xml/ws/wsaddressing/W3CEndpointReferenceBuilder.java | 2 +- .../jaxws_classes/javax/xml/ws/wsaddressing/package-info.java | 2 +- .../share/jaxws_classes/javax/xml/ws/wsaddressing/package.html | 2 +- 1301 files changed, 1301 insertions(+), 1301 deletions(-) diff --git a/jaxws/build.properties b/jaxws/build.properties index 9240acc57f8..f2c977cd749 100644 --- a/jaxws/build.properties +++ b/jaxws/build.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2012, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it diff --git a/jaxws/build.xml b/jaxws/build.xml index afea552e3b8..ef0402f3b01 100644 --- a/jaxws/build.xml +++ b/jaxws/build.xml @@ -1,6 +1,6 @@ + + + + + DISPLAY + 2 + + + THERMOMETER + 1 + + + CLOCK + 4 + + + \ No newline at end of file diff --git a/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/Module.java b/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/Module.java new file mode 100644 index 00000000000..2b97b4e832d --- /dev/null +++ b/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/Module.java @@ -0,0 +1,49 @@ +package checker; + +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation and proper error handling, might not be present in + * this sample code. + */ + + +/** + * Represents available modules. + */ +public enum Module { + + DISPLAY, CLOCK, THERMOMETER, HEATER, SPEAKER, GSM, LED; +} diff --git a/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/PluginChecker.java b/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/PluginChecker.java new file mode 100644 index 00000000000..6db5bae4141 --- /dev/null +++ b/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/PluginChecker.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation and proper error handling, might not be present in + * this sample code. + */ +package checker; + +import javax.annotation.processing.ProcessingEnvironment; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.annotation.processing.SupportedSourceVersion; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.Element; +import javax.lang.model.element.TypeElement; +import javax.tools.Diagnostic; +import javax.xml.bind.JAXBContext; +import java.io.File; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + +import javax.xml.bind.JAXBException; + +/** + * Reads the device configuration from the XML file specified by -Adevice=device.xml. + * For each class in a project, checks required modules. If the device doesn't have + * the required module, then a compilation error will be shown. + */ +@SupportedAnnotationTypes("checker.RequireContainer") +@SupportedSourceVersion(SourceVersion.RELEASE_8) +public class PluginChecker extends javax.annotation.processing.AbstractProcessor { + + /** + * Name of the option to get the path to the xml with device configuration. + */ + public static final String DEVICE_OPTION = "device"; + private Device device; + + /** + * Only the device option is supported. + * + * {@inheritDoc} + */ + @Override + public Set getSupportedOptions() { + return new HashSet<>(Arrays.asList(DEVICE_OPTION)); + } + + /** + * Initializes the processor by loading the device configuration. + * + * {@inheritDoc} + */ + @Override + public synchronized void init(ProcessingEnvironment processingEnv) { + super.init(processingEnv); + try { + String deviceOption = processingEnv.getOptions().get(DEVICE_OPTION); + device = (Device) JAXBContext.newInstance(Device.class) + .createUnmarshaller().unmarshal(new File(deviceOption)); + } catch (JAXBException e) { + throw new RuntimeException( + "Please specify device by -Adevice=device.xml\n" + + e.toString(), e); + } + } + + /** + * Processes @Require annotations and checks that Device meets requirements. + * + * {@inheritDoc} + */ + @Override + public boolean process(Set annotations, + RoundEnvironment roundEnv) { + for (Element el : roundEnv.getElementsAnnotatedWith(RequireContainer.class)) { + for (Require req : el.getAnnotationsByType(Require.class)) { + //for every Require annotation checks if device has module of required version. + Integer version = device.getSupportedModules().get(req.value()); + + if (version == null + || version < req.minVersion() + || version > req.maxVersion()) { + //if module is optional then show only warning not error + if (req.optional()) { + processingEnv.getMessager() + .printMessage(Diagnostic.Kind.WARNING, + "Plugin [" + el + "] requires " + req + + "\n but device " + (version == null + ? "doesn't have such module." + + " This module is optional." + + " So plugin will work but miss" + + " some functionality" + : "has " + version + + " version of that module")); + } else { + processingEnv.getMessager() + .printMessage(Diagnostic.Kind.ERROR, + "Plugin [" + el + "] requires " + req + + "\n but device " + + (version == null + ? "doesn't have such module" + : "has " + version + + " version of that module")); + } + } + } + return true; + } + return false; + } +} diff --git a/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/Require.java b/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/Require.java new file mode 100644 index 00000000000..6681c2810e2 --- /dev/null +++ b/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/Require.java @@ -0,0 +1,81 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation and proper error handling, might not be present in + * this sample code. + */ +package checker; + +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Indicates that a plug-in depends on a module. + */ +@Retention(RetentionPolicy.CLASS) +@Repeatable(RequireContainer.class) +public @interface Require { + + /** + * Returns the required module. + * + * @return required module. + */ + Module value(); + + /** + * Returns the minimum supported version of a module. + * + * @return minimum supported version of a module. + */ + int minVersion() default 1; + + /** + * Returns the maximum supported version of a module. + * + * @return maximum supported version of a module. + */ + int maxVersion() default Integer.MAX_VALUE; + + /** + * Returns true if a module is optional. A module is optional if a system + * works without that module but is missing some functionality. Returns false if a system + * won't work without the specified module. + * + * @return true if module is optional. False otherwise. + */ + boolean optional() default false; +} diff --git a/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/RequireContainer.java b/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/RequireContainer.java new file mode 100644 index 00000000000..d18e0d523c0 --- /dev/null +++ b/jdk/src/share/sample/annotations/DependencyChecker/PluginChecker/src/checker/RequireContainer.java @@ -0,0 +1,51 @@ +package checker; + +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation and proper error handling, might not be present in + * this sample code. + */ +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * A container for the repeatable @Require annotation. + */ +@Retention(RetentionPolicy.CLASS) +public @interface RequireContainer { + + Require[] value(); +} diff --git a/jdk/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/BoilerPlugin.java b/jdk/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/BoilerPlugin.java new file mode 100644 index 00000000000..3a9d842e5b0 --- /dev/null +++ b/jdk/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/BoilerPlugin.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation and proper error handling, might not be present in + * this sample code. + */ +package plugins; + +import checker.Module; +import checker.Require; + +/** + * BoilerPlugin provides support for boiling water and keeping water warm. + */ +@Require(value = Module.CLOCK, maxVersion = 3) +@Require(value = Module.THERMOMETER) +@Require(value = Module.HEATER) +@Require(value = Module.LED, optional = true) //will use if present +public class BoilerPlugin { + + /** + * Heats water up to 100 degrees Celsius. + */ + public void boil() { + boil(100); + } + + /** + * Heats water up to temperature. + * + * @param temperature - desired temperature of the water in the boiler + */ + public void boil(int temperature) { + /* + * Turn on heater and wait while temperature reaches desired temperature + * in Celsius. Finally, turn off heater. + * If present, the LED light changes color according to the temperature. + */ + } + + /** + * Keeps desired temperature. + * + * @param temperature - desired temperature of the water in the boiler + * @param seconds - period of time for checking temperature in seconds + */ + public void keepWarm(int temperature, int seconds) { + //Every n seconds check temperature and warm up, if necessary. + } + +} diff --git a/jdk/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/ExtendedBoilerPlugin.java b/jdk/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/ExtendedBoilerPlugin.java new file mode 100644 index 00000000000..b7be61025a0 --- /dev/null +++ b/jdk/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/ExtendedBoilerPlugin.java @@ -0,0 +1,75 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation and proper error handling, might not be present in + * this sample code. + */ +package plugins; + +import checker.Module; +import checker.Require; +import java.util.Calendar; + +/** + * Introduces new features for BoilerPlugin. Features are boiling water by an + * SMS and boiling water by date with notification by a phone call. + */ +@Require(value = Module.SPEAKER) +@Require(value = Module.GSM, minVersion = 3) +@Require(value = Module.DISPLAY) +public class ExtendedBoilerPlugin extends BoilerPlugin { + + /** + * Boils water at the appointed time and wakes you up by a ring and phone + * call. Shows "Good morning" and a quote of the day from the Internet on the + * display. + * + * @param calendar - date and time when water should be boiled + * @param phoneNumber - phone number to call + */ + public void boilAndWakeUp(Calendar calendar, int phoneNumber) { + //implementation + } + + /** + * Boils water at the appointed time by getting an SMS of fixed format. + * Sends an SMS on finish. + * + * @param sms - text of SMS + */ + public void boilBySMS(String sms) { + //implementation + } +} diff --git a/jdk/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/TimerPlugin.java b/jdk/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/TimerPlugin.java new file mode 100644 index 00000000000..678785c5cf4 --- /dev/null +++ b/jdk/src/share/sample/annotations/DependencyChecker/Plugins/src/plugins/TimerPlugin.java @@ -0,0 +1,71 @@ +/* + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation and proper error handling, might not be present in + * this sample code. + */ +package plugins; + +import checker.Module; +import checker.Require; + +/** + * Timer plug-in is used to support an alarm and a timer. It depends on Display and + * Clock modules. + */ +@Require(Module.DISPLAY) +@Require(value = Module.CLOCK, maxVersion = 3) +public class TimerPlugin { + + /** + * Sets timer. + * + * @param time - the remaining time. + */ + public void timer(long time) { + //start timer + //show the remaining time on display + } + + /** + * Sets alarm. + * + * @param time - the alarm time. + */ + public void alarm(long time) { + //start alarm + //show current time and alarm time on display + } +} diff --git a/jdk/src/share/sample/annotations/Validator/src/PositiveIntegerSupplier.java b/jdk/src/share/sample/annotations/Validator/src/PositiveIntegerSupplier.java new file mode 100644 index 00000000000..0a149139b53 --- /dev/null +++ b/jdk/src/share/sample/annotations/Validator/src/PositiveIntegerSupplier.java @@ -0,0 +1,59 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation and proper error handling, might not be present in + * this sample code. + */ +import java.util.function.Supplier; + +/** + * Supplies a positive number. + */ +@Validate(value = Validator.INTEGER_NUMBER, + description = "It's not an Integer ") +@Validate(value = Validator.POSITIVE_NUMBER, + description = "It's not a positive Number") +public class PositiveIntegerSupplier implements Supplier { + + /** + * Returns a string representation of a positive integer. + * + * @return string representation of a positive integer. + */ + @Override + public String get() { + return "20005"; //random number + } +} diff --git a/jdk/src/share/sample/annotations/Validator/src/SupplierValidator.java b/jdk/src/share/sample/annotations/Validator/src/SupplierValidator.java new file mode 100644 index 00000000000..479ac8643e1 --- /dev/null +++ b/jdk/src/share/sample/annotations/Validator/src/SupplierValidator.java @@ -0,0 +1,66 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation and proper error handling, might not be present in + * this sample code. + */ +import javax.xml.bind.ValidationException; +import java.util.function.Supplier; + +/** + * Validates the supplier. + */ +public class SupplierValidator { + + /** + * Validates the supplier. + * + * @param supplier - Supplier that needs to be validated. + * @return true if supplier has passed validation check. False otherwise. + */ + public static boolean validate(Supplier supplier) { + for (Validate annotation + : supplier.getClass().getAnnotationsByType(Validate.class)) { + try { + annotation.value().validate(supplier); + } catch (ValidationException e) { + System.out.println(annotation.description()); + e.printStackTrace(); + return false; + } + } + return true; + } +} diff --git a/jdk/src/share/sample/annotations/Validator/src/Validate.java b/jdk/src/share/sample/annotations/Validator/src/Validate.java new file mode 100644 index 00000000000..e0404ea9471 --- /dev/null +++ b/jdk/src/share/sample/annotations/Validator/src/Validate.java @@ -0,0 +1,74 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation and proper error handling, might not be present in + * this sample code. + */ +import java.lang.annotation.Repeatable; +import java.lang.annotation.Retention; +import java.lang.annotation.RetentionPolicy; + +/** + * Indicates that the class should be validated by the specified validator. + */ +@Retention(RetentionPolicy.RUNTIME) +@Repeatable(ValidateContainer.class) +public @interface Validate { + + /** + * Returns the validator that should validate the annotated class. + * + * @return Validator that should validate annotated class. + */ + Validator value(); + + /** + * Returns text to describe the failure of the validation check. + * + * @return text to describe the failure of the validation check. + */ + String description() default ""; +} + +/** + * A container for the repeatable @Validate annotation. + * + * @author Andrey Nazarov + */ +@Retention(RetentionPolicy.RUNTIME) +@interface ValidateContainer { + + Validate[] value(); +} diff --git a/jdk/src/share/sample/annotations/Validator/src/Validator.java b/jdk/src/share/sample/annotations/Validator/src/Validator.java new file mode 100644 index 00000000000..9e074f5a8e5 --- /dev/null +++ b/jdk/src/share/sample/annotations/Validator/src/Validator.java @@ -0,0 +1,99 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation and proper error handling, might not be present in + * this sample code. + */ +import javax.xml.bind.ValidationException; +import java.util.function.Supplier; + +/** + * Enum of Validator implementations. + */ +public enum Validator { + + /** + * This validator checks that the string represents an integer. + */ + INTEGER_NUMBER { + /** + * Checks that the string represents an integer. + * + * @param string - a string supplier + * @throws ValidationException if the validation check fails + */ + @Override + void validate(Supplier string) throws ValidationException { + try { + Integer.parseInt((String) string.get()); + } catch (NumberFormatException ex) { + throw new ValidationException("Error while validating " + + string.get()); + } + } + }, + /** + * This validator checks that the string represents a positive number. + */ + POSITIVE_NUMBER { + /** + * Checks that the string represents a positive number. + * + * @param string - an string supplier + * @throws ValidationException if the validation check fails + */ + @Override + void validate(Supplier string) throws ValidationException { + try { + if (Double.compare(0.0, Double.parseDouble( + (String) string.get())) > 0) { + throw new Exception(); + } + } catch (Exception ex) { + throw new ValidationException("Error while validating " + + string.get()); + } + } + }; + + /** + * Checks that the supplier is valid. + * + * @param string - a string supplier + * @throws ValidationException if validation check fails + */ + abstract void validate(Supplier string) throws ValidationException; + +} diff --git a/jdk/src/share/sample/annotations/index.html b/jdk/src/share/sample/annotations/index.html new file mode 100644 index 00000000000..804c83df441 --- /dev/null +++ b/jdk/src/share/sample/annotations/index.html @@ -0,0 +1,67 @@ + + + + Repeating Annotations Demo + + +

Repeating Annotations Demo

+ +

+ This demo shows how to use repeating annotations at runtime and at compile time. +

+ +
    +
  • Dependency checker.

    + +

    + Shows how to define repeating annotations and process them at compile time. + The problem domain is some code that performs useful operations on hardware devices. + The code relies on "modules" to be present on the devices. Applicability of the code to a particular + device is checked while compiling the code for a particular device. + A set of modules provided by a device is listed in an xml file that turns red during the compilation + phase and is compared with the required module set specified by annotations. + For instance, there is kettle with hardware modules: thermometer, display, and clock. + There is also a boiler plug-in that requires clock, thermometer, heater, and optionally an LED light. + + Build the PluginChecker annotation processor first. + Then, run javac with the annotation processor against plug-in sources using the following command:

    + + javac -cp "PluginChecker.jar" -processor checker.PluginChecker -Adevice=Kettle.xml -proc:only <source + files> + +

    + where PluginChecker.jar - path to jar file that contains PluginChecker annotation processor + class.
    + Kettle.xml - path to device descriptor Kettle.xml
    + <source files> - source files in Plugins/src +

    + For more information, see the source files. +

    + + +
  • Validator.

    + +

    + Shows how to define repeating annotations and process them at runtime. + A problem domain is code that needs to validate provided Suppliers for conformance to some criteria. + The criteria are implemented by the Validator class which is applied by using annotations that are placed in + the code whenever validation is needed. For more information, see the + source files. +

    + +

    +

    +

    + Sources: Validator/src/ +
+ + \ No newline at end of file From 7bdf4708b27ba1b8634de6554b8005073a470c40 Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Fri, 31 Jan 2014 11:57:12 +0100 Subject: [PATCH 069/159] 8031650: Update bulk operation demo Reviewed-by: psandoz, mduigou --- .../lambda/BulkDataOperations/index.html | 49 +++ .../BulkDataOperations/src/CSVProcessor.java | 368 ++++++++++++++++++ .../lambda/BulkDataOperations/src/Grep.java | 185 +++++++++ .../src/PasswordGenerator.java | 113 ++++++ .../lambda/BulkDataOperations/src/WC.java | 217 +++++++++++ 5 files changed, 932 insertions(+) create mode 100644 jdk/src/share/sample/lambda/BulkDataOperations/index.html create mode 100644 jdk/src/share/sample/lambda/BulkDataOperations/src/CSVProcessor.java create mode 100644 jdk/src/share/sample/lambda/BulkDataOperations/src/Grep.java create mode 100644 jdk/src/share/sample/lambda/BulkDataOperations/src/PasswordGenerator.java create mode 100644 jdk/src/share/sample/lambda/BulkDataOperations/src/WC.java diff --git a/jdk/src/share/sample/lambda/BulkDataOperations/index.html b/jdk/src/share/sample/lambda/BulkDataOperations/index.html new file mode 100644 index 00000000000..5a16695f21d --- /dev/null +++ b/jdk/src/share/sample/lambda/BulkDataOperations/index.html @@ -0,0 +1,49 @@ + + + + Bulk Data Operations Demo + + +

Bulk Data Operations Demo

+ +

+ This demo shows how to use bulk data operations with the new JDK8 + Collections API. + The demo also demonstrates new features of JDK8 such as lambda expressions + and method/constructor references. +

+ +
    +
  • CSV Processor

    + +

    + Analyzes a CSV file, finds and collects useful information, computes + different statistics. For more information, see the source file. +

    + Source: src/CSVProcessor.java +
  • Grep

    + +

    + Behaves like the standard Linux tool Grep. For more information, see + the source file. +

    + Source: src/Grep.java +
  • PasswordGenerator

    + +

    + Produces a password of desired length. For more information see + source file. +

    + Source: src/PasswordGenerator.java +
  • WC

    + +

    + Counts newlines, words, characters, and the maximum line length of a + text file. For more information, see the source + file. +

    + Source: src/WC.java +
+ + \ No newline at end of file diff --git a/jdk/src/share/sample/lambda/BulkDataOperations/src/CSVProcessor.java b/jdk/src/share/sample/lambda/BulkDataOperations/src/CSVProcessor.java new file mode 100644 index 00000000000..ded9030209d --- /dev/null +++ b/jdk/src/share/sample/lambda/BulkDataOperations/src/CSVProcessor.java @@ -0,0 +1,368 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation, and proper error handling, might not be present in + * this sample code. + */ + +import java.io.BufferedReader; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.*; +import java.util.function.*; +import java.util.regex.Pattern; +import java.util.stream.Collector; +import java.util.stream.Collectors; + +import static java.lang.Double.parseDouble; +import static java.util.stream.Collectors.*; + +/** + * CSVProcessor is a tool for processing CSV files. There are several + * command-line options. Consult the {@link #printUsageAndExit} method for + * instructions and command line parameters. This sample shows examples of the + * following features: + *
    + *
  • Lambda and bulk operations. Working with streams: map(...), filter(...), + * sorted(...) methods. The collect(...) method with different collectors: + * Collectors.maxBy(...), Collectors.minBy(...), Collectors.toList(), + * Collectors.toCollection(...), Collectors.groupingBy(...), + * Collectors.toDoubleSummaryStatistics(...), and a custom Collector.
  • + *
  • Static method reference for printing values.
  • + *
  • Try-with-resources feature for closing files.
  • + *
  • Switch by String feature.
  • + *
  • Other new APIs: Pattern.asPredicate(), BinaryOperator + * BufferedReader.lines(), Collection.forEach(...), Comparator.comparing(...), + * Comparator.reversed(), Arrays.stream(...).
  • + *
+ * + */ +public class CSVProcessor { + + //Number of characters that may be read + private static final int READ_AHEAD_LIMIT = 100_000_000; + + /** + * The main method for the CSVProcessor program. Run the program with an + * empty argument list to see possible arguments. + * + * @param args the argument list for CSVProcessor. + */ + public static void main(String[] args) { + if (args.length < 2) { + printUsageAndExit(); + } + try (BufferedReader br = new BufferedReader( + Files.newBufferedReader(Paths.get(args[args.length - 1])))) { + //Assume that the first line contains column names. + List header = Arrays.stream(br.readLine().split(",")) + .map(String::trim).collect(toList()); + //Calculate an index of the column in question. + int column = getColumnNumber(header, args[1]); + switch (args[0]) { + case "sort": + verifyArgumentNumber(args, 4); + //Define the sort order. + boolean isAsc; + switch (args[2].toUpperCase()) { + case "ASC": + isAsc = true; + break; + case "DESC": + isAsc = false; + break; + default: + printUsageAndExit("Illegal argument" + args[2]); + return;//Should not be reached. + } + /* + * Create a comparator that compares lines by comparing + * values in the specified column. + */ + Comparator cmp + = Comparator.comparing(str -> getCell(str, column), + String.CASE_INSENSITIVE_ORDER); + /* + * sorted(...) is used to sort records. + * forEach(...) is used to output sorted records. + */ + br.lines().sorted(isAsc ? cmp : cmp.reversed()) + .forEach(System.out::println); + break; + case "search": + verifyArgumentNumber(args, 4); + /* + * Records are filtered by a regex. + * forEach(...) is used to output filtered records. + */ + Predicate pattern + = Pattern.compile(args[2]).asPredicate(); + br.lines().filter(str -> pattern.test(getCell(str, column))) + .forEach(System.out::println); + break; + case "groupby": + verifyArgumentNumber(args, 3); + /* + * Group lines by values in the column with collect(...), and + * print with forEach(...) for every distinct value within + * the column. + */ + br.lines().collect( + Collectors.groupingBy(str -> getCell(str, column), + toCollection(TreeSet::new))) + .forEach((str, set) -> { + System.out.println(str + ":"); + set.forEach(System.out::println); + }); + break; + case "stat": + verifyArgumentNumber(args, 3); + + /* + * BufferedReader will be read several times. + * Mark this point to return here after each pass. + * BufferedReader will be read right after the headers line + * because it is already read. + */ + br.mark(READ_AHEAD_LIMIT); + + /* + * Statistics can be collected by a custom collector in one + * pass. One pass is preferable. + */ + System.out.println( + br.lines().collect(new Statistics(column))); + + /* + * Alternatively, statistics can be collected + * by a built-in API in several passes. + * This method demonstrates how separate operations can be + * implemented using a built-in API. + */ + br.reset(); + statInSeveralPasses(br, column); + break; + default: + printUsageAndExit("Illegal argument" + args[0]); + } + } catch (IOException e) { + printUsageAndExit(e.toString()); + } + } + + private static void statInSeveralPasses(BufferedReader br, int column) + throws IOException { + System.out.println("#-----Statistics in several passes-------#"); + //Create a comparator to compare records by the column. + Comparator comparator + = Comparator.comparing( + (String str) -> parseDouble(getCell(str, column))); + //Find max record by using Collectors.maxBy(...) + System.out.println( + "Max: " + br.lines().collect(maxBy(comparator)).get()); + br.reset(); + //Find min record by using Collectors.minBy(...) + System.out.println( + "Min: " + br.lines().collect(minBy(comparator)).get()); + br.reset(); + //Compute the average value and sum with + //Collectors.toDoubleSummaryStatistics(...) + DoubleSummaryStatistics doubleSummaryStatistics + = br.lines().collect(summarizingDouble( + str -> parseDouble(getCell(str, column)))); + System.out.println("Average: " + doubleSummaryStatistics.getAverage()); + System.out.println("Sum: " + doubleSummaryStatistics.getSum()); + } + + private static void verifyArgumentNumber(String[] args, int n) { + if (args.length != n) { + printUsageAndExit("Expected " + n + " arguments but was " + + args.length); + } + } + + private static int getColumnNumber(List header, String name) { + int column = header.indexOf(name); + if (column == -1) { + printUsageAndExit("There is no column with name " + name); + } + return column; + } + + private static String getCell(String record, int column) { + return record.split(",")[column].trim(); + } + + private static void printUsageAndExit(String... str) { + System.out.println("Usages:"); + + System.out.println("CSVProcessor sort COLUMN_NAME ASC|DESC FILE"); + System.out.println("Sort lines by column COLUMN_NAME in CSV FILE\n"); + + System.out.println("CSVProcessor search COLUMN_NAME REGEX FILE"); + System.out.println("Search for REGEX in column COLUMN_NAME in CSV FILE\n"); + + System.out.println("CSVProcessor groupby COLUMN_NAME FILE"); + System.out.println("Split lines into different groups according to column " + + "COLUMN_NAME value\n"); + + System.out.println("CSVProcessor stat COLUMN_NAME FILE"); + System.out.println("Compute max/min/average/sum statistics by column " + + "COLUMN_NAME\n"); + + Arrays.asList(str).forEach(System.err::println); + System.exit(1); + } + + /* + * This is a custom implementation of the Collector interface. + * Statistics are objects gather max,min,sum,average statistics. + */ + private static class Statistics + implements Collector { + + + /* + * This implementation does not need to be thread safe because + * the parallel implementation of + * {@link java.util.stream.Stream#collect Stream.collect()} + * provides the necessary partitioning and isolation for safe parallel + * execution. + */ + private String maxRecord; + private String minRecord; + + private double sum; + private int lineCount; + private final BinaryOperator maxOperator; + private final BinaryOperator minOperator; + private final int column; + + public Statistics(int column) { + this.column = column; + Comparator cmp = Comparator.comparing( + (String str) -> parseDouble(getCell(str, column))); + maxOperator = BinaryOperator.maxBy(cmp); + minOperator = BinaryOperator.minBy(cmp); + } + + /* + * Process line. + */ + public Statistics accept(String line) { + maxRecord = maxRecord == null + ? line : maxOperator.apply(maxRecord, line); + minRecord = minRecord == null + ? line : minOperator.apply(minRecord, line); + + sum += parseDouble(getCell(line, column)); + lineCount++; + return this; + } + + + /* + * Merge two Statistics. + */ + public Statistics combine(Statistics stat) { + maxRecord = maxOperator.apply(maxRecord, stat.getMaxRecord()); + minRecord = minOperator.apply(minRecord, stat.getMinRecord()); + sum += stat.getSum(); + lineCount += stat.getLineCount(); + return this; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("#------Statistics------#\n"); + sb.append("Max: ").append(getMaxRecord()).append("\n"); + sb.append("Min: ").append(getMinRecord()).append("\n"); + sb.append("Sum = ").append(getSum()).append("\n"); + sb.append("Average = ").append(average()).append("\n"); + sb.append("#------Statistics------#\n"); + return sb.toString(); + } + + @Override + public Supplier supplier() { + return () -> new Statistics(column); + } + + @Override + public BiConsumer accumulator() { + return Statistics::accept; + } + + @Override + public BinaryOperator combiner() { + return Statistics::combine; + + } + + @Override + public Function finisher() { + return stat -> stat; + } + + @Override + public Set characteristics() { + return EnumSet.of(Characteristics.IDENTITY_FINISH); + } + + private String getMaxRecord() { + return maxRecord; + } + + private String getMinRecord() { + return minRecord; + } + + private double getSum() { + return sum; + } + + private double average() { + return sum / lineCount; + } + + private int getLineCount() { + return lineCount; + } + + } + +} diff --git a/jdk/src/share/sample/lambda/BulkDataOperations/src/Grep.java b/jdk/src/share/sample/lambda/BulkDataOperations/src/Grep.java new file mode 100644 index 00000000000..cb4bdf765cb --- /dev/null +++ b/jdk/src/share/sample/lambda/BulkDataOperations/src/Grep.java @@ -0,0 +1,185 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation, and proper error handling, might not be present in + * this sample code. + */ + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.Arrays; +import java.util.List; +import java.util.regex.Pattern; +import java.util.stream.Stream; + +import static java.util.stream.Collectors.toList; + +/** + * Grep prints lines matching a regex. See {@link #printUsageAndExit(String...)} + * method for instructions and command line parameters. This sample shows + * examples of using next features: + *
    + *
  • Lambda and bulk operations. Working with streams: + * map(...),filter(...),flatMap(...),limit(...) methods.
  • + *
  • Static method reference for printing values.
  • + *
  • New Collections API forEach(...) method.
  • + *
  • Try-with-resources feature.
  • + *
  • new Files.walk(...), Files.lines(...) API.
  • + *
  • Streams that need to be closed.
  • + *
+ * + */ +public class Grep { + + private static void printUsageAndExit(String... str) { + System.out.println("Usage: " + Grep.class.getSimpleName() + + " [OPTION]... PATTERN FILE..."); + System.out.println("Search for PATTERN in each FILE. " + + "If FILE is a directory then whole file tree of the directory" + + " will be processed."); + System.out.println("Example: grep -m 100 'hello world' menu.h main.c"); + System.out.println("Options:"); + System.out.println(" -m NUM: stop analysis after NUM matches"); + Arrays.asList(str).forEach(System.err::println); + System.exit(1); + } + + /** + * The main method for the Grep program. Run program with empty argument + * list to see possible arguments. + * + * @param args the argument list for Grep. + * @throws java.io.IOException If an I/O error occurs. + */ + public static void main(String[] args) throws IOException { + long maxCount = Long.MAX_VALUE; + if (args.length < 2) { + printUsageAndExit(); + } + int i = 0; + //parse OPTIONS + while (args[i].startsWith("-")) { + switch (args[i]) { + case "-m": + try { + maxCount = Long.parseLong(args[++i]); + } catch (NumberFormatException ex) { + printUsageAndExit(ex.toString()); + } + break; + default: + printUsageAndExit("Unexpected option " + args[i]); + } + i++; + } + //parse PATTERN + Pattern pattern = Pattern.compile(args[i++]); + if (i == args.length) { + printUsageAndExit("There are no files for input"); + } + + try { + /* + * First obtain the list of all paths. + * For a small number of arguments there is little to be gained + * by producing this list in parallel. For one argument + * there will be no parallelism. + * + * File names are converted to paths. If a path is a directory then + * Stream is populated with whole file tree of the directory by + * flatMap() method. Files are filtered from directories. + */ + List files = Arrays.stream(args, i, args.length) + .map(Paths::get) + // flatMap will ensure each I/O-based stream will be closed + .flatMap(Grep::getPathStream) + .filter(Files::isRegularFile) + .collect(toList()); + /* + * Then operate on that list in parallel. + * This is likely to give a more even distribution of work for + * parallel execution. + * + * Lines are extracted from files. Lines are filtered by pattern. + * Stream is limited by number of matches. Each remaining string is + * displayed in std output by method reference System.out::println. + */ + files.parallelStream() + // flatMap will ensure each I/O-based stream will be closed + .flatMap(Grep::path2Lines) + .filter(pattern.asPredicate()) + .limit(maxCount) + .forEachOrdered(System.out::println); + } catch (UncheckedIOException ioe) { + printUsageAndExit(ioe.toString()); + } + } + + /** + * Flattens file system hierarchy into a stream. This code is not inlined + * for the reason of Files.walk() throwing a checked IOException that must + * be caught. + * + * @param path - the file or directory + * @return Whole file tree starting from path, a stream with one element - + * the path itself - if it is a file. + */ + private static Stream getPathStream(Path path) { + try { + return Files.walk(path); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } + + /** + * Produces a stream of lines from a file. The result is a stream in order + * to close it later. This code is not inlined for the reason of + * Files.lines() throwing a checked IOException that must be caught. + * + * @param path - the file to read + * @return stream of lines from the file + */ + private static Stream path2Lines(Path path) { + try { + return Files.lines(path); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + } +} diff --git a/jdk/src/share/sample/lambda/BulkDataOperations/src/PasswordGenerator.java b/jdk/src/share/sample/lambda/BulkDataOperations/src/PasswordGenerator.java new file mode 100644 index 00000000000..e4677985929 --- /dev/null +++ b/jdk/src/share/sample/lambda/BulkDataOperations/src/PasswordGenerator.java @@ -0,0 +1,113 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation, and proper error handling, might not be present in + * this sample code. + */ + +import java.security.SecureRandom; +import java.util.ArrayList; +import java.util.List; +import java.util.stream.IntStream; + +/** + * Generates password of desired length. See {@link #usage} method + * for instructions and command line parameters. This sample shows usages of: + *
    + *
  • Method references.
  • + *
  • Lambda and bulk operations. A stream of random integers is mapped to + * chars, limited by desired length and printed in standard output as password + * string.
  • + *
+ * + */ +public class PasswordGenerator { + + private static void usage() { + System.out.println("Usage: PasswordGenerator LENGTH"); + System.out.println( + "Password Generator produces password of desired LENGTH."); + } + + private static final List PASSWORD_CHARS = new ArrayList<>(); + + //Valid symbols. + static { + IntStream.rangeClosed('0', '9').forEach(PASSWORD_CHARS::add); // 0-9 + IntStream.rangeClosed('A', 'Z').forEach(PASSWORD_CHARS::add); // A-Z + IntStream.rangeClosed('a', 'z').forEach(PASSWORD_CHARS::add); // a-z + } + + /** + * The main method for the PasswordGenerator program. Run program with empty + * argument list to see possible arguments. + * + * @param args the argument list for PasswordGenerator. + */ + public static void main(String[] args) { + + if (args.length != 1) { + usage(); + return; + } + + long passwordLength; + try { + passwordLength = Long.parseLong(args[0]); + if (passwordLength < 1) { + printMessageAndUsage("Length has to be positive"); + return; + } + } catch (NumberFormatException ex) { + printMessageAndUsage("Unexpected number format" + args[0]); + return; + } + /* + * Stream of random integers is created containing Integer values + * in range from 0 to PASSWORD_CHARS.size(). + * The stream is limited by passwordLength. + * Valid chars are selected by generated index. + */ + new SecureRandom().ints(passwordLength, 0, PASSWORD_CHARS.size()) + .map(PASSWORD_CHARS::get) + .forEach(i -> System.out.print((char) i)); + } + + private static void printMessageAndUsage(String message) { + System.err.println(message); + usage(); + } + +} diff --git a/jdk/src/share/sample/lambda/BulkDataOperations/src/WC.java b/jdk/src/share/sample/lambda/BulkDataOperations/src/WC.java new file mode 100644 index 00000000000..c724f159a19 --- /dev/null +++ b/jdk/src/share/sample/lambda/BulkDataOperations/src/WC.java @@ -0,0 +1,217 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation, and proper error handling, might not be present in + * this sample code. + */ + +import java.io.BufferedReader; +import java.io.FileNotFoundException; +import java.io.FileReader; +import java.io.IOException; +import java.util.function.Consumer; +import java.util.regex.Pattern; + +/** + * WC - Prints newline, word, and character counts for each file. See + * the {@link #usage} method for instructions and command line parameters. This + * sample shows usages of: + *
    + *
  • Lambda and bulk operations. Shows how to create a custom collector to + * gather custom statistics. Implements the collection of statistics using a + * built-in API.
  • + *
  • Constructor reference.
  • + *
  • Try-with-resources feature.
  • + *
+ * + */ +public class WC { + + //The number of characters that may be read. + private static final int READ_AHEAD_LIMIT = 100_000_000; + + //The pattern for splitting strings by non word characters to get words. + private static final Pattern nonWordPattern = Pattern.compile("\\W"); + + /** + * The main method for the WC program. Run the program with an empty + * argument list to see possible arguments. + * + * @param args the argument list for WC + * @throws java.io.IOException If an input exception occurred. + */ + public static void main(String[] args) throws IOException { + + if (args.length != 1) { + usage(); + return; + } + + try (BufferedReader reader = new BufferedReader( + new FileReader(args[0]))) { + reader.mark(READ_AHEAD_LIMIT); + /* + * Statistics can be gathered in four passes using a built-in API. + * The method demonstrates how separate operations can be + * implemented using a built-in API. + */ + collectInFourPasses(reader); + /* + * Usage of several passes to collect data is not the best way. + * Statistics can be gathered by a custom collector in one pass. + */ + reader.reset(); + collectInOnePass(reader); + } catch (FileNotFoundException e) { + usage(); + System.err.println(e); + } + } + + private static void collectInFourPasses(BufferedReader reader) + throws IOException { + /* + * Input is read as a stream of lines by lines(). + * Every line is turned into a stream of chars by the flatMapToInt(...) + * method. + * Length of the stream is counted by count(). + */ + System.out.println("Character count = " + + reader.lines().flatMapToInt(String::chars).count()); + /* + * Input is read as a stream of lines by lines(). + * Every line is split by nonWordPattern into words by flatMap(...) + * method. + * Empty lines are removed by the filter(...) method. + * Length of the stream is counted by count(). + */ + reader.reset(); + System.out.println("Word count = " + + reader.lines() + .flatMap(nonWordPattern::splitAsStream) + .filter(str -> !str.isEmpty()).count()); + + reader.reset(); + System.out.println("Newline count = " + reader.lines().count()); + /* + * Input is read as a stream of lines by lines(). + * Every line is mapped to its length. + * Maximum of the lengths is calculated. + */ + reader.reset(); + System.out.println("Max line length = " + + reader.lines().mapToInt(String::length).max().getAsInt()); + } + + private static void collectInOnePass(BufferedReader reader) { + /* + * The collect() method has three parameters: + * The first parameter is the {@code WCStatistic} constructor reference. + * collect() will create {@code WCStatistics} instances, where + * statistics will be aggregated. + * The second parameter shows how {@code WCStatistics} will process + * String. + * The third parameter shows how to merge two {@code WCStatistic} + * instances. + * + * Also {@code Collector} can be used, which would be more reusable + * solution. See {@code CSVProcessor} example for how {@code Collector} + * can be implemented. + * + * Note that the any performance increase when going parallel will + * depend on the size of the input (lines) and the cost per-element. + */ + WCStatistics wc = reader.lines().parallel() + .collect(WCStatistics::new, + WCStatistics::accept, + WCStatistics::combine); + System.out.println(wc); + } + + private static void usage() { + System.out.println("Usage: " + WC.class.getSimpleName() + " FILE"); + System.out.println("Print newline, word," + + " character counts and max line length for FILE."); + } + + private static class WCStatistics implements Consumer { + /* + * @implNote This implementation does not need to be thread safe because + * the parallel implementation of + * {@link java.util.stream.Stream#collect Stream.collect()} + * provides the necessary partitioning and isolation for safe parallel + * execution. + */ + + private long characterCount; + private long lineCount; + private long wordCount; + private long maxLineLength; + + + /* + * Processes line. + */ + @Override + public void accept(String line) { + characterCount += line.length(); + lineCount++; + wordCount += nonWordPattern.splitAsStream(line) + .filter(str -> !str.isEmpty()).count(); + maxLineLength = Math.max(maxLineLength, line.length()); + } + + /* + * Merges two WCStatistics. + */ + public void combine(WCStatistics stat) { + wordCount += stat.wordCount; + lineCount += stat.lineCount; + characterCount += stat.characterCount; + maxLineLength = Math.max(maxLineLength, stat.maxLineLength); + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("#------WCStatistic------#\n"); + sb.append("Character count = ").append(characterCount).append('\n'); + sb.append("Word count = ").append(wordCount).append('\n'); + sb.append("Newline count = ").append(lineCount).append('\n'); + sb.append("Max line length = ").append(maxLineLength).append('\n'); + return sb.toString(); + } + } +} From a7acbb1cb79a7250ab6f0ebd45bc512e4d08f135 Mon Sep 17 00:00:00 2001 From: Andrey Nazarov Date: Fri, 31 Jan 2014 11:57:38 +0100 Subject: [PATCH 070/159] 8032020: Update try-with-resources demo Reviewed-by: darcy, alanb, smarks --- .../sample/try-with-resources/index.html | 36 +++++ .../src/CustomAutoCloseableSample.java | 137 ++++++++++++++++++ .../sample/try-with-resources/src/Unzip.java | 83 +++++++++++ .../sample/try-with-resources/src/ZipCat.java | 83 +++++++++++ 4 files changed, 339 insertions(+) create mode 100644 jdk/src/share/sample/try-with-resources/index.html create mode 100644 jdk/src/share/sample/try-with-resources/src/CustomAutoCloseableSample.java create mode 100644 jdk/src/share/sample/try-with-resources/src/Unzip.java create mode 100644 jdk/src/share/sample/try-with-resources/src/ZipCat.java diff --git a/jdk/src/share/sample/try-with-resources/index.html b/jdk/src/share/sample/try-with-resources/index.html new file mode 100644 index 00000000000..ff237d89ce6 --- /dev/null +++ b/jdk/src/share/sample/try-with-resources/index.html @@ -0,0 +1,36 @@ + + + + + Try-with-Resources Feature Demo + + +

Try-with-Resources Feature Demo

+ +

+ This demo shows how to use the try-with-resources feature introduced in JDK7. +

+ +
    +
  • Custom AutoCloseable.

    + +

    + Shows how to use a custom resource with the try-with-resources construct. + For more information, see the source file. +

    + Source: src/CustomAutoCloseableSample.java + +
  • Unzip

    + +

    + Extracts archived files. For more information, see the source file. +

    + Source: src/Unzip.java +
  • ZipCat

    + +

    Prints data about a specified file from an archive. For more information, see the source file.

    + Source: src/ZipCat.java + +
+ + \ No newline at end of file diff --git a/jdk/src/share/sample/try-with-resources/src/CustomAutoCloseableSample.java b/jdk/src/share/sample/try-with-resources/src/CustomAutoCloseableSample.java new file mode 100644 index 00000000000..9bbe09aa1ed --- /dev/null +++ b/jdk/src/share/sample/try-with-resources/src/CustomAutoCloseableSample.java @@ -0,0 +1,137 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation, and proper error handling, might not be present in + * this sample code. + */ + +import java.io.BufferedOutputStream; +import java.io.IOException; +import java.io.OutputStream; +import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; + +/** + * This sample demonstrates the ability to create custom resource that + * implements the {@code AutoCloseable} interface. This resource can be used in + * the try-with-resources construct. + */ +public class CustomAutoCloseableSample { + + /** + * The main method for the CustomAutoCloseableSample program. + * + * @param args is not used. + */ + public static void main(String[] args) { + /* + * TeeStream will be closed automatically after the try block. + */ + try (TeeStream teeStream = new TeeStream(System.out, Paths.get("out.txt")); + PrintStream out = new PrintStream(teeStream)) { + out.print("Hello, world"); + } catch (Exception e) { + e.printStackTrace(); + System.exit(1); + } + } + + /** + * Passes the output through to the specified output stream while copying it into a file. + * The TeeStream functionality is similar to the Unix tee utility. + * TeeStream implements AutoCloseable interface. See OutputStream for details. + */ + public static class TeeStream extends OutputStream { + + private final OutputStream fileStream; + private final OutputStream outputStream; + + /** + * Creates a TeeStream. + * + * @param outputStream an output stream. + * @param outputFile an path to file. + * @throws IOException If an I/O error occurs. + */ + public TeeStream(OutputStream outputStream, Path outputFile) throws IOException { + this.fileStream = new BufferedOutputStream(Files.newOutputStream(outputFile)); + this.outputStream = outputStream; + } + + /** + * Writes the specified byte to the specified output stream + * and copies it to the file. + * + * @param b the byte to be written. + * @throws IOException If an I/O error occurs. + */ + @Override + public void write(int b) throws IOException { + fileStream.write(b); + outputStream.write(b); + } + + /** + * Flushes this output stream and forces any buffered output bytes + * to be written out. + * The flush method of TeeStream flushes + * the specified output stream and the file output stream. + * + * @throws IOException if an I/O error occurs. + */ + @Override + public void flush() throws IOException { + outputStream.flush(); + fileStream.flush(); + } + + /** + * Closes underlying streams and resources. + * The external output stream won't be closed. + * This method is the member of AutoCloseable interface and + * it will be invoked automatically after the try-with-resources block. + * + * @throws IOException If an I/O error occurs. + */ + @Override + public void close() throws IOException { + try (OutputStream file = fileStream) { + flush(); + } + } + } +} diff --git a/jdk/src/share/sample/try-with-resources/src/Unzip.java b/jdk/src/share/sample/try-with-resources/src/Unzip.java new file mode 100644 index 00000000000..d75eba52c78 --- /dev/null +++ b/jdk/src/share/sample/try-with-resources/src/Unzip.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation, and proper error handling, might not be present in + * this sample code. + */ + +import java.io.IOException; +import java.io.UncheckedIOException; +import java.nio.file.*; + +import static java.nio.file.StandardCopyOption.REPLACE_EXISTING; + +/** + * Extract (unzip) a file to the current directory. + */ +public class Unzip { + + /** + * The main method for the Unzip program. Run the program with an empty + * argument list to see possible arguments. + * + * @param args the argument list for {@code Unzip}. + */ + public static void main(String[] args) { + if (args.length != 1) { + System.out.println("Usage: Unzip zipfile"); + } + final Path destDir = Paths.get("."); + /* + * Create AutoCloseable FileSystem. It will be closed automatically + * after the try block. + */ + try (FileSystem zipFileSystem = FileSystems.newFileSystem(Paths.get(args[0]), null)) { + + Path top = zipFileSystem.getPath("/"); + Files.walk(top).skip(1).forEach(file -> { + Path target = destDir.resolve(top.relativize(file).toString()); + System.out.println("Extracting " + target); + try { + Files.copy(file, target, REPLACE_EXISTING); + } catch (IOException e) { + throw new UncheckedIOException(e); + } + }); + } catch (UncheckedIOException | IOException e) { + e.printStackTrace(); + System.exit(1); + } + } +} diff --git a/jdk/src/share/sample/try-with-resources/src/ZipCat.java b/jdk/src/share/sample/try-with-resources/src/ZipCat.java new file mode 100644 index 00000000000..4bbf513a538 --- /dev/null +++ b/jdk/src/share/sample/try-with-resources/src/ZipCat.java @@ -0,0 +1,83 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/* + * This source code is provided to illustrate the usage of a given feature + * or technique and has been deliberately simplified. Additional steps + * required for a production-quality application, such as security checks, + * input validation, and proper error handling, might not be present in + * this sample code. + */ + +import java.io.IOException; +import java.io.InputStream; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.Paths; + +/** + * Prints data of the specified file to standard output from a zip archive. + */ +public class ZipCat { + + /** + * The main method for the ZipCat program. Run the program with an empty + * argument list to see possible arguments. + * + * @param args the argument list for ZipCat + */ + public static void main(String[] args) { + if (args.length != 2) { + System.out.println("Usage: ZipCat zipfile fileToPrint"); + } + /* + * Creates AutoCloseable FileSystem and BufferedReader. + * They will be closed automatically after the try block. + * If reader initialization fails, then zipFileSystem will be closed + * automatically. + */ + try (FileSystem zipFileSystem + = FileSystems.newFileSystem(Paths.get(args[0]),null); + InputStream input + = Files.newInputStream(zipFileSystem.getPath(args[1]))) { + byte[] buffer = new byte[1024]; + int len; + while ((len = input.read(buffer)) != -1) { + System.out.write(buffer, 0, len); + } + + } catch (IOException e) { + e.printStackTrace(); + System.exit(1); + } + } +} From 9378d4b0660391d7372f824ba184dad882d45cf1 Mon Sep 17 00:00:00 2001 From: Taras Ledkov Date: Fri, 31 Jan 2014 11:57:53 +0100 Subject: [PATCH 071/159] 8032056: Create demo to illustrate new practices of the default methods usage Reviewed-by: briangoetz, rfield, psandoz --- .../lambda/DefaultMethods/ArrayIterator.java | 118 ++++++++++++++ .../DefaultMethods/DiamondInheritance.java | 145 ++++++++++++++++++ .../lambda/DefaultMethods/Inheritance.java | 142 +++++++++++++++++ .../sample/lambda/DefaultMethods/MixIn.java | 114 ++++++++++++++ .../lambda/DefaultMethods/Reflection.java | 136 ++++++++++++++++ .../lambda/DefaultMethods/SimplestUsage.java | 91 +++++++++++ 6 files changed, 746 insertions(+) create mode 100644 jdk/src/share/sample/lambda/DefaultMethods/ArrayIterator.java create mode 100644 jdk/src/share/sample/lambda/DefaultMethods/DiamondInheritance.java create mode 100644 jdk/src/share/sample/lambda/DefaultMethods/Inheritance.java create mode 100644 jdk/src/share/sample/lambda/DefaultMethods/MixIn.java create mode 100644 jdk/src/share/sample/lambda/DefaultMethods/Reflection.java create mode 100644 jdk/src/share/sample/lambda/DefaultMethods/SimplestUsage.java diff --git a/jdk/src/share/sample/lambda/DefaultMethods/ArrayIterator.java b/jdk/src/share/sample/lambda/DefaultMethods/ArrayIterator.java new file mode 100644 index 00000000000..2eca80149b8 --- /dev/null +++ b/jdk/src/share/sample/lambda/DefaultMethods/ArrayIterator.java @@ -0,0 +1,118 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.util.Iterator; +import java.util.NoSuchElementException; + +/** + * The code sample illustrates the usage of default methods in the JDK 8. Most + * implementations of {@link Iterator} don't provide a useful + * {@link Iterator#remove()} method, however, + * they still have to implement this method to throw + * an UnsupportedOperationException. With the default method, the same + * default behavior in interface Iterator itself can be provided. + */ +public class ArrayIterator { + + /** Close the constructor because ArrayIterator is part of the utility + * class. + */ + protected ArrayIterator() { + throw new UnsupportedOperationException(); + } + + /** + * Returns an iterator that goes over the elements in the array. + * + * @param type of an array element + * @param array source array to iterate over it + * @return an iterator that goes over the elements in the array + */ + public static Iterator iterator(final E[] array) { + return new Iterator() { + /** + * Index of the current position + * + */ + private int index = 0; + + /** + * Returns the next element in the iteration + * + * @return the next element in the iteration + * @throws NoSuchElementException if the iteration has no more + * elements + */ + @Override + public boolean hasNext() { + return (index < array.length); + } + + /** + * Returns {@code true} if the iteration has more elements. (In + * other words, returns {@code true} if {@link #next} returns + * an element, rather than throwing an exception.) + * + * @return {@code true} if the iteration has more elements + */ + @Override + public E next() { + if (!hasNext()) { + throw new NoSuchElementException(); + } + return array[index++]; + } + + /** + * This method does not need to be overwritten in JDK 8. + */ + //@Override + //public void remove() { + // throw UnsupportedOperationException( + // "Arrays don't support remove.") + //} + }; + } + + /** + * Sample usage of the ArrayIterator + * + * @param args command-line arguments + */ + public static void main(final String[] args) { + Iterator it = ArrayIterator.iterator( + new String[]{"one", "two", "three"}); + + while (it.hasNext()) { + System.out.println(it.next()); + } + } +} diff --git a/jdk/src/share/sample/lambda/DefaultMethods/DiamondInheritance.java b/jdk/src/share/sample/lambda/DefaultMethods/DiamondInheritance.java new file mode 100644 index 00000000000..9214d58a788 --- /dev/null +++ b/jdk/src/share/sample/lambda/DefaultMethods/DiamondInheritance.java @@ -0,0 +1,145 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * This sample diamond interface inheritance with default methods. + * If there's not already a unique method implementation to inherit, + * you must provide it. The inheritance diagram is similar to the following: + *
+ *                   Animal
+ *                    /   \
+ *                 Horse   Bird
+ *                    \   /
+ *                   Pegasus
+ * 
+ * + * Both {@link Horse} and {@link Bird} interfaces implements the go + * method. The {@link Pegasus} class have to overrides the + * go method. + * + * The new syntax of super-call is used here: + *
+ *     <interface_name>.super.<method>(...);
+ *     For example:  Horse.super.go();
+ * 
So, Pegasus moves like a horse. + */ +public class DiamondInheritance { + + /** + * Base interface to illustrate the diamond inheritance. + * + * @see DiamondInheritance + */ + public interface Animal { + + /** + * Return string representation of the "go" action for concrete animal + * + * @return string representation of the "go" action for concrete animal + */ + String go(); + } + + /** + * Interface to illustrate the diamond inheritance. + * + * @see DiamondInheritance + */ + public interface Horse extends Animal { + + /** + * Return string representation of the "go" action for horse + * + * @return string representation of the "go" action for horse + */ + @Override + default String go() { + return this.getClass().getSimpleName() + " walks on four legs"; + } + } + + /** + * Interface to illustrate the diamond inheritance. + * + * @see DiamondInheritance + */ + public interface Bird extends Animal { + + /** + * Return string representation of the "go" action for bird + * + * @return string representation of the "go" action for bird + */ + @Override + default String go() { + return this.getClass().getSimpleName() + " walks on two legs"; + } + + /** + * Return string representation of the "fly" action for bird + * + * @return string representation of the "fly" action for bird + */ + default String fly() { + return "I can fly"; + } + } + + /** + * Class to illustrate the diamond inheritance. Pegasus must mix horse and + * bird behavior. + * + * @see DiamondInheritance + */ + public static class Pegasus implements Horse, Bird { + + /** + * Return string representation of the "go" action for the fictitious + * creature Pegasus + * + * @return string representation of the "go" action for the fictitious + * creature Pegasus + */ + @Override + public String go() { + return Horse.super.go(); + } + } + + /** + * Illustrate the behavior of the {@link Pegasus} class + * + * @param args command line arguments + */ + public static void main(final String[] args) { + System.out.println(new Pegasus().go()); + } +} diff --git a/jdk/src/share/sample/lambda/DefaultMethods/Inheritance.java b/jdk/src/share/sample/lambda/DefaultMethods/Inheritance.java new file mode 100644 index 00000000000..961de2c24d5 --- /dev/null +++ b/jdk/src/share/sample/lambda/DefaultMethods/Inheritance.java @@ -0,0 +1,142 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * The sample illustrates rules to resolve conflicts between inheritance + * candidates with default methods. There are two simple rules: + *
    + *
  • Class wins. If the superclass has a concrete or abstract declaration of + * this method, then it is preferred over all defaults.
  • + *
  • Subtype wins. If an interface extends another interface, and both provide + * a default, then the more specific interface wins.
  • + *
+ */ +public class Inheritance { + + /** + * The behavior of an creature that can swim + */ + public interface Swimable { + + /** + * Return string representation of the swim action for a creature that + * can swim + * + * @return string representation of the swim action for a creature + * that can swim + */ + default String swim() { + return "I can swim."; + } + } + + /** + * The abstract class that overrides {@link #swim} method + */ + public abstract static class Fish implements Swimable { + + /** + * Return string representation of the swim action for a fish + * + * @return string representation of the swim action for a fish + */ + @Override + public String swim() { + return this.getClass().getSimpleName() + " swims under water"; + } + } + + /** + * This class is used for the illustration rule of 1. See the source code + * of the {@link #main} method. + *
+     *      System.out.println(new Tuna().swim()); //"Tuna swims under water" output is suspected here
+     * 
+ */ + public static class Tuna extends Fish implements Swimable { + } + + /** + * The behavior of an creature that can dive: the interface that overrides + * {@link #swim} method (subtype of {@link Swimable}) + */ + public interface Diveable extends Swimable { + + /** + * Return string representation of the swim action for a creature that + * can dive + * + * @return string representation of the swim action for a creature + * that can dive + */ + @Override + default String swim() { + return "I can swim on the surface of the water."; + } + + /** + * Return string representation of the dive action for a creature that + * can dive + * + * @return string representation of the dive action for a creature + * that can dive + */ + default String dive() { + return "I can dive."; + } + } + + /** + * This class is used for the illustration of rule 2. See the source code + * of the {@link #main} method + *
+     *      //"I can swim on the surface of the water." output is suspected here
+     *      System.out.println(new Duck().swim());
+     * 
+ */ + public static class Duck implements Swimable, Diveable { + } + + /** + * Illustrate behavior of the classes: {@link Tuna} and {@link Duck} + * + * @param args command line arguments + */ + public static void main(final String[] args) { + // Illustrates rule 1. The Fish.swim() implementation wins + //"Tuna swims under water" is output + System.out.println(new Tuna().swim()); + + // Illustrates rule 2. The Diveable.swim() implementation wins + //"I can swim on the surface of the water." is output + System.out.println(new Duck().swim()); + } +} diff --git a/jdk/src/share/sample/lambda/DefaultMethods/MixIn.java b/jdk/src/share/sample/lambda/DefaultMethods/MixIn.java new file mode 100644 index 00000000000..d9ed81dee27 --- /dev/null +++ b/jdk/src/share/sample/lambda/DefaultMethods/MixIn.java @@ -0,0 +1,114 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.io.IOException; +import java.lang.reflect.Field; + +/** + * The example illustrates how to use the default method for mixin. + * @see BuildType + * @see Debuggable + */ +public class MixIn { + + /** + * Implement this interface for a class that must be in debug print + */ + public interface Debuggable { + + /** + * Print the class name and all fields to a string. Uses reflection to + * obtain and access fields of this object. + * + * @return the string formatted like the following:
+         * State of the: <Class Name>
+         * <member name> : <value>
+         * ...
+         * 
+ */ + default String toDebugString() { + StringBuilder sb = new StringBuilder(); + sb.append("State of the: ").append( + this.getClass().getSimpleName()).append("\n"); + for (Class cls = this.getClass(); + cls != null; + cls = cls.getSuperclass()) { + for (Field f : cls.getDeclaredFields()) { + try { + f.setAccessible(true); + sb.append(f.getName()).append(" : "). + append(f.get(this)).append("\n"); + } catch (IllegalAccessException e) { + } + } + } + return sb.toString(); + } + } + + /** + * Sample exception class to demonstrate mixin. This enum inherits the + * behavior of the {@link Debuggable} + */ + public static enum BuildType implements Debuggable { + + BUILD(0, "-build"), + PLAN(0, "-plan"), + EXCLUDE(1, "-exclude"), + TOTAL(2, "-total"); + + private final int compareOrder; + private final String pathSuffix; + + private BuildType(int compareOrder, String pathSuffix) { + this.compareOrder = compareOrder; + this.pathSuffix = pathSuffix; + } + + public int getCompareOrder() { + return compareOrder; + } + + public String getPathSuffix() { + return pathSuffix; + } + } + + /** + * Illustrate the behavior of the MixClass + * + * @param args command-line arguments + * @throws java.io.IOException internal demo error + */ + public static void main(final String[] args) throws IOException { + System.out.println(BuildType.BUILD.toDebugString()); + } +} diff --git a/jdk/src/share/sample/lambda/DefaultMethods/Reflection.java b/jdk/src/share/sample/lambda/DefaultMethods/Reflection.java new file mode 100644 index 00000000000..78424a240e8 --- /dev/null +++ b/jdk/src/share/sample/lambda/DefaultMethods/Reflection.java @@ -0,0 +1,136 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +import java.lang.reflect.InvocationTargetException; +import java.lang.reflect.Method; +import java.util.Arrays; +import java.util.stream.Stream; + +/** + * The code sample illustrates changes in the reflection API linked + * default methods. Since Java SE 8, a new method is added into the class + * java.lang.reflect.Method, with which you can reflectively + * determine whether or not a default method provided by an interface + * (Method.isDefault()). + */ +public class Reflection { + + /** + * Base interface to illustrate the new reflection API. + * + * @see Dog + */ + public interface Animal { + + /** + * Return string representation of the eat action for Animal + * + * @return string representation of the eat action for Animal + */ + default String eat() { + return this.getClass().getSimpleName() + + " eats like an ordinary animal"; + } + + /** + * Return string representation of the sleep action for Animal + * + * @return string representation of the sleep action for Animal + */ + default String sleep() { + return this.getClass().getSimpleName() + + " sleeps like an ordinary animal"; + } + + /** + * Return string representation of the go action for Animal + * + * @return string representation of the go action for Animal + */ + String go(); + } + + /** + * Dog class to illustrate the new reflection API. You can see that: + *
    + *
  • the {@link #go} and {@link #sleep} methods are not default. + * {@link #go} is not the default implementation and the {@link #sleep} + * method implementation wins as subtype (according with {@link Inheritance} + * rule. 2)
  • + *
  • the {@link #eat} is a simple default method that is not overridden + * in this class. + *
  • + *
+ */ + public static class Dog implements Animal { + + /** + * Return string representation of the go action for Dog + * + * @return string representation of the go action for Dog + */ + @Override + public String go() { + return "Dog walks on four legs"; + } + + /** + * Return string representation of the sleep action for Dog + * + * @return string representation of the sleep action for Dog + */ + @Override + public String sleep() { + return "Dog sleeps"; + } + } + + /** + * Illustrate the usage of the method java.lang.reflect.Method.isDefault() + * + * @param args command-line arguments + * @throws NoSuchMethodException internal demo error + */ + public static void main(final String[] args) throws NoSuchMethodException { + Dog dog = new Dog(); + Stream.of(Dog.class.getMethod("eat"), Dog.class.getMethod("go"), Dog.class.getMethod("sleep")) + .forEach((m) -> { + System.out.println("Method name: " + m.getName()); + System.out.println(" isDefault: " + m.isDefault()); + System.out.print(" invoke: "); + try { + m.invoke(dog); + } catch (IllegalAccessException | IllegalArgumentException | InvocationTargetException ex) { + } + System.out.println(); + }); + } +} diff --git a/jdk/src/share/sample/lambda/DefaultMethods/SimplestUsage.java b/jdk/src/share/sample/lambda/DefaultMethods/SimplestUsage.java new file mode 100644 index 00000000000..a971858f589 --- /dev/null +++ b/jdk/src/share/sample/lambda/DefaultMethods/SimplestUsage.java @@ -0,0 +1,91 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * - Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * - Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * - Neither the name of Oracle nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + * IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, + * THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ + +/** + * The sample illustrates the simplest use case of the default methods. + */ +public class SimplestUsage { + + /** + * The Animal interface provides the default implementation + * of the {@link #eat} method. + */ + public interface Animal { + + /** + * Return string representation of the eat action for Animal + * + * @return string representation of the eat action for Animal + */ + default String eat() { + return this.getClass().getSimpleName() + + " eats like an ordinary animal"; + } + } + + /** + * The Dog class doesn't have its own implementation of the {@link #eat} + * method and uses the default implementation. + */ + public static class Dog implements Animal { + } + + /** + * The Mosquito class implements {@link #eat} method, its own implementation + * overrides the default implementation. + * + */ + public static class Mosquito implements Animal { + + /** + * Return string representation of the eat action for Mosquito + * + * @return string representation of the eat action for Mosquito + */ + @Override + public String eat() { + return "Mosquito consumes blood"; + } + } + + /** + * Illustrate behavior of the classes: {@link Dog} and {@link Mosquito} + * + * @param args command-line arguments + */ + public static void main(String[] args) { + // "Dog eats like an ordinary animal" is output + System.out.println(new Dog().eat()); + + // "Mosquito consumes blood" is output + System.out.println(new Mosquito().eat()); + } +} From e3f4248c427de75f5d7fa953e283946cf0745079 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Markus=20Gr=C3=B6nlund?= Date: Fri, 31 Jan 2014 12:06:34 +0100 Subject: [PATCH 072/159] 8032518: fatal error has been detected by the Java Runtime Environment(access violation) Reviewed-by: sla, dholmes, jbachorik, dsamersoff, coleenp --- .../native/sun/management/DiagnosticCommandImpl.c | 10 +++++++--- 1 file changed, 7 insertions(+), 3 deletions(-) diff --git a/jdk/src/share/native/sun/management/DiagnosticCommandImpl.c b/jdk/src/share/native/sun/management/DiagnosticCommandImpl.c index 6258ac3e9cf..59f3f7db971 100644 --- a/jdk/src/share/native/sun/management/DiagnosticCommandImpl.c +++ b/jdk/src/share/native/sun/management/DiagnosticCommandImpl.c @@ -30,12 +30,12 @@ JNIEXPORT void JNICALL Java_sun_management_DiagnosticCommandImpl_setNotificationEnabled (JNIEnv *env, jobject dummy, jboolean enabled) { - if(jmm_version > JMM_VERSION_1_2_2) { - jmm_interface->SetDiagnosticFrameworkNotificationEnabled(env, enabled); - } else { + if (jmm_version <= JMM_VERSION_1_2_2) { JNU_ThrowByName(env, "java/lang/UnsupportedOperationException", "JMX interface to diagnostic framework notifications is not supported by this VM"); + return; } + jmm_interface->SetDiagnosticFrameworkNotificationEnabled(env, enabled); } JNIEXPORT jobjectArray JNICALL @@ -124,6 +124,7 @@ Java_sun_management_DiagnosticCommandImpl_getDiagnosticCommandInfo result = (*env)->NewObjectArray(env, num_commands, dcmdInfoCls, NULL); if (result == NULL) { JNU_ThrowOutOfMemoryError(env, 0); + return NULL; } if (num_commands == 0) { /* Handle the 'zero commands' case specially to avoid calling 'malloc()' */ @@ -133,6 +134,7 @@ Java_sun_management_DiagnosticCommandImpl_getDiagnosticCommandInfo dcmd_info_array = (dcmdInfo*) malloc(num_commands * sizeof(dcmdInfo)); if (dcmd_info_array == NULL) { JNU_ThrowOutOfMemoryError(env, NULL); + return NULL; } jmm_interface->GetDiagnosticCommandInfo(env, commands, dcmd_info_array); for (i=0; iSetObjectArrayElement(env, result, i, obj); } From 49605b7bf933f2e1470498aeb415f85103c5641b Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Fri, 31 Jan 2014 11:10:36 +0000 Subject: [PATCH 073/159] 7150539: HttpURLConnection.getResponseMessage() doesn't throw IOException on server error (OS X) Reviewed-by: michaelm, alanb --- jdk/test/sun/net/www/http/HttpClient/RetryPost.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/test/sun/net/www/http/HttpClient/RetryPost.java b/jdk/test/sun/net/www/http/HttpClient/RetryPost.java index 2f5add47afa..da7d868c3f2 100644 --- a/jdk/test/sun/net/www/http/HttpClient/RetryPost.java +++ b/jdk/test/sun/net/www/http/HttpClient/RetryPost.java @@ -55,8 +55,8 @@ public class RetryPost void doClient() { try { InetSocketAddress address = httpServer.getAddress(); - URL url = new URL("http://" + address.getHostName() + ":" + address.getPort() + "/test/"); - HttpURLConnection uc = (HttpURLConnection)url.openConnection(); + URL url = new URL("http://localhost:" + address.getPort() + "/test/"); + HttpURLConnection uc = (HttpURLConnection)url.openConnection(Proxy.NO_PROXY); uc.setDoOutput(true); uc.setRequestMethod("POST"); uc.getResponseCode(); From 592907e7f24d7262a2c0f69cd123c0e88d3d6753 Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Thu, 30 Jan 2014 00:02:46 +0400 Subject: [PATCH 074/159] 8027348: (process) Enhancement of handling async close of ProcessInputStream Reviewed-by: martin --- .../classes/java/lang/UNIXProcess.java.bsd | 44 +++--- .../classes/java/lang/UNIXProcess.java.linux | 44 +++--- .../java/lang/ProcessBuilder/CloseRace.java | 140 +++++++++++++++++ .../java/lang/Runtime/exec/CloseRace.java | 146 ------------------ 4 files changed, 176 insertions(+), 198 deletions(-) create mode 100644 jdk/test/java/lang/ProcessBuilder/CloseRace.java delete mode 100644 jdk/test/java/lang/Runtime/exec/CloseRace.java diff --git a/jdk/src/solaris/classes/java/lang/UNIXProcess.java.bsd b/jdk/src/solaris/classes/java/lang/UNIXProcess.java.bsd index df22bd2f3b9..7f0c3b12bf0 100644 --- a/jdk/src/solaris/classes/java/lang/UNIXProcess.java.bsd +++ b/jdk/src/solaris/classes/java/lang/UNIXProcess.java.bsd @@ -342,47 +342,39 @@ final class UNIXProcess extends Process { ProcessPipeInputStream(int fd) { super(new FileInputStream(newFileDescriptor(fd))); } - - private InputStream drainInputStream(InputStream in) + private static byte[] drainInputStream(InputStream in) throws IOException { int n = 0; int j; byte[] a = null; - synchronized (closeLock) { - if (buf == null) // asynchronous close()? - return null; // discard - j = in.available(); - } - while (j > 0) { + while ((j = in.available()) > 0) { a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j); - synchronized (closeLock) { - if (buf == null) // asynchronous close()? - return null; // discard - n += in.read(a, n, j); - j = in.available(); - } + n += in.read(a, n, j); } - return (a == null) ? - ProcessBuilder.NullInputStream.INSTANCE : - new ByteArrayInputStream(n == a.length ? a : Arrays.copyOf(a, n)); + return (a == null || n == a.length) ? a : Arrays.copyOf(a, n); } /** Called by the process reaper thread when the process exits. */ synchronized void processExited() { - try { - InputStream in = this.in; - if (in != null) { - InputStream stragglers = drainInputStream(in); - in.close(); - this.in = stragglers; - } - } catch (IOException ignored) { } + synchronized (closeLock) { + try { + InputStream in = this.in; + // this stream is closed if and only if: in == null + if (in != null) { + byte[] stragglers = drainInputStream(in); + in.close(); + this.in = (stragglers == null) ? + ProcessBuilder.NullInputStream.INSTANCE : + new ByteArrayInputStream(stragglers); + } + } catch (IOException ignored) {} + } } @Override public void close() throws IOException { // BufferedInputStream#close() is not synchronized unlike most other methods. - // Synchronizing helps avoid racing with drainInputStream(). + // Synchronizing helps avoid race with processExited(). synchronized (closeLock) { super.close(); } diff --git a/jdk/src/solaris/classes/java/lang/UNIXProcess.java.linux b/jdk/src/solaris/classes/java/lang/UNIXProcess.java.linux index 5ce8a61682a..be267d3ef0c 100644 --- a/jdk/src/solaris/classes/java/lang/UNIXProcess.java.linux +++ b/jdk/src/solaris/classes/java/lang/UNIXProcess.java.linux @@ -344,47 +344,39 @@ final class UNIXProcess extends Process { ProcessPipeInputStream(int fd) { super(new FileInputStream(newFileDescriptor(fd))); } - - private InputStream drainInputStream(InputStream in) + private static byte[] drainInputStream(InputStream in) throws IOException { int n = 0; int j; byte[] a = null; - synchronized (closeLock) { - if (buf == null) // asynchronous close()? - return null; // discard - j = in.available(); - } - while (j > 0) { + while ((j = in.available()) > 0) { a = (a == null) ? new byte[j] : Arrays.copyOf(a, n + j); - synchronized (closeLock) { - if (buf == null) // asynchronous close()? - return null; // discard - n += in.read(a, n, j); - j = in.available(); - } + n += in.read(a, n, j); } - return (a == null) ? - ProcessBuilder.NullInputStream.INSTANCE : - new ByteArrayInputStream(n == a.length ? a : Arrays.copyOf(a, n)); + return (a == null || n == a.length) ? a : Arrays.copyOf(a, n); } /** Called by the process reaper thread when the process exits. */ synchronized void processExited() { - try { - InputStream in = this.in; - if (in != null) { - InputStream stragglers = drainInputStream(in); - in.close(); - this.in = stragglers; - } - } catch (IOException ignored) { } + synchronized (closeLock) { + try { + InputStream in = this.in; + // this stream is closed if and only if: in == null + if (in != null) { + byte[] stragglers = drainInputStream(in); + in.close(); + this.in = (stragglers == null) ? + ProcessBuilder.NullInputStream.INSTANCE : + new ByteArrayInputStream(stragglers); + } + } catch (IOException ignored) {} + } } @Override public void close() throws IOException { // BufferedInputStream#close() is not synchronized unlike most other methods. - // Synchronizing helps avoid racing with drainInputStream(). + // Synchronizing helps avoid race with processExited(). synchronized (closeLock) { super.close(); } diff --git a/jdk/test/java/lang/ProcessBuilder/CloseRace.java b/jdk/test/java/lang/ProcessBuilder/CloseRace.java new file mode 100644 index 00000000000..ff2e81fe7a8 --- /dev/null +++ b/jdk/test/java/lang/ProcessBuilder/CloseRace.java @@ -0,0 +1,140 @@ +/* + * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8024521 + * @summary Closing ProcessPipeInputStream at the time the process exits is racy + * and leads to data corruption. Run this test manually (as + * an ordinary java program) with -Xmx8M to repro bug 8024521. + * @run main/othervm -Xmx8M -Dtest.duration=2 CloseRace + */ + +import java.io.*; +import java.util.ArrayList; +import java.util.List; + +public class CloseRace { + private static final String BIG_FILE = "bigfile"; + + private static final int[] procFDs = new int[6]; + + /** default value sufficient to repro bug 8024521. */ + private static final int testDurationSeconds + = Integer.getInteger("test.duration", 600); + + static boolean fdInUse(int i) { + return new File("/proc/self/fd/" + i).exists(); + } + + static boolean[] procFDsInUse() { + boolean[] inUse = new boolean[procFDs.length]; + for (int i = 0; i < procFDs.length; i++) + inUse[i] = fdInUse(procFDs[i]); + return inUse; + } + + static int count(boolean[] bits) { + int count = 0; + for (int i = 0; i < bits.length; i++) + count += bits[i] ? 1 : 0; + return count; + } + + public static void main(String args[]) throws Exception { + if (!(new File("/proc/self/fd").isDirectory())) + return; + + // Catch Errors from process reaper + Thread.setDefaultUncaughtExceptionHandler + ((t, e) -> { e.printStackTrace(); System.exit(1); }); + + try (RandomAccessFile f = new RandomAccessFile(BIG_FILE, "rw")) { + f.setLength(Runtime.getRuntime().maxMemory()); // provoke OOME + } + + for (int i = 0, j = 0; j < procFDs.length; i++) + if (!fdInUse(i)) + procFDs[j++] = i; + + Thread[] threads = { + new Thread(new OpenLoop()), + new Thread(new ExecLoop()), + }; + for (Thread thread : threads) + thread.start(); + + Thread.sleep(testDurationSeconds * 1000); + + for (Thread thread : threads) + thread.interrupt(); + for (Thread thread : threads) + thread.join(); + } + + static class OpenLoop implements Runnable { + public void run() { + while (!Thread.interrupted()) { + try { + // wait for ExecLoop to finish creating process + do {} while (count(procFDsInUse()) != 3); + List iss = new ArrayList<>(4); + + // eat up three "holes" (closed ends of pipe fd pairs) + for (int i = 0; i < 3; i++) + iss.add(new FileInputStream(BIG_FILE)); + do {} while (count(procFDsInUse()) == procFDs.length); + // hopefully this will racily occupy empty fd slot + iss.add(new FileInputStream(BIG_FILE)); + Thread.sleep(1); // Widen race window + for (InputStream is : iss) + is.close(); + } catch (InterruptedException e) { + break; + } catch (Exception e) { + throw new Error(e); + } + } + } + } + + static class ExecLoop implements Runnable { + public void run() { + ProcessBuilder builder = new ProcessBuilder("/bin/true"); + while (!Thread.interrupted()) { + try { + // wait for OpenLoop to finish + do {} while (count(procFDsInUse()) > 0); + Process process = builder.start(); + InputStream is = process.getInputStream(); + process.waitFor(); + is.close(); + } catch (InterruptedException e) { + break; + } catch (Exception e) { + throw new Error(e); + } + } + } + } +} diff --git a/jdk/test/java/lang/Runtime/exec/CloseRace.java b/jdk/test/java/lang/Runtime/exec/CloseRace.java deleted file mode 100644 index a1e57902e31..00000000000 --- a/jdk/test/java/lang/Runtime/exec/CloseRace.java +++ /dev/null @@ -1,146 +0,0 @@ -/* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. - * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. - * - * This code is free software; you can redistribute it and/or modify it - * under the terms of the 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 8024521 - * @summary Closing ProcessPipeInputStream at the time the process exits is racy - * and leads to the data corruption. - * @library /lib/testlibrary - * @run main/othervm/timeout=80 CloseRace - */ - -/** - * This test has a little chance to catch the race during the given default - * time gap of 20 seconds. To increase the time gap, set the system property - * CloseRaceTimeGap=N to the number of seconds. - * Jtreg's timeoutFactor should also be set appropriately. - * - * For example, to run the test for 10 minutes: - * > jtreg \ - * -testjdk:$(PATH_TO_TESTED_JDK) \ - * -timeoutFactor:10 \ - * -DCloseRaceTimeGap=600 \ - * $(PATH_TO_TESTED_JDK_SOURCE)/test/java/lang/Runtime/exec/CloseRace.java - */ - -import java.io.*; -import java.nio.file.Files; -import java.nio.file.Path; -import java.nio.file.Paths; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.LinkedList; -import java.util.List; -import jdk.testlibrary.OutputAnalyzer; -import static jdk.testlibrary.ProcessTools.*; - -public class CloseRace { - - public static void main(String args[]) throws Exception { - ProcessBuilder pb = createJavaProcessBuilder("-Xmx64M", "CloseRace$Child", - System.getProperty("CloseRaceTimeGap", "20")); - OutputAnalyzer oa = new OutputAnalyzer(pb.start()); - oa.stderrShouldNotContain("java.lang.OutOfMemoryError"); - } - - public static class Child { - private static final String BIG_FILE = "bigfile"; - private static final String SMALL_FILE = "smallfile"; - private static int timeGap = 20; // seconds - - public static void main(String args[]) throws Exception { - if (args.length > 0) { - try { - timeGap = Integer.parseUnsignedInt(args[0]); - timeGap = Integer.max(timeGap, 10); - timeGap = Integer.min(timeGap, 10 * 60 * 60); // no more than 10 hours - } catch (NumberFormatException ignore) {} - } - try (RandomAccessFile f = new RandomAccessFile(BIG_FILE, "rw")) { - f.setLength(1024 * 1024 * 1024); // 1 Gb, greater than max heap size - } - try (FileOutputStream fs = new FileOutputStream(SMALL_FILE); - PrintStream ps = new PrintStream(fs)) { - for (int i = 0; i < 128; ++i) - ps.println("line of text"); - } - - List threads = new LinkedList<>(); - for (int i = 0; i < 99; ++i) { - Thread t = new Thread (new OpenLoop()); - t.start(); - threads.add(t); - } - Thread t2 = new Thread (new ExecLoop()); - t2.start(); - threads.add(t2); - - Thread.sleep(timeGap); - - for (Thread t : threads) { - t.interrupt(); - t.join(); - } - } - - private static class OpenLoop implements Runnable { - public void run() { - final Path bigFilePath = Paths.get(BIG_FILE); - while (!Thread.interrupted()) { - try (InputStream in = Files.newInputStream(bigFilePath)) { - // Widen the race window by sleeping 1ms - Thread.sleep(1); - } catch (InterruptedException e) { - break; - } catch (Exception e) { - System.err.println(e); - } - } - } - } - - private static class ExecLoop implements Runnable { - public void run() { - List command = new ArrayList<>( - Arrays.asList("/bin/cat", SMALL_FILE)); - while (!Thread.interrupted()) { - try { - ProcessBuilder builder = new ProcessBuilder(command); - final Process process = builder.start(); - InputStream is = process.getInputStream(); - InputStreamReader isr = new InputStreamReader(is); - BufferedReader br = new BufferedReader(isr); - while (br.readLine() != null) {} - process.waitFor(); - isr.close(); - } catch (InterruptedException e) { - break; - } catch (Exception e) { - System.err.println(e); - } - } - } - } - } -} From b9f32d484285c5122114022115cbaa8a65b30c1f Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Wed, 29 Jan 2014 22:55:43 +0100 Subject: [PATCH 075/159] 8033119: Improve and document boot-jdk.m4 Reviewed-by: erikj --- common/autoconf/boot-jdk.m4 | 94 +- common/autoconf/generated-configure.sh | 2121 ++++++++++++++++++++---- common/autoconf/spec.gmk.in | 16 +- 3 files changed, 1866 insertions(+), 365 deletions(-) diff --git a/common/autoconf/boot-jdk.m4 b/common/autoconf/boot-jdk.m4 index ad8dab31e73..dde3c926c2f 100644 --- a/common/autoconf/boot-jdk.m4 +++ b/common/autoconf/boot-jdk.m4 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -23,6 +23,34 @@ # questions. # +######################################################################## +# This file handles detection of the Boot JDK. The Boot JDK detection +# process has been developed as a response to solve a complex real-world +# problem. Initially, it was simple, but it has grown as platform after +# platform, idiosyncracy after idiosyncracy has been supported. +# +# The basic idea is this: +# 1) You need an acceptable *) JDK to use as a Boot JDK +# 2) There are several ways to locate a JDK, that are mostly platform +# dependent **) +# 3) You can have multiple JDKs installed +# 4) If possible, configure should try to dig out an acceptable JDK +# automatically, without having to resort to command-line options +# +# *) acceptable means e.g. JDK7 for building JDK8, a complete JDK (with +# javac) and not a JRE, etc. +# +# **) On Windows we typically use a well-known path. +# On MacOSX we typically use the tool java_home. +# On Linux we typically find javac in the $PATH, and then follow a +# chain of symlinks that often ends up in a real JDK. +# +# This leads to the code where we check in different ways to locate a +# JDK, and if one is found, check if it is acceptable. If not, we print +# our reasons for rejecting it (useful when debugging non-working +# configure situations) and continue checking the next one. +######################################################################## + # Execute the check given as argument, and verify the result # If the Boot JDK was previously found, do nothing # $1 A command line (typically autoconf macro) to execute @@ -54,10 +82,10 @@ AC_DEFUN([BOOTJDK_DO_CHECK], BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - [FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'`] - if test "x$FOUND_VERSION_78" = x; then + [FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'`] + if test "x$FOUND_CORRECT_VERSION" = x; then AC_MSG_NOTICE([Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring]) - AC_MSG_NOTICE([(Your Boot JDK must be version 7 or 8)]) + AC_MSG_NOTICE([(Your Boot JDK must be version 7, 8 or 9)]) BOOT_JDK_FOUND=no else # We're done! :-) @@ -136,12 +164,26 @@ AC_DEFUN([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK], ]) # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) +# $1: Argument to the java_home binary (optional) AC_DEFUN([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME], [ if test -x /usr/libexec/java_home; then - BOOT_JDK=`/usr/libexec/java_home` + BOOT_JDK=`/usr/libexec/java_home $1` BOOT_JDK_FOUND=maybe - AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home]) + AC_MSG_NOTICE([Found potential Boot JDK using /usr/libexec/java_home $1]) + fi +]) + +# Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? +AC_DEFUN([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR], +[ + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + # First check at user selected default + BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME()]) + # If that did not work out (e.g. too old), try explicit versions instead + BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.9])]) + BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.8])]) + BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME([-v 1.7])]) fi ]) @@ -201,14 +243,19 @@ AC_DEFUN([BOOTJDK_CHECK_WELL_KNOWN_LOCATIONS], # $2 = name of binary AC_DEFUN([BOOTJDK_CHECK_TOOL_IN_BOOTJDK], [ - AC_MSG_CHECKING([for $2 in Boot JDK]) - $1=$BOOT_JDK/bin/$2 - if test ! -x [$]$1; then - AC_MSG_RESULT(not found) - AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk]) - AC_MSG_ERROR([Could not find $2 in the Boot JDK]) - fi - AC_MSG_RESULT(ok) + # Use user overridden value if available, otherwise locate tool in the Boot JDK. + BASIC_SETUP_TOOL($1, + [ + AC_MSG_CHECKING([for $2 in Boot JDK]) + $1=$BOOT_JDK/bin/$2 + if test ! -x [$]$1; then + AC_MSG_RESULT(not found) + AC_MSG_NOTICE([Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk]) + AC_MSG_ERROR([Could not find $2 in the Boot JDK]) + fi + AC_MSG_RESULT(ok) + AC_SUBST($1) + ]) ]) ############################################################################### @@ -238,12 +285,12 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], # Test: Is bootjdk available from builddeps? BOOTJDK_DO_CHECK([BOOTJDK_CHECK_BUILDDEPS]) + # Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? + BOOTJDK_DO_CHECK([BOOTJDK_CHECK_MACOSX_JAVA_LOCATOR]) + # Test: Is $JAVA_HOME set? BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_HOME]) - # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) - BOOTJDK_DO_CHECK([BOOTJDK_CHECK_LIBEXEC_JAVA_HOME]) - # Test: Is there a java or javac in the PATH, which is a symlink to the JDK? BOOTJDK_DO_CHECK([BOOTJDK_CHECK_JAVA_IN_PATH_IS_SYMLINK]) @@ -275,13 +322,12 @@ AC_DEFUN_ONCE([BOOTJDK_SETUP_BOOT_JDK], AC_SUBST(BOOT_JDK) # Setup tools from the Boot JDK. - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA,java) - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC,javac) - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH,javah) - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAP,javap) - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR,jar) - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(RMIC,rmic) - BOOTJDK_CHECK_TOOL_IN_BOOTJDK(NATIVE2ASCII,native2ascii) + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVA, java) + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAC, javac) + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAVAH, javah) + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JAR, jar) + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(NATIVE2ASCII, native2ascii) + BOOTJDK_CHECK_TOOL_IN_BOOTJDK(JARSIGNER, jarsigner) # Finally, set some other options... diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index f7dc3f66d6d..998d2004ea2 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -792,6 +792,12 @@ LANGTOOLS_TOPDIR BOOT_JDK_JVMARGS JAVAC_FLAGS BOOT_JDK_SOURCETARGET +JARSIGNER +NATIVE2ASCII +JAR +JAVAH +JAVAC +JAVA BOOT_JDK BOOT_TOOLSJAR BOOT_RTJAR @@ -1134,6 +1140,12 @@ DSYMUTIL XATTR CODESIGN PKG_CONFIG +JAVA +JAVAC +JAVAH +JAR +NATIVE2ASCII +JARSIGNER BUILD_CC BUILD_CXX BUILD_LD @@ -1980,6 +1992,13 @@ Some influential environment variables: XATTR Override default value for XATTR CODESIGN Override default value for CODESIGN PKG_CONFIG path to pkg-config utility + JAVA Override default value for JAVA + JAVAC Override default value for JAVAC + JAVAH Override default value for JAVAH + JAR Override default value for JAR + NATIVE2ASCII + Override default value for NATIVE2ASCII + JARSIGNER Override default value for JARSIGNER BUILD_CC Override default value for BUILD_CC BUILD_CXX Override default value for BUILD_CXX BUILD_LD Override default value for BUILD_LD @@ -3485,7 +3504,7 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # ... then the rest # -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -3509,6 +3528,34 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # questions. # +######################################################################## +# This file handles detection of the Boot JDK. The Boot JDK detection +# process has been developed as a response to solve a complex real-world +# problem. Initially, it was simple, but it has grown as platform after +# platform, idiosyncracy after idiosyncracy has been supported. +# +# The basic idea is this: +# 1) You need an acceptable *) JDK to use as a Boot JDK +# 2) There are several ways to locate a JDK, that are mostly platform +# dependent **) +# 3) You can have multiple JDKs installed +# 4) If possible, configure should try to dig out an acceptable JDK +# automatically, without having to resort to command-line options +# +# *) acceptable means e.g. JDK7 for building JDK8, a complete JDK (with +# javac) and not a JRE, etc. +# +# **) On Windows we typically use a well-known path. +# On MacOSX we typically use the tool java_home. +# On Linux we typically find javac in the $PATH, and then follow a +# chain of symlinks that often ends up in a real JDK. +# +# This leads to the code where we check in different ways to locate a +# JDK, and if one is found, check if it is acceptable. If not, we print +# our reasons for rejecting it (useful when debugging non-working +# configure situations) and continue checking the next one. +######################################################################## + # Execute the check given as argument, and verify the result # If the Boot JDK was previously found, do nothing # $1 A command line (typically autoconf macro) to execute @@ -3527,6 +3574,10 @@ ac_configure="$SHELL $ac_aux_dir/configure" # Please don't use this var. # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) +# $1: Argument to the java_home binary (optional) + + +# Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? # Look for a jdk in the given path. If there are multiple, try to select the newest. @@ -4036,7 +4087,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1390994270 +DATE_WHEN_GENERATED=1391032272 ############################################################################### # @@ -19491,12 +19542,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -19823,12 +19874,942 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} + BOOT_JDK_FOUND=no + else + # We're done! :-) + BOOT_JDK_FOUND=yes + + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # Input might be given as Windows format, start by converting to + # unix format. + path="$BOOT_JDK" + new_path=`$CYGPATH -u "$path"` + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-stile (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + + if test "x$path" != "x$new_path"; then + BOOT_JDK="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} + fi + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + path="$BOOT_JDK" + has_colon=`$ECHO $path | $GREP ^.:` + new_path="$path" + if test "x$has_colon" = x; then + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $path` + fi + + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + if test "x$path" != "x$new_path"; then + BOOT_JDK="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} + fi + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + + else + # We're on a posix platform. Hooray! :) + path="$BOOT_JDK" + has_space=`$ECHO "$path" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 + fi + + # Use eval to expand a potential ~ + eval path="$path" + if test ! -f "$path" && test ! -d "$path"; then + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 + fi + + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 +$as_echo_n "checking for Boot JDK... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 +$as_echo "$BOOT_JDK" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 +$as_echo_n "checking Boot JDK version... " >&6; } + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 +$as_echo "$BOOT_JDK_VERSION" >&6; } + fi # end check jdk version + fi # end check rt.jar + fi # end check javac + fi # end check java + fi # end check boot jdk found + fi + + + # Test: On MacOS X, can we find a boot jdk using /usr/libexec/java_home? + + if test "x$BOOT_JDK_FOUND" = xno; then + # Now execute the test + + if test "x$OPENJDK_TARGET_OS" = xmacosx; then + # First check at user selected default + + if test "x$BOOT_JDK_FOUND" = xno; then + # Now execute the test + + if test -x /usr/libexec/java_home; then + BOOT_JDK=`/usr/libexec/java_home ` + BOOT_JDK_FOUND=maybe + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using /usr/libexec/java_home " >&5 +$as_echo "$as_me: Found potential Boot JDK using /usr/libexec/java_home " >&6;} + fi + + + # If previous step claimed to have found a JDK, check it to see if it seems to be valid. + if test "x$BOOT_JDK_FOUND" = xmaybe; then + # Do we have a bin/java? + if test ! -x "$BOOT_JDK/bin/java"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} + BOOT_JDK_FOUND=no + else + # Do we have a bin/javac? + if test ! -x "$BOOT_JDK/bin/javac"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 +$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} + BOOT_JDK_FOUND=no + else + # Do we have an rt.jar? (On MacOSX it is called classes.jar) + if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} + BOOT_JDK_FOUND=no + else + # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` + + # Extra M4 quote needed to protect [] in grep expression. + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} + BOOT_JDK_FOUND=no + else + # We're done! :-) + BOOT_JDK_FOUND=yes + + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # Input might be given as Windows format, start by converting to + # unix format. + path="$BOOT_JDK" + new_path=`$CYGPATH -u "$path"` + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-stile (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + + if test "x$path" != "x$new_path"; then + BOOT_JDK="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} + fi + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + path="$BOOT_JDK" + has_colon=`$ECHO $path | $GREP ^.:` + new_path="$path" + if test "x$has_colon" = x; then + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $path` + fi + + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + if test "x$path" != "x$new_path"; then + BOOT_JDK="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} + fi + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + + else + # We're on a posix platform. Hooray! :) + path="$BOOT_JDK" + has_space=`$ECHO "$path" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 + fi + + # Use eval to expand a potential ~ + eval path="$path" + if test ! -f "$path" && test ! -d "$path"; then + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 + fi + + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 +$as_echo_n "checking for Boot JDK... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 +$as_echo "$BOOT_JDK" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 +$as_echo_n "checking Boot JDK version... " >&6; } + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 +$as_echo "$BOOT_JDK_VERSION" >&6; } + fi # end check jdk version + fi # end check rt.jar + fi # end check javac + fi # end check java + fi # end check boot jdk found + fi + + # If that did not work out (e.g. too old), try explicit versions instead + + if test "x$BOOT_JDK_FOUND" = xno; then + # Now execute the test + + if test -x /usr/libexec/java_home; then + BOOT_JDK=`/usr/libexec/java_home -v 1.9` + BOOT_JDK_FOUND=maybe + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using /usr/libexec/java_home -v 1.9" >&5 +$as_echo "$as_me: Found potential Boot JDK using /usr/libexec/java_home -v 1.9" >&6;} + fi + + + # If previous step claimed to have found a JDK, check it to see if it seems to be valid. + if test "x$BOOT_JDK_FOUND" = xmaybe; then + # Do we have a bin/java? + if test ! -x "$BOOT_JDK/bin/java"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} + BOOT_JDK_FOUND=no + else + # Do we have a bin/javac? + if test ! -x "$BOOT_JDK/bin/javac"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 +$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} + BOOT_JDK_FOUND=no + else + # Do we have an rt.jar? (On MacOSX it is called classes.jar) + if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} + BOOT_JDK_FOUND=no + else + # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` + + # Extra M4 quote needed to protect [] in grep expression. + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} + BOOT_JDK_FOUND=no + else + # We're done! :-) + BOOT_JDK_FOUND=yes + + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # Input might be given as Windows format, start by converting to + # unix format. + path="$BOOT_JDK" + new_path=`$CYGPATH -u "$path"` + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-stile (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + + if test "x$path" != "x$new_path"; then + BOOT_JDK="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} + fi + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + path="$BOOT_JDK" + has_colon=`$ECHO $path | $GREP ^.:` + new_path="$path" + if test "x$has_colon" = x; then + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $path` + fi + + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + if test "x$path" != "x$new_path"; then + BOOT_JDK="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} + fi + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + + else + # We're on a posix platform. Hooray! :) + path="$BOOT_JDK" + has_space=`$ECHO "$path" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 + fi + + # Use eval to expand a potential ~ + eval path="$path" + if test ! -f "$path" && test ! -d "$path"; then + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 + fi + + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 +$as_echo_n "checking for Boot JDK... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 +$as_echo "$BOOT_JDK" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 +$as_echo_n "checking Boot JDK version... " >&6; } + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 +$as_echo "$BOOT_JDK_VERSION" >&6; } + fi # end check jdk version + fi # end check rt.jar + fi # end check javac + fi # end check java + fi # end check boot jdk found + fi + + + if test "x$BOOT_JDK_FOUND" = xno; then + # Now execute the test + + if test -x /usr/libexec/java_home; then + BOOT_JDK=`/usr/libexec/java_home -v 1.8` + BOOT_JDK_FOUND=maybe + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using /usr/libexec/java_home -v 1.8" >&5 +$as_echo "$as_me: Found potential Boot JDK using /usr/libexec/java_home -v 1.8" >&6;} + fi + + + # If previous step claimed to have found a JDK, check it to see if it seems to be valid. + if test "x$BOOT_JDK_FOUND" = xmaybe; then + # Do we have a bin/java? + if test ! -x "$BOOT_JDK/bin/java"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} + BOOT_JDK_FOUND=no + else + # Do we have a bin/javac? + if test ! -x "$BOOT_JDK/bin/javac"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 +$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} + BOOT_JDK_FOUND=no + else + # Do we have an rt.jar? (On MacOSX it is called classes.jar) + if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} + BOOT_JDK_FOUND=no + else + # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` + + # Extra M4 quote needed to protect [] in grep expression. + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} + BOOT_JDK_FOUND=no + else + # We're done! :-) + BOOT_JDK_FOUND=yes + + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # Input might be given as Windows format, start by converting to + # unix format. + path="$BOOT_JDK" + new_path=`$CYGPATH -u "$path"` + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-stile (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + + if test "x$path" != "x$new_path"; then + BOOT_JDK="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} + fi + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + path="$BOOT_JDK" + has_colon=`$ECHO $path | $GREP ^.:` + new_path="$path" + if test "x$has_colon" = x; then + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $path` + fi + + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + if test "x$path" != "x$new_path"; then + BOOT_JDK="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} + fi + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + + else + # We're on a posix platform. Hooray! :) + path="$BOOT_JDK" + has_space=`$ECHO "$path" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 + fi + + # Use eval to expand a potential ~ + eval path="$path" + if test ! -f "$path" && test ! -d "$path"; then + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 + fi + + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 +$as_echo_n "checking for Boot JDK... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 +$as_echo "$BOOT_JDK" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 +$as_echo_n "checking Boot JDK version... " >&6; } + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 +$as_echo "$BOOT_JDK_VERSION" >&6; } + fi # end check jdk version + fi # end check rt.jar + fi # end check javac + fi # end check java + fi # end check boot jdk found + fi + + + if test "x$BOOT_JDK_FOUND" = xno; then + # Now execute the test + + if test -x /usr/libexec/java_home; then + BOOT_JDK=`/usr/libexec/java_home -v 1.7` + BOOT_JDK_FOUND=maybe + { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using /usr/libexec/java_home -v 1.7" >&5 +$as_echo "$as_me: Found potential Boot JDK using /usr/libexec/java_home -v 1.7" >&6;} + fi + + + # If previous step claimed to have found a JDK, check it to see if it seems to be valid. + if test "x$BOOT_JDK_FOUND" = xmaybe; then + # Do we have a bin/java? + if test ! -x "$BOOT_JDK/bin/java"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} + BOOT_JDK_FOUND=no + else + # Do we have a bin/javac? + if test ! -x "$BOOT_JDK/bin/javac"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 +$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} + BOOT_JDK_FOUND=no + else + # Do we have an rt.jar? (On MacOSX it is called classes.jar) + if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} + BOOT_JDK_FOUND=no + else + # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` + + # Extra M4 quote needed to protect [] in grep expression. + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} + BOOT_JDK_FOUND=no + else + # We're done! :-) + BOOT_JDK_FOUND=yes + + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + + # Input might be given as Windows format, start by converting to + # unix format. + path="$BOOT_JDK" + new_path=`$CYGPATH -u "$path"` + + # Cygwin tries to hide some aspects of the Windows file system, such that binaries are + # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered + # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then + # "foo.exe" is OK but "foo" is an error. + # + # This test is therefore slightly more accurate than "test -f" to check for file precense. + # It is also a way to make sure we got the proper file name for the real test later on. + test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` + if test "x$test_shortpath" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 + fi + + # Call helper function which possibly converts this using DOS-style short mode. + # If so, the updated path is stored in $new_path. + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + shortmode_path=`$CYGPATH -s -m -a "$input_path"` + path_after_shortmode=`$CYGPATH -u "$shortmode_path"` + if test "x$path_after_shortmode" != "x$input_to_shortpath"; then + # Going to short mode and back again did indeed matter. Since short mode is + # case insensitive, let's make it lowercase to improve readability. + shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + # Now convert it back to Unix-stile (cygpath) + input_path=`$CYGPATH -u "$shortmode_path"` + new_path="$input_path" + fi + fi + + test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` + if test "x$test_cygdrive_prefix" = x; then + # As a simple fix, exclude /usr/bin since it's not a real path. + if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then + # The path is in a Cygwin special directory (e.g. /home). We need this converted to + # a path prefixed by /cygdrive for fixpath to work. + new_path="$CYGWIN_ROOT_PATH$input_path" + fi + fi + + + if test "x$path" != "x$new_path"; then + BOOT_JDK="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} + fi + + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + + path="$BOOT_JDK" + has_colon=`$ECHO $path | $GREP ^.:` + new_path="$path" + if test "x$has_colon" = x; then + # Not in mixed or Windows style, start by that. + new_path=`cmd //c echo $path` + fi + + + input_path="$new_path" + # Check if we need to convert this using DOS-style short mode. If the path + # contains just simple characters, use it. Otherwise (spaces, weird characters), + # take no chances and rewrite it. + # Note: m4 eats our [], so we need to use [ and ] instead. + has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` + if test "x$has_forbidden_chars" != x; then + # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) + new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` + fi + + + windows_path="$new_path" + if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then + unix_path=`$CYGPATH -u "$windows_path"` + new_path="$unix_path" + elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then + unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` + new_path="$unix_path" + fi + + if test "x$path" != "x$new_path"; then + BOOT_JDK="$new_path" + { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 +$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} + fi + + # Save the first 10 bytes of this path to the storage, so fixpath can work. + all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") + + else + # We're on a posix platform. Hooray! :) + path="$BOOT_JDK" + has_space=`$ECHO "$path" | $GREP " "` + if test "x$has_space" != x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 +$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} + as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 + fi + + # Use eval to expand a potential ~ + eval path="$path" + if test ! -f "$path" && test ! -d "$path"; then + as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 + fi + + BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" + fi + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 +$as_echo_n "checking for Boot JDK... " >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 +$as_echo "$BOOT_JDK" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 +$as_echo_n "checking Boot JDK version... " >&6; } + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 +$as_echo "$BOOT_JDK_VERSION" >&6; } + fi # end check jdk version + fi # end check rt.jar + fi # end check javac + fi # end check java + fi # end check boot jdk found + fi + + fi + + + # If previous step claimed to have found a JDK, check it to see if it seems to be valid. + if test "x$BOOT_JDK_FOUND" = xmaybe; then + # Do we have a bin/java? + if test ! -x "$BOOT_JDK/bin/java"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} + BOOT_JDK_FOUND=no + else + # Do we have a bin/javac? + if test ! -x "$BOOT_JDK/bin/javac"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 +$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} + BOOT_JDK_FOUND=no + else + # Do we have an rt.jar? (On MacOSX it is called classes.jar) + if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} + BOOT_JDK_FOUND=no + else + # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? + BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` + + # Extra M4 quote needed to protect [] in grep expression. + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then + { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 +$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -20141,200 +21122,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} - BOOT_JDK_FOUND=no - else - # We're done! :-) - BOOT_JDK_FOUND=yes - - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - - # Input might be given as Windows format, start by converting to - # unix format. - path="$BOOT_JDK" - new_path=`$CYGPATH -u "$path"` - - # Cygwin tries to hide some aspects of the Windows file system, such that binaries are - # named .exe but called without that suffix. Therefore, "foo" and "foo.exe" are considered - # the same file, most of the time (as in "test -f"). But not when running cygpath -s, then - # "foo.exe" is OK but "foo" is an error. - # - # This test is therefore slightly more accurate than "test -f" to check for file precense. - # It is also a way to make sure we got the proper file name for the real test later on. - test_shortpath=`$CYGPATH -s -m "$new_path" 2> /dev/null` - if test "x$test_shortpath" = x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 -$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - as_fn_error $? "Cannot locate the the path of BOOT_JDK" "$LINENO" 5 - fi - - # Call helper function which possibly converts this using DOS-style short mode. - # If so, the updated path is stored in $new_path. - - input_path="$new_path" - # Check if we need to convert this using DOS-style short mode. If the path - # contains just simple characters, use it. Otherwise (spaces, weird characters), - # take no chances and rewrite it. - # Note: m4 eats our [], so we need to use [ and ] instead. - has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-._/a-zA-Z0-9]` - if test "x$has_forbidden_chars" != x; then - # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) - shortmode_path=`$CYGPATH -s -m -a "$input_path"` - path_after_shortmode=`$CYGPATH -u "$shortmode_path"` - if test "x$path_after_shortmode" != "x$input_to_shortpath"; then - # Going to short mode and back again did indeed matter. Since short mode is - # case insensitive, let's make it lowercase to improve readability. - shortmode_path=`$ECHO "$shortmode_path" | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - # Now convert it back to Unix-stile (cygpath) - input_path=`$CYGPATH -u "$shortmode_path"` - new_path="$input_path" - fi - fi - - test_cygdrive_prefix=`$ECHO $input_path | $GREP ^/cygdrive/` - if test "x$test_cygdrive_prefix" = x; then - # As a simple fix, exclude /usr/bin since it's not a real path. - if test "x`$ECHO $new_path | $GREP ^/usr/bin/`" = x; then - # The path is in a Cygwin special directory (e.g. /home). We need this converted to - # a path prefixed by /cygdrive for fixpath to work. - new_path="$CYGWIN_ROOT_PATH$input_path" - fi - fi - - - if test "x$path" != "x$new_path"; then - BOOT_JDK="$new_path" - { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 -$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} - fi - - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - - path="$BOOT_JDK" - has_colon=`$ECHO $path | $GREP ^.:` - new_path="$path" - if test "x$has_colon" = x; then - # Not in mixed or Windows style, start by that. - new_path=`cmd //c echo $path` - fi - - - input_path="$new_path" - # Check if we need to convert this using DOS-style short mode. If the path - # contains just simple characters, use it. Otherwise (spaces, weird characters), - # take no chances and rewrite it. - # Note: m4 eats our [], so we need to use [ and ] instead. - has_forbidden_chars=`$ECHO "$input_path" | $GREP [^-_/:a-zA-Z0-9]` - if test "x$has_forbidden_chars" != x; then - # Now convert it to mixed DOS-style, short mode (no spaces, and / instead of \) - new_path=`cmd /c "for %A in (\"$input_path\") do @echo %~sA"|$TR \\\\\\\\ / | $TR 'ABCDEFGHIJKLMNOPQRSTUVWXYZ' 'abcdefghijklmnopqrstuvwxyz'` - fi - - - windows_path="$new_path" - if test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.cygwin"; then - unix_path=`$CYGPATH -u "$windows_path"` - new_path="$unix_path" - elif test "x$OPENJDK_BUILD_OS_ENV" = "xwindows.msys"; then - unix_path=`$ECHO "$windows_path" | $SED -e 's,^\\(.\\):,/\\1,g' -e 's,\\\\,/,g'` - new_path="$unix_path" - fi - - if test "x$path" != "x$new_path"; then - BOOT_JDK="$new_path" - { $as_echo "$as_me:${as_lineno-$LINENO}: Rewriting BOOT_JDK to \"$new_path\"" >&5 -$as_echo "$as_me: Rewriting BOOT_JDK to \"$new_path\"" >&6;} - fi - - # Save the first 10 bytes of this path to the storage, so fixpath can work. - all_fixpath_prefixes=("${all_fixpath_prefixes[@]}" "${new_path:0:10}") - - else - # We're on a posix platform. Hooray! :) - path="$BOOT_JDK" - has_space=`$ECHO "$path" | $GREP " "` - if test "x$has_space" != x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&5 -$as_echo "$as_me: The path of BOOT_JDK, which resolves as \"$path\", is invalid." >&6;} - as_fn_error $? "Spaces are not allowed in this path." "$LINENO" 5 - fi - - # Use eval to expand a potential ~ - eval path="$path" - if test ! -f "$path" && test ! -d "$path"; then - as_fn_error $? "The path of BOOT_JDK, which resolves as \"$path\", is not found." "$LINENO" 5 - fi - - BOOT_JDK="`cd "$path"; $THEPWDCMD -L`" - fi - - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for Boot JDK" >&5 -$as_echo_n "checking for Boot JDK... " >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK" >&5 -$as_echo "$BOOT_JDK" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking Boot JDK version" >&5 -$as_echo_n "checking Boot JDK version... " >&6; } - BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | $TR '\n\r' ' '` - { $as_echo "$as_me:${as_lineno-$LINENO}: result: $BOOT_JDK_VERSION" >&5 -$as_echo "$BOOT_JDK_VERSION" >&6; } - fi # end check jdk version - fi # end check rt.jar - fi # end check javac - fi # end check java - fi # end check boot jdk found - fi - - - # Test: Is there a /usr/libexec/java_home? (Typically on MacOSX) - - if test "x$BOOT_JDK_FOUND" = xno; then - # Now execute the test - - if test -x /usr/libexec/java_home; then - BOOT_JDK=`/usr/libexec/java_home` - BOOT_JDK_FOUND=maybe - { $as_echo "$as_me:${as_lineno-$LINENO}: Found potential Boot JDK using /usr/libexec/java_home" >&5 -$as_echo "$as_me: Found potential Boot JDK using /usr/libexec/java_home" >&6;} - fi - - - # If previous step claimed to have found a JDK, check it to see if it seems to be valid. - if test "x$BOOT_JDK_FOUND" = xmaybe; then - # Do we have a bin/java? - if test ! -x "$BOOT_JDK/bin/java"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&5 -$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/java; ignoring" >&6;} - BOOT_JDK_FOUND=no - else - # Do we have a bin/javac? - if test ! -x "$BOOT_JDK/bin/javac"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&5 -$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain bin/javac; ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (This might be an JRE instead of an JDK)" >&5 -$as_echo "$as_me: (This might be an JRE instead of an JDK)" >&6;} - BOOT_JDK_FOUND=no - else - # Do we have an rt.jar? (On MacOSX it is called classes.jar) - if test ! -f "$BOOT_JDK/jre/lib/rt.jar" && test ! -f "$BOOT_JDK/../Classes/classes.jar"; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&5 -$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.jar; ignoring" >&6;} - BOOT_JDK_FOUND=no - else - # Oh, this is looking good! We probably have found a proper JDK. Is it the correct version? - BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` - - # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then - { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 -$as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -20657,12 +21450,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -20872,12 +21665,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -21052,12 +21845,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -21260,12 +22053,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -21440,12 +22233,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -21648,12 +22441,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -21828,12 +22621,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -22036,12 +22829,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -22216,12 +23009,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -22411,12 +23204,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -22589,12 +23382,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -22785,12 +23578,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -22963,12 +23756,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -23158,12 +23951,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -23336,12 +24129,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -23532,12 +24325,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -23710,12 +24503,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -23887,12 +24680,12 @@ $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK did not contain an rt.ja BOOT_JDK_VERSION=`"$BOOT_JDK/bin/java" -version 2>&1 | head -n 1` # Extra M4 quote needed to protect [] in grep expression. - FOUND_VERSION_78=`echo $BOOT_JDK_VERSION | grep '\"1\.[78]\.'` - if test "x$FOUND_VERSION_78" = x; then + FOUND_CORRECT_VERSION=`echo $BOOT_JDK_VERSION | grep '\"1\.[789]\.'` + if test "x$FOUND_CORRECT_VERSION" = x; then { $as_echo "$as_me:${as_lineno-$LINENO}: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&5 $as_echo "$as_me: Potential Boot JDK found at $BOOT_JDK is incorrect JDK version ($BOOT_JDK_VERSION); ignoring" >&6;} - { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7 or 8)" >&5 -$as_echo "$as_me: (Your Boot JDK must be version 7 or 8)" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: (Your Boot JDK must be version 7, 8 or 9)" >&5 +$as_echo "$as_me: (Your Boot JDK must be version 7, 8 or 9)" >&6;} BOOT_JDK_FOUND=no else # We're done! :-) @@ -24093,104 +24886,768 @@ $as_echo "$as_me: This might be fixed by explicitely setting --with-boot-jdk" >& # Setup tools from the Boot JDK. - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for java in Boot JDK" >&5 + # Use user overridden value if available, otherwise locate tool in the Boot JDK. + + # Publish this variable in the help. + + + if test "x$JAVA" = x; then + # The variable is not set by user, try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for java in Boot JDK" >&5 $as_echo_n "checking for java in Boot JDK... " >&6; } - JAVA=$BOOT_JDK/bin/java - if test ! -x $JAVA; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 + JAVA=$BOOT_JDK/bin/java + if test ! -x $JAVA; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - as_fn_error $? "Could not find java in the Boot JDK" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 + as_fn_error $? "Could not find java in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javac in Boot JDK" >&5 + else + # The variable is set, but is it from the command line or the environment? + + # Try to remove the string !JAVA! from our list. + try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!JAVA!/} + if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then + # If it failed, the variable was not from the command line. Ignore it, + # but warn the user (except for BASH, which is always set by the calling BASH). + if test "xJAVA" != xBASH; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of JAVA from the environment. Use command line variables instead." >&5 +$as_echo "$as_me: WARNING: Ignoring value of JAVA from the environment. Use command line variables instead." >&2;} + fi + # Try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for java in Boot JDK" >&5 +$as_echo_n "checking for java in Boot JDK... " >&6; } + JAVA=$BOOT_JDK/bin/java + if test ! -x $JAVA; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + as_fn_error $? "Could not find java in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } + + + else + # If it succeeded, then it was overridden by the user. We will use it + # for the tool. + + # First remove it from the list of overridden variables, so we can test + # for unknown variables in the end. + CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var" + + # Check if the provided tool contains a complete path. + tool_specified="$JAVA" + tool_basename="${tool_specified##*/}" + if test "x$tool_basename" = "x$tool_specified"; then + # A command without a complete path is provided, search $PATH. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool JAVA=$tool_basename" >&5 +$as_echo "$as_me: Will search for user supplied tool JAVA=$tool_basename" >&6;} + # Extract the first word of "$tool_basename", so it can be a program name with args. +set dummy $tool_basename; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_JAVA+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $JAVA in + [\\/]* | ?:[\\/]*) + ac_cv_path_JAVA="$JAVA" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_JAVA="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +JAVA=$ac_cv_path_JAVA +if test -n "$JAVA"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVA" >&5 +$as_echo "$JAVA" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "x$JAVA" = x; then + as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5 + fi + else + # Otherwise we believe it is a complete path. Use it as it is. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool JAVA=$tool_specified" >&5 +$as_echo "$as_me: Will use user supplied tool JAVA=$tool_specified" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JAVA" >&5 +$as_echo_n "checking for JAVA... " >&6; } + if test ! -x "$tool_specified"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + as_fn_error $? "User supplied tool JAVA=$tool_specified does not exist or is not executable" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5 +$as_echo "$tool_specified" >&6; } + fi + fi + fi + + + + # Use user overridden value if available, otherwise locate tool in the Boot JDK. + + # Publish this variable in the help. + + + if test "x$JAVAC" = x; then + # The variable is not set by user, try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javac in Boot JDK" >&5 $as_echo_n "checking for javac in Boot JDK... " >&6; } - JAVAC=$BOOT_JDK/bin/javac - if test ! -x $JAVAC; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 + JAVAC=$BOOT_JDK/bin/javac + if test ! -x $JAVAC; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - as_fn_error $? "Could not find javac in the Boot JDK" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 + as_fn_error $? "Could not find javac in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javah in Boot JDK" >&5 + else + # The variable is set, but is it from the command line or the environment? + + # Try to remove the string !JAVAC! from our list. + try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!JAVAC!/} + if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then + # If it failed, the variable was not from the command line. Ignore it, + # but warn the user (except for BASH, which is always set by the calling BASH). + if test "xJAVAC" != xBASH; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of JAVAC from the environment. Use command line variables instead." >&5 +$as_echo "$as_me: WARNING: Ignoring value of JAVAC from the environment. Use command line variables instead." >&2;} + fi + # Try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javac in Boot JDK" >&5 +$as_echo_n "checking for javac in Boot JDK... " >&6; } + JAVAC=$BOOT_JDK/bin/javac + if test ! -x $JAVAC; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + as_fn_error $? "Could not find javac in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } + + + else + # If it succeeded, then it was overridden by the user. We will use it + # for the tool. + + # First remove it from the list of overridden variables, so we can test + # for unknown variables in the end. + CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var" + + # Check if the provided tool contains a complete path. + tool_specified="$JAVAC" + tool_basename="${tool_specified##*/}" + if test "x$tool_basename" = "x$tool_specified"; then + # A command without a complete path is provided, search $PATH. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool JAVAC=$tool_basename" >&5 +$as_echo "$as_me: Will search for user supplied tool JAVAC=$tool_basename" >&6;} + # Extract the first word of "$tool_basename", so it can be a program name with args. +set dummy $tool_basename; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_JAVAC+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $JAVAC in + [\\/]* | ?:[\\/]*) + ac_cv_path_JAVAC="$JAVAC" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_JAVAC="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +JAVAC=$ac_cv_path_JAVAC +if test -n "$JAVAC"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVAC" >&5 +$as_echo "$JAVAC" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "x$JAVAC" = x; then + as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5 + fi + else + # Otherwise we believe it is a complete path. Use it as it is. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool JAVAC=$tool_specified" >&5 +$as_echo "$as_me: Will use user supplied tool JAVAC=$tool_specified" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JAVAC" >&5 +$as_echo_n "checking for JAVAC... " >&6; } + if test ! -x "$tool_specified"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + as_fn_error $? "User supplied tool JAVAC=$tool_specified does not exist or is not executable" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5 +$as_echo "$tool_specified" >&6; } + fi + fi + fi + + + + # Use user overridden value if available, otherwise locate tool in the Boot JDK. + + # Publish this variable in the help. + + + if test "x$JAVAH" = x; then + # The variable is not set by user, try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javah in Boot JDK" >&5 $as_echo_n "checking for javah in Boot JDK... " >&6; } - JAVAH=$BOOT_JDK/bin/javah - if test ! -x $JAVAH; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 + JAVAH=$BOOT_JDK/bin/javah + if test ! -x $JAVAH; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - as_fn_error $? "Could not find javah in the Boot JDK" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 + as_fn_error $? "Could not find javah in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javap in Boot JDK" >&5 -$as_echo_n "checking for javap in Boot JDK... " >&6; } - JAVAP=$BOOT_JDK/bin/javap - if test ! -x $JAVAP; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 + else + # The variable is set, but is it from the command line or the environment? + + # Try to remove the string !JAVAH! from our list. + try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!JAVAH!/} + if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then + # If it failed, the variable was not from the command line. Ignore it, + # but warn the user (except for BASH, which is always set by the calling BASH). + if test "xJAVAH" != xBASH; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of JAVAH from the environment. Use command line variables instead." >&5 +$as_echo "$as_me: WARNING: Ignoring value of JAVAH from the environment. Use command line variables instead." >&2;} + fi + # Try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for javah in Boot JDK" >&5 +$as_echo_n "checking for javah in Boot JDK... " >&6; } + JAVAH=$BOOT_JDK/bin/javah + if test ! -x $JAVAH; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - as_fn_error $? "Could not find javap in the Boot JDK" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 + as_fn_error $? "Could not find javah in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jar in Boot JDK" >&5 + else + # If it succeeded, then it was overridden by the user. We will use it + # for the tool. + + # First remove it from the list of overridden variables, so we can test + # for unknown variables in the end. + CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var" + + # Check if the provided tool contains a complete path. + tool_specified="$JAVAH" + tool_basename="${tool_specified##*/}" + if test "x$tool_basename" = "x$tool_specified"; then + # A command without a complete path is provided, search $PATH. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool JAVAH=$tool_basename" >&5 +$as_echo "$as_me: Will search for user supplied tool JAVAH=$tool_basename" >&6;} + # Extract the first word of "$tool_basename", so it can be a program name with args. +set dummy $tool_basename; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_JAVAH+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $JAVAH in + [\\/]* | ?:[\\/]*) + ac_cv_path_JAVAH="$JAVAH" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_JAVAH="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +JAVAH=$ac_cv_path_JAVAH +if test -n "$JAVAH"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAVAH" >&5 +$as_echo "$JAVAH" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "x$JAVAH" = x; then + as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5 + fi + else + # Otherwise we believe it is a complete path. Use it as it is. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool JAVAH=$tool_specified" >&5 +$as_echo "$as_me: Will use user supplied tool JAVAH=$tool_specified" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JAVAH" >&5 +$as_echo_n "checking for JAVAH... " >&6; } + if test ! -x "$tool_specified"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + as_fn_error $? "User supplied tool JAVAH=$tool_specified does not exist or is not executable" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5 +$as_echo "$tool_specified" >&6; } + fi + fi + fi + + + + # Use user overridden value if available, otherwise locate tool in the Boot JDK. + + # Publish this variable in the help. + + + if test "x$JAR" = x; then + # The variable is not set by user, try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jar in Boot JDK" >&5 $as_echo_n "checking for jar in Boot JDK... " >&6; } - JAR=$BOOT_JDK/bin/jar - if test ! -x $JAR; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 + JAR=$BOOT_JDK/bin/jar + if test ! -x $JAR; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - as_fn_error $? "Could not find jar in the Boot JDK" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 + as_fn_error $? "Could not find jar in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for rmic in Boot JDK" >&5 -$as_echo_n "checking for rmic in Boot JDK... " >&6; } - RMIC=$BOOT_JDK/bin/rmic - if test ! -x $RMIC; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 + else + # The variable is set, but is it from the command line or the environment? + + # Try to remove the string !JAR! from our list. + try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!JAR!/} + if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then + # If it failed, the variable was not from the command line. Ignore it, + # but warn the user (except for BASH, which is always set by the calling BASH). + if test "xJAR" != xBASH; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of JAR from the environment. Use command line variables instead." >&5 +$as_echo "$as_me: WARNING: Ignoring value of JAR from the environment. Use command line variables instead." >&2;} + fi + # Try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jar in Boot JDK" >&5 +$as_echo_n "checking for jar in Boot JDK... " >&6; } + JAR=$BOOT_JDK/bin/jar + if test ! -x $JAR; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - as_fn_error $? "Could not find rmic in the Boot JDK" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 + as_fn_error $? "Could not find jar in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: checking for native2ascii in Boot JDK" >&5 + else + # If it succeeded, then it was overridden by the user. We will use it + # for the tool. + + # First remove it from the list of overridden variables, so we can test + # for unknown variables in the end. + CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var" + + # Check if the provided tool contains a complete path. + tool_specified="$JAR" + tool_basename="${tool_specified##*/}" + if test "x$tool_basename" = "x$tool_specified"; then + # A command without a complete path is provided, search $PATH. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool JAR=$tool_basename" >&5 +$as_echo "$as_me: Will search for user supplied tool JAR=$tool_basename" >&6;} + # Extract the first word of "$tool_basename", so it can be a program name with args. +set dummy $tool_basename; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_JAR+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $JAR in + [\\/]* | ?:[\\/]*) + ac_cv_path_JAR="$JAR" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_JAR="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +JAR=$ac_cv_path_JAR +if test -n "$JAR"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JAR" >&5 +$as_echo "$JAR" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "x$JAR" = x; then + as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5 + fi + else + # Otherwise we believe it is a complete path. Use it as it is. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool JAR=$tool_specified" >&5 +$as_echo "$as_me: Will use user supplied tool JAR=$tool_specified" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JAR" >&5 +$as_echo_n "checking for JAR... " >&6; } + if test ! -x "$tool_specified"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + as_fn_error $? "User supplied tool JAR=$tool_specified does not exist or is not executable" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5 +$as_echo "$tool_specified" >&6; } + fi + fi + fi + + + + # Use user overridden value if available, otherwise locate tool in the Boot JDK. + + # Publish this variable in the help. + + + if test "x$NATIVE2ASCII" = x; then + # The variable is not set by user, try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for native2ascii in Boot JDK" >&5 $as_echo_n "checking for native2ascii in Boot JDK... " >&6; } - NATIVE2ASCII=$BOOT_JDK/bin/native2ascii - if test ! -x $NATIVE2ASCII; then - { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 + NATIVE2ASCII=$BOOT_JDK/bin/native2ascii + if test ! -x $NATIVE2ASCII; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 $as_echo "not found" >&6; } - { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 $as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} - as_fn_error $? "Could not find native2ascii in the Boot JDK" "$LINENO" 5 - fi - { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 + as_fn_error $? "Could not find native2ascii in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 $as_echo "ok" >&6; } + else + # The variable is set, but is it from the command line or the environment? + + # Try to remove the string !NATIVE2ASCII! from our list. + try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!NATIVE2ASCII!/} + if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then + # If it failed, the variable was not from the command line. Ignore it, + # but warn the user (except for BASH, which is always set by the calling BASH). + if test "xNATIVE2ASCII" != xBASH; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of NATIVE2ASCII from the environment. Use command line variables instead." >&5 +$as_echo "$as_me: WARNING: Ignoring value of NATIVE2ASCII from the environment. Use command line variables instead." >&2;} + fi + # Try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for native2ascii in Boot JDK" >&5 +$as_echo_n "checking for native2ascii in Boot JDK... " >&6; } + NATIVE2ASCII=$BOOT_JDK/bin/native2ascii + if test ! -x $NATIVE2ASCII; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + as_fn_error $? "Could not find native2ascii in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } + + + else + # If it succeeded, then it was overridden by the user. We will use it + # for the tool. + + # First remove it from the list of overridden variables, so we can test + # for unknown variables in the end. + CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var" + + # Check if the provided tool contains a complete path. + tool_specified="$NATIVE2ASCII" + tool_basename="${tool_specified##*/}" + if test "x$tool_basename" = "x$tool_specified"; then + # A command without a complete path is provided, search $PATH. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool NATIVE2ASCII=$tool_basename" >&5 +$as_echo "$as_me: Will search for user supplied tool NATIVE2ASCII=$tool_basename" >&6;} + # Extract the first word of "$tool_basename", so it can be a program name with args. +set dummy $tool_basename; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_NATIVE2ASCII+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $NATIVE2ASCII in + [\\/]* | ?:[\\/]*) + ac_cv_path_NATIVE2ASCII="$NATIVE2ASCII" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_NATIVE2ASCII="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +NATIVE2ASCII=$ac_cv_path_NATIVE2ASCII +if test -n "$NATIVE2ASCII"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $NATIVE2ASCII" >&5 +$as_echo "$NATIVE2ASCII" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "x$NATIVE2ASCII" = x; then + as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5 + fi + else + # Otherwise we believe it is a complete path. Use it as it is. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool NATIVE2ASCII=$tool_specified" >&5 +$as_echo "$as_me: Will use user supplied tool NATIVE2ASCII=$tool_specified" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for NATIVE2ASCII" >&5 +$as_echo_n "checking for NATIVE2ASCII... " >&6; } + if test ! -x "$tool_specified"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + as_fn_error $? "User supplied tool NATIVE2ASCII=$tool_specified does not exist or is not executable" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5 +$as_echo "$tool_specified" >&6; } + fi + fi + fi + + + + # Use user overridden value if available, otherwise locate tool in the Boot JDK. + + # Publish this variable in the help. + + + if test "x$JARSIGNER" = x; then + # The variable is not set by user, try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jarsigner in Boot JDK" >&5 +$as_echo_n "checking for jarsigner in Boot JDK... " >&6; } + JARSIGNER=$BOOT_JDK/bin/jarsigner + if test ! -x $JARSIGNER; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + as_fn_error $? "Could not find jarsigner in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } + + + else + # The variable is set, but is it from the command line or the environment? + + # Try to remove the string !JARSIGNER! from our list. + try_remove_var=${CONFIGURE_OVERRIDDEN_VARIABLES//!JARSIGNER!/} + if test "x$try_remove_var" = "x$CONFIGURE_OVERRIDDEN_VARIABLES"; then + # If it failed, the variable was not from the command line. Ignore it, + # but warn the user (except for BASH, which is always set by the calling BASH). + if test "xJARSIGNER" != xBASH; then + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: Ignoring value of JARSIGNER from the environment. Use command line variables instead." >&5 +$as_echo "$as_me: WARNING: Ignoring value of JARSIGNER from the environment. Use command line variables instead." >&2;} + fi + # Try to locate tool using the code snippet + + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for jarsigner in Boot JDK" >&5 +$as_echo_n "checking for jarsigner in Boot JDK... " >&6; } + JARSIGNER=$BOOT_JDK/bin/jarsigner + if test ! -x $JARSIGNER; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + { $as_echo "$as_me:${as_lineno-$LINENO}: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&5 +$as_echo "$as_me: Your Boot JDK seems broken. This might be fixed by explicitely setting --with-boot-jdk" >&6;} + as_fn_error $? "Could not find jarsigner in the Boot JDK" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: ok" >&5 +$as_echo "ok" >&6; } + + + else + # If it succeeded, then it was overridden by the user. We will use it + # for the tool. + + # First remove it from the list of overridden variables, so we can test + # for unknown variables in the end. + CONFIGURE_OVERRIDDEN_VARIABLES="$try_remove_var" + + # Check if the provided tool contains a complete path. + tool_specified="$JARSIGNER" + tool_basename="${tool_specified##*/}" + if test "x$tool_basename" = "x$tool_specified"; then + # A command without a complete path is provided, search $PATH. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will search for user supplied tool JARSIGNER=$tool_basename" >&5 +$as_echo "$as_me: Will search for user supplied tool JARSIGNER=$tool_basename" >&6;} + # Extract the first word of "$tool_basename", so it can be a program name with args. +set dummy $tool_basename; ac_word=$2 +{ $as_echo "$as_me:${as_lineno-$LINENO}: checking for $ac_word" >&5 +$as_echo_n "checking for $ac_word... " >&6; } +if ${ac_cv_path_JARSIGNER+:} false; then : + $as_echo_n "(cached) " >&6 +else + case $JARSIGNER in + [\\/]* | ?:[\\/]*) + ac_cv_path_JARSIGNER="$JARSIGNER" # Let the user override the test with a path. + ;; + *) + as_save_IFS=$IFS; IFS=$PATH_SEPARATOR +for as_dir in $PATH +do + IFS=$as_save_IFS + test -z "$as_dir" && as_dir=. + for ac_exec_ext in '' $ac_executable_extensions; do + if as_fn_executable_p "$as_dir/$ac_word$ac_exec_ext"; then + ac_cv_path_JARSIGNER="$as_dir/$ac_word$ac_exec_ext" + $as_echo "$as_me:${as_lineno-$LINENO}: found $as_dir/$ac_word$ac_exec_ext" >&5 + break 2 + fi +done + done +IFS=$as_save_IFS + + ;; +esac +fi +JARSIGNER=$ac_cv_path_JARSIGNER +if test -n "$JARSIGNER"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $JARSIGNER" >&5 +$as_echo "$JARSIGNER" >&6; } +else + { $as_echo "$as_me:${as_lineno-$LINENO}: result: no" >&5 +$as_echo "no" >&6; } +fi + + + if test "x$JARSIGNER" = x; then + as_fn_error $? "User supplied tool $tool_basename could not be found" "$LINENO" 5 + fi + else + # Otherwise we believe it is a complete path. Use it as it is. + { $as_echo "$as_me:${as_lineno-$LINENO}: Will use user supplied tool JARSIGNER=$tool_specified" >&5 +$as_echo "$as_me: Will use user supplied tool JARSIGNER=$tool_specified" >&6;} + { $as_echo "$as_me:${as_lineno-$LINENO}: checking for JARSIGNER" >&5 +$as_echo_n "checking for JARSIGNER... " >&6; } + if test ! -x "$tool_specified"; then + { $as_echo "$as_me:${as_lineno-$LINENO}: result: not found" >&5 +$as_echo "not found" >&6; } + as_fn_error $? "User supplied tool JARSIGNER=$tool_specified does not exist or is not executable" "$LINENO" 5 + fi + { $as_echo "$as_me:${as_lineno-$LINENO}: result: $tool_specified" >&5 +$as_echo "$tool_specified" >&6; } + fi + fi + fi + + + # Finally, set some other options... # When compiling code to be executed by the Boot JDK, force jdk7 compatibility. diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 63fc13ba005..4342d1517ee 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -438,22 +438,20 @@ POST_MCS_CMD:=@POST_MCS_CMD@ JAVA_FLAGS:=@BOOT_JDK_JVMARGS@ -JAVA=@FIXPATH@ $(BOOT_JDK)/bin/java $(JAVA_FLAGS) +JAVA=@FIXPATH@ @JAVA@ $(JAVA_FLAGS) -JAVAC=@FIXPATH@ $(BOOT_JDK)/bin/javac +JAVAC:=@FIXPATH@ @JAVAC@ # Hotspot sets this variable before reading the SPEC when compiling sa-jdi.jar. Avoid # overriding that value by using ?=. JAVAC_FLAGS?=@JAVAC_FLAGS@ -JAVAH=@FIXPATH@ $(BOOT_JDK)/bin/javah +JAVAH:=@FIXPATH@ @JAVAH@ -JAR=@FIXPATH@ $(BOOT_JDK)/bin/jar +JAR:=@FIXPATH@ @JAR@ -RMIC=@FIXPATH@ $(BOOT_JDK)/bin/rmic +NATIVE2ASCII:=@FIXPATH@ @NATIVE2ASCII@ -NATIVE2ASCII=@FIXPATH@ $(BOOT_JDK)/bin/native2ascii - -JARSIGNER=@FIXPATH@ $(BOOT_JDK)/bin/jarsigner +JARSIGNER:=@FIXPATH@ @JARSIGNER@ # You run the new javac using the boot jdk with $(BOOT_JDK)/bin/java $(NEW_JAVAC) ... BOOTSTRAP_JAVAC_JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar From 214de0eb69f80cc2cee0229037a3b9216198622f Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 29 Jan 2014 14:32:27 -0800 Subject: [PATCH 076/159] 8032869: remove support for legacy options in javap Reviewed-by: ksrini --- .../com/sun/tools/classfile/Attribute.java | 33 ++++++--------- .../com/sun/tools/javap/AttributeWriter.java | 28 ++----------- .../com/sun/tools/javap/ClassWriter.java | 17 ++++---- .../com/sun/tools/javap/JavapTask.java | 42 +------------------ .../classes/com/sun/tools/javap/Options.java | 4 +- .../tools/javap/resources/javap.properties | 3 -- .../test/tools/javap/InvalidOptions.java | 7 ++-- 7 files changed, 29 insertions(+), 105 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/classfile/Attribute.java b/langtools/src/share/classes/com/sun/tools/classfile/Attribute.java index 2688036a7f5..ce5ec7076b1 100644 --- a/langtools/src/share/classes/com/sun/tools/classfile/Attribute.java +++ b/langtools/src/share/classes/com/sun/tools/classfile/Attribute.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,10 +71,6 @@ public abstract class Attribute { // defer init of standardAttributeClasses until after options set up } - public void setCompat(boolean compat) { - this.compat = compat; - } - public Attribute createAttribute(ClassReader cr, int name_index, byte[] data) throws IOException { if (standardAttributes == null) { @@ -109,9 +105,10 @@ public abstract class Attribute { protected void init() { standardAttributes = new HashMap<>(); standardAttributes.put(AnnotationDefault, AnnotationDefault_attribute.class); - standardAttributes.put(BootstrapMethods, BootstrapMethods_attribute.class); + standardAttributes.put(BootstrapMethods, BootstrapMethods_attribute.class); standardAttributes.put(CharacterRangeTable, CharacterRangeTable_attribute.class); standardAttributes.put(Code, Code_attribute.class); + standardAttributes.put(CompilationID, CompilationID_attribute.class); standardAttributes.put(ConstantValue, ConstantValue_attribute.class); standardAttributes.put(Deprecated, Deprecated_attribute.class); standardAttributes.put(EnclosingMethod, EnclosingMethod_attribute.class); @@ -120,29 +117,23 @@ public abstract class Attribute { standardAttributes.put(LineNumberTable, LineNumberTable_attribute.class); standardAttributes.put(LocalVariableTable, LocalVariableTable_attribute.class); standardAttributes.put(LocalVariableTypeTable, LocalVariableTypeTable_attribute.class); - - if (!compat) { // old javap does not recognize recent attributes - standardAttributes.put(MethodParameters, MethodParameters_attribute.class); - standardAttributes.put(CompilationID, CompilationID_attribute.class); - standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class); - standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class); - standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class); - standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class); - standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class); - standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class); - standardAttributes.put(Signature, Signature_attribute.class); - standardAttributes.put(SourceID, SourceID_attribute.class); - } - + standardAttributes.put(MethodParameters, MethodParameters_attribute.class); + standardAttributes.put(RuntimeInvisibleAnnotations, RuntimeInvisibleAnnotations_attribute.class); + standardAttributes.put(RuntimeInvisibleParameterAnnotations, RuntimeInvisibleParameterAnnotations_attribute.class); + standardAttributes.put(RuntimeVisibleAnnotations, RuntimeVisibleAnnotations_attribute.class); + standardAttributes.put(RuntimeVisibleParameterAnnotations, RuntimeVisibleParameterAnnotations_attribute.class); + standardAttributes.put(RuntimeVisibleTypeAnnotations, RuntimeVisibleTypeAnnotations_attribute.class); + standardAttributes.put(RuntimeInvisibleTypeAnnotations, RuntimeInvisibleTypeAnnotations_attribute.class); + standardAttributes.put(Signature, Signature_attribute.class); standardAttributes.put(SourceDebugExtension, SourceDebugExtension_attribute.class); standardAttributes.put(SourceFile, SourceFile_attribute.class); + standardAttributes.put(SourceID, SourceID_attribute.class); standardAttributes.put(StackMap, StackMap_attribute.class); standardAttributes.put(StackMapTable, StackMapTable_attribute.class); standardAttributes.put(Synthetic, Synthetic_attribute.class); } private Map> standardAttributes; - private boolean compat; // don't support recent attrs in compatibility mode } public static Attribute read(ClassReader cr) throws IOException { diff --git a/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java b/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java index dd721c2c077..49bdc467bac 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javap/AttributeWriter.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -227,10 +227,7 @@ public class AttributeWriter extends BasicWriter } public Void visitConstantValue(ConstantValue_attribute attr, Void ignore) { - if (options.compat) // BUG 6622216 javap names some attributes incorrectly - print("Constant value: "); - else - print("ConstantValue: "); + print("ConstantValue: "); constantWriter.write(attr.constantvalue_index); println(); return null; @@ -291,20 +288,10 @@ public class AttributeWriter extends BasicWriter public Void visitInnerClasses(InnerClasses_attribute attr, Void ignore) { boolean first = true; - if (options.compat) { - writeInnerClassHeader(); - first = false; - } for (int i = 0 ; i < attr.classes.length; i++) { InnerClasses_attribute.Info info = attr.classes[i]; //access AccessFlags access_flags = info.inner_class_access_flags; - if (options.compat) { - // BUG 6622215: javap ignores certain relevant access flags - access_flags = access_flags.ignore(ACC_STATIC | ACC_PROTECTED | ACC_PRIVATE | ACC_INTERFACE | ACC_SYNTHETIC | ACC_ENUM); - // BUG 6622232: javap gets whitespace confused - print(" "); - } if (options.checkAccess(access_flags)) { if (first) { writeInnerClassHeader(); @@ -346,11 +333,7 @@ public class AttributeWriter extends BasicWriter } private void writeInnerClassHeader() { - if (options.compat) // BUG 6622216: javap names some attributes incorrectly - print("InnerClass"); - else - print("InnerClasses"); - println(":"); + println("InnerClasses:"); indent(+1); } @@ -711,10 +694,7 @@ public class AttributeWriter extends BasicWriter } String toHex(byte b, int w) { - if (options.compat) // BUG 6622260: javap prints negative bytes incorrectly in hex - return toHex((int) b, w); - else - return toHex(b & 0xff, w); + return toHex(b & 0xff, w); } static String toHex(int i) { diff --git a/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java b/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java index 07e22dec757..83b8ba8e9e1 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java +++ b/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java @@ -120,7 +120,7 @@ public class ClassWriter extends BasicWriter { public void write(ClassFile cf) { setClassFile(cf); - if ((options.sysInfo || options.verbose) && !options.compat) { + if (options.sysInfo || options.verbose) { if (uri != null) { if (uri.getScheme().equals("file")) println("Classfile " + uri.getPath()); @@ -152,7 +152,7 @@ public class ClassWriter extends BasicWriter { println("Compiled from \"" + getSourceFile((SourceFile_attribute) sfa) + "\""); } - if ((options.sysInfo || options.verbose) && !options.compat) { + if (options.sysInfo || options.verbose) { indent(-1); } @@ -205,8 +205,7 @@ public class ClassWriter extends BasicWriter { attrWriter.write(cf, cf.attributes, constant_pool); println("minor version: " + cf.minor_version); println("major version: " + cf.major_version); - if (!options.compat) - writeList("flags: ", flags.getClassFlags(), "\n"); + writeList("flags: ", flags.getClassFlags(), "\n"); indent(-1); constantWriter.writeConstantPool(); } else { @@ -372,7 +371,7 @@ public class ClassWriter extends BasicWriter { } print(" "); print(getFieldName(f)); - if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents + if (options.showConstants) { Attribute a = f.attributes.get(Attribute.ConstantValue); if (a instanceof ConstantValue_attribute) { print(" = "); @@ -390,7 +389,7 @@ public class ClassWriter extends BasicWriter { if (options.showDescriptors) println("descriptor: " + getValue(f.descriptor)); - if (options.verbose && !options.compat) + if (options.verbose) writeList("flags: ", flags.getFieldFlags(), "\n"); if (options.showAllAttrs) { @@ -487,7 +486,7 @@ public class ClassWriter extends BasicWriter { println("descriptor: " + getValue(m.descriptor)); } - if (options.verbose && !options.compat) { + if (options.verbose) { writeList("flags: ", flags.getMethodFlags(), "\n"); } @@ -553,13 +552,11 @@ public class ClassWriter extends BasicWriter { } Signature_attribute getSignature(Attributes attributes) { - if (options.compat) // javap does not recognize recent attributes - return null; return (Signature_attribute) attributes.get(Attribute.Signature); } String adjustVarargs(AccessFlags flags, String params) { - if (flags.is(ACC_VARARGS) && !options.compat) { + if (flags.is(ACC_VARARGS)) { int i = params.lastIndexOf("[]"); if (i > 0) return params.substring(0, i) + "..." + params.substring(i+2); diff --git a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java index 23576737c21..57284a4c003 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java +++ b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -195,48 +195,12 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { } }, -// new Option(false, "-all") { -// void process(JavapTask task, String opt, String arg) { -// task.options.showAllAttrs = true; -// } -// }, - - new Option(false, "-h") { - void process(JavapTask task, String opt, String arg) throws BadArgs { - throw task.new BadArgs("err.h.not.supported"); - } - }, - - new Option(false, "-verify", "-verify-verbose") { - void process(JavapTask task, String opt, String arg) throws BadArgs { - throw task.new BadArgs("err.verify.not.supported"); - } - }, - new Option(false, "-sysinfo") { void process(JavapTask task, String opt, String arg) { task.options.sysInfo = true; } }, - new Option(false, "-Xold") { - void process(JavapTask task, String opt, String arg) throws BadArgs { - task.log.println(task.getMessage("warn.Xold.not.supported")); - } - }, - - new Option(false, "-Xnew") { - void process(JavapTask task, String opt, String arg) throws BadArgs { - // ignore: this _is_ the new version - } - }, - - new Option(false, "-XDcompat") { - void process(JavapTask task, String opt, String arg) { - task.options.compat = true; - } - }, - new Option(false, "-XDdetails") { void process(JavapTask task, String opt, String arg) { task.options.details = EnumSet.allOf(InstructionDetailWriter.Kind.class); @@ -520,7 +484,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { throw new BadArgs("err.unknown.option", arg).showUsage(true); } - if (!options.compat && options.accessOptions.size() > 1) { + if (options.accessOptions.size() > 1) { StringBuilder sb = new StringBuilder(); for (String opt: options.accessOptions) { if (sb.length() > 0) @@ -581,8 +545,6 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { SourceWriter sourceWriter = SourceWriter.instance(context); sourceWriter.setFileManager(fileManager); - attributeFactory.setCompat(options.compat); - int result = EXIT_OK; for (String className: classes) { diff --git a/langtools/src/share/classes/com/sun/tools/javap/Options.java b/langtools/src/share/classes/com/sun/tools/javap/Options.java index 7d0a9a7fe4b..fbfc30b2190 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/Options.java +++ b/langtools/src/share/classes/com/sun/tools/javap/Options.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -88,6 +88,4 @@ public class Options { public boolean showInnerClasses; public int indentWidth = 2; // #spaces per indentWidth level public int tabColumn = 40; // column number for comments - - public boolean compat; // bug-for-bug compatibility mode with old javap } diff --git a/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties b/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties index c77024f75f5..a704e7f5e51 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties +++ b/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties @@ -6,7 +6,6 @@ err.class.not.found=class not found: {0} err.crash=A serious internal error has occurred: {0}\nPlease file a bug report, and include the following information:\n{1} err.end.of.file=unexpected end of file while reading {0} err.file.not.found=file not found: {0} -err.h.not.supported=-h is no longer available - use the 'javah' program err.incompatible.options=bad combination of options: {0} err.internal.error=internal error: {0} {1} {2} err.invalid.arg.for.option=invalid argument for option: {0} @@ -15,11 +14,9 @@ err.missing.arg=no value given for {0} err.no.classes.specified=no classes specified err.not.standard.file.manager=can only specify class files when using a standard file manager err.unknown.option=unknown option: {0} -err.verify.not.supported=-verify not supported err.no.SourceFile.attribute=no SourceFile attribute err.source.file.not.found=source file not found err.bad.innerclasses.attribute=bad InnerClasses attribute for {0} -warn.Xold.not.supported=-Xold is no longer available main.usage.summary=\ Usage: {0} \n\ diff --git a/langtools/test/tools/javap/InvalidOptions.java b/langtools/test/tools/javap/InvalidOptions.java index d92f644ba85..764fd8a861c 100644 --- a/langtools/test/tools/javap/InvalidOptions.java +++ b/langtools/test/tools/javap/InvalidOptions.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -23,8 +23,8 @@ /* * @test - * @bug 8027411 - * @summary test invalid options -h and -b + * @bug 8027411 8032869 + * @summary test an invalid option */ import java.io.*; @@ -39,7 +39,6 @@ public class InvalidOptions { } void run() throws Exception { - test(2, "-h", "Error: -h is no longer available - use the javah program"); test(2, "-b", "Error: unknown option: -b", "Usage: javap ", "use -help for a list of possible options"); From ca53cc64e58dbb6ee6c24f750670e50843da4915 Mon Sep 17 00:00:00 2001 From: Eric McCorkle Date: Thu, 30 Jan 2014 07:35:49 -0500 Subject: [PATCH 077/159] 8033218: Silent failure in TypeAnnotations.resolveFrame Change silent no-op to assertion failure when resolveFrame is called before attribution. Reviewed-by: jfranck --- .../classes/com/sun/tools/javac/code/TypeAnnotations.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java index 1ed8f161a7d..35ccc58a14e 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java @@ -912,11 +912,7 @@ public class TypeAnnotations { // not care about inner types. JCAnnotatedType atypetree = (JCAnnotatedType) frame; final Type utype = atypetree.underlyingType.type; - if (utype == null) { - // This might happen during DeferredAttr; - // we will be back later. - return; - } + Assert.checkNonNull(utype); Symbol tsym = utype.tsym; if (tsym.getKind().equals(ElementKind.TYPE_PARAMETER) || utype.getKind().equals(TypeKind.WILDCARD) || From 3d9115510cebf8b94c5cc3b29a105a2f144e0d10 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Thu, 30 Jan 2014 18:26:15 +0530 Subject: [PATCH 078/159] 8032943: Improve reflection in Nashorn Reviewed-by: jlaskey, attila, ahgross --- .../internal/objects/NativeObject.java | 3 +- nashorn/test/script/sandbox/classbind.js | 41 +++++++++++++++++++ 2 files changed, 43 insertions(+), 1 deletion(-) create mode 100644 nashorn/test/script/sandbox/classbind.js diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java index 5777c96c870..74d56ba614b 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java @@ -645,10 +645,12 @@ public final class NativeObject { targetObj.addBoundProperties(source, props); } else if (source instanceof StaticClass) { final Class clazz = ((StaticClass)source).getRepresentedClass(); + Bootstrap.checkReflectionAccess(clazz); bindBeanProperties(targetObj, source, BeansLinker.getReadableStaticPropertyNames(clazz), BeansLinker.getWritableStaticPropertyNames(clazz), BeansLinker.getStaticMethodNames(clazz)); } else { final Class clazz = source.getClass(); + Bootstrap.checkReflectionAccess(clazz); bindBeanProperties(targetObj, source, BeansLinker.getReadableInstancePropertyNames(clazz), BeansLinker.getWritableInstancePropertyNames(clazz), BeansLinker.getInstanceMethodNames(clazz)); } @@ -663,7 +665,6 @@ public final class NativeObject { propertyNames.addAll(writablePropertyNames); final Class clazz = source.getClass(); - Bootstrap.checkReflectionAccess(clazz); final MethodType getterType = MethodType.methodType(Object.class, clazz); final MethodType setterType = MethodType.methodType(Object.class, clazz, Object.class); diff --git a/nashorn/test/script/sandbox/classbind.js b/nashorn/test/script/sandbox/classbind.js new file mode 100644 index 00000000000..2dabb3e23d8 --- /dev/null +++ b/nashorn/test/script/sandbox/classbind.js @@ -0,0 +1,41 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the 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. + */ + +/** + * Try to bind properties of StaticClass representing Class. + * + * @test + * @bug JDK-8032943: Improve reflection in Nashorn + */ + + +var obj = {} + +try { + Object.bindProperties(obj, Java.type("java.lang.Class")); + fail("SecurityException should have been thrown"); +} catch (e) { + if (! (e instanceof java.lang.SecurityException)) { + fail("SecurityException expected, got " + e); + } +} From 6d897ac7a88cbca14bd67ac62c02509c823d8b8a Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Thu, 30 Jan 2014 18:49:47 +0530 Subject: [PATCH 079/159] 8032954: Nashorn: extend Java.extend Reviewed-by: jlaskey, attila, ahgross --- .../runtime/linker/JavaAdapterFactory.java | 2 ++ nashorn/test/script/sandbox/classloader.js | 22 +++++++++++++++++++ .../script/sandbox/classloader.js.EXPECTED | 2 ++ 3 files changed, 26 insertions(+) diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java index b221d000034..878c0058c76 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java @@ -110,6 +110,8 @@ public final class JavaAdapterFactory { for (Class type : types) { // check for restricted package access Context.checkPackageAccess(type); + // check for classes, interfaces in reflection + ReflectionCheckLinker.checkReflectionAccess(type); } } return getAdapterInfo(types).getAdapterClassFor(classOverrides); diff --git a/nashorn/test/script/sandbox/classloader.js b/nashorn/test/script/sandbox/classloader.js index 7676496060d..9de1a5c37f2 100644 --- a/nashorn/test/script/sandbox/classloader.js +++ b/nashorn/test/script/sandbox/classloader.js @@ -26,6 +26,7 @@ * * @test * @security + * @bug JDK-8032954: Nashorn: extend Java.extend */ try { @@ -39,3 +40,24 @@ try { } } +try { + Java.extend(Java.type('java.lang.ClassLoader')); + fail("should have thrown SecurityException"); +} catch (e) { + if (e instanceof java.lang.SecurityException) { + print(e); + } else { + fail("expected SecurityException, got " + e); + } +} + +try { + Java.extend(Java.type("javax.management.loading.MLet")); + fail("should have thrown SecurityException"); +} catch (e) { + if (e instanceof java.lang.SecurityException) { + print(e); + } else { + fail("expected SecurityException, got " + e); + } +} diff --git a/nashorn/test/script/sandbox/classloader.js.EXPECTED b/nashorn/test/script/sandbox/classloader.js.EXPECTED index 356053d4e1d..8c241912f36 100644 --- a/nashorn/test/script/sandbox/classloader.js.EXPECTED +++ b/nashorn/test/script/sandbox/classloader.js.EXPECTED @@ -1 +1,3 @@ java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection") +java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection") +java.security.AccessControlException: access denied ("java.lang.RuntimePermission" "nashorn.JavaReflection") From ea24aa581b4702756773505782f160263c7f31db Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Thu, 30 Jan 2014 19:28:40 +0530 Subject: [PATCH 080/159] 8032948: Nashorn linkages awry Reviewed-by: jlaskey, attila, ahgross --- .../internal/objects/NativeObject.java | 4 +- .../internal/runtime/linker/Bootstrap.java | 5 +- .../runtime/linker/JavaAdapterFactory.java | 2 +- .../linker/NashornStaticClassLinker.java | 2 +- .../runtime/linker/ReflectionCheckLinker.java | 23 ++++- .../scripting/ScriptEngineSecurityTest.java | 97 +++++++++++++++++++ .../api/scripting/ScriptEngineTest.java | 25 +++++ 7 files changed, 150 insertions(+), 8 deletions(-) diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java index 74d56ba614b..d102c0fb011 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeObject.java @@ -645,12 +645,12 @@ public final class NativeObject { targetObj.addBoundProperties(source, props); } else if (source instanceof StaticClass) { final Class clazz = ((StaticClass)source).getRepresentedClass(); - Bootstrap.checkReflectionAccess(clazz); + Bootstrap.checkReflectionAccess(clazz, true); bindBeanProperties(targetObj, source, BeansLinker.getReadableStaticPropertyNames(clazz), BeansLinker.getWritableStaticPropertyNames(clazz), BeansLinker.getStaticMethodNames(clazz)); } else { final Class clazz = source.getClass(); - Bootstrap.checkReflectionAccess(clazz); + Bootstrap.checkReflectionAccess(clazz, false); bindBeanProperties(targetObj, source, BeansLinker.getReadableInstancePropertyNames(clazz), BeansLinker.getWritableInstancePropertyNames(clazz), BeansLinker.getInstanceMethodNames(clazz)); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java index 0d5f68a1e2f..c8f39fcfaca 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/Bootstrap.java @@ -278,9 +278,10 @@ public final class Bootstrap { * {@code java.lang.invoke} package, as well a {@link Class} and any subclass of {@link ClassLoader}) and there is * a security manager in the system, then it checks the {@code nashorn.JavaReflection} {@code RuntimePermission}. * @param clazz the class being tested + * @param isStatic is access checked for static members (or instance members) */ - public static void checkReflectionAccess(Class clazz) { - ReflectionCheckLinker.checkReflectionAccess(clazz); + public static void checkReflectionAccess(Class clazz, boolean isStatic) { + ReflectionCheckLinker.checkReflectionAccess(clazz, isStatic); } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java index 878c0058c76..ccb2c87982e 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java @@ -111,7 +111,7 @@ public final class JavaAdapterFactory { // check for restricted package access Context.checkPackageAccess(type); // check for classes, interfaces in reflection - ReflectionCheckLinker.checkReflectionAccess(type); + ReflectionCheckLinker.checkReflectionAccess(type, true); } } return getAdapterInfo(types).getAdapterClassFor(classOverrides); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java index 72ed97666d0..21e2d14eb4e 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java @@ -65,7 +65,7 @@ final class NashornStaticClassLinker implements TypeBasedGuardingDynamicLinker { return null; } final Class receiverClass = ((StaticClass) self).getRepresentedClass(); - Bootstrap.checkReflectionAccess(receiverClass); + Bootstrap.checkReflectionAccess(receiverClass, true); final CallSiteDescriptor desc = request.getCallSiteDescriptor(); // We intercept "new" on StaticClass instances to provide additional capabilities if ("new".equals(desc.getNameToken(CallSiteDescriptor.OPERATOR))) { diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java index 6772cbee037..8fc76c19ed6 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/ReflectionCheckLinker.java @@ -26,6 +26,7 @@ package jdk.nashorn.internal.runtime.linker; import java.lang.reflect.Modifier; +import java.lang.reflect.Proxy; import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; @@ -47,6 +48,7 @@ final class ReflectionCheckLinker implements TypeBasedGuardingDynamicLinker{ if (type == Class.class || ClassLoader.class.isAssignableFrom(type)) { return true; } + final String name = type.getName(); return name.startsWith("java.lang.reflect.") || name.startsWith("java.lang.invoke."); } @@ -59,9 +61,25 @@ final class ReflectionCheckLinker implements TypeBasedGuardingDynamicLinker{ return null; } - static void checkReflectionAccess(Class clazz) { + private static boolean isReflectiveCheckNeeded(final Class type, final boolean isStatic) { + // special handling for Proxy subclasses + if (Proxy.class.isAssignableFrom(type)) { + if (Proxy.isProxyClass(type)) { + // real Proxy class - filter only static access + return isStatic; + } + + // fake Proxy subclass - filter it always! + return true; + } + + // check for any other reflective Class + return isReflectionClass(type); + } + + static void checkReflectionAccess(final Class clazz, final boolean isStatic) { final SecurityManager sm = System.getSecurityManager(); - if (sm != null && isReflectionClass(clazz)) { + if (sm != null && isReflectiveCheckNeeded(clazz, isStatic)) { checkReflectionPermission(sm); } } @@ -78,6 +96,7 @@ final class ReflectionCheckLinker implements TypeBasedGuardingDynamicLinker{ if (desc.getNameTokenCount() > CallSiteDescriptor.NAME_OPERAND && "static".equals(desc.getNameToken(CallSiteDescriptor.NAME_OPERAND))) { if (Context.isAccessibleClass((Class)self) && !isReflectionClass((Class)self)) { + // If "getProp:static" passes access checks, allow access. return; } diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java index 4f036101bfa..9cea21ba2f5 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java @@ -27,6 +27,9 @@ package jdk.nashorn.api.scripting; import static org.testng.Assert.fail; +import java.lang.reflect.Method; +import java.lang.reflect.InvocationHandler; +import java.lang.reflect.Proxy; import java.util.Objects; import javax.script.Invocable; import javax.script.ScriptEngine; @@ -183,4 +186,98 @@ public class ScriptEngineSecurityTest { } } } + + // @bug 8032948: Nashorn linkages awry + public static class FakeProxy extends Proxy { + public FakeProxy(InvocationHandler ih) { + super(ih); + } + + public static Class makeProxyClass(ClassLoader cl, Class... ifaces) { + return Proxy.getProxyClass(cl, ifaces); + } + } + + @Test + public void fakeProxySubclassAccessCheckTest() throws ScriptException { + if (System.getSecurityManager() == null) { + // pass vacuously + return; + } + + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + + e.put("name", ScriptEngineSecurityTest.class.getName()); + e.put("cl", ScriptEngineSecurityTest.class.getClassLoader()); + e.put("intfs", new Class[] { Runnable.class }); + + String getClass = "Java.type(name + '$FakeProxy').getProxyClass(cl, intfs);"; + + // Should not be able to call static methods of Proxy via fake subclass + try { + Class c = (Class)e.eval(getClass); + fail("should have thrown SecurityException"); + } catch (final Exception exp) { + if (! (exp instanceof SecurityException)) { + fail("SecurityException expected, got " + exp); + } + } + } + + @Test + public void fakeProxySubclassAccessCheckTest2() throws ScriptException { + if (System.getSecurityManager() == null) { + // pass vacuously + return; + } + + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + + e.put("name", ScriptEngineSecurityTest.class.getName()); + e.put("cl", ScriptEngineSecurityTest.class.getClassLoader()); + e.put("intfs", new Class[] { Runnable.class }); + + String getClass = "Java.type(name + '$FakeProxy').makeProxyClass(cl, intfs);"; + + // Should not be able to call static methods of Proxy via fake subclass + try { + Class c = (Class)e.eval(getClass); + fail("should have thrown SecurityException"); + } catch (final Exception exp) { + if (! (exp instanceof SecurityException)) { + fail("SecurityException expected, got " + exp); + } + } + } + + @Test + public static void proxyStaticAccessCheckTest() throws ScriptException { + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + final Runnable r = (Runnable)Proxy.newProxyInstance( + ScriptEngineTest.class.getClassLoader(), + new Class[] { Runnable.class }, + new InvocationHandler() { + @Override + public Object invoke(Object p, Method m, Object[] a) { + return null; + } + }); + + e.put("rc", r.getClass()); + e.put("cl", ScriptEngineSecurityTest.class.getClassLoader()); + e.put("intfs", new Class[] { Runnable.class }); + + // make sure static methods of Proxy is not accessible via subclass + try { + e.eval("rc.static.getProxyClass(cl, intfs)"); + fail("Should have thrown SecurityException"); + } catch (final Exception exp) { + if (! (exp instanceof SecurityException)) { + fail("SecurityException expected, got " + exp); + } + } + } } diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java index 2c7df64d4b6..df8696d8e4c 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineTest.java @@ -33,7 +33,9 @@ import static org.testng.Assert.fail; import java.io.PrintWriter; import java.io.StringReader; import java.io.StringWriter; +import java.lang.reflect.InvocationHandler; import java.lang.reflect.Method; +import java.lang.reflect.Proxy; import java.util.concurrent.Callable; import javax.script.Compilable; import javax.script.CompiledScript; @@ -535,6 +537,29 @@ public class ScriptEngineTest { assertEquals(e.eval("Window.funcJSObject(obj)"), "hello"); } + // @bug 8032948: Nashorn linkages awry + @Test + public void checkProxyAccess() throws ScriptException { + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + final boolean[] reached = new boolean[1]; + final Runnable r = (Runnable)Proxy.newProxyInstance( + ScriptEngineTest.class.getClassLoader(), + new Class[] { Runnable.class }, + new InvocationHandler() { + @Override + public Object invoke(Object p, Method m, Object[] a) { + reached[0] = true; + return null; + } + }); + + e.put("r", r); + e.eval("r.run()"); + + assertTrue(reached[0]); + } + private static final String LINE_SEPARATOR = System.getProperty("line.separator"); // Returns String that would be the result of calling PrintWriter.println From 281b87b796c3071af54b89c638afda04be83c439 Mon Sep 17 00:00:00 2001 From: Attila Szegedi Date: Thu, 30 Jan 2014 20:13:27 +0100 Subject: [PATCH 081/159] 8032681: Issues with Nashorn Reviewed-by: ahgross, jlaskey, sundar --- .../linker/GuardedTypeConversion.java | 102 +++++++ .../linker/GuardingTypeConverterFactory.java | 20 +- .../dynalink/support/LinkerServicesImpl.java | 25 +- .../support/TypeConverterFactory.java | 73 ++++- .../api/scripting/NashornScriptEngine.java | 6 +- .../nashorn/internal/objects/NativeJava.java | 37 ++- .../internal/objects/NativeJavaImporter.java | 4 +- .../jdk/nashorn/internal/runtime/Context.java | 16 +- .../internal/runtime/NativeJavaPackage.java | 2 + .../internal/runtime/ScriptFunction.java | 9 +- .../runtime/linker/AdaptationResult.java | 3 +- .../runtime/linker/JSObjectLinker.java | 5 +- .../linker/JavaAdapterBytecodeGenerator.java | 275 ++++++++++-------- .../linker/JavaAdapterClassLoader.java | 35 +-- .../runtime/linker/JavaAdapterFactory.java | 94 ++++-- .../runtime/linker/JavaAdapterServices.java | 83 +++++- .../runtime/linker/NashornBottomLinker.java | 9 +- .../runtime/linker/NashornLinker.java | 38 ++- .../linker/NashornPrimitiveLinker.java | 5 +- .../linker/NashornStaticClassLinker.java | 3 +- .../runtime/resources/Messages.properties | 1 + nashorn/test/script/basic/JDK-8014647.js | 7 +- .../test/script/basic/JDK-8014647.js.EXPECTED | 4 +- .../test/script/basic/javaclassoverrides.js | 13 +- .../basic/javaclassoverrides.js.EXPECTED | 6 +- nashorn/test/script/sandbox/javaextend.js | 15 + .../script/sandbox/javaextend.js.EXPECTED | 2 + .../scripting/ScriptEngineSecurityTest.java | 19 +- .../test/models/ClassWithFinalFinalizer.java | 31 ++ .../ClassWithInheritedFinalFinalizer.java | 29 ++ 30 files changed, 727 insertions(+), 244 deletions(-) create mode 100644 nashorn/src/jdk/internal/dynalink/linker/GuardedTypeConversion.java create mode 100644 nashorn/test/src/jdk/nashorn/test/models/ClassWithFinalFinalizer.java create mode 100644 nashorn/test/src/jdk/nashorn/test/models/ClassWithInheritedFinalFinalizer.java diff --git a/nashorn/src/jdk/internal/dynalink/linker/GuardedTypeConversion.java b/nashorn/src/jdk/internal/dynalink/linker/GuardedTypeConversion.java new file mode 100644 index 00000000000..9baed7c0ebd --- /dev/null +++ b/nashorn/src/jdk/internal/dynalink/linker/GuardedTypeConversion.java @@ -0,0 +1,102 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +/* + * This file is available under and governed by the GNU General Public + * License version 2 only, as published by the Free Software Foundation. + * However, the following notice accompanied the original version of this + * file, and Oracle licenses the original version of this file under the BSD + * license: + */ +/* + Copyright 2009-2013 Attila Szegedi + + Licensed under both the Apache License, Version 2.0 (the "Apache License") + and the BSD License (the "BSD License"), with licensee being free to + choose either of the two at their discretion. + + You may not use this file except in compliance with either the Apache + License or the BSD License. + + If you choose to use this file in compliance with the Apache License, the + following notice applies to you: + + You may obtain a copy of the Apache License at + + http://www.apache.org/licenses/LICENSE-2.0 + + Unless required by applicable law or agreed to in writing, software + distributed under the License is distributed on an "AS IS" BASIS, + WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or + implied. See the License for the specific language governing + permissions and limitations under the License. + + If you choose to use this file in compliance with the BSD License, the + following notice applies to you: + + Redistribution and use in source and binary forms, with or without + modification, are permitted provided that the following conditions are + met: + * Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + * Redistributions in binary form must reproduce the above copyright + notice, this list of conditions and the following disclaimer in the + documentation and/or other materials provided with the distribution. + * Neither the name of the copyright holder nor the names of + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + + THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS + IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A + PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDER + BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR + CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF + SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR + BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, + WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR + OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF + ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. +*/ + +package jdk.internal.dynalink.linker; + +public class GuardedTypeConversion { + private final GuardedInvocation conversionInvocation; + private final boolean cacheable; + + public GuardedTypeConversion(final GuardedInvocation conversionInvocation, final boolean cacheable) { + this.conversionInvocation = conversionInvocation; + this.cacheable = cacheable; + } + + public GuardedInvocation getConversionInvocation() { + return conversionInvocation; + } + + public boolean isCacheable() { + return cacheable; + } +} diff --git a/nashorn/src/jdk/internal/dynalink/linker/GuardingTypeConverterFactory.java b/nashorn/src/jdk/internal/dynalink/linker/GuardingTypeConverterFactory.java index 30ab9467ec4..5f66e8a4bca 100644 --- a/nashorn/src/jdk/internal/dynalink/linker/GuardingTypeConverterFactory.java +++ b/nashorn/src/jdk/internal/dynalink/linker/GuardingTypeConverterFactory.java @@ -96,19 +96,19 @@ import jdk.internal.dynalink.support.TypeUtilities; */ public interface GuardingTypeConverterFactory { /** - * Returns a guarded invocation that receives an Object of the specified source type and returns an Object converted - * to the specified target type. The type of the invocation is targetType(sourceType), while the type of the guard - * is boolean(sourceType). Note that this will never be invoked for type conversions allowed by the JLS 5.3 "Method - * Invocation Conversion", see {@link TypeUtilities#isMethodInvocationConvertible(Class, Class)} for details. An - * implementation can assume it is never requested to produce a converter for these conversions. + * Returns a guarded type conversion that receives an Object of the specified source type and returns an Object + * converted to the specified target type. The type of the invocation is targetType(sourceType), while the type of + * the guard is boolean(sourceType). Note that this will never be invoked for type conversions allowed by the JLS + * 5.3 "Method Invocation Conversion", see {@link TypeUtilities#isMethodInvocationConvertible(Class, Class)} for + * details. An implementation can assume it is never requested to produce a converter for these conversions. * * @param sourceType source type * @param targetType the target type. - * @return a guarded invocation that can take an object (if it passes guard) and returns another object that is its - * representation coerced into the target type. In case the factory is certain it is unable to handle a conversion, - * it can return null. In case the factory is certain that it can always handle the conversion, it can return an - * unconditional invocation (one whose guard is null). + * @return a guarded type conversion that contains a guarded invocation that can take an object (if it passes guard) + * and return another object that is its representation coerced into the target type. In case the factory is certain + * it is unable to handle a conversion, it can return null. In case the factory is certain that it can always handle + * the conversion, it can return an unconditional invocation (one whose guard is null). * @throws Exception if there was an error during creation of the converter */ - public GuardedInvocation convertToType(Class sourceType, Class targetType) throws Exception; + public GuardedTypeConversion convertToType(Class sourceType, Class targetType) throws Exception; } diff --git a/nashorn/src/jdk/internal/dynalink/support/LinkerServicesImpl.java b/nashorn/src/jdk/internal/dynalink/support/LinkerServicesImpl.java index 4eb0ca9da7e..3b8e7b46abe 100644 --- a/nashorn/src/jdk/internal/dynalink/support/LinkerServicesImpl.java +++ b/nashorn/src/jdk/internal/dynalink/support/LinkerServicesImpl.java @@ -98,6 +98,9 @@ import jdk.internal.dynalink.linker.LinkerServices; */ public class LinkerServicesImpl implements LinkerServices { + private static final RuntimePermission GET_CURRENT_LINK_REQUEST = new RuntimePermission("dynalink.getCurrentLinkRequest"); + private static final ThreadLocal threadLinkRequest = new ThreadLocal<>(); + private final TypeConverterFactory typeConverterFactory; private final GuardingDynamicLinker topLevelLinker; @@ -135,6 +138,26 @@ public class LinkerServicesImpl implements LinkerServices { @Override public GuardedInvocation getGuardedInvocation(LinkRequest linkRequest) throws Exception { - return topLevelLinker.getGuardedInvocation(linkRequest, this); + final LinkRequest prevLinkRequest = threadLinkRequest.get(); + threadLinkRequest.set(linkRequest); + try { + return topLevelLinker.getGuardedInvocation(linkRequest, this); + } finally { + threadLinkRequest.set(prevLinkRequest); + } + } + + /** + * Returns the currently processed link request, or null if the method is invoked outside of the linking process. + * @return the currently processed link request, or null. + * @throws SecurityException if the calling code doesn't have the {@code "dynalink.getCurrentLinkRequest"} runtime + * permission. + */ + public static LinkRequest getCurrentLinkRequest() { + SecurityManager sm = System.getSecurityManager(); + if(sm != null) { + sm.checkPermission(GET_CURRENT_LINK_REQUEST); + } + return threadLinkRequest.get(); } } diff --git a/nashorn/src/jdk/internal/dynalink/support/TypeConverterFactory.java b/nashorn/src/jdk/internal/dynalink/support/TypeConverterFactory.java index 5ab541f33f9..436acad7faf 100644 --- a/nashorn/src/jdk/internal/dynalink/support/TypeConverterFactory.java +++ b/nashorn/src/jdk/internal/dynalink/support/TypeConverterFactory.java @@ -94,6 +94,7 @@ import java.util.List; import jdk.internal.dynalink.linker.ConversionComparator; import jdk.internal.dynalink.linker.ConversionComparator.Comparison; import jdk.internal.dynalink.linker.GuardedInvocation; +import jdk.internal.dynalink.linker.GuardedTypeConversion; import jdk.internal.dynalink.linker.GuardingTypeConverterFactory; import jdk.internal.dynalink.linker.LinkerServices; @@ -134,8 +135,8 @@ public class TypeConverterFactory { @Override protected MethodHandle computeValue(Class targetType) { if(!canAutoConvert(sourceType, targetType)) { - final MethodHandle converter = getTypeConverterNull(sourceType, targetType); - if(converter != null) { + final MethodHandle converter = getCacheableTypeConverter(sourceType, targetType); + if(converter != IDENTITY_CONVERSION) { return converter; } } @@ -145,6 +146,24 @@ public class TypeConverterFactory { } }; + private final ClassValue> canConvert = new ClassValue>() { + @Override + protected ClassMap computeValue(final Class sourceType) { + return new ClassMap(getClassLoader(sourceType)) { + @Override + protected Boolean computeValue(Class targetType) { + try { + return getTypeConverterNull(sourceType, targetType) != null; + } catch (RuntimeException e) { + throw e; + } catch (Exception e) { + throw new RuntimeException(e); + } + } + }; + } + }; + private static final ClassLoader getClassLoader(final Class clazz) { return AccessController.doPrivileged(new PrivilegedAction() { @Override @@ -253,7 +272,7 @@ public class TypeConverterFactory { * @return true if there can be a conversion, false if there can not. */ public boolean canConvert(final Class from, final Class to) { - return canAutoConvert(from, to) || getTypeConverterNull(from, to) != null; + return canAutoConvert(from, to) || canConvert.get(from).get(to).booleanValue(); } /** @@ -294,11 +313,23 @@ public class TypeConverterFactory { return TypeUtilities.isMethodInvocationConvertible(fromType, toType); } - /*private*/ MethodHandle getTypeConverterNull(Class sourceType, Class targetType) { - final MethodHandle converter = converterMap.get(sourceType).get(targetType); + /*private*/ MethodHandle getCacheableTypeConverterNull(Class sourceType, Class targetType) { + final MethodHandle converter = getCacheableTypeConverter(sourceType, targetType); return converter == IDENTITY_CONVERSION ? null : converter; } + /*private*/ MethodHandle getTypeConverterNull(Class sourceType, Class targetType) { + try { + return getCacheableTypeConverterNull(sourceType, targetType); + } catch(NotCacheableConverter e) { + return e.converter; + } + } + + /*private*/ MethodHandle getCacheableTypeConverter(Class sourceType, Class targetType) { + return converterMap.get(sourceType).get(targetType); + } + /** * Given a source and target type, returns a method handle that converts between them. Never returns null; in worst * case it will return an identity conversion (that might fail for some values at runtime). You can use this method @@ -309,22 +340,44 @@ public class TypeConverterFactory { * @return a method handle performing the conversion. */ public MethodHandle getTypeConverter(Class sourceType, Class targetType) { - return converterIdentityMap.get(sourceType).get(targetType); + try { + return converterIdentityMap.get(sourceType).get(targetType); + } catch(NotCacheableConverter e) { + return e.converter; + } } /*private*/ MethodHandle createConverter(Class sourceType, Class targetType) throws Exception { final MethodType type = MethodType.methodType(targetType, sourceType); final MethodHandle identity = IDENTITY_CONVERSION.asType(type); MethodHandle last = identity; + boolean cacheable = true; for(int i = factories.length; i-- > 0;) { - final GuardedInvocation next = factories[i].convertToType(sourceType, targetType); + final GuardedTypeConversion next = factories[i].convertToType(sourceType, targetType); if(next != null) { - next.assertType(type); - last = next.compose(last); + cacheable = cacheable && next.isCacheable(); + final GuardedInvocation conversionInvocation = next.getConversionInvocation(); + conversionInvocation.assertType(type); + last = conversionInvocation.compose(last); } } - return last == identity ? IDENTITY_CONVERSION : last; + if(last == identity) { + return IDENTITY_CONVERSION; + } + if(cacheable) { + return last; + } + throw new NotCacheableConverter(last); } /*private*/ static final MethodHandle IDENTITY_CONVERSION = MethodHandles.identity(Object.class); + + private static class NotCacheableConverter extends RuntimeException { + final MethodHandle converter; + + NotCacheableConverter(final MethodHandle converter) { + super("", null, false, false); + this.converter = converter; + } + } } diff --git a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java index 8028cce229e..3c4d29fc025 100644 --- a/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java +++ b/nashorn/src/jdk/nashorn/api/scripting/NashornScriptEngine.java @@ -32,6 +32,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.Reader; +import java.lang.invoke.MethodHandles; import java.lang.reflect.Method; import java.lang.reflect.Modifier; import java.net.URL; @@ -104,7 +105,7 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C private volatile Property contextProperty; // default options passed to Nashorn Options object - private static final String[] DEFAULT_OPTIONS = new String[] { "-scripting", "-doe" }; + private static final String[] DEFAULT_OPTIONS = new String[] { "-doe" }; // Nashorn script engine error message management private static final String MESSAGES_RESOURCE = "jdk.nashorn.api.scripting.resources.Messages"; @@ -355,7 +356,8 @@ public final class NashornScriptEngine extends AbstractScriptEngine implements C if (! isInterfaceImplemented(clazz, realSelf)) { return null; } - return clazz.cast(JavaAdapterFactory.getConstructor(realSelf.getClass(), clazz).invoke(realSelf)); + return clazz.cast(JavaAdapterFactory.getConstructor(realSelf.getClass(), clazz, + MethodHandles.publicLookup()).invoke(realSelf)); } finally { if (globalChanged) { Context.setGlobal(oldGlobal); diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java b/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java index 5e9ac83d5e1..b863e24f2a5 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJava.java @@ -28,6 +28,7 @@ package jdk.nashorn.internal.objects; import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; +import java.lang.invoke.MethodHandles; import java.lang.reflect.Array; import java.util.Collection; import java.util.Deque; @@ -463,12 +464,14 @@ public final class NativeJava { * * We can see several important concepts in the above example: *
    - *
  • Every specified list of Java types will have exactly one extender subclass in Nashorn - repeated invocations - * of {@code extend} for the same list of types will yield the same extender type. It's a generic adapter that - * delegates to whatever JavaScript functions its implementation object has on a per-instance basis.
  • + *
  • Every specified list of Java types will have one extender subclass in Nashorn per caller protection domain - + * repeated invocations of {@code extend} for the same list of types for scripts same protection domain will yield + * the same extender type. It's a generic adapter that delegates to whatever JavaScript functions its implementation + * object has on a per-instance basis.
  • *
  • If the Java method is overloaded (as in the above example {@code List.add()}), then your JavaScript adapter * must be prepared to deal with all overloads.
  • - *
  • You can't invoke {@code super.*()} from adapters for now.
  • + *
  • To invoke super methods from adapters, call them on the adapter instance prefixing them with {@code super$}, + * or use the special {@link #_super(Object, Object) super-adapter}.
  • *
  • It is also possible to specify an ordinary JavaScript object as the last argument to {@code extend}. In that * case, it is treated as a class-level override. {@code extend} will return an extender class where all instances * will have the methods implemented by functions on that object, just as if that object were passed as the last @@ -486,15 +489,18 @@ public final class NativeJava { * t.join() * * As you can see, you don't have to pass any object when you create a new instance of {@code R1} as its - * {@code run()} function was defined already when extending the class. Of course, you can still provide - * instance-level overrides on these objects. The order of precedence is instance-level method, class-level method, - * superclass method, or {@code UnsupportedOperationException} if the superclass method is abstract. If we continue - * our previous example: + * {@code run()} function was defined already when extending the class. If you also want to add instance-level + * overrides on these objects, you will have to repeatedly use {@code extend()} to subclass the class-level adapter. + * For such adapters, the order of precedence is instance-level method, class-level method, superclass method, or + * {@code UnsupportedOperationException} if the superclass method is abstract. If we continue our previous example: *
    -     * var r2 = new R1(function() { print("r2.run() invoked!") })
    +     * var R2 = Java.extend(R1);
    +     * var r2 = new R2(function() { print("r2.run() invoked!") })
          * r2.run()
          * 
    * We'll see it'll print {@code "r2.run() invoked!"}, thus overriding on instance-level the class-level behavior. + * Note that you must use {@code Java.extend} to explicitly create an instance-override adapter class from a + * class-override adapter class, as the class-override adapter class is no longer abstract. *
  • *
* @param self not used @@ -541,7 +547,18 @@ public final class NativeJava { } catch(final ClassCastException e) { throw typeError("extend.expects.java.types"); } - return JavaAdapterFactory.getAdapterClassFor(stypes, classOverrides); + // Note that while the public API documentation claims self is not used, we actually use it. + // ScriptFunction.findCallMethod will bind the lookup object into it, and we can then use that lookup when + // requesting the adapter class. Note that if Java.extend is invoked with no lookup object, it'll pass the + // public lookup which'll result in generation of a no-permissions adapter. A typical situation this can happen + // is when the extend function is bound. + final MethodHandles.Lookup lookup; + if(self instanceof MethodHandles.Lookup) { + lookup = (MethodHandles.Lookup)self; + } else { + lookup = MethodHandles.publicLookup(); + } + return JavaAdapterFactory.getAdapterClassFor(stypes, classOverrides, lookup); } /** diff --git a/nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java b/nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java index dd9231d9386..56baf66d229 100644 --- a/nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java +++ b/nashorn/src/jdk/nashorn/internal/objects/NativeJavaImporter.java @@ -33,6 +33,7 @@ import jdk.nashorn.internal.objects.annotations.Attribute; import jdk.nashorn.internal.objects.annotations.Constructor; import jdk.nashorn.internal.objects.annotations.Function; import jdk.nashorn.internal.objects.annotations.ScriptClass; +import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.NativeJavaPackage; import jdk.nashorn.internal.runtime.PropertyMap; import jdk.nashorn.internal.runtime.ScriptObject; @@ -161,8 +162,9 @@ public final class NativeJavaImporter extends ScriptObject { } else if (obj instanceof NativeJavaPackage) { final String pkgName = ((NativeJavaPackage)obj).getName(); final String fullName = pkgName.isEmpty() ? name : (pkgName + "." + name); + final Context context = Global.instance().getContext(); try { - return StaticClass.forClass(Class.forName(fullName)); + return StaticClass.forClass(context.findClass(fullName)); } catch (final ClassNotFoundException e) { // IGNORE } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/Context.java b/nashorn/src/jdk/nashorn/internal/runtime/Context.java index 1817ca928ba..e15ddd2c8fb 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/Context.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/Context.java @@ -37,7 +37,6 @@ import java.io.PrintWriter; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.reflect.Modifier; -import java.util.concurrent.atomic.AtomicLong; import java.net.MalformedURLException; import java.net.URL; import java.security.AccessControlContext; @@ -48,7 +47,7 @@ import java.security.Permissions; import java.security.PrivilegedAction; import java.security.ProtectionDomain; import java.util.Map; - +import java.util.concurrent.atomic.AtomicLong; import jdk.internal.org.objectweb.asm.ClassReader; import jdk.internal.org.objectweb.asm.util.CheckClassAdapter; import jdk.nashorn.api.scripting.ScriptObjectMirror; @@ -651,6 +650,19 @@ public final class Context { } } + /** + * Checks that the given package name can be accessed from no permissions context. + * + * @param pkgName package name + * @throw SecurityException if not accessible + */ + public static void checkPackageAccess(final String pkgName) { + final SecurityManager sm = System.getSecurityManager(); + if (sm != null) { + checkPackageAccess(sm, pkgName.endsWith(".")? pkgName : pkgName + "."); + } + } + /** * Checks that the given package can be accessed from no permissions context. * diff --git a/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java b/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java index a5abacb2134..591fd327c64 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/NativeJavaPackage.java @@ -85,6 +85,8 @@ public final class NativeJavaPackage extends ScriptObject { */ public NativeJavaPackage(final String name, final ScriptObject proto) { super(proto, null); + // defense-in-path, check here for sensitive packages + Context.checkPackageAccess(name); this.name = name; } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java index ae59855cb4b..d0669d709de 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/ScriptFunction.java @@ -26,14 +26,13 @@ package jdk.nashorn.internal.runtime; import static jdk.nashorn.internal.codegen.CompilerConstants.virtualCallNoLookup; +import static jdk.nashorn.internal.lookup.Lookup.MH; import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; -import static jdk.nashorn.internal.lookup.Lookup.MH; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; - import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.GuardedInvocation; import jdk.internal.dynalink.linker.LinkRequest; @@ -524,7 +523,11 @@ public abstract class ScriptFunction extends ScriptObject { } } else { final MethodHandle callHandle = getBestInvoker(type.dropParameterTypes(0, 1), request.getArguments()); - if (scopeCall) { + if (data.isBuiltin() && "extend".equals(data.getName())) { + // NOTE: the only built-in named "extend" is NativeJava.extend. As a special-case we're binding the + // current lookup as its "this" so it can do security-sensitive creation of adapter classes. + boundHandle = MH.dropArguments(MH.bindTo(callHandle, desc.getLookup()), 0, Object.class, Object.class); + } else if (scopeCall) { // Make a handle that drops the passed "this" argument and substitutes either Global or Undefined // (this, args...) => (args...) boundHandle = MH.bindTo(callHandle, needsWrappedThis() ? Context.getGlobalTrusted() : ScriptRuntime.UNDEFINED); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/AdaptationResult.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/AdaptationResult.java index de1cfccc2a9..52511e5d94e 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/AdaptationResult.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/AdaptationResult.java @@ -47,7 +47,8 @@ final class AdaptationResult { ERROR_NON_PUBLIC_CLASS, ERROR_NO_ACCESSIBLE_CONSTRUCTOR, ERROR_MULTIPLE_SUPERCLASSES, - ERROR_NO_COMMON_LOADER + ERROR_NO_COMMON_LOADER, + ERROR_FINAL_FINALIZER } static final AdaptationResult SUCCESSFUL_RESULT = new AdaptationResult(Outcome.SUCCESS, ""); diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java index f0d45317a8a..f3c8284be86 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JSObjectLinker.java @@ -32,6 +32,7 @@ import java.util.HashMap; import java.util.Map; import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.GuardedInvocation; +import jdk.internal.dynalink.linker.GuardedTypeConversion; import jdk.internal.dynalink.linker.GuardingTypeConverterFactory; import jdk.internal.dynalink.linker.LinkRequest; import jdk.internal.dynalink.linker.LinkerServices; @@ -79,7 +80,7 @@ final class JSObjectLinker implements TypeBasedGuardingDynamicLinker, GuardingTy } @Override - public GuardedInvocation convertToType(final Class sourceType, final Class targetType) throws Exception { + public GuardedTypeConversion convertToType(final Class sourceType, final Class targetType) throws Exception { final boolean sourceIsAlwaysJSObject = JSObject.class.isAssignableFrom(sourceType); if(!sourceIsAlwaysJSObject && !sourceType.isAssignableFrom(JSObject.class)) { return null; @@ -90,7 +91,7 @@ final class JSObjectLinker implements TypeBasedGuardingDynamicLinker, GuardingTy return null; } - return new GuardedInvocation(converter, sourceIsAlwaysJSObject ? null : IS_JSOBJECT_GUARD).asType(MethodType.methodType(targetType, sourceType)); + return new GuardedTypeConversion(new GuardedInvocation(converter, sourceIsAlwaysJSObject ? null : IS_JSOBJECT_GUARD).asType(MethodType.methodType(targetType, sourceType)), true); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java index ef2a6829a25..5aceb206331 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterBytecodeGenerator.java @@ -59,6 +59,7 @@ import java.util.Iterator; import java.util.List; import java.util.Set; import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.Handle; import jdk.internal.org.objectweb.asm.Label; import jdk.internal.org.objectweb.asm.Opcodes; import jdk.internal.org.objectweb.asm.Type; @@ -66,21 +67,23 @@ import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptObject; +import jdk.nashorn.internal.runtime.linker.AdaptationResult.Outcome; import sun.reflect.CallerSensitive; /** * Generates bytecode for a Java adapter class. Used by the {@link JavaAdapterFactory}. *

- * For every protected or public constructor in the extended class, the adapter class will have between one to three + * For every protected or public constructor in the extended class, the adapter class will have either one or two * public constructors (visibility of protected constructors in the extended class is promoted to public). - *

    - *
  • In every case, a constructor taking a trailing ScriptObject argument preceded by original constructor arguments - * is always created on the adapter class. When such a constructor is invoked, the passed ScriptObject's member - * functions are used to implement and/or override methods on the original class, dispatched by name. A single - * JavaScript function will act as the implementation for all overloaded methods of the same name. When methods on an - * adapter instance are invoked, the functions are invoked having the ScriptObject passed in the instance constructor as - * their "this". Subsequent changes to the ScriptObject (reassignment or removal of its functions) are not reflected in - * the adapter instance; the method implementations are bound to functions at constructor invocation time. + *
  • + *
  • For adapter classes with instance-level overrides, a constructor taking a trailing ScriptObject argument preceded + * by original constructor arguments is always created on the adapter class. When such a constructor is invoked, the + * passed ScriptObject's member functions are used to implement and/or override methods on the original class, + * dispatched by name. A single JavaScript function will act as the implementation for all overloaded methods of the + * same name. When methods on an adapter instance are invoked, the functions are invoked having the ScriptObject passed + * in the instance constructor as their "this". Subsequent changes to the ScriptObject (reassignment or removal of its + * functions) are not reflected in the adapter instance; the method implementations are bound to functions at + * constructor invocation time. * {@code java.lang.Object} methods {@code equals}, {@code hashCode}, and {@code toString} can also be overridden. The * only restriction is that since every JavaScript object already has a {@code toString} function through the * {@code Object.prototype}, the {@code toString} in the adapter is only overridden if the passed ScriptObject has a @@ -89,16 +92,17 @@ import sun.reflect.CallerSensitive; *
  • *
  • * If the original types collectively have only one abstract method, or have several of them, but all share the - * same name, an additional constructor is provided for every original constructor; this one takes a ScriptFunction as - * its last argument preceded by original constructor arguments. This constructor will use the passed function as the - * implementation for all abstract methods. For consistency, any concrete methods sharing the single abstract method - * name will also be overridden by the function. When methods on the adapter instance are invoked, the ScriptFunction is - * invoked with global or UNDEFINED as its "this" depending whether the function is non-strict or not. + * same name, an additional constructor for instance-level override adapter is provided for every original constructor; + * this one takes a ScriptFunction as its last argument preceded by original constructor arguments. This constructor + * will use the passed function as the implementation for all abstract methods. For consistency, any concrete methods + * sharing the single abstract method name will also be overridden by the function. When methods on the adapter instance + * are invoked, the ScriptFunction is invoked with UNDEFINED or Global as its "this" depending whether the function is + * strict or not. *
  • *
  • * If the adapter being generated can have class-level overrides, constructors taking same arguments as the superclass - * constructors are also created. These constructors simply delegate to the superclass constructor. They are used to - * create instances of the adapter class with no instance-level overrides. + * constructors are created. These constructors simply delegate to the superclass constructor. They are simply used to + * create instances of the adapter class, with no instance-level overrides, as they don't have them. *
  • *
*

@@ -111,16 +115,20 @@ import sun.reflect.CallerSensitive; * source-level script expression new X(a, b) { ... } (which is a proprietary syntax extension Nashorn uses * to resemble Java anonymous classes) is actually equivalent to new X(a, b, { ... }). *

- * It is possible to create two different classes: those that can have both class-level and instance-level overrides, - * and those that can only have instance-level overrides. When - * {@link JavaAdapterFactory#getAdapterClassFor(Class[], ScriptObject)} is invoked with non-null {@code classOverrides} - * parameter, an adapter class is created that can have class-level overrides, and the passed script object will be used - * as the implementations for its methods, just as in the above case of the constructor taking a script object. Note - * that in the case of class-level overrides, a new adapter class is created on every invocation, and the implementation - * object is bound to the class, not to any instance. All created instances will share these functions. Of course, when - * instances of such a class are being created, they can still take another object (or possibly a function) in their - * constructor's trailing position and thus provide further instance-specific overrides. The order of invocation is - * always instance-specified method, then a class-specified method, and finally the superclass method. + * It is possible to create two different adapter classes: those that can have class-level overrides, and those that can + * have instance-level overrides. When {@link JavaAdapterFactory#getAdapterClassFor(Class[], ScriptObject)} is invoked + * with non-null {@code classOverrides} parameter, an adapter class is created that can have class-level overrides, and + * the passed script object will be used as the implementations for its methods, just as in the above case of the + * constructor taking a script object. Note that in the case of class-level overrides, a new adapter class is created on + * every invocation, and the implementation object is bound to the class, not to any instance. All created instances + * will share these functions. If it is required to have both class-level overrides and instance-level overrides, the + * class-level override adapter class should be subclassed with an instance-override adapter. Since adapters delegate to + * super class when an overriding method handle is not specified, this will behave as expected. It is not possible to + * have both class-level and instance-level overrides in the same class for security reasons: adapter classes are + * defined with a protection domain of their creator code, and an adapter class that has both class and instance level + * overrides would need to have two potentially different protection domains: one for class-based behavior and one for + * instance-based behavior; since Java classes can only belong to a single protection domain, this could not be + * implemented securely. */ final class JavaAdapterBytecodeGenerator { static final Type CONTEXT_TYPE = Type.getType(Context.class); @@ -171,7 +179,6 @@ final class JavaAdapterBytecodeGenerator { private static final int MAX_GENERATED_TYPE_NAME_LENGTH = 255; private static final String CLASS_INIT = ""; - private static final String STATIC_GLOBAL_FIELD_NAME = "staticGlobal"; // Method name prefix for invoking super-methods static final String SUPER_PREFIX = "super$"; @@ -199,6 +206,7 @@ final class JavaAdapterBytecodeGenerator { private final Set finalMethods = new HashSet<>(EXCLUDED); private final Set methodInfos = new HashSet<>(); private boolean autoConvertibleFromFunction = false; + private boolean hasExplicitFinalizer = false; private final ClassWriter cw; @@ -207,8 +215,8 @@ final class JavaAdapterBytecodeGenerator { * @param superClass the superclass the adapter will extend. * @param interfaces the interfaces the adapter will implement. * @param commonLoader the class loader that can see all of superClass, interfaces, and Nashorn classes. - * @param classOverride true to generate the bytecode for the adapter that has both class-level and instance-level - * overrides, false to generate the bytecode for the adapter that only has instance-level overrides. + * @param classOverride true to generate the bytecode for the adapter that has class-level overrides, false to + * generate the bytecode for the adapter that has instance-level overrides. * @throws AdaptationException if the adapter can not be generated for some reason. */ JavaAdapterBytecodeGenerator(final Class superClass, final List> interfaces, @@ -230,8 +238,7 @@ final class JavaAdapterBytecodeGenerator { superClassName = Type.getInternalName(superClass); generatedClassName = getGeneratedClassName(superClass, interfaces); - cw.visit(Opcodes.V1_7, ACC_PUBLIC | ACC_SUPER | ACC_FINAL, generatedClassName, null, superClassName, getInternalTypeNames(interfaces)); - + cw.visit(Opcodes.V1_7, ACC_PUBLIC | ACC_SUPER, generatedClassName, null, superClassName, getInternalTypeNames(interfaces)); generateGlobalFields(); gatherMethods(superClass); @@ -244,17 +251,16 @@ final class JavaAdapterBytecodeGenerator { generateConstructors(); generateMethods(); generateSuperMethods(); + if (hasExplicitFinalizer) { + generateFinalizerMethods(); + } // } cw.visitEnd(); } private void generateGlobalFields() { - cw.visitField(ACC_PRIVATE | ACC_FINAL, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR, null, null).visitEnd(); + cw.visitField(ACC_PRIVATE | ACC_FINAL | (classOverride ? ACC_STATIC : 0), GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR, null, null).visitEnd(); usedFieldNames.add(GLOBAL_FIELD_NAME); - if(classOverride) { - cw.visitField(ACC_PRIVATE | ACC_FINAL | ACC_STATIC, STATIC_GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR, null, null).visitEnd(); - usedFieldNames.add(STATIC_GLOBAL_FIELD_NAME); - } } JavaAdapterClassLoader createAdapterClassLoader() { @@ -305,11 +311,9 @@ final class JavaAdapterBytecodeGenerator { } private void generateHandleFields() { + final int flags = ACC_PRIVATE | ACC_FINAL | (classOverride ? ACC_STATIC : 0); for (final MethodInfo mi: methodInfos) { - cw.visitField(ACC_PRIVATE | ACC_FINAL, mi.methodHandleInstanceFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR, null, null).visitEnd(); - if(classOverride) { - cw.visitField(ACC_PRIVATE | ACC_FINAL | ACC_STATIC, mi.methodHandleClassFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR, null, null).visitEnd(); - } + cw.visitField(flags, mi.methodHandleFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR, null, null).visitEnd(); } } @@ -337,7 +341,7 @@ final class JavaAdapterBytecodeGenerator { } else { mv.visitInsn(ACONST_NULL); } - mv.putstatic(generatedClassName, mi.methodHandleClassFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); + mv.putstatic(generatedClassName, mi.methodHandleFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); } initGlobal = new Label(); mv.goTo(initGlobal); @@ -351,15 +355,15 @@ final class JavaAdapterBytecodeGenerator { mv.aconst(mi.getName()); mv.aconst(Type.getMethodType(mi.type.toMethodDescriptorString())); mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getHandle", GET_HANDLE_OBJECT_DESCRIPTOR, false); - mv.putstatic(generatedClassName, mi.methodHandleClassFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); + mv.putstatic(generatedClassName, mi.methodHandleFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); } if(initGlobal != null) { mv.visitLabel(initGlobal); } - // Assign "staticGlobal = Context.getGlobal()" + // Assign "global = Context.getGlobal()" invokeGetGlobalWithNullCheck(mv); - mv.putstatic(generatedClassName, STATIC_GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); + mv.putstatic(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); endInitMethod(mv); } @@ -390,21 +394,21 @@ final class JavaAdapterBytecodeGenerator { // Generate a constructor that just delegates to ctor. This is used with class-level overrides, when we want // to create instances without further per-instance overrides. generateDelegatingConstructor(ctor); - } + } else { + // Generate a constructor that delegates to ctor, but takes an additional ScriptObject parameter at the + // beginning of its parameter list. + generateOverridingConstructor(ctor, false); - // Generate a constructor that delegates to ctor, but takes an additional ScriptObject parameter at the - // beginning of its parameter list. - generateOverridingConstructor(ctor, false); - - if (samName != null) { - if (!autoConvertibleFromFunction && ctor.getParameterTypes().length == 0) { - // If the original type only has a single abstract method name, as well as a default ctor, then it can - // be automatically converted from JS function. - autoConvertibleFromFunction = true; + if (samName != null) { + if (!autoConvertibleFromFunction && ctor.getParameterTypes().length == 0) { + // If the original type only has a single abstract method name, as well as a default ctor, then it can + // be automatically converted from JS function. + autoConvertibleFromFunction = true; + } + // If all our abstract methods have a single name, generate an additional constructor, one that takes a + // ScriptFunction as its first parameter and assigns it as the implementation for all abstract methods. + generateOverridingConstructor(ctor, true); } - // If all our abstract methods have a single name, generate an additional constructor, one that takes a - // ScriptFunction as its first parameter and assigns it as the implementation for all abstract methods. - generateOverridingConstructor(ctor, true); } } @@ -430,7 +434,7 @@ final class JavaAdapterBytecodeGenerator { } /** - * Generates a constructor for the adapter class. This constructor will take the same arguments as the supertype + * Generates a constructor for the instance adapter class. This constructor will take the same arguments as the supertype * constructor passed as the argument here, and delegate to it. However, it will take an additional argument of * either ScriptObject or ScriptFunction type (based on the value of the "fromFunction" parameter), and initialize * all the method handle fields of the adapter instance with functions from the script object (or the script @@ -498,7 +502,7 @@ final class JavaAdapterBytecodeGenerator { mv.aconst(Type.getMethodType(mi.type.toMethodDescriptorString())); mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "getHandle", getHandleDescriptor, false); } - mv.putfield(generatedClassName, mi.methodHandleInstanceFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); + mv.putfield(generatedClassName, mi.methodHandleFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); } // Assign "this.global = Context.getGlobal()" @@ -536,8 +540,7 @@ final class JavaAdapterBytecodeGenerator { private static class MethodInfo { private final Method method; private final MethodType type; - private String methodHandleInstanceFieldName; - private String methodHandleClassFieldName; + private String methodHandleFieldName; private MethodInfo(final Class clazz, final String name, final Class... argTypes) throws NoSuchMethodException { this(clazz.getDeclaredMethod(name, argTypes)); @@ -567,25 +570,20 @@ final class JavaAdapterBytecodeGenerator { return getName().hashCode() ^ type.hashCode(); } - void setIsCanonical(final Set usedFieldNames, boolean classOverride) { - methodHandleInstanceFieldName = nextName(usedFieldNames); - if(classOverride) { - methodHandleClassFieldName = nextName(usedFieldNames); - } + void setIsCanonical(final JavaAdapterBytecodeGenerator self) { + methodHandleFieldName = self.nextName(getName()); } + } - String nextName(final Set usedFieldNames) { - int i = 0; - final String name = getName(); - String nextName = name; - while (!usedFieldNames.add(nextName)) { - final String ordinal = String.valueOf(i++); - final int maxNameLen = 255 - ordinal.length(); - nextName = (name.length() <= maxNameLen ? name : name.substring(0, maxNameLen)).concat(ordinal); - } - return nextName; + private String nextName(final String name) { + int i = 0; + String nextName = name; + while (!usedFieldNames.add(nextName)) { + final String ordinal = String.valueOf(i++); + final int maxNameLen = 255 - ordinal.length(); + nextName = (name.length() <= maxNameLen ? name : name.substring(0, maxNameLen)).concat(ordinal); } - + return nextName; } private void generateMethods() { @@ -624,23 +622,19 @@ final class JavaAdapterBytecodeGenerator { methodDesc, null, exceptionNames)); mv.visitCode(); - final Label instanceHandleDefined = new Label(); - final Label classHandleDefined = new Label(); + final Label handleDefined = new Label(); final Type asmReturnType = Type.getType(type.returnType()); - // See if we have instance handle defined - mv.visitVarInsn(ALOAD, 0); - mv.getfield(generatedClassName, mi.methodHandleInstanceFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); - // stack: [instanceHandle] - jumpIfNonNullKeepOperand(mv, instanceHandleDefined); - + // See if we have overriding method handle defined if(classOverride) { - // See if we have the static handle - mv.getstatic(generatedClassName, mi.methodHandleClassFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); - // stack: [classHandle] - jumpIfNonNullKeepOperand(mv, classHandleDefined); + mv.getstatic(generatedClassName, mi.methodHandleFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); + } else { + mv.visitVarInsn(ALOAD, 0); + mv.getfield(generatedClassName, mi.methodHandleFieldName, METHOD_HANDLE_TYPE_DESCRIPTOR); } + // stack: [handle] + jumpIfNonNullKeepOperand(mv, handleDefined); // No handle is available, fall back to default behavior if(Modifier.isAbstract(method.getModifiers())) { @@ -654,25 +648,17 @@ final class JavaAdapterBytecodeGenerator { emitSuperCall(mv, method.getDeclaringClass(), name, methodDesc); } - final Label setupGlobal = new Label(); - + mv.visitLabel(handleDefined); + // Load the creatingGlobal object if(classOverride) { - mv.visitLabel(classHandleDefined); // If class handle is defined, load the static defining global - mv.getstatic(generatedClassName, STATIC_GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); - // stack: [creatingGlobal := classGlobal, classHandle] - mv.goTo(setupGlobal); + mv.getstatic(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); + } else { + mv.visitVarInsn(ALOAD, 0); + mv.getfield(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); } - - mv.visitLabel(instanceHandleDefined); - // If instance handle is defined, load the instance defining global - mv.visitVarInsn(ALOAD, 0); - mv.getfield(generatedClassName, GLOBAL_FIELD_NAME, SCRIPT_OBJECT_TYPE_DESCRIPTOR); - // stack: [creatingGlobal := instanceGlobal, instanceHandle] - - // fallthrough to setupGlobal - - // stack: [creatingGlobal, someHandle] + // stack: [creatingGlobal, handle] + final Label setupGlobal = new Label(); mv.visitLabel(setupGlobal); // Determine the first index for a local variable @@ -685,38 +671,39 @@ final class JavaAdapterBytecodeGenerator { final int globalsDifferVar = nextLocalVar++; mv.dup(); - // stack: [creatingGlobal, creatingGlobal, someHandle] + // stack: [creatingGlobal, creatingGlobal, handle] // Emit code for switching to the creating global // ScriptObject currentGlobal = Context.getGlobal(); invokeGetGlobal(mv); mv.dup(); + mv.visitVarInsn(ASTORE, currentGlobalVar); - // stack: [currentGlobal, creatingGlobal, creatingGlobal, someHandle] + // stack: [currentGlobal, creatingGlobal, creatingGlobal, handle] // if(definingGlobal == currentGlobal) { final Label globalsDiffer = new Label(); mv.ifacmpne(globalsDiffer); - // stack: [someGlobal, someHandle] + // stack: [creatingGlobal, handle] // globalsDiffer = false mv.pop(); - // stack: [someHandle] + // stack: [handle] mv.iconst(0); // false - // stack: [false, someHandle] + // stack: [false, handle] final Label invokeHandle = new Label(); mv.goTo(invokeHandle); mv.visitLabel(globalsDiffer); // } else { // Context.setGlobal(definingGlobal); - // stack: [someGlobal, someHandle] + // stack: [creatingGlobal, handle] invokeSetGlobal(mv); - // stack: [someHandle] + // stack: [handle] // globalsDiffer = true mv.iconst(1); - // stack: [true, someHandle] + // stack: [true, handle] mv.visitLabel(invokeHandle); mv.visitVarInsn(ISTORE, globalsDifferVar); - // stack: [someHandle] + // stack: [handle] // Load all parameters back on stack for dynamic invocation. int varOffset = 1; @@ -835,7 +822,7 @@ final class JavaAdapterBytecodeGenerator { endMethod(mv); } - private void emitSuperCall(final InstructionAdapter mv, final Class owner, final String name, final String methodDesc) { + private void emitSuperCall(final InstructionAdapter mv, final Class owner, final String name, final String methodDesc) { mv.visitVarInsn(ALOAD, 0); int nextParam = 1; final Type methodType = Type.getMethodType(methodDesc); @@ -853,6 +840,42 @@ final class JavaAdapterBytecodeGenerator { mv.areturn(methodType.getReturnType()); } + private void generateFinalizerMethods() { + final String finalizerDelegateName = nextName("access$"); + generateFinalizerDelegate(finalizerDelegateName); + generateFinalizerOverride(finalizerDelegateName); + } + + private void generateFinalizerDelegate(final String finalizerDelegateName) { + // Generate a delegate that will be invoked from the no-permission trampoline. Note it can be private, as we'll + // refer to it with a MethodHandle constant pool entry in the overridden finalize() method (see + // generateFinalizerOverride()). + final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PRIVATE | ACC_STATIC, + finalizerDelegateName, Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE), null, null)); + + // Simply invoke super.finalize() + mv.visitVarInsn(ALOAD, 0); + mv.checkcast(Type.getType(generatedClassName)); + mv.invokespecial(superClassName, "finalize", Type.getMethodDescriptor(Type.VOID_TYPE), false); + + mv.visitInsn(RETURN); + endMethod(mv); + } + + private void generateFinalizerOverride(final String finalizerDelegateName) { + final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC, "finalize", + VOID_NOARG_METHOD_DESCRIPTOR, null, null)); + // Overridden finalizer will take a MethodHandle to the finalizer delegating method, ... + mv.aconst(new Handle(Opcodes.H_INVOKESTATIC, generatedClassName, finalizerDelegateName, + Type.getMethodDescriptor(Type.VOID_TYPE, OBJECT_TYPE))); + mv.visitVarInsn(ALOAD, 0); + // ...and invoke it through JavaAdapterServices.invokeNoPermissions + mv.invokestatic(SERVICES_CLASS_TYPE_NAME, "invokeNoPermissions", + Type.getMethodDescriptor(METHOD_HANDLE_TYPE, OBJECT_TYPE), false); + mv.visitInsn(RETURN); + endMethod(mv); + } + private static String[] getExceptionNames(final Class[] exceptions) { final String[] exceptionNames = new String[exceptions.length]; for (int i = 0; i < exceptions.length; ++i) { @@ -873,16 +896,32 @@ final class JavaAdapterBytecodeGenerator { * class. * @param type the type defining the methods. */ - private void gatherMethods(final Class type) { + private void gatherMethods(final Class type) throws AdaptationException { if (Modifier.isPublic(type.getModifiers())) { final Method[] typeMethods = type.isInterface() ? type.getMethods() : type.getDeclaredMethods(); for (final Method typeMethod: typeMethods) { + final String name = typeMethod.getName(); + if(name.startsWith(SUPER_PREFIX)) { + continue; + } final int m = typeMethod.getModifiers(); if (Modifier.isStatic(m)) { continue; } if (Modifier.isPublic(m) || Modifier.isProtected(m)) { + // Is it a "finalize()"? + if(name.equals("finalize") && typeMethod.getParameterCount() == 0) { + if(type != Object.class) { + hasExplicitFinalizer = true; + if(Modifier.isFinal(m)) { + // Must be able to override an explicit finalizer + throw new AdaptationException(Outcome.ERROR_FINAL_FINALIZER, type.getCanonicalName()); + } + } + continue; + } + final MethodInfo mi = new MethodInfo(typeMethod); if (Modifier.isFinal(m) || isCallerSensitive(typeMethod)) { finalMethods.add(mi); @@ -890,7 +929,7 @@ final class JavaAdapterBytecodeGenerator { if (Modifier.isAbstract(m)) { abstractMethodNames.add(mi.getName()); } - mi.setIsCanonical(usedFieldNames, classOverride); + mi.setIsCanonical(this); } } } @@ -911,7 +950,7 @@ final class JavaAdapterBytecodeGenerator { } } - private void gatherMethods(final List> classes) { + private void gatherMethods(final List> classes) throws AdaptationException { for(final Class c: classes) { gatherMethods(c); } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java index 0062cd5f893..fa162d88d47 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterClassLoader.java @@ -27,10 +27,6 @@ package jdk.nashorn.internal.runtime.linker; import java.security.AccessControlContext; import java.security.AccessController; -import java.security.AllPermission; -import java.security.CodeSigner; -import java.security.CodeSource; -import java.security.Permissions; import java.security.PrivilegedAction; import java.security.ProtectionDomain; import java.security.SecureClassLoader; @@ -45,35 +41,29 @@ import jdk.internal.dynalink.beans.StaticClass; */ @SuppressWarnings("javadoc") final class JavaAdapterClassLoader { - private static final ProtectionDomain GENERATED_PROTECTION_DOMAIN = createGeneratedProtectionDomain(); private static final AccessControlContext CREATE_LOADER_ACC_CTXT = ClassAndLoader.createPermAccCtxt("createClassLoader"); private final String className; - private volatile byte[] classBytes; + private final byte[] classBytes; JavaAdapterClassLoader(String className, byte[] classBytes) { this.className = className.replace('/', '.'); this.classBytes = classBytes; } - /** - * clear classBytes after loading class. - */ - void clearClassBytes() { - this.classBytes = null; - } - /** * Loads the generated adapter class into the JVM. * @param parentLoader the parent class loader for the generated class loader + * @param protectionDomain the protection domain for the generated class * @return the generated adapter class */ - StaticClass generateClass(final ClassLoader parentLoader) { + StaticClass generateClass(final ClassLoader parentLoader, final ProtectionDomain protectionDomain) { + assert protectionDomain != null; return AccessController.doPrivileged(new PrivilegedAction() { @Override public StaticClass run() { try { - return StaticClass.forClass(Class.forName(className, true, createClassLoader(parentLoader))); + return StaticClass.forClass(Class.forName(className, true, createClassLoader(parentLoader, protectionDomain))); } catch (final ClassNotFoundException e) { throw new AssertionError(e); // cannot happen } @@ -88,7 +78,7 @@ final class JavaAdapterClassLoader { // it even more by separating its invocation into a separate static method on the adapter class, but then someone // with ability to introspect on the class and use setAccessible(true) on it could invoke the method. It's a // security tradeoff... - private ClassLoader createClassLoader(final ClassLoader parentLoader) { + private ClassLoader createClassLoader(final ClassLoader parentLoader, final ProtectionDomain protectionDomain) { return new SecureClassLoader(parentLoader) { private final ClassLoader myLoader = getClass().getClassLoader(); @@ -112,21 +102,10 @@ final class JavaAdapterClassLoader { protected Class findClass(final String name) throws ClassNotFoundException { if(name.equals(className)) { assert classBytes != null : "what? already cleared .class bytes!!"; - return defineClass(name, classBytes, 0, classBytes.length, GENERATED_PROTECTION_DOMAIN); + return defineClass(name, classBytes, 0, classBytes.length, protectionDomain); } throw new ClassNotFoundException(name); } }; } - - private static ProtectionDomain createGeneratedProtectionDomain() { - // Generated classes need to have AllPermission. Since we require the "createClassLoader" RuntimePermission, we - // can create a class loader that'll load new classes with any permissions. Our generated classes are just - // delegating adapters, so having AllPermission can't cause anything wrong; the effective set of permissions for - // the executing script functions will still be limited by the permissions of the caller and the permissions of - // the script. - final Permissions permissions = new Permissions(); - permissions.add(new AllPermission()); - return new ProtectionDomain(new CodeSource(null, (CodeSigner[])null), permissions); - } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java index ccb2c87982e..5e0b890a6d2 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterFactory.java @@ -29,17 +29,23 @@ import static jdk.nashorn.internal.lookup.Lookup.MH; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles.Lookup; import java.lang.invoke.MethodType; import java.lang.reflect.Modifier; import java.security.AccessControlContext; import java.security.AccessController; +import java.security.CodeSigner; +import java.security.CodeSource; +import java.security.Permissions; import java.security.PrivilegedAction; +import java.security.ProtectionDomain; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; import java.util.HashMap; import java.util.List; import java.util.Map; +import java.util.concurrent.ConcurrentHashMap; import jdk.internal.dynalink.beans.StaticClass; import jdk.internal.dynalink.support.LinkRequestImpl; import jdk.nashorn.internal.objects.NativeJava; @@ -70,6 +76,8 @@ import jdk.nashorn.internal.runtime.ScriptObject; @SuppressWarnings("javadoc") public final class JavaAdapterFactory { + private static final ProtectionDomain MINIMAL_PERMISSION_DOMAIN = createMinimalPermissionDomain(); + // context with permissions needs for AdapterInfo creation private static final AccessControlContext CREATE_ADAPTER_INFO_ACC_CTXT = ClassAndLoader.createPermAccCtxt("createClassLoader", "getClassLoader", @@ -99,11 +107,18 @@ public final class JavaAdapterFactory { * @param classOverrides a JavaScript object with functions serving as the class-level overrides and * implementations. These overrides are defined for all instances of the class, and can be further overridden on a * per-instance basis by passing additional objects in the constructor. + * @param lookup the lookup object identifying the caller class. The generated adapter class will have the + * protection domain of the caller class iff the lookup object is full-strength, otherwise it will be completely + * unprivileged. * @return an adapter class. See this class' documentation for details on the generated adapter class. * @throws ECMAException with a TypeError if the adapter class can not be generated because the original class is * final, non-public, or has no public or protected constructors. */ - public static StaticClass getAdapterClassFor(final Class[] types, ScriptObject classOverrides) { + public static StaticClass getAdapterClassFor(final Class[] types, ScriptObject classOverrides, final MethodHandles.Lookup lookup) { + return getAdapterClassFor(types, classOverrides, getProtectionDomain(lookup)); + } + + private static StaticClass getAdapterClassFor(final Class[] types, ScriptObject classOverrides, final ProtectionDomain protectionDomain) { assert types != null && types.length > 0; final SecurityManager sm = System.getSecurityManager(); if (sm != null) { @@ -114,7 +129,23 @@ public final class JavaAdapterFactory { ReflectionCheckLinker.checkReflectionAccess(type, true); } } - return getAdapterInfo(types).getAdapterClassFor(classOverrides); + return getAdapterInfo(types).getAdapterClass(classOverrides, protectionDomain); + } + + private static ProtectionDomain getProtectionDomain(final MethodHandles.Lookup lookup) { + if((lookup.lookupModes() & Lookup.PRIVATE) == 0) { + return MINIMAL_PERMISSION_DOMAIN; + } + return getProtectionDomain(lookup.lookupClass()); + } + + private static ProtectionDomain getProtectionDomain(final Class clazz) { + return AccessController.doPrivileged(new PrivilegedAction() { + @Override + public ProtectionDomain run() { + return clazz.getProtectionDomain(); + } + }); } /** @@ -129,10 +160,10 @@ public final class JavaAdapterFactory { * @return the constructor method handle. * @throws Exception if anything goes wrong */ - public static MethodHandle getConstructor(final Class sourceType, final Class targetType) throws Exception { - final StaticClass adapterClass = getAdapterClassFor(new Class[] { targetType }, null); + public static MethodHandle getConstructor(final Class sourceType, final Class targetType, final MethodHandles.Lookup lookup) throws Exception { + final StaticClass adapterClass = getAdapterClassFor(new Class[] { targetType }, null, lookup); return MH.bindTo(Bootstrap.getLinkerServices().getGuardedInvocation(new LinkRequestImpl( - NashornCallSiteDescriptor.get(MethodHandles.publicLookup(), "dyn:new", + NashornCallSiteDescriptor.get(lookup, "dyn:new", MethodType.methodType(targetType, StaticClass.class, sourceType), 0), false, adapterClass, null)).getInvocation(), adapterClass); } @@ -220,10 +251,10 @@ public final class JavaAdapterFactory { private static final ClassAndLoader SCRIPT_OBJECT_LOADER = new ClassAndLoader(ScriptObject.class, true); private final ClassLoader commonLoader; - private final JavaAdapterClassLoader adapterGenerator; - // Cacheable adapter class that is shared by all adapter instances that don't have class overrides, only - // instance overrides. - final StaticClass instanceAdapterClass; + // TODO: soft reference the JavaAdapterClassLoader objects. They can be recreated when needed. + private final JavaAdapterClassLoader classAdapterGenerator; + private final JavaAdapterClassLoader instanceAdapterGenerator; + private final Map instanceAdapters = new ConcurrentHashMap<>(); final boolean autoConvertibleFromFunction; final AdaptationResult adaptationResult; @@ -231,11 +262,8 @@ public final class JavaAdapterFactory { this.commonLoader = findCommonLoader(definingLoader); final JavaAdapterBytecodeGenerator gen = new JavaAdapterBytecodeGenerator(superClass, interfaces, commonLoader, false); this.autoConvertibleFromFunction = gen.isAutoConvertibleFromFunction(); - final JavaAdapterClassLoader jacl = gen.createAdapterClassLoader(); - this.instanceAdapterClass = jacl.generateClass(commonLoader); - // loaded Class - no need to keep class bytes around - jacl.clearClassBytes(); - this.adapterGenerator = new JavaAdapterBytecodeGenerator(superClass, interfaces, commonLoader, true).createAdapterClassLoader(); + instanceAdapterGenerator = gen.createAdapterClassLoader(); + this.classAdapterGenerator = new JavaAdapterBytecodeGenerator(superClass, interfaces, commonLoader, true).createAdapterClassLoader(); this.adaptationResult = AdaptationResult.SUCCESSFUL_RESULT; } @@ -245,22 +273,42 @@ public final class JavaAdapterFactory { AdapterInfo(final AdaptationResult adaptationResult) { this.commonLoader = null; - this.adapterGenerator = null; - this.instanceAdapterClass = null; + this.classAdapterGenerator = null; + this.instanceAdapterGenerator = null; this.autoConvertibleFromFunction = false; this.adaptationResult = adaptationResult; } - StaticClass getAdapterClassFor(ScriptObject classOverrides) { + StaticClass getAdapterClass(final ScriptObject classOverrides, final ProtectionDomain protectionDomain) { if(adaptationResult.getOutcome() != AdaptationResult.Outcome.SUCCESS) { throw adaptationResult.typeError(); } - if(classOverrides == null) { + return classOverrides == null ? getInstanceAdapterClass(protectionDomain) : + getClassAdapterClass(classOverrides, protectionDomain); + } + + private StaticClass getInstanceAdapterClass(final ProtectionDomain protectionDomain) { + CodeSource codeSource = protectionDomain.getCodeSource(); + if(codeSource == null) { + codeSource = MINIMAL_PERMISSION_DOMAIN.getCodeSource(); + } + StaticClass instanceAdapterClass = instanceAdapters.get(codeSource); + if(instanceAdapterClass != null) { return instanceAdapterClass; } + // Any "unknown source" code source will default to no permission domain. + final ProtectionDomain effectiveDomain = codeSource.equals(MINIMAL_PERMISSION_DOMAIN.getCodeSource()) ? + MINIMAL_PERMISSION_DOMAIN : protectionDomain; + + instanceAdapterClass = instanceAdapterGenerator.generateClass(commonLoader, effectiveDomain); + final StaticClass existing = instanceAdapters.putIfAbsent(codeSource, instanceAdapterClass); + return existing == null ? instanceAdapterClass : existing; + } + + private StaticClass getClassAdapterClass(final ScriptObject classOverrides, final ProtectionDomain protectionDomain) { JavaAdapterServices.setClassOverrides(classOverrides); try { - return adapterGenerator.generateClass(commonLoader); + return classAdapterGenerator.generateClass(commonLoader, protectionDomain); } finally { JavaAdapterServices.setClassOverrides(null); } @@ -285,4 +333,12 @@ public final class JavaAdapterFactory { throw new AdaptationException(AdaptationResult.Outcome.ERROR_NO_COMMON_LOADER, classAndLoader.getRepresentativeClass().getCanonicalName()); } } + + private static ProtectionDomain createMinimalPermissionDomain() { + // Generated classes need to have at least the permission to access Nashorn runtime and runtime.linker packages. + final Permissions permissions = new Permissions(); + permissions.add(new RuntimePermission("accessClassInPackage.jdk.nashorn.internal.runtime")); + permissions.add(new RuntimePermission("accessClassInPackage.jdk.nashorn.internal.runtime.linker")); + return new ProtectionDomain(new CodeSource(null, (CodeSigner[])null), permissions); + } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterServices.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterServices.java index 06ae1b1109b..1188c6b6f73 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterServices.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/JavaAdapterServices.java @@ -25,10 +25,28 @@ package jdk.nashorn.internal.runtime.linker; +import static jdk.internal.org.objectweb.asm.Opcodes.ACC_FINAL; +import static jdk.internal.org.objectweb.asm.Opcodes.ACC_PUBLIC; +import static jdk.internal.org.objectweb.asm.Opcodes.ACC_STATIC; +import static jdk.internal.org.objectweb.asm.Opcodes.ACC_SUPER; +import static jdk.internal.org.objectweb.asm.Opcodes.ALOAD; +import static jdk.internal.org.objectweb.asm.Opcodes.RETURN; import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; import java.lang.invoke.MethodHandle; +import java.lang.invoke.MethodHandles; import java.lang.invoke.MethodType; +import java.security.AccessController; +import java.security.CodeSigner; +import java.security.CodeSource; +import java.security.Permissions; +import java.security.PrivilegedAction; +import java.security.ProtectionDomain; +import java.security.SecureClassLoader; +import jdk.internal.org.objectweb.asm.ClassWriter; +import jdk.internal.org.objectweb.asm.Opcodes; +import jdk.internal.org.objectweb.asm.Type; +import jdk.internal.org.objectweb.asm.commons.InstructionAdapter; import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptObject; @@ -40,6 +58,7 @@ import jdk.nashorn.internal.runtime.Undefined; */ public final class JavaAdapterServices { private static final ThreadLocal classOverrides = new ThreadLocal<>(); + private static final MethodHandle NO_PERMISSIONS_INVOKER = createNoPermissionsInvoker(); private JavaAdapterServices() { } @@ -55,7 +74,7 @@ public final class JavaAdapterServices { */ public static MethodHandle getHandle(final ScriptFunction fn, final MethodType type) { // JS "this" will be global object or undefined depending on if 'fn' is strict or not - return adaptHandle(fn.getBoundInvokeHandle(fn.isStrict()? ScriptRuntime.UNDEFINED : Context.getGlobal()), type); + return bindAndAdaptHandle(fn, fn.isStrict()? ScriptRuntime.UNDEFINED : Context.getGlobal(), type); } /** @@ -83,7 +102,7 @@ public final class JavaAdapterServices { final Object fnObj = sobj.get(name); if (fnObj instanceof ScriptFunction) { - return adaptHandle(((ScriptFunction)fnObj).getBoundInvokeHandle(sobj), type); + return bindAndAdaptHandle((ScriptFunction)fnObj, sobj, type); } else if(fnObj == null || fnObj instanceof Undefined) { return null; } else { @@ -103,11 +122,67 @@ public final class JavaAdapterServices { return overrides; } + /** + * Takes a method handle and an argument to it, and invokes the method handle passing it the argument. Basically + * equivalent to {@code method.invokeExact(arg)}, except that the method handle will be invoked in a protection + * domain with absolutely no permissions. + * @param method the method handle to invoke. The handle must have the exact type of {@code void(Object)}. + * @param arg the argument to pass to the handle. + * @throws Throwable if anything goes wrong. + */ + public static void invokeNoPermissions(final MethodHandle method, final Object arg) throws Throwable { + NO_PERMISSIONS_INVOKER.invokeExact(method, arg); + } + static void setClassOverrides(ScriptObject overrides) { classOverrides.set(overrides); } - private static MethodHandle adaptHandle(final MethodHandle handle, final MethodType type) { - return Bootstrap.getLinkerServices().asType(ScriptObject.pairArguments(handle, type, false), type); + private static MethodHandle bindAndAdaptHandle(final ScriptFunction fn, final Object self, final MethodType type) { + return Bootstrap.getLinkerServices().asType(ScriptObject.pairArguments(fn.getBoundInvokeHandle(self), type, false), type); + } + + private static MethodHandle createNoPermissionsInvoker() { + final String className = "NoPermissionsInvoker"; + + final ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_FRAMES | ClassWriter.COMPUTE_MAXS); + cw.visit(Opcodes.V1_7, ACC_PUBLIC | ACC_SUPER | ACC_FINAL, className, null, "java/lang/Object", null); + final Type objectType = Type.getType(Object.class); + final Type methodHandleType = Type.getType(MethodHandle.class); + final InstructionAdapter mv = new InstructionAdapter(cw.visitMethod(ACC_PUBLIC | ACC_STATIC, "invoke", + Type.getMethodDescriptor(Type.VOID_TYPE, methodHandleType, objectType), null, null)); + mv.visitCode(); + mv.visitVarInsn(ALOAD, 0); + mv.visitVarInsn(ALOAD, 1); + mv.invokevirtual(methodHandleType.getInternalName(), "invokeExact", Type.getMethodDescriptor( + Type.VOID_TYPE, objectType), false); + mv.visitInsn(RETURN); + mv.visitMaxs(0, 0); + mv.visitEnd(); + cw.visitEnd(); + final byte[] bytes = cw.toByteArray(); + + final ClassLoader loader = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public ClassLoader run() { + return new SecureClassLoader(null) { + @Override + protected Class findClass(String name) throws ClassNotFoundException { + if(name.equals(className)) { + return defineClass(name, bytes, 0, bytes.length, new ProtectionDomain( + new CodeSource(null, (CodeSigner[])null), new Permissions())); + } + throw new ClassNotFoundException(name); + } + }; + } + }); + + try { + return MethodHandles.lookup().findStatic(Class.forName(className, true, loader), "invoke", + MethodType.methodType(void.class, MethodHandle.class, Object.class)); + } catch(ReflectiveOperationException e) { + throw new AssertionError(e.getMessage(), e); + } } } diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java index c94df15b192..88ccf5a4847 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornBottomLinker.java @@ -25,19 +25,20 @@ package jdk.nashorn.internal.runtime.linker; +import static jdk.nashorn.internal.lookup.Lookup.MH; import static jdk.nashorn.internal.runtime.ECMAErrors.typeError; import static jdk.nashorn.internal.runtime.ScriptRuntime.UNDEFINED; -import static jdk.nashorn.internal.lookup.Lookup.MH; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodType; import java.lang.reflect.Method; import java.lang.reflect.Modifier; -import java.util.Map; import java.util.HashMap; +import java.util.Map; import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.beans.BeansLinker; import jdk.internal.dynalink.linker.GuardedInvocation; +import jdk.internal.dynalink.linker.GuardedTypeConversion; import jdk.internal.dynalink.linker.GuardingDynamicLinker; import jdk.internal.dynalink.linker.GuardingTypeConverterFactory; import jdk.internal.dynalink.linker.LinkRequest; @@ -134,9 +135,9 @@ final class NashornBottomLinker implements GuardingDynamicLinker, GuardingTypeCo } @Override - public GuardedInvocation convertToType(final Class sourceType, final Class targetType) throws Exception { + public GuardedTypeConversion convertToType(final Class sourceType, final Class targetType) throws Exception { final GuardedInvocation gi = convertToTypeNoCast(sourceType, targetType); - return gi == null ? null : gi.asType(MH.type(targetType, sourceType)); + return gi == null ? null : new GuardedTypeConversion(gi.asType(MH.type(targetType, sourceType)), true); } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornLinker.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornLinker.java index 27e4573f572..0ac5f9a56e5 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornLinker.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornLinker.java @@ -29,7 +29,10 @@ import static jdk.nashorn.internal.lookup.Lookup.MH; import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; +import java.lang.invoke.MethodHandles.Lookup; import java.lang.reflect.Modifier; +import java.security.AccessController; +import java.security.PrivilegedAction; import java.util.Deque; import java.util.List; import java.util.Map; @@ -37,16 +40,17 @@ import javax.script.Bindings; import jdk.internal.dynalink.CallSiteDescriptor; import jdk.internal.dynalink.linker.ConversionComparator; import jdk.internal.dynalink.linker.GuardedInvocation; +import jdk.internal.dynalink.linker.GuardedTypeConversion; import jdk.internal.dynalink.linker.GuardingTypeConverterFactory; import jdk.internal.dynalink.linker.LinkRequest; import jdk.internal.dynalink.linker.LinkerServices; import jdk.internal.dynalink.linker.TypeBasedGuardingDynamicLinker; import jdk.internal.dynalink.support.Guards; +import jdk.internal.dynalink.support.LinkerServicesImpl; import jdk.nashorn.api.scripting.JSObject; import jdk.nashorn.api.scripting.ScriptObjectMirror; import jdk.nashorn.api.scripting.ScriptUtils; import jdk.nashorn.internal.objects.NativeArray; -import jdk.nashorn.internal.runtime.Context; import jdk.nashorn.internal.runtime.JSType; import jdk.nashorn.internal.runtime.ScriptFunction; import jdk.nashorn.internal.runtime.ScriptObject; @@ -100,9 +104,16 @@ final class NashornLinker implements TypeBasedGuardingDynamicLinker, GuardingTyp } @Override - public GuardedInvocation convertToType(final Class sourceType, final Class targetType) throws Exception { - final GuardedInvocation gi = convertToTypeNoCast(sourceType, targetType); - return gi == null ? null : gi.asType(MH.type(targetType, sourceType)); + public GuardedTypeConversion convertToType(final Class sourceType, final Class targetType) throws Exception { + GuardedInvocation gi = convertToTypeNoCast(sourceType, targetType); + if(gi != null) { + return new GuardedTypeConversion(gi.asType(MH.type(targetType, sourceType)), true); + } + gi = getSamTypeConverter(sourceType, targetType); + if(gi != null) { + return new GuardedTypeConversion(gi.asType(MH.type(targetType, sourceType)), false); + } + return null; } /** @@ -126,12 +137,7 @@ final class NashornLinker implements TypeBasedGuardingDynamicLinker, GuardingTyp return arrayConverter; } - final GuardedInvocation mirrorConverter = getMirrorConverter(sourceType, targetType); - if(mirrorConverter != null) { - return mirrorConverter; - } - - return getSamTypeConverter(sourceType, targetType); + return getMirrorConverter(sourceType, targetType); } /** @@ -150,13 +156,23 @@ final class NashornLinker implements TypeBasedGuardingDynamicLinker, GuardingTyp final boolean isSourceTypeGeneric = sourceType.isAssignableFrom(ScriptFunction.class); if ((isSourceTypeGeneric || ScriptFunction.class.isAssignableFrom(sourceType)) && isAutoConvertibleFromFunction(targetType)) { - final MethodHandle ctor = JavaAdapterFactory.getConstructor(ScriptFunction.class, targetType); + final MethodHandle ctor = JavaAdapterFactory.getConstructor(ScriptFunction.class, targetType, getCurrentLookup()); assert ctor != null; // if isAutoConvertibleFromFunction() returned true, then ctor must exist. return new GuardedInvocation(ctor, isSourceTypeGeneric ? IS_SCRIPT_FUNCTION : null); } return null; } + private static Lookup getCurrentLookup() { + final LinkRequest currentRequest = AccessController.doPrivileged(new PrivilegedAction() { + @Override + public LinkRequest run() { + return LinkerServicesImpl.getCurrentLinkRequest(); + } + }); + return currentRequest == null ? MethodHandles.publicLookup() : currentRequest.getCallSiteDescriptor().getLookup(); + } + /** * Returns a guarded invocation that converts from a source type that is NativeArray to a Java array or List or * Deque type. diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java index ccd95fda642..5cc1cd2c632 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornPrimitiveLinker.java @@ -31,6 +31,7 @@ import java.lang.invoke.MethodHandle; import java.lang.invoke.MethodHandles; import jdk.internal.dynalink.linker.ConversionComparator; import jdk.internal.dynalink.linker.GuardedInvocation; +import jdk.internal.dynalink.linker.GuardedTypeConversion; import jdk.internal.dynalink.linker.GuardingTypeConverterFactory; import jdk.internal.dynalink.linker.LinkRequest; import jdk.internal.dynalink.linker.LinkerServices; @@ -75,13 +76,13 @@ final class NashornPrimitiveLinker implements TypeBasedGuardingDynamicLinker, Gu * @return a conditional converter from source to target type */ @Override - public GuardedInvocation convertToType(final Class sourceType, final Class targetType) { + public GuardedTypeConversion convertToType(final Class sourceType, final Class targetType) { final MethodHandle mh = JavaArgumentConverters.getConverter(targetType); if (mh == null) { return null; } - return new GuardedInvocation(mh, canLinkTypeStatic(sourceType) ? null : GUARD_PRIMITIVE).asType(mh.type().changeParameterType(0, sourceType)); + return new GuardedTypeConversion(new GuardedInvocation(mh, canLinkTypeStatic(sourceType) ? null : GUARD_PRIMITIVE).asType(mh.type().changeParameterType(0, sourceType)), true); } /** diff --git a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java index 21e2d14eb4e..272b4ec0ac4 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java +++ b/nashorn/src/jdk/nashorn/internal/runtime/linker/NashornStaticClassLinker.java @@ -76,7 +76,8 @@ final class NashornStaticClassLinker implements TypeBasedGuardingDynamicLinker { if (NashornLinker.isAbstractClass(receiverClass)) { // Change this link request into a link request on the adapter class. final Object[] args = request.getArguments(); - args[0] = JavaAdapterFactory.getAdapterClassFor(new Class[] { receiverClass }, null); + args[0] = JavaAdapterFactory.getAdapterClassFor(new Class[] { receiverClass }, null, + linkRequest.getCallSiteDescriptor().getLookup()); final LinkRequest adapterRequest = request.replaceArguments(request.getCallSiteDescriptor(), args); final GuardedInvocation gi = checkNullConstructor(delegate(linkerServices, adapterRequest), receiverClass); // Finally, modify the guard to test for the original abstract class. diff --git a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties index 1a37ba7bf76..95993c9f40e 100644 --- a/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties +++ b/nashorn/src/jdk/nashorn/internal/runtime/resources/Messages.properties @@ -130,6 +130,7 @@ type.error.extend.ERROR_NON_PUBLIC_CLASS=Can not extend/implement non-public cla type.error.extend.ERROR_NO_ACCESSIBLE_CONSTRUCTOR=Can not extend class {0} as it has no public or protected constructors. type.error.extend.ERROR_MULTIPLE_SUPERCLASSES=Can not extend multiple classes {0}. At most one of the specified types can be a class, the rest must all be interfaces. type.error.extend.ERROR_NO_COMMON_LOADER=Can not find a common class loader for ScriptObject and {0}. +type.error.extend.ERROR_FINAL_FINALIZER=Can not extend class because {0} has a final finalize method. type.error.no.constructor.matches.args=Can not construct {0} with the passed arguments; they do not match any of its constructor signatures. type.error.no.method.matches.args=Can not invoke method {0} with the passed arguments; they do not match any of its method signatures. type.error.method.not.constructor=Java method {0} can't be used as a constructor. diff --git a/nashorn/test/script/basic/JDK-8014647.js b/nashorn/test/script/basic/JDK-8014647.js index 8ecc21101d5..8d06848f557 100644 --- a/nashorn/test/script/basic/JDK-8014647.js +++ b/nashorn/test/script/basic/JDK-8014647.js @@ -32,9 +32,10 @@ var RunnableImpl1 = Java.extend(java.lang.Runnable, function() { print("I'm runn var RunnableImpl2 = Java.extend(java.lang.Runnable, function() { print("I'm runnable 2!") }) var r1 = new RunnableImpl1() var r2 = new RunnableImpl2() -var r3 = new RunnableImpl2(function() { print("I'm runnable 3!") }) +var RunnableImpl3 = Java.extend(RunnableImpl2); +var r3 = new RunnableImpl3({ run: function() { print("I'm runnable 3!") }}) r1.run() r2.run() r3.run() -print("r1.class === r2.class: " + (r1.class === r2.class)) -print("r2.class === r3.class: " + (r2.class === r3.class)) +print("r1.class !== r2.class: " + (r1.class !== r2.class)) +print("r2.class !== r3.class: " + (r2.class !== r3.class)) diff --git a/nashorn/test/script/basic/JDK-8014647.js.EXPECTED b/nashorn/test/script/basic/JDK-8014647.js.EXPECTED index 641a13b1d45..f4f51dcc38f 100644 --- a/nashorn/test/script/basic/JDK-8014647.js.EXPECTED +++ b/nashorn/test/script/basic/JDK-8014647.js.EXPECTED @@ -1,5 +1,5 @@ I'm runnable 1! I'm runnable 2! I'm runnable 3! -r1.class === r2.class: false -r2.class === r3.class: true +r1.class !== r2.class: true +r2.class !== r3.class: true diff --git a/nashorn/test/script/basic/javaclassoverrides.js b/nashorn/test/script/basic/javaclassoverrides.js index e7ad61d841f..2fa7a85720d 100644 --- a/nashorn/test/script/basic/javaclassoverrides.js +++ b/nashorn/test/script/basic/javaclassoverrides.js @@ -46,7 +46,8 @@ var R2 = Java.extend(java.lang.Runnable, { var r1 = new R1 var r2 = new R2 // Create one with an instance-override too -var r3 = new R2(function() { print("r3.run() invoked") }) +var R3 = Java.extend(R2) +var r3 = new R3({ run: function() { print("r3.run() invoked") }}) // Run 'em - we're passing them through a Thread to make sure they indeed // are full-blown Runnables @@ -60,9 +61,9 @@ runInThread(r2) runInThread(r3) // Two class-override classes differ -print("r1.class != r2.class: " + (r1.class != r2.class)) -// However, adding instance-overrides doesn't change the class -print("r2.class == r3.class: " + (r2.class == r3.class)) +print("r1.class !== r2.class: " + (r1.class !== r2.class)) +// instance-override class also differs +print("r2.class !== r3.class: " + (r2.class !== r3.class)) function checkAbstract(r) { try { @@ -77,10 +78,10 @@ function checkAbstract(r) { // overrides nor instance overrides are present var RAbstract = Java.extend(java.lang.Runnable, {}) checkAbstract(new RAbstract()) // class override (empty) -checkAbstract(new RAbstract() {}) // class+instance override (empty) +checkAbstract(new (Java.extend(RAbstract))() {}) // class+instance override (empty) // Check we delegate to superclass if neither class // overrides nor instance overrides are present var ExtendsList = Java.extend(java.util.ArrayList, {}) print("(new ExtendsList).size() = " + (new ExtendsList).size()) -print("(new ExtendsList(){}).size() = " + (new ExtendsList(){}).size()) \ No newline at end of file +print("(new (Java.extend(ExtendsList)){}).size() = " + (new (Java.extend(ExtendsList)){}).size()) diff --git a/nashorn/test/script/basic/javaclassoverrides.js.EXPECTED b/nashorn/test/script/basic/javaclassoverrides.js.EXPECTED index 6c534302d48..ceec09cff85 100644 --- a/nashorn/test/script/basic/javaclassoverrides.js.EXPECTED +++ b/nashorn/test/script/basic/javaclassoverrides.js.EXPECTED @@ -1,9 +1,9 @@ R1.run() invoked R2.run() invoked r3.run() invoked -r1.class != r2.class: true -r2.class == r3.class: true +r1.class !== r2.class: true +r2.class !== r3.class: true Got exception: java.lang.UnsupportedOperationException Got exception: java.lang.UnsupportedOperationException (new ExtendsList).size() = 0 -(new ExtendsList(){}).size() = 0 +(new (Java.extend(ExtendsList)){}).size() = 0 diff --git a/nashorn/test/script/sandbox/javaextend.js b/nashorn/test/script/sandbox/javaextend.js index 33cc6b01fa0..60eab74d14c 100644 --- a/nashorn/test/script/sandbox/javaextend.js +++ b/nashorn/test/script/sandbox/javaextend.js @@ -51,6 +51,21 @@ try { print(e) } +// Can't extend a class with explicit non-overridable finalizer +try { + Java.extend(model("ClassWithFinalFinalizer")) +} catch(e) { + print(e) +} + +// Can't extend a class with inherited non-overridable finalizer +try { + Java.extend(model("ClassWithInheritedFinalFinalizer")) +} catch(e) { + print(e) +} + + // Can't extend two classes try { Java.extend(java.lang.Thread,java.lang.Number) diff --git a/nashorn/test/script/sandbox/javaextend.js.EXPECTED b/nashorn/test/script/sandbox/javaextend.js.EXPECTED index 69c7818929c..c72774595e8 100644 --- a/nashorn/test/script/sandbox/javaextend.js.EXPECTED +++ b/nashorn/test/script/sandbox/javaextend.js.EXPECTED @@ -1,6 +1,8 @@ TypeError: Can not extend final class jdk.nashorn.test.models.FinalClass. TypeError: Can not extend class jdk.nashorn.test.models.NoAccessibleConstructorClass as it has no public or protected constructors. TypeError: Can not extend/implement non-public class/interface jdk.nashorn.test.models.NonPublicClass. +TypeError: Can not extend class because jdk.nashorn.test.models.ClassWithFinalFinalizer has a final finalize method. +TypeError: Can not extend class because jdk.nashorn.test.models.ClassWithFinalFinalizer has a final finalize method. TypeError: Can not extend multiple classes java.lang.Number and java.lang.Thread. At most one of the specified types can be a class, the rest must all be interfaces. abcdabcd run-object diff --git a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java index 9cea21ba2f5..6d0d40f6042 100644 --- a/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java +++ b/nashorn/test/src/jdk/nashorn/api/scripting/ScriptEngineSecurityTest.java @@ -33,8 +33,8 @@ import java.lang.reflect.Proxy; import java.util.Objects; import javax.script.Invocable; import javax.script.ScriptEngine; -import javax.script.ScriptException; import javax.script.ScriptEngineManager; +import javax.script.ScriptException; import org.testng.annotations.Test; /** @@ -130,6 +130,23 @@ public class ScriptEngineSecurityTest { } } + + @Test + public void securitySystemExitFromFinalizerThread() throws ScriptException { + if (System.getSecurityManager() == null) { + // pass vacuously + return; + } + + final ScriptEngineManager m = new ScriptEngineManager(); + final ScriptEngine e = m.getEngineByName("nashorn"); + e.eval("var o = Java.extend(Java.type('javax.imageio.spi.ServiceRegistry'), { deregisterAll: this.exit.bind(null, 1234)});\n" + + "new o(new java.util.ArrayList().iterator())"); + System.gc(); + System.runFinalization(); + // NOTE: this test just exits the VM if it fails. + } + @Test public void securitySystemLoadLibrary() { if (System.getSecurityManager() == null) { diff --git a/nashorn/test/src/jdk/nashorn/test/models/ClassWithFinalFinalizer.java b/nashorn/test/src/jdk/nashorn/test/models/ClassWithFinalFinalizer.java new file mode 100644 index 00000000000..ba0d86d8a96 --- /dev/null +++ b/nashorn/test/src/jdk/nashorn/test/models/ClassWithFinalFinalizer.java @@ -0,0 +1,31 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.test.models; + +public class ClassWithFinalFinalizer { + protected final void finalize() { + } +} diff --git a/nashorn/test/src/jdk/nashorn/test/models/ClassWithInheritedFinalFinalizer.java b/nashorn/test/src/jdk/nashorn/test/models/ClassWithInheritedFinalFinalizer.java new file mode 100644 index 00000000000..80393fbbe2b --- /dev/null +++ b/nashorn/test/src/jdk/nashorn/test/models/ClassWithInheritedFinalFinalizer.java @@ -0,0 +1,29 @@ +/* + * Copyright (c) 2010, 2013, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +package jdk.nashorn.test.models; + +public class ClassWithInheritedFinalFinalizer extends ClassWithFinalFinalizer { +} From 30e97838505eafa1a970716718249c7b497b103f Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Thu, 30 Jan 2014 17:46:25 -0800 Subject: [PATCH 082/159] 8033180: An inappropriate newline symbol in the help section Reviewed-by: ksrini --- .../com/sun/tools/javap/JavapTask.java | 16 ++-- langtools/test/tools/javap/T8033180.java | 88 +++++++++++++++++++ 2 files changed, 99 insertions(+), 5 deletions(-) create mode 100644 langtools/test/tools/javap/T8033180.java diff --git a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java index 57284a4c003..6033433d40e 100644 --- a/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java +++ b/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java @@ -430,7 +430,7 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { } catch (BadArgs e) { reportError(e.key, e.args); if (e.showUsage) { - log.println(getMessage("main.usage.summary", progname)); + printLines(getMessage("main.usage.summary", progname)); } return EXIT_CMDERR; } catch (InternalError e) { @@ -839,27 +839,33 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { } private void showHelp() { - log.println(getMessage("main.usage", progname)); + printLines(getMessage("main.usage", progname)); for (Option o: recognizedOptions) { String name = o.aliases[0].substring(1); // there must always be at least one name if (name.startsWith("X") || name.equals("fullversion") || name.equals("h") || name.equals("verify")) continue; - log.println(getMessage("main.opt." + name)); + printLines(getMessage("main.opt." + name)); } String[] fmOptions = { "-classpath", "-cp", "-bootclasspath" }; for (String o: fmOptions) { if (fileManager.isSupportedOption(o) == -1) continue; String name = o.substring(1); - log.println(getMessage("main.opt." + name)); + printLines(getMessage("main.opt." + name)); } } private void showVersion(boolean full) { - log.println(version(full ? "full" : "release")); + printLines(version(full ? "full" : "release")); } + private void printLines(String msg) { + log.println(msg.replace("\n", nl)); + } + + private static final String nl = System.getProperty("line.separator"); + private static final String versionRBName = "com.sun.tools.javap.resources.version"; private static ResourceBundle versionRB; diff --git a/langtools/test/tools/javap/T8033180.java b/langtools/test/tools/javap/T8033180.java new file mode 100644 index 00000000000..e7840eaf03f --- /dev/null +++ b/langtools/test/tools/javap/T8033180.java @@ -0,0 +1,88 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8033180 + * @summary Bad newline characters + */ + +import java.io.*; +import java.util.*; + +public class T8033180 { + + public static void main(String... args) throws Exception { + new T8033180().run(); + } + + void run() throws Exception { + // fast-track this case, because test cannot fail in this case + if (lineSep.equals(nl)) + return; + + test("-help"); + test("-version"); + + if (errors > 0) + throw new Exception(errors + " errors occurred"); + } + + static final String lineSep = System.getProperty("line.separator"); + static final String nl = "\n"; + + void test(String... opts) throws Exception { + System.err.println("test " + Arrays.asList(opts)); + List args = new ArrayList(); + args.addAll(Arrays.asList(opts)); + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = com.sun.tools.javap.Main.run(args.toArray(new String[args.size()]), pw); + pw.close(); + String out = sw.toString(); + if (rc != 0) + throw new Exception("javap failed unexpectedly: rc=" + rc); + + // remove all valid platform newline sequences + String out2 = out.replace(lineSep, ""); + + // count the remaining simple newline characters + int count = 0; + int i = out2.indexOf(nl, 0); + while (i != -1) { + count++; + i = out2.indexOf(nl, i + nl.length()); + } + + if (count > 0) + error(count + " newline characters found"); + } + + void error(String msg) { + System.err.println("Error: " + msg); + errors++; + } + + int errors = 0; +} + From a9618434af9ab788d8c91c306bc7ab836772ab34 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Fri, 31 Jan 2014 10:24:58 +0100 Subject: [PATCH 083/159] 8033292: only warn, not fail, on unknown variables in configure Reviewed-by: erikj --- common/autoconf/basics.m4 | 2 +- common/autoconf/generated-configure.sh | 5 +++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/common/autoconf/basics.m4 b/common/autoconf/basics.m4 index 6bd29145e39..d34615d5a2a 100644 --- a/common/autoconf/basics.m4 +++ b/common/autoconf/basics.m4 @@ -250,7 +250,7 @@ AC_DEFUN([BASIC_CHECK_LEFTOVER_OVERRIDDEN], if test "x$CONFIGURE_OVERRIDDEN_VARIABLES" != x; then # Replace the separating ! with spaces before presenting for end user. unknown_variables=${CONFIGURE_OVERRIDDEN_VARIABLES//!/ } - AC_MSG_ERROR([The following variables are unknown to configure: $unknown_variables]) + AC_MSG_WARN([The following variables might be unknown to configure: $unknown_variables]) fi ]) diff --git a/common/autoconf/generated-configure.sh b/common/autoconf/generated-configure.sh index 998d2004ea2..a03ee5cdb85 100644 --- a/common/autoconf/generated-configure.sh +++ b/common/autoconf/generated-configure.sh @@ -4087,7 +4087,7 @@ fi #CUSTOM_AUTOCONF_INCLUDE # Do not change or remove the following line, it is needed for consistency checks: -DATE_WHEN_GENERATED=1391032272 +DATE_WHEN_GENERATED=1391160222 ############################################################################### # @@ -48539,7 +48539,8 @@ $as_echo "no, disabling ccaching of precompiled headers" >&6; } if test "x$CONFIGURE_OVERRIDDEN_VARIABLES" != x; then # Replace the separating ! with spaces before presenting for end user. unknown_variables=${CONFIGURE_OVERRIDDEN_VARIABLES//!/ } - as_fn_error $? "The following variables are unknown to configure: $unknown_variables" "$LINENO" 5 + { $as_echo "$as_me:${as_lineno-$LINENO}: WARNING: The following variables might be unknown to configure: $unknown_variables" >&5 +$as_echo "$as_me: WARNING: The following variables might be unknown to configure: $unknown_variables" >&2;} fi From e72d99fef1791ccff064b21ad0a492cf2e1dbc30 Mon Sep 17 00:00:00 2001 From: Naoto Sato Date: Fri, 31 Jan 2014 10:04:16 -0800 Subject: [PATCH 084/159] 8030696: Norwegian locales nb_NO and nn_NO should be available locales Reviewed-by: okutsu --- jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk | 4 +-- .../resources/no/LocaleNames_no.properties | 2 ++ .../no/LocaleNames_no_NO_NY.properties | 4 ++- jdk/test/java/util/Locale/LocaleTest.java | 27 +++++++++++++++---- 4 files changed, 29 insertions(+), 8 deletions(-) diff --git a/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk b/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk index 98947a0b92c..bf2e3a34552 100644 --- a/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk +++ b/jdk/make/gensrc/GensrcLocaleDataMetaInfo.gmk @@ -53,8 +53,8 @@ endif # The EN locales EN_LOCALES := en% -# ja-JP-JP and th-TH-TH need to be manually added, as they don't have any resource files. -ALL_NON_EN_LOCALES := ja-JP-JP th-TH-TH +# Locales that don't have any resource files should be included here. +ALL_NON_EN_LOCALES := ja-JP-JP nb-NO nn-NO th-TH-TH SED_ARGS := -e 's|$(HASH)warn This file is preprocessed before being compiled|// -- This file was mechanically generated: Do not edit! -- //|g' diff --git a/jdk/src/share/classes/sun/util/resources/no/LocaleNames_no.properties b/jdk/src/share/classes/sun/util/resources/no/LocaleNames_no.properties index 3a43b04dcc9..f39dfb66568 100644 --- a/jdk/src/share/classes/sun/util/resources/no/LocaleNames_no.properties +++ b/jdk/src/share/classes/sun/util/resources/no/LocaleNames_no.properties @@ -38,6 +38,8 @@ # language names # key is ISO 639 language code +nb=bokm\u00e5l +nn=nynorsk no=norsk # country names diff --git a/jdk/src/share/classes/sun/util/resources/no/LocaleNames_no_NO_NY.properties b/jdk/src/share/classes/sun/util/resources/no/LocaleNames_no_NO_NY.properties index 3a43b04dcc9..e56e415a512 100644 --- a/jdk/src/share/classes/sun/util/resources/no/LocaleNames_no_NO_NY.properties +++ b/jdk/src/share/classes/sun/util/resources/no/LocaleNames_no_NO_NY.properties @@ -38,12 +38,14 @@ # language names # key is ISO 639 language code +nb=bokm\u00e5l +nn=nynorsk no=norsk # country names # key is ISO 3166 country code -NO=Norge +NO=Noreg # variant names diff --git a/jdk/test/java/util/Locale/LocaleTest.java b/jdk/test/java/util/Locale/LocaleTest.java index 8c9c4f16199..2a6824222b3 100644 --- a/jdk/test/java/util/Locale/LocaleTest.java +++ b/jdk/test/java/util/Locale/LocaleTest.java @@ -25,7 +25,7 @@ * @bug 4052404 4052440 4084688 4092475 4101316 4105828 4107014 4107953 4110613 * 4118587 4118595 4122371 4126371 4126880 4135316 4135752 4139504 4139940 4143951 * 4147315 4147317 4147552 4335196 4778440 4940539 5010672 6475525 6544471 6627549 - * 6786276 7066203 7085757 + * 6786276 7066203 7085757 8030696 * @summary test Locales */ /* @@ -62,6 +62,8 @@ */ import java.text.*; +import java.util.Arrays; +import java.util.List; import java.util.Locale; import java.util.MissingResourceException; import java.util.Date; @@ -925,16 +927,20 @@ test commented out pending API-change approval } /* - * @bug 4147552 4778440 + * @bug 4147552 4778440 8030696 */ public void Test4147552() { Locale[] locales = { new Locale("no", "NO"), new Locale("no", "NO", "B"), - new Locale("no", "NO", "NY") }; + new Locale("no", "NO", "NY"), new Locale("nb", "NO"), + new Locale("nn", "NO") }; String[] englishDisplayNames = { "Norwegian (Norway)", "Norwegian (Norway,Bokm\u00e5l)", - "Norwegian (Norway,Nynorsk)" }; + "Norwegian (Norway,Nynorsk)", + "Norwegian Bokm\u00e5l (Norway)", + "Norwegian Nynorsk (Norway)" }; String[] norwegianDisplayNames = { "norsk (Norge)", - "norsk (Norge,bokm\u00e5l)", "norsk (Norge,nynorsk)" }; + "norsk (Norge,bokm\u00e5l)", "norsk (Noreg,nynorsk)", + "bokm\u00e5l (Norge)", "nynorsk (Noreg)" }; for (int i = 0; i < locales.length; i++) { Locale loc = locales[i]; @@ -948,6 +954,17 @@ test commented out pending API-change approval } } + /* + * @bug 8030696 + */ + public void Test8030696() { + List av = Arrays.asList(Locale.getAvailableLocales()); + if (!av.contains(new Locale("nb", "NO")) || + !av.contains(new Locale("nn", "NO"))) { + errln("\"nb-NO\" and/or \"nn-NO\" locale(s) not returned from getAvailableLocales()."); + } + } + static String escapeUnicode(String s) { StringBuffer buf = new StringBuffer(); for (int i=0; i Date: Fri, 31 Jan 2014 18:32:07 +0000 Subject: [PATCH 085/159] 8011645: CopyOnWriteArrayList.COWSubList.subList does not validate range properly Reviewed-by: martin, psandoz --- .../util/concurrent/CopyOnWriteArrayList.java | 2 +- .../CopyOnWriteArrayList/COWSubList.java | 58 +++++++++++++++++++ 2 files changed, 59 insertions(+), 1 deletion(-) create mode 100644 jdk/test/java/util/concurrent/CopyOnWriteArrayList/COWSubList.java diff --git a/jdk/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java b/jdk/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java index fae67b2b2d0..162ad3b51d1 100644 --- a/jdk/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java +++ b/jdk/src/share/classes/java/util/concurrent/CopyOnWriteArrayList.java @@ -1400,7 +1400,7 @@ public class CopyOnWriteArrayList lock.lock(); try { checkForComodification(); - if (fromIndex < 0 || toIndex > size) + if (fromIndex < 0 || toIndex > size || fromIndex > toIndex) throw new IndexOutOfBoundsException(); return new COWSubList(l, fromIndex + offset, toIndex + offset); diff --git a/jdk/test/java/util/concurrent/CopyOnWriteArrayList/COWSubList.java b/jdk/test/java/util/concurrent/CopyOnWriteArrayList/COWSubList.java new file mode 100644 index 00000000000..5cbfea7ec6b --- /dev/null +++ b/jdk/test/java/util/concurrent/CopyOnWriteArrayList/COWSubList.java @@ -0,0 +1,58 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8011645 + * @summary CopyOnWriteArrayList.COWSubList.subList does not validate range properly + */ +import java.util.List; +import java.util.concurrent.CopyOnWriteArrayList; + +public class COWSubList { + public static void main(String[] args) { + List list = new CopyOnWriteArrayList<>(); + list.add("A"); + list.add("B"); + list.add("C"); + list.add("D"); + list.add("E"); + + expectThrow(() -> list.subList(-1, 5)); + expectThrow(() -> list.subList(0, 6)); + expectThrow(() -> list.subList(4, 3)); + expectThrow(() -> list.subList(0, 5).subList(-1, 5)); + expectThrow(() -> list.subList(0, 5).subList(0, 6)); + expectThrow(() -> list.subList(0, 5).subList(4, 3)); + } + + static void expectThrow(Runnable r) { + try { + r.run(); + throw new RuntimeException("Failed: expected IOOBE to be thrown"); + } catch (IndexOutOfBoundsException x) { + // ok, excpeted + } + } +} + From 930a4614e6bc8ecdc04a8da28a2bb30f8a0ef1be Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Fri, 31 Jan 2014 13:42:31 -0500 Subject: [PATCH 086/159] 8032221: Typo in java.util.date Trancate -> truncate; updated html and to use {@code ...} Reviewed-by: darcy, lancea --- jdk/src/share/classes/java/util/Date.java | 343 +++++++++++----------- 1 file changed, 170 insertions(+), 173 deletions(-) diff --git a/jdk/src/share/classes/java/util/Date.java b/jdk/src/share/classes/java/util/Date.java index 502daaefdbb..f16ea496604 100644 --- a/jdk/src/share/classes/java/util/Date.java +++ b/jdk/src/share/classes/java/util/Date.java @@ -41,20 +41,20 @@ import sun.util.calendar.Gregorian; import sun.util.calendar.ZoneInfo; /** - * The class Date represents a specific instant + * The class {@code Date} represents a specific instant * in time, with millisecond precision. *

- * Prior to JDK 1.1, the class Date had two additional + * Prior to JDK 1.1, the class {@code Date} had two additional * functions. It allowed the interpretation of dates as year, month, day, hour, * minute, and second values. It also allowed the formatting and parsing * of date strings. Unfortunately, the API for these functions was not * amenable to internationalization. As of JDK 1.1, the - * Calendar class should be used to convert between dates and time - * fields and the DateFormat class should be used to format and + * {@code Calendar} class should be used to convert between dates and time + * fields and the {@code DateFormat} class should be used to format and * parse date strings. - * The corresponding methods in Date are deprecated. + * The corresponding methods in {@code Date} are deprecated. *

- * Although the Date class is intended to reflect + * Although the {@code Date} class is intended to reflect * coordinated universal time (UTC), it may not do so exactly, * depending on the host environment of the Java Virtual Machine. * Nearly all modern operating systems assume that 1 day = @@ -93,12 +93,12 @@ import sun.util.calendar.ZoneInfo; * http://tycho.usno.navy.mil/systime.html * *

- * In all methods of class Date that accept or return + * In all methods of class {@code Date} that accept or return * year, month, date, hours, minutes, and seconds values, the * following representations are used: *

    *
  • A year y is represented by the integer - * y - 1900. + * y {@code - 1900}. *
  • A month is represented by an integer from 0 to 11; 0 is January, * 1 is February, and so forth; thus 11 is December. *
  • A date (day of month) is represented by an integer from 1 to 31 @@ -155,7 +155,7 @@ public class Date private static final long serialVersionUID = 7523967970034938905L; /** - * Allocates a Date object and initializes it so that + * Allocates a {@code Date} object and initializes it so that * it represents the time at which it was allocated, measured to the * nearest millisecond. * @@ -166,7 +166,7 @@ public class Date } /** - * Allocates a Date object and initializes it to + * Allocates a {@code Date} object and initializes it to * represent the specified number of milliseconds since the * standard base time known as "the epoch", namely January 1, * 1970, 00:00:00 GMT. @@ -179,18 +179,18 @@ public class Date } /** - * Allocates a Date object and initializes it so that + * Allocates a {@code Date} object and initializes it so that * it represents midnight, local time, at the beginning of the day - * specified by the year, month, and - * date arguments. + * specified by the {@code year}, {@code month}, and + * {@code date} arguments. * * @param year the year minus 1900. * @param month the month between 0-11. * @param date the day of the month between 1-31. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.set(year + 1900, month, date) - * or GregorianCalendar(year + 1900, month, date). + * replaced by {@code Calendar.set(year + 1900, month, date)} + * or {@code GregorianCalendar(year + 1900, month, date)}. */ @Deprecated public Date(int year, int month, int date) { @@ -198,10 +198,10 @@ public class Date } /** - * Allocates a Date object and initializes it so that + * Allocates a {@code Date} object and initializes it so that * it represents the instant at the start of the minute specified by - * the year, month, date, - * hrs, and min arguments, in the local + * the {@code year}, {@code month}, {@code date}, + * {@code hrs}, and {@code min} arguments, in the local * time zone. * * @param year the year minus 1900. @@ -211,9 +211,8 @@ public class Date * @param min the minutes between 0-59. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.set(year + 1900, month, date, - * hrs, min) or GregorianCalendar(year + 1900, - * month, date, hrs, min). + * replaced by {@code Calendar.set(year + 1900, month, date, hrs, min)} + * or {@code GregorianCalendar(year + 1900, month, date, hrs, min)}. */ @Deprecated public Date(int year, int month, int date, int hrs, int min) { @@ -221,10 +220,10 @@ public class Date } /** - * Allocates a Date object and initializes it so that + * Allocates a {@code Date} object and initializes it so that * it represents the instant at the start of the second specified - * by the year, month, date, - * hrs, min, and sec arguments, + * by the {@code year}, {@code month}, {@code date}, + * {@code hrs}, {@code min}, and {@code sec} arguments, * in the local time zone. * * @param year the year minus 1900. @@ -235,9 +234,8 @@ public class Date * @param sec the seconds between 0-59. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.set(year + 1900, month, date, - * hrs, min, sec) or GregorianCalendar(year + 1900, - * month, date, hrs, min, sec). + * replaced by {@code Calendar.set(year + 1900, month, date, hrs, min, sec)} + * or {@code GregorianCalendar(year + 1900, month, date, hrs, min, sec)}. */ @Deprecated public Date(int year, int month, int date, int hrs, int min, int sec) { @@ -258,16 +256,16 @@ public class Date } /** - * Allocates a Date object and initializes it so that + * Allocates a {@code Date} object and initializes it so that * it represents the date and time indicated by the string - * s, which is interpreted as if by the + * {@code s}, which is interpreted as if by the * {@link Date#parse} method. * * @param s a string representation of the date. * @see java.text.DateFormat * @see java.util.Date#parse(java.lang.String) * @deprecated As of JDK version 1.1, - * replaced by DateFormat.parse(String s). + * replaced by {@code DateFormat.parse(String s)}. */ @Deprecated public Date(String s) { @@ -292,7 +290,7 @@ public class Date * Determines the date and time based on the arguments. The * arguments are interpreted as a year, month, day of the month, * hour of the day, minute within the hour, and second within the - * minute, exactly as for the Date constructor with six + * minute, exactly as for the {@code Date} constructor with six * arguments, except that the arguments are interpreted relative * to UTC rather than to the local time zone. The time indicated is * returned represented as the distance, measured in milliseconds, @@ -308,10 +306,9 @@ public class Date * the date and time specified by the arguments. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.set(year + 1900, month, date, - * hrs, min, sec) or GregorianCalendar(year + 1900, - * month, date, hrs, min, sec), using a UTC - * TimeZone, followed by Calendar.getTime().getTime(). + * replaced by {@code Calendar.set(year + 1900, month, date, hrs, min, sec)} + * or {@code GregorianCalendar(year + 1900, month, date, hrs, min, sec)}, using a UTC + * {@code TimeZone}, followed by {@code Calendar.getTime().getTime()}. */ @Deprecated public static long UTC(int year, int month, int date, @@ -338,12 +335,12 @@ public class Date } /** - * Attempts to interpret the string s as a representation + * Attempts to interpret the string {@code s} as a representation * of a date and time. If the attempt is successful, the time * indicated is returned represented as the distance, measured in * milliseconds, of that time from the epoch (00:00:00 GMT on * January 1, 1970). If the attempt fails, an - * IllegalArgumentException is thrown. + * {@code IllegalArgumentException} is thrown. *

    * It accepts many syntaxes; in particular, it recognizes the IETF * standard date syntax: "Sat, 12 Aug 1995 13:30:00 GMT". It also @@ -353,11 +350,11 @@ public class Date * meridian). If no time zone is specified, the local time zone is * assumed. GMT and UTC are considered equivalent. *

    - * The string s is processed from left to right, looking for - * data of interest. Any material in s that is within the - * ASCII parenthesis characters ( and ) is ignored. + * The string {@code s} is processed from left to right, looking for + * data of interest. Any material in {@code s} that is within the + * ASCII parenthesis characters {@code (} and {@code )} is ignored. * Parentheses may be nested. Otherwise, the only characters permitted - * within s are these ASCII characters: + * within {@code s} are these ASCII characters: *

          * abcdefghijklmnopqrstuvwxyz
          * ABCDEFGHIJKLMNOPQRSTUVWXYZ
    @@ -365,18 +362,18 @@ public class Date
          * and whitespace characters.

    * A consecutive sequence of decimal digits is treated as a decimal * number:

      - *
    • If a number is preceded by + or - and a year + *
    • If a number is preceded by {@code +} or {@code -} and a year * has already been recognized, then the number is a time-zone * offset. If the number is less than 24, it is an offset measured * in hours. Otherwise, it is regarded as an offset in minutes, * expressed in 24-hour time format without punctuation. A - * preceding - means a westward offset. Time zone offsets + * preceding {@code -} means a westward offset. Time zone offsets * are always relative to UTC (Greenwich). Thus, for example, - * -5 occurring in the string would mean "five hours west - * of Greenwich" and +0430 would mean "four hours and + * {@code -5} occurring in the string would mean "five hours west + * of Greenwich" and {@code +0430} would mean "four hours and * thirty minutes east of Greenwich." It is permitted for the - * string to specify GMT, UT, or UTC - * redundantly-for example, GMT-5 or utc+0430. + * string to specify {@code GMT}, {@code UT}, or {@code UTC} + * redundantly-for example, {@code GMT-5} or {@code utc+0430}. *
    • The number is regarded as a year number if one of the * following conditions is true: *
        @@ -399,8 +396,8 @@ public class Date * unless an hour has already been recognized, in which case it is * regarded as a minute. *
      • If the number is followed by a slash, it is regarded as a month - * (it is decreased by 1 to produce a number in the range 0 - * to 11), unless a month has already been recognized, in + * (it is decreased by 1 to produce a number in the range {@code 0} + * to {@code 11}), unless a month has already been recognized, in * which case it is regarded as a day of the month. *
      • If the number is followed by whitespace, a comma, a hyphen, or * end of string, then if an hour has been recognized but not a @@ -409,31 +406,31 @@ public class Date * otherwise, it is regarded as a day of the month.

      * A consecutive sequence of letters is regarded as a word and treated * as follows:

        - *
      • A word that matches AM, ignoring case, is ignored (but + *
      • A word that matches {@code AM}, ignoring case, is ignored (but * the parse fails if an hour has not been recognized or is less - * than 1 or greater than 12). - *
      • A word that matches PM, ignoring case, adds 12 + * than {@code 1} or greater than {@code 12}). + *
      • A word that matches {@code PM}, ignoring case, adds {@code 12} * to the hour (but the parse fails if an hour has not been - * recognized or is less than 1 or greater than 12). - *
      • Any word that matches any prefix of SUNDAY, MONDAY, TUESDAY, - * WEDNESDAY, THURSDAY, FRIDAY, or SATURDAY, ignoring - * case, is ignored. For example, sat, Friday, TUE, and - * Thurs are ignored. - *
      • Otherwise, any word that matches any prefix of JANUARY, + * recognized or is less than {@code 1} or greater than {@code 12}). + *
      • Any word that matches any prefix of {@code SUNDAY, MONDAY, TUESDAY, + * WEDNESDAY, THURSDAY, FRIDAY}, or {@code SATURDAY}, ignoring + * case, is ignored. For example, {@code sat, Friday, TUE}, and + * {@code Thurs} are ignored. + *
      • Otherwise, any word that matches any prefix of {@code JANUARY, * FEBRUARY, MARCH, APRIL, MAY, JUNE, JULY, AUGUST, SEPTEMBER, - * OCTOBER, NOVEMBER, or DECEMBER, ignoring case, and + * OCTOBER, NOVEMBER}, or {@code DECEMBER}, ignoring case, and * considering them in the order given here, is recognized as - * specifying a month and is converted to a number (0 to - * 11). For example, aug, Sept, april, and - * NOV are recognized as months. So is Ma, which - * is recognized as MARCH, not MAY. - *
      • Any word that matches GMT, UT, or UTC, ignoring + * specifying a month and is converted to a number ({@code 0} to + * {@code 11}). For example, {@code aug, Sept, april}, and + * {@code NOV} are recognized as months. So is {@code Ma}, which + * is recognized as {@code MARCH}, not {@code MAY}. + *
      • Any word that matches {@code GMT, UT}, or {@code UTC}, ignoring * case, is treated as referring to UTC. - *
      • Any word that matches EST, CST, MST, or PST, + *
      • Any word that matches {@code EST, CST, MST}, or {@code PST}, * ignoring case, is recognized as referring to the time zone in * North America that is five, six, seven, or eight hours west of - * Greenwich, respectively. Any word that matches EDT, CDT, - * MDT, or PDT, ignoring case, is recognized as + * Greenwich, respectively. Any word that matches {@code EDT, CDT, + * MDT}, or {@code PDT}, ignoring case, is recognized as * referring to the same time zone, respectively, during daylight * saving time.

      * Once the entire string s has been scanned, it is converted to a time @@ -448,7 +445,7 @@ public class Date * represented by the string argument. * @see java.text.DateFormat * @deprecated As of JDK version 1.1, - * replaced by DateFormat.parse(String s). + * replaced by {@code DateFormat.parse(String s)}. */ @Deprecated public static long parse(String s) { @@ -638,13 +635,13 @@ public class Date /** * Returns a value that is the result of subtracting 1900 from the * year that contains or begins with the instant in time represented - * by this Date object, as interpreted in the local + * by this {@code Date} object, as interpreted in the local * time zone. * * @return the year represented by this date, minus 1900. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.get(Calendar.YEAR) - 1900. + * replaced by {@code Calendar.get(Calendar.YEAR) - 1900}. */ @Deprecated public int getYear() { @@ -652,8 +649,8 @@ public class Date } /** - * Sets the year of this Date object to be the specified - * value plus 1900. This Date object is modified so + * Sets the year of this {@code Date} object to be the specified + * value plus 1900. This {@code Date} object is modified so * that it represents a point in time within the specified year, * with the month, date, hour, minute, and second the same as * before, as interpreted in the local time zone. (Of course, if @@ -664,7 +661,7 @@ public class Date * @param year the year value. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.set(Calendar.YEAR, year + 1900). + * replaced by {@code Calendar.set(Calendar.YEAR, year + 1900)}. */ @Deprecated public void setYear(int year) { @@ -673,14 +670,14 @@ public class Date /** * Returns a number representing the month that contains or begins - * with the instant in time represented by this Date object. - * The value returned is between 0 and 11, - * with the value 0 representing January. + * with the instant in time represented by this {@code Date} object. + * The value returned is between {@code 0} and {@code 11}, + * with the value {@code 0} representing January. * * @return the month represented by this date. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.get(Calendar.MONTH). + * replaced by {@code Calendar.get(Calendar.MONTH)}. */ @Deprecated public int getMonth() { @@ -689,7 +686,7 @@ public class Date /** * Sets the month of this date to the specified value. This - * Date object is modified so that it represents a point + * {@code Date} object is modified so that it represents a point * in time within the specified month, with the year, date, hour, * minute, and second the same as before, as interpreted in the * local time zone. If the date was October 31, for example, and @@ -699,7 +696,7 @@ public class Date * @param month the month value between 0-11. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.set(Calendar.MONTH, int month). + * replaced by {@code Calendar.set(Calendar.MONTH, int month)}. */ @Deprecated public void setMonth(int month) { @@ -719,16 +716,16 @@ public class Date } /** - * Returns the day of the month represented by this Date object. - * The value returned is between 1 and 31 + * Returns the day of the month represented by this {@code Date} object. + * The value returned is between {@code 1} and {@code 31} * representing the day of the month that contains or begins with the - * instant in time represented by this Date object, as + * instant in time represented by this {@code Date} object, as * interpreted in the local time zone. * * @return the day of the month represented by this date. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.get(Calendar.DAY_OF_MONTH). + * replaced by {@code Calendar.get(Calendar.DAY_OF_MONTH)}. * @deprecated */ @Deprecated @@ -737,8 +734,8 @@ public class Date } /** - * Sets the day of the month of this Date object to the - * specified value. This Date object is modified so that + * Sets the day of the month of this {@code Date} object to the + * specified value. This {@code Date} object is modified so that * it represents a point in time within the specified day of the * month, with the year, month, hour, minute, and second the same * as before, as interpreted in the local time zone. If the date @@ -749,7 +746,7 @@ public class Date * @param date the day of the month value between 1-31. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.set(Calendar.DAY_OF_MONTH, int date). + * replaced by {@code Calendar.set(Calendar.DAY_OF_MONTH, int date)}. */ @Deprecated public void setDate(int date) { @@ -758,17 +755,17 @@ public class Date /** * Returns the day of the week represented by this date. The - * returned value (0 = Sunday, 1 = Monday, - * 2 = Tuesday, 3 = Wednesday, 4 = - * Thursday, 5 = Friday, 6 = Saturday) + * returned value ({@code 0} = Sunday, {@code 1} = Monday, + * {@code 2} = Tuesday, {@code 3} = Wednesday, {@code 4} = + * Thursday, {@code 5} = Friday, {@code 6} = Saturday) * represents the day of the week that contains or begins with - * the instant in time represented by this Date object, + * the instant in time represented by this {@code Date} object, * as interpreted in the local time zone. * * @return the day of the week represented by this date. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.get(Calendar.DAY_OF_WEEK). + * replaced by {@code Calendar.get(Calendar.DAY_OF_WEEK)}. */ @Deprecated public int getDay() { @@ -776,16 +773,16 @@ public class Date } /** - * Returns the hour represented by this Date object. The - * returned value is a number (0 through 23) + * Returns the hour represented by this {@code Date} object. The + * returned value is a number ({@code 0} through {@code 23}) * representing the hour within the day that contains or begins - * with the instant in time represented by this Date + * with the instant in time represented by this {@code Date} * object, as interpreted in the local time zone. * * @return the hour represented by this date. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.get(Calendar.HOUR_OF_DAY). + * replaced by {@code Calendar.get(Calendar.HOUR_OF_DAY)}. */ @Deprecated public int getHours() { @@ -793,8 +790,8 @@ public class Date } /** - * Sets the hour of this Date object to the specified value. - * This Date object is modified so that it represents a point + * Sets the hour of this {@code Date} object to the specified value. + * This {@code Date} object is modified so that it represents a point * in time within the specified hour of the day, with the year, month, * date, minute, and second the same as before, as interpreted in the * local time zone. @@ -802,7 +799,7 @@ public class Date * @param hours the hour value. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.set(Calendar.HOUR_OF_DAY, int hours). + * replaced by {@code Calendar.set(Calendar.HOUR_OF_DAY, int hours)}. */ @Deprecated public void setHours(int hours) { @@ -812,12 +809,12 @@ public class Date /** * Returns the number of minutes past the hour represented by this date, * as interpreted in the local time zone. - * The value returned is between 0 and 59. + * The value returned is between {@code 0} and {@code 59}. * * @return the number of minutes past the hour represented by this date. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.get(Calendar.MINUTE). + * replaced by {@code Calendar.get(Calendar.MINUTE)}. */ @Deprecated public int getMinutes() { @@ -825,8 +822,8 @@ public class Date } /** - * Sets the minutes of this Date object to the specified value. - * This Date object is modified so that it represents a point + * Sets the minutes of this {@code Date} object to the specified value. + * This {@code Date} object is modified so that it represents a point * in time within the specified minute of the hour, with the year, month, * date, hour, and second the same as before, as interpreted in the * local time zone. @@ -834,7 +831,7 @@ public class Date * @param minutes the value of the minutes. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.set(Calendar.MINUTE, int minutes). + * replaced by {@code Calendar.set(Calendar.MINUTE, int minutes)}. */ @Deprecated public void setMinutes(int minutes) { @@ -843,14 +840,14 @@ public class Date /** * Returns the number of seconds past the minute represented by this date. - * The value returned is between 0 and 61. The - * values 60 and 61 can only occur on those + * The value returned is between {@code 0} and {@code 61}. The + * values {@code 60} and {@code 61} can only occur on those * Java Virtual Machines that take leap seconds into account. * * @return the number of seconds past the minute represented by this date. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.get(Calendar.SECOND). + * replaced by {@code Calendar.get(Calendar.SECOND)}. */ @Deprecated public int getSeconds() { @@ -858,8 +855,8 @@ public class Date } /** - * Sets the seconds of this Date to the specified value. - * This Date object is modified so that it represents a + * Sets the seconds of this {@code Date} to the specified value. + * This {@code Date} object is modified so that it represents a * point in time within the specified second of the minute, with * the year, month, date, hour, and minute the same as before, as * interpreted in the local time zone. @@ -867,7 +864,7 @@ public class Date * @param seconds the seconds value. * @see java.util.Calendar * @deprecated As of JDK version 1.1, - * replaced by Calendar.set(Calendar.SECOND, int seconds). + * replaced by {@code Calendar.set(Calendar.SECOND, int seconds)}. */ @Deprecated public void setSeconds(int seconds) { @@ -876,7 +873,7 @@ public class Date /** * Returns the number of milliseconds since January 1, 1970, 00:00:00 GMT - * represented by this Date object. + * represented by this {@code Date} object. * * @return the number of milliseconds since January 1, 1970, 00:00:00 GMT * represented by this date. @@ -893,8 +890,8 @@ public class Date } /** - * Sets this Date object to represent a point in time that is - * time milliseconds after January 1, 1970 00:00:00 GMT. + * Sets this {@code Date} object to represent a point in time that is + * {@code time} milliseconds after January 1, 1970 00:00:00 GMT. * * @param time the number of milliseconds. */ @@ -907,11 +904,11 @@ public class Date * Tests if this date is before the specified date. * * @param when a date. - * @return true if and only if the instant of time - * represented by this Date object is strictly - * earlier than the instant represented by when; - * false otherwise. - * @exception NullPointerException if when is null. + * @return {@code true} if and only if the instant of time + * represented by this {@code Date} object is strictly + * earlier than the instant represented by {@code when}; + * {@code false} otherwise. + * @exception NullPointerException if {@code when} is null. */ public boolean before(Date when) { return getMillisOf(this) < getMillisOf(when); @@ -921,11 +918,11 @@ public class Date * Tests if this date is after the specified date. * * @param when a date. - * @return true if and only if the instant represented - * by this Date object is strictly later than the - * instant represented by when; - * false otherwise. - * @exception NullPointerException if when is null. + * @return {@code true} if and only if the instant represented + * by this {@code Date} object is strictly later than the + * instant represented by {@code when}; + * {@code false} otherwise. + * @exception NullPointerException if {@code when} is null. */ public boolean after(Date when) { return getMillisOf(this) > getMillisOf(when); @@ -933,17 +930,17 @@ public class Date /** * Compares two dates for equality. - * The result is true if and only if the argument is - * not null and is a Date object that + * The result is {@code true} if and only if the argument is + * not {@code null} and is a {@code Date} object that * represents the same point in time, to the millisecond, as this object. *

      - * Thus, two Date objects are equal if and only if the - * getTime method returns the same long + * Thus, two {@code Date} objects are equal if and only if the + * {@code getTime} method returns the same {@code long} * value for both. * * @param obj the object to compare with. - * @return true if the objects are the same; - * false otherwise. + * @return {@code true} if the objects are the same; + * {@code false} otherwise. * @see java.util.Date#getTime() */ public boolean equals(Object obj) { @@ -951,7 +948,7 @@ public class Date } /** - * Returns the millisecond value of this Date object + * Returns the millisecond value of this {@code Date} object * without affecting its internal state. */ static final long getMillisOf(Date date) { @@ -965,13 +962,13 @@ public class Date /** * Compares two Dates for ordering. * - * @param anotherDate the Date to be compared. - * @return the value 0 if the argument Date is equal to - * this Date; a value less than 0 if this Date + * @param anotherDate the {@code Date} to be compared. + * @return the value {@code 0} if the argument Date is equal to + * this Date; a value less than {@code 0} if this Date * is before the Date argument; and a value greater than - * 0 if this Date is after the Date argument. + * {@code 0} if this Date is after the Date argument. * @since 1.2 - * @exception NullPointerException if anotherDate is null. + * @exception NullPointerException if {@code anotherDate} is null. */ public int compareTo(Date anotherDate) { long thisTime = getMillisOf(this); @@ -981,7 +978,7 @@ public class Date /** * Returns a hash code value for this object. The result is the - * exclusive OR of the two halves of the primitive long + * exclusive OR of the two halves of the primitive {@code long} * value returned by the {@link Date#getTime} * method. That is, the hash code is the value of the expression: *

      {@code
      @@ -996,29 +993,29 @@ public class Date
           }
       
           /**
      -     * Converts this Date object to a String
      +     * Converts this {@code Date} object to a {@code String}
            * of the form:
            * 
            * dow mon dd hh:mm:ss zzz yyyy
      * where:
        - *
      • dow is the day of the week (Sun, Mon, Tue, Wed, - * Thu, Fri, Sat). - *
      • mon is the month (Jan, Feb, Mar, Apr, May, Jun, - * Jul, Aug, Sep, Oct, Nov, Dec). - *
      • dd is the day of the month (01 through - * 31), as two decimal digits. - *
      • hh is the hour of the day (00 through - * 23), as two decimal digits. - *
      • mm is the minute within the hour (00 through - * 59), as two decimal digits. - *
      • ss is the second within the minute (00 through - * 61, as two decimal digits. - *
      • zzz is the time zone (and may reflect daylight saving + *
      • {@code dow} is the day of the week ({@code Sun, Mon, Tue, Wed, + * Thu, Fri, Sat}). + *
      • {@code mon} is the month ({@code Jan, Feb, Mar, Apr, May, Jun, + * Jul, Aug, Sep, Oct, Nov, Dec}). + *
      • {@code dd} is the day of the month ({@code 01} through + * {@code 31}), as two decimal digits. + *
      • {@code hh} is the hour of the day ({@code 00} through + * {@code 23}), as two decimal digits. + *
      • {@code mm} is the minute within the hour ({@code 00} through + * {@code 59}), as two decimal digits. + *
      • {@code ss} is the second within the minute ({@code 00} through + * {@code 61}, as two decimal digits. + *
      • {@code zzz} is the time zone (and may reflect daylight saving * time). Standard time zone abbreviations include those - * recognized by the method parse. If time zone - * information is not available, then zzz is empty - + * recognized by the method {@code parse}. If time zone + * information is not available, then {@code zzz} is empty - * that is, it consists of no characters at all. - *
      • yyyy is the year, as four decimal digits. + *
      • {@code yyyy} is the year, as four decimal digits. *
      * * @return a string representation of this date. @@ -1053,7 +1050,7 @@ public class Date /** * Converts the given name to its 3-letter abbreviation (e.g., * "monday" -> "Mon") and stored the abbreviation in the given - * StringBuilder. + * {@code StringBuilder}. */ private static final StringBuilder convertToAbbr(StringBuilder sb, String name) { sb.append(Character.toUpperCase(name.charAt(0))); @@ -1062,11 +1059,11 @@ public class Date } /** - * Creates a string representation of this Date object in an + * Creates a string representation of this {@code Date} object in an * implementation-dependent form. The intent is that the form should * be familiar to the user of the Java application, wherever it may * happen to be running. The intent is comparable to that of the - * "%c" format supported by the strftime() + * "{@code %c}" format supported by the {@code strftime()} * function of ISO C. * * @return a string representation of this date, using the locale @@ -1075,7 +1072,7 @@ public class Date * @see java.util.Date#toString() * @see java.util.Date#toGMTString() * @deprecated As of JDK version 1.1, - * replaced by DateFormat.format(Date date). + * replaced by {@code DateFormat.format(Date date)}. */ @Deprecated public String toLocaleString() { @@ -1084,23 +1081,23 @@ public class Date } /** - * Creates a string representation of this Date object of + * Creates a string representation of this {@code Date} object of * the form: *
            * d mon yyyy hh:mm:ss GMT
      * where:
        - *
      • d is the day of the month (1 through 31), + *
      • d is the day of the month ({@code 1} through {@code 31}), * as one or two decimal digits. - *
      • mon is the month (Jan, Feb, Mar, Apr, May, Jun, Jul, - * Aug, Sep, Oct, Nov, Dec). + *
      • mon is the month ({@code Jan, Feb, Mar, Apr, May, Jun, Jul, + * Aug, Sep, Oct, Nov, Dec}). *
      • yyyy is the year, as four decimal digits. - *
      • hh is the hour of the day (00 through 23), + *
      • hh is the hour of the day ({@code 00} through {@code 23}), * as two decimal digits. - *
      • mm is the minute within the hour (00 through - * 59), as two decimal digits. - *
      • ss is the second within the minute (00 through - * 61), as two decimal digits. - *
      • GMT is exactly the ASCII letters "GMT" to indicate + *
      • mm is the minute within the hour ({@code 00} through + * {@code 59}), as two decimal digits. + *
      • ss is the second within the minute ({@code 00} through + * {@code 61}), as two decimal digits. + *
      • GMT is exactly the ASCII letters "{@code GMT}" to indicate * Greenwich Mean Time. *

      * The result does not depend on the local time zone. @@ -1111,8 +1108,8 @@ public class Date * @see java.util.Date#toString() * @see java.util.Date#toLocaleString() * @deprecated As of JDK version 1.1, - * replaced by DateFormat.format(Date date), using a - * GMT TimeZone. + * replaced by {@code DateFormat.format(Date date)}, using a + * GMT {@code TimeZone}. */ @Deprecated public String toGMTString() { @@ -1135,7 +1132,7 @@ public class Date /** * Returns the offset, measured in minutes, for the local time zone * relative to UTC that is appropriate for the time represented by - * this Date object. + * this {@code Date} object. *

      * For example, in Massachusetts, five time zones west of Greenwich: *

      @@ -1161,8 +1158,8 @@ public class Date
            * @see     java.util.Calendar#DST_OFFSET
            * @see     java.util.TimeZone#getDefault
            * @deprecated As of JDK version 1.1,
      -     * replaced by -(Calendar.get(Calendar.ZONE_OFFSET) +
      -     * Calendar.get(Calendar.DST_OFFSET)) / (60 * 1000).
      +     * replaced by {@code -(Calendar.get(Calendar.ZONE_OFFSET) +
      +     * Calendar.get(Calendar.DST_OFFSET)) / (60 * 1000)}.
            */
           @Deprecated
           public int getTimezoneOffset() {
      @@ -1313,7 +1310,7 @@ public class Date
           /**
            * Save the state of this object to a stream (i.e., serialize it).
            *
      -     * @serialData The value returned by getTime()
      +     * @serialData The value returned by {@code getTime()}
            *             is emitted (long).  This represents the offset from
            *             January 1, 1970, 00:00:00 GMT in milliseconds.
            */
      @@ -1336,7 +1333,7 @@ public class Date
            * Obtains an instance of {@code Date} from an {@code Instant} object.
            * 

      * {@code Instant} uses a precision of nanoseconds, whereas {@code Date} - * uses a precision of milliseconds. The conversion will trancate any + * uses a precision of milliseconds. The conversion will truncate any * excess precision information as though the amount in nanoseconds was * subject to integer division by one million. *

      From 806b45a0f25d94ac3827a5cd6027fcbedffc80b2 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Sat, 1 Feb 2014 10:27:55 -0800 Subject: [PATCH 087/159] 8033223: Fix serial lint warnings in sun.{font, java2d[.*]} Reviewed-by: bae --- .../com/sun/imageio/plugins/common/BogusColorSpace.java | 3 ++- .../com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java | 1 + jdk/src/share/classes/sun/font/FontScalerException.java | 3 ++- jdk/src/share/classes/sun/java2d/InvalidPipeException.java | 3 ++- jdk/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java | 3 ++- 5 files changed, 9 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/common/BogusColorSpace.java b/jdk/src/share/classes/com/sun/imageio/plugins/common/BogusColorSpace.java index ea7fa4f0272..81924044610 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/common/BogusColorSpace.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/common/BogusColorSpace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ import java.awt.color.ColorSpace; * A dummy ColorSpace to enable ColorModel * for image data which do not have an innate color representation. */ +@SuppressWarnings("serial") // JDK-implementation class public class BogusColorSpace extends ColorSpace { /** * Return the type given the number of components. diff --git a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java index 21e5a26ad8d..393548e5b14 100644 --- a/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java +++ b/jdk/src/share/classes/com/sun/imageio/plugins/jpeg/JFIFMarkerSegment.java @@ -558,6 +558,7 @@ class JFIFMarkerSegment extends MarkerSegment { // Could put reason codes in here to be parsed in writeJFXXSegment // in order to provide more meaningful warnings. + @SuppressWarnings("serial") // JDK-implementation class private class IllegalThumbException extends Exception {} /** diff --git a/jdk/src/share/classes/sun/font/FontScalerException.java b/jdk/src/share/classes/sun/font/FontScalerException.java index 32db6d80679..b88aed62773 100644 --- a/jdk/src/share/classes/sun/font/FontScalerException.java +++ b/jdk/src/share/classes/sun/font/FontScalerException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.font; +@SuppressWarnings("serial") // JDK-implementation class public class FontScalerException extends Exception { public FontScalerException() { super("Font scaler encountered runtime problem."); diff --git a/jdk/src/share/classes/sun/java2d/InvalidPipeException.java b/jdk/src/share/classes/sun/java2d/InvalidPipeException.java index 569bdc7682d..22ac0661093 100644 --- a/jdk/src/share/classes/sun/java2d/InvalidPipeException.java +++ b/jdk/src/share/classes/sun/java2d/InvalidPipeException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,6 +34,7 @@ package sun.java2d; * windows which toggle the need to use platform graphics or direct * graphics access. */ +@SuppressWarnings("serial") // JDK-implementation class public class InvalidPipeException extends IllegalStateException { /** * Constructs an InvalidPipeException with no detail message. diff --git a/jdk/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java b/jdk/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java index 2f862cdeb10..1bcb05ccbb7 100644 --- a/jdk/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java +++ b/jdk/src/share/classes/sun/java2d/cmm/lcms/LCMSImageLayout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -376,6 +376,7 @@ class LCMSImageLayout { return (int)res; } + @SuppressWarnings("serial") // JDK-implementation class public static class ImageLayoutException extends Exception { public ImageLayoutException(String message) { super(message); From 4724c454cddd53730e0123b3996b60d5d9d84182 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Sun, 2 Feb 2014 12:12:01 +0100 Subject: [PATCH 088/159] 8030091: Request to update error messages from javac for negative varargs test cases Introducing a new error message for vararg parameter not being the last parameter, improving error message for unexpected character after a parameter. Reviewed-by: jjg, sogoel --- .../sun/tools/javac/parser/JavacParser.java | 14 ++++++++-- .../tools/javac/resources/compiler.properties | 5 +++- .../diags/examples/VarargsMustBeLast.java | 28 +++++++++++++++++++ .../javac/parser/ErroneousParameters.java | 16 +++++++++++ .../javac/parser/ErroneousParameters.out | 14 ++++++++++ .../TestParseErrors/TestParseErrors.out | 2 +- 6 files changed, 74 insertions(+), 5 deletions(-) create mode 100644 langtools/test/tools/javac/diags/examples/VarargsMustBeLast.java create mode 100644 langtools/test/tools/javac/parser/ErroneousParameters.java create mode 100644 langtools/test/tools/javac/parser/ErroneousParameters.out diff --git a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java index 55f46195024..49f68b13ae6 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java +++ b/langtools/src/share/classes/com/sun/tools/javac/parser/JavacParser.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3648,12 +3648,20 @@ public class JavacParser implements Parser { params.append(lastParam); } this.allowThisIdent = false; - while ((lastParam.mods.flags & Flags.VARARGS) == 0 && token.kind == COMMA) { + while (token.kind == COMMA) { + if ((lastParam.mods.flags & Flags.VARARGS) != 0) { + error(lastParam, "varargs.must.be.last"); + } nextToken(); params.append(lastParam = formalParameter(lambdaParameters)); } } - accept(RPAREN); + if (token.kind == RPAREN) { + nextToken(); + } else { + setErrorEndPos(token.pos); + reportSyntaxError(S.prevToken().endPos, "expected3", COMMA, RPAREN, LBRACKET); + } return params.toList(); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties index 709a11ae096..abbdf4847c6 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties +++ b/langtools/src/share/classes/com/sun/tools/javac/resources/compiler.properties @@ -1,5 +1,5 @@ # -# Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -597,6 +597,9 @@ compiler.err.varargs.and.old.array.syntax=\ compiler.err.varargs.and.receiver =\ varargs notation not allowed on receiver parameter +compiler.err.varargs.must.be.last =\ + varargs parameter must be the last parameter + compiler.err.array.and.receiver =\ legacy array notation not allowed on receiver parameter diff --git a/langtools/test/tools/javac/diags/examples/VarargsMustBeLast.java b/langtools/test/tools/javac/diags/examples/VarargsMustBeLast.java new file mode 100644 index 00000000000..bff1fbb6fcb --- /dev/null +++ b/langtools/test/tools/javac/diags/examples/VarargsMustBeLast.java @@ -0,0 +1,28 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + */ + +// key: compiler.err.varargs.must.be.last + +class VarargMustBeFinal { + public void invalidVarArg(String... invalidVarArg, String extra) { } +} diff --git a/langtools/test/tools/javac/parser/ErroneousParameters.java b/langtools/test/tools/javac/parser/ErroneousParameters.java new file mode 100644 index 00000000000..f6311d6f2db --- /dev/null +++ b/langtools/test/tools/javac/parser/ErroneousParameters.java @@ -0,0 +1,16 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8030091 + * @summary Producing reasonable errors for unexpected tokens in method parameters + * @compile/fail/ref=ErroneousParameters.out -XDrawDiagnostics ErroneousParameters.java + */ + +public class ErroneousParameters { + + public static void test(int... extraVarArg, int additionalParam) { } + public static void test(byte param...) { } + public static void test(char param,) { } + public static void test(short param[) { } + public static void test(int param=) { } + +} diff --git a/langtools/test/tools/javac/parser/ErroneousParameters.out b/langtools/test/tools/javac/parser/ErroneousParameters.out new file mode 100644 index 00000000000..89d9e3743e6 --- /dev/null +++ b/langtools/test/tools/javac/parser/ErroneousParameters.out @@ -0,0 +1,14 @@ +ErroneousParameters.java:10:36: compiler.err.varargs.must.be.last +ErroneousParameters.java:11:39: compiler.err.expected3: ',', ')', '[' +ErroneousParameters.java:11:42: compiler.err.illegal.start.of.type +ErroneousParameters.java:11:43: compiler.err.expected: token.identifier +ErroneousParameters.java:11:45: compiler.err.expected: ';' +ErroneousParameters.java:12:40: compiler.err.illegal.start.of.type +ErroneousParameters.java:12:41: compiler.err.expected3: ',', ')', '[' +ErroneousParameters.java:12:43: compiler.err.expected: ';' +ErroneousParameters.java:13:41: compiler.err.expected: ']' +ErroneousParameters.java:14:38: compiler.err.expected3: ',', ')', '[' +ErroneousParameters.java:14:39: compiler.err.illegal.start.of.type +ErroneousParameters.java:14:40: compiler.err.expected: token.identifier +ErroneousParameters.java:14:42: compiler.err.expected: ';' +13 errors diff --git a/langtools/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.out b/langtools/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.out index 947e921dd4d..11cff7ddcf1 100644 --- a/langtools/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.out +++ b/langtools/test/tools/javac/processing/errors/TestParseErrors/TestParseErrors.out @@ -1,6 +1,6 @@ ParseErrors.java:37:37: compiler.err.expected: token.identifier ParseErrors.java:38:1: compiler.err.illegal.start.of.type -ParseErrors.java:38:2: compiler.err.expected: ')' +ParseErrors.java:38:2: compiler.err.expected3: ',', ')', '[' ParseErrors.java:40:6: compiler.err.expected: ';' ParseErrors.java:40:20: compiler.err.illegal.start.of.type ParseErrors.java:41:5: compiler.err.expected: '(' From 24b84458a100ee4e55697820c2c52a20f95da957 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 3 Feb 2014 14:00:43 +0000 Subject: [PATCH 089/159] 8028792: (ch) Channels native code needs to be checked for methods calling JNI with pending excepitons 8032668: Check jdk/src/solaris/native/java/io for pending JNI exception issues Reviewed-by: chegar, simonis --- .../sun/nio/fs/AixNativeDispatcher.java | 2 +- .../native/sun/nio/fs/AixNativeDispatcher.c | 17 +++--- .../native/java/io/UnixFileSystem_md.c | 11 ++-- .../native/sun/nio/ch/DatagramChannelImpl.c | 22 ++++---- jdk/src/solaris/native/sun/nio/ch/FileKey.c | 4 +- jdk/src/solaris/native/sun/nio/ch/IOUtil.c | 4 +- .../sun/nio/ch/ServerSocketChannelImpl.c | 17 +++++- .../native/sun/nio/ch/sctp/SctpChannelImpl.c | 4 +- .../solaris/native/sun/nio/ch/sctp/SctpNet.c | 10 ++-- .../native/sun/nio/fs/BsdNativeDispatcher.c | 9 ++-- .../native/sun/nio/fs/LinuxNativeDispatcher.c | 8 +-- .../sun/nio/fs/SolarisNativeDispatcher.c | 9 ++-- .../native/sun/nio/fs/UnixNativeDispatcher.c | 36 +++++++++---- .../native/java/io/FileDescriptor_md.c | 4 +- .../native/java/io/WinNTFileSystem_md.c | 47 ++++++++-------- .../native/sun/nio/ch/DatagramChannelImpl.c | 20 ++++--- jdk/src/windows/native/sun/nio/ch/FileKey.c | 6 +-- jdk/src/windows/native/sun/nio/ch/IOUtil.c | 6 +-- jdk/src/windows/native/sun/nio/ch/Iocp.c | 11 ++-- .../sun/nio/ch/ServerSocketChannelImpl.c | 14 +++-- .../native/sun/nio/ch/SocketChannelImpl.c | 4 +- .../sun/nio/fs/WindowsNativeDispatcher.c | 53 ++++++++++--------- 22 files changed, 194 insertions(+), 124 deletions(-) diff --git a/jdk/src/aix/classes/sun/nio/fs/AixNativeDispatcher.java b/jdk/src/aix/classes/sun/nio/fs/AixNativeDispatcher.java index d46d80fc97f..76e833ae19a 100644 --- a/jdk/src/aix/classes/sun/nio/fs/AixNativeDispatcher.java +++ b/jdk/src/aix/classes/sun/nio/fs/AixNativeDispatcher.java @@ -43,7 +43,7 @@ class AixNativeDispatcher extends UnixNativeDispatcher { static native UnixMountEntry[] getmntctl() throws UnixException; // initialize - private static native int init(); + private static native void init(); static { AccessController.doPrivileged(new PrivilegedAction() { diff --git a/jdk/src/aix/native/sun/nio/fs/AixNativeDispatcher.c b/jdk/src/aix/native/sun/nio/fs/AixNativeDispatcher.c index 82d8f6203e7..e7afb205280 100644 --- a/jdk/src/aix/native/sun/nio/fs/AixNativeDispatcher.c +++ b/jdk/src/aix/native/sun/nio/fs/AixNativeDispatcher.c @@ -56,23 +56,26 @@ static void throwUnixException(JNIEnv* env, int errnum) { /** * Initialization */ -JNIEXPORT jint JNICALL +JNIEXPORT void JNICALL Java_sun_nio_fs_AixNativeDispatcher_init(JNIEnv* env, jclass this) { - jint flags = 0; jclass clazz; clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry"); - if (clazz == NULL) { - return 0; - } + CHECK_NULL(clazz); entry_name = (*env)->GetFieldID(env, clazz, "name", "[B"); + CHECK_NULL(entry_name); entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B"); + CHECK_NULL(entry_dir); entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B"); + CHECK_NULL(entry_fstype); entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B"); + CHECK_NULL(entry_options); entry_cls = (*env)->NewGlobalRef(env, clazz); - - return 0; + if (entry_cls == NULL) { + JNU_ThrowOutOfMemoryError(env, NULL); + return; + } } /** diff --git a/jdk/src/solaris/native/java/io/UnixFileSystem_md.c b/jdk/src/solaris/native/java/io/UnixFileSystem_md.c index 5f95cd998c8..487e8a2bac3 100644 --- a/jdk/src/solaris/native/java/io/UnixFileSystem_md.c +++ b/jdk/src/solaris/native/java/io/UnixFileSystem_md.c @@ -283,6 +283,10 @@ Java_java_io_UnixFileSystem_list(JNIEnv *env, jobject this, struct dirent64 *result; int len, maxlen; jobjectArray rv, old; + jclass str_class; + + str_class = JNU_ClassString(env); + CHECK_NULL_RETURN(str_class, NULL); WITH_FIELD_PLATFORM_STRING(env, file, ids.path, path) { dir = opendir(path); @@ -299,7 +303,7 @@ Java_java_io_UnixFileSystem_list(JNIEnv *env, jobject this, /* Allocate an initial String array */ len = 0; maxlen = 16; - rv = (*env)->NewObjectArray(env, maxlen, JNU_ClassString(env), NULL); + rv = (*env)->NewObjectArray(env, maxlen, str_class, NULL); if (rv == NULL) goto error; /* Scan the directory */ @@ -309,8 +313,7 @@ Java_java_io_UnixFileSystem_list(JNIEnv *env, jobject this, continue; if (len == maxlen) { old = rv; - rv = (*env)->NewObjectArray(env, maxlen <<= 1, - JNU_ClassString(env), NULL); + rv = (*env)->NewObjectArray(env, maxlen <<= 1, str_class, NULL); if (rv == NULL) goto error; if (JNU_CopyObjectArray(env, rv, old, len) < 0) goto error; (*env)->DeleteLocalRef(env, old); @@ -329,7 +332,7 @@ Java_java_io_UnixFileSystem_list(JNIEnv *env, jobject this, /* Copy the final results into an appropriately-sized array */ old = rv; - rv = (*env)->NewObjectArray(env, len, JNU_ClassString(env), NULL); + rv = (*env)->NewObjectArray(env, len, str_class, NULL); if (rv == NULL) { return NULL; } diff --git a/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c b/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c index 816270c9b8e..f5dd361c4fc 100644 --- a/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c +++ b/jdk/src/solaris/native/sun/nio/ch/DatagramChannelImpl.c @@ -56,18 +56,28 @@ JNIEXPORT void JNICALL Java_sun_nio_ch_DatagramChannelImpl_initIDs(JNIEnv *env, jclass clazz) { clazz = (*env)->FindClass(env, "java/net/InetSocketAddress"); + CHECK_NULL(clazz); isa_class = (*env)->NewGlobalRef(env, clazz); + if (isa_class == NULL) { + JNU_ThrowOutOfMemoryError(env, NULL); + return; + } isa_ctorID = (*env)->GetMethodID(env, clazz, "", "(Ljava/net/InetAddress;I)V"); + CHECK_NULL(isa_ctorID); clazz = (*env)->FindClass(env, "sun/nio/ch/DatagramChannelImpl"); + CHECK_NULL(clazz); dci_senderID = (*env)->GetFieldID(env, clazz, "sender", "Ljava/net/SocketAddress;"); + CHECK_NULL(dci_senderID); dci_senderAddrID = (*env)->GetFieldID(env, clazz, "cachedSenderInetAddress", "Ljava/net/InetAddress;"); + CHECK_NULL(dci_senderAddrID); dci_senderPortID = (*env)->GetFieldID(env, clazz, "cachedSenderPort", "I"); + CHECK_NULL(dci_senderPortID); } JNIEXPORT void JNICALL @@ -121,7 +131,7 @@ Java_sun_nio_ch_DatagramChannelImpl_disconnect0(JNIEnv *env, jobject this, * but that is acceptable. */ if (rv < 0 && errno == EAFNOSUPPORT) - rv = errno = 0; + rv = errno = 0; #endif } #endif @@ -192,17 +202,11 @@ Java_sun_nio_ch_DatagramChannelImpl_receive0(JNIEnv *env, jobject this, if (senderAddr == NULL) { jobject isa = NULL; int port; - jobject ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, - &port); - + jobject ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port); if (ia != NULL) { isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port); } - - if (isa == NULL) { - JNU_ThrowOutOfMemoryError(env, "heap allocation failed"); - return IOS_THROWN; - } + CHECK_NULL_RETURN(isa, IOS_THROWN); (*env)->SetObjectField(env, this, dci_senderAddrID, ia); (*env)->SetIntField(env, this, dci_senderPortID, diff --git a/jdk/src/solaris/native/sun/nio/ch/FileKey.c b/jdk/src/solaris/native/sun/nio/ch/FileKey.c index ddb88329eca..bdb42a6324b 100644 --- a/jdk/src/solaris/native/sun/nio/ch/FileKey.c +++ b/jdk/src/solaris/native/sun/nio/ch/FileKey.c @@ -43,8 +43,8 @@ static jfieldID key_st_ino; /* id for FileKey.st_ino */ JNIEXPORT void JNICALL Java_sun_nio_ch_FileKey_initIDs(JNIEnv *env, jclass clazz) { - key_st_dev = (*env)->GetFieldID(env, clazz, "st_dev", "J"); - key_st_ino = (*env)->GetFieldID(env, clazz, "st_ino", "J"); + CHECK_NULL(key_st_dev = (*env)->GetFieldID(env, clazz, "st_dev", "J")); + CHECK_NULL(key_st_ino = (*env)->GetFieldID(env, clazz, "st_ino", "J")); } diff --git a/jdk/src/solaris/native/sun/nio/ch/IOUtil.c b/jdk/src/solaris/native/sun/nio/ch/IOUtil.c index 7dbf010fcac..438bf41ddea 100644 --- a/jdk/src/solaris/native/sun/nio/ch/IOUtil.c +++ b/jdk/src/solaris/native/sun/nio/ch/IOUtil.c @@ -42,8 +42,8 @@ static jfieldID fd_fdID; /* for jint 'fd' in java.io.FileDescriptor */ JNIEXPORT void JNICALL Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz) { - clazz = (*env)->FindClass(env, "java/io/FileDescriptor"); - fd_fdID = (*env)->GetFieldID(env, clazz, "fd", "I"); + CHECK_NULL(clazz = (*env)->FindClass(env, "java/io/FileDescriptor")); + CHECK_NULL(fd_fdID = (*env)->GetFieldID(env, clazz, "fd", "I")); } JNIEXPORT jboolean JNICALL diff --git a/jdk/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c b/jdk/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c index 7a730cc0b25..e96c9b0cc0a 100644 --- a/jdk/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c +++ b/jdk/src/solaris/native/sun/nio/ch/ServerSocketChannelImpl.c @@ -57,12 +57,20 @@ Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(JNIEnv *env, jclass c) jclass cls; cls = (*env)->FindClass(env, "java/io/FileDescriptor"); + CHECK_NULL(cls); fd_fdID = (*env)->GetFieldID(env, cls, "fd", "I"); + CHECK_NULL(fd_fdID); cls = (*env)->FindClass(env, "java/net/InetSocketAddress"); + CHECK_NULL(cls); isa_class = (*env)->NewGlobalRef(env, cls); + if (isa_class == NULL) { + JNU_ThrowOutOfMemoryError(env, NULL); + return; + } isa_ctorID = (*env)->GetMethodID(env, cls, "", "(Ljava/net/InetAddress;I)V"); + CHECK_NULL(isa_ctorID); } JNIEXPORT jint JNICALL @@ -79,6 +87,10 @@ Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv *env, jobject this, jint remote_port; NET_AllocSockaddr(&sa, &alloc_len); + if (sa == NULL) { + JNU_ThrowOutOfMemoryError(env, NULL); + return IOS_THROWN; + } /* * accept connection but ignore ECONNABORTED indicating that @@ -110,8 +122,9 @@ Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv *env, jobject this, (*env)->SetIntField(env, newfdo, fd_fdID, newfd); remote_ia = NET_SockaddrToInetAddress(env, sa, (int *)&remote_port); free((void *)sa); - isa = (*env)->NewObject(env, isa_class, isa_ctorID, - remote_ia, remote_port); + CHECK_NULL_RETURN(remote_ia, IOS_THROWN); + isa = (*env)->NewObject(env, isa_class, isa_ctorID, remote_ia, remote_port); + CHECK_NULL_RETURN(isa, IOS_THROWN); (*env)->SetObjectArrayElement(env, isaa, 0, isa); return 1; } diff --git a/jdk/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c index 225556b4d9f..54e16af7f6b 100644 --- a/jdk/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c +++ b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpChannelImpl.c @@ -214,6 +214,7 @@ void handleSendFailed /* retrieved address from sockaddr */ isaObj = SockAddrToInetSocketAddress(env, sap); + CHECK_NULL(isaObj); /* data retrieved from sff_data */ if (dataLength > 0) { @@ -338,6 +339,7 @@ void handlePeerAddrChange } addressObj = SockAddrToInetSocketAddress(env, (struct sockaddr*)&spc->spc_aaddr); + CHECK_NULL(addressObj); /* create PeerAddressChanged */ resultObj = (*env)->NewObject(env, spc_class, spc_ctrID, spc->spc_assoc_id, @@ -394,6 +396,7 @@ void handleMessage } isa = SockAddrToInetSocketAddress(env, sap); + CHECK_NULL(isa); getControlData(msg, cdata); /* create MessageInfoImpl */ @@ -580,4 +583,3 @@ JNIEXPORT jint JNICALL Java_sun_nio_ch_sctp_SctpChannelImpl_checkConnect return Java_sun_nio_ch_SocketChannelImpl_checkConnect(env, this, fdo, block, ready); } - diff --git a/jdk/src/solaris/native/sun/nio/ch/sctp/SctpNet.c b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpNet.c index 57c4fae4fa5..f03be57b5d0 100644 --- a/jdk/src/solaris/native/sun/nio/ch/sctp/SctpNet.c +++ b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpNet.c @@ -382,8 +382,9 @@ JNIEXPORT jobjectArray JNICALL Java_sun_nio_ch_sctp_SctpNet_getLocalAddresses0 ia = NET_SockaddrToInetAddress(env, sap, &port); if (ia != NULL) isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port); - if (isa != NULL) - (*env)->SetObjectArrayElement(env, isaa, i, isa); + if (isa == NULL) + break; + (*env)->SetObjectArrayElement(env, isaa, i, isa); if (sap->sa_family == AF_INET) addr_buf = ((struct sockaddr_in*)addr_buf) + 1; @@ -433,8 +434,9 @@ jobjectArray getRemoteAddresses ia = NET_SockaddrToInetAddress(env, sap, &port); if (ia != NULL) isa = (*env)->NewObject(env, isaCls, isaCtrID, ia, port); - if (isa != NULL) - (*env)->SetObjectArrayElement(env, isaa, i, isa); + if (isa == NULL) + break; + (*env)->SetObjectArrayElement(env, isaa, i, isa); if (sap->sa_family == AF_INET) addr_buf = ((struct sockaddr_in*)addr_buf) + 1; diff --git a/jdk/src/solaris/native/sun/nio/fs/BsdNativeDispatcher.c b/jdk/src/solaris/native/sun/nio/fs/BsdNativeDispatcher.c index 0b4f2a74dff..9453f75d3de 100644 --- a/jdk/src/solaris/native/sun/nio/fs/BsdNativeDispatcher.c +++ b/jdk/src/solaris/native/sun/nio/fs/BsdNativeDispatcher.c @@ -72,13 +72,15 @@ Java_sun_nio_fs_BsdNativeDispatcher_initIDs(JNIEnv* env, jclass this) jclass clazz; clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry"); - if (clazz == NULL) { - return; - } + CHECK_NULL(clazz); entry_name = (*env)->GetFieldID(env, clazz, "name", "[B"); + CHECK_NULL(entry_name); entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B"); + CHECK_NULL(entry_dir); entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B"); + CHECK_NULL(entry_fstype); entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B"); + CHECK_NULL(entry_options); } JNIEXPORT jlong JNICALL @@ -201,4 +203,3 @@ Java_sun_nio_fs_BsdNativeDispatcher_endfsstat(JNIEnv* env, jclass this, jlong va free(iter); } } - diff --git a/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c b/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c index 1de7d5b3c98..c8500db5c87 100644 --- a/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c +++ b/jdk/src/solaris/native/sun/nio/fs/LinuxNativeDispatcher.c @@ -68,13 +68,15 @@ Java_sun_nio_fs_LinuxNativeDispatcher_init(JNIEnv *env, jclass clazz) my_flistxattr_func = (flistxattr_func*)dlsym(RTLD_DEFAULT, "flistxattr"); clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry"); - if (clazz == NULL) - return; - + CHECK_NULL(clazz); entry_name = (*env)->GetFieldID(env, clazz, "name", "[B"); + CHECK_NULL(entry_name); entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B"); + CHECK_NULL(entry_dir); entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B"); + CHECK_NULL(entry_fstype); entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B"); + CHECK_NULL(entry_options); } JNIEXPORT jint JNICALL diff --git a/jdk/src/solaris/native/sun/nio/fs/SolarisNativeDispatcher.c b/jdk/src/solaris/native/sun/nio/fs/SolarisNativeDispatcher.c index 1480ea9046b..de04bbddc7c 100644 --- a/jdk/src/solaris/native/sun/nio/fs/SolarisNativeDispatcher.c +++ b/jdk/src/solaris/native/sun/nio/fs/SolarisNativeDispatcher.c @@ -55,14 +55,17 @@ static void throwUnixException(JNIEnv* env, int errnum) { JNIEXPORT void JNICALL Java_sun_nio_fs_SolarisNativeDispatcher_init(JNIEnv *env, jclass clazz) { clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry"); - if (clazz == NULL) - return; - + CHECK_NULL(clazz); entry_name = (*env)->GetFieldID(env, clazz, "name", "[B"); + CHECK_NULL(entry_name); entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B"); + CHECK_NULL(entry_dir); entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B"); + CHECK_NULL(entry_fstype); entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B"); + CHECK_NULL(entry_options); entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J"); + CHECK_NULL(entry_dev); } JNIEXPORT jint JNICALL diff --git a/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c b/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c index 12f399d8512..8901376361d 100644 --- a/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c +++ b/jdk/src/solaris/native/sun/nio/fs/UnixNativeDispatcher.c @@ -179,46 +179,64 @@ Java_sun_nio_fs_UnixNativeDispatcher_init(JNIEnv* env, jclass this) jclass clazz; clazz = (*env)->FindClass(env, "sun/nio/fs/UnixFileAttributes"); - if (clazz == NULL) { - return 0; - } + CHECK_NULL_RETURN(clazz, 0); attrs_st_mode = (*env)->GetFieldID(env, clazz, "st_mode", "I"); + CHECK_NULL_RETURN(attrs_st_mode, 0); attrs_st_ino = (*env)->GetFieldID(env, clazz, "st_ino", "J"); + CHECK_NULL_RETURN(attrs_st_ino, 0); attrs_st_dev = (*env)->GetFieldID(env, clazz, "st_dev", "J"); + CHECK_NULL_RETURN(attrs_st_dev, 0); attrs_st_rdev = (*env)->GetFieldID(env, clazz, "st_rdev", "J"); + CHECK_NULL_RETURN(attrs_st_rdev, 0); attrs_st_nlink = (*env)->GetFieldID(env, clazz, "st_nlink", "I"); + CHECK_NULL_RETURN(attrs_st_nlink, 0); attrs_st_uid = (*env)->GetFieldID(env, clazz, "st_uid", "I"); + CHECK_NULL_RETURN(attrs_st_uid, 0); attrs_st_gid = (*env)->GetFieldID(env, clazz, "st_gid", "I"); + CHECK_NULL_RETURN(attrs_st_gid, 0); attrs_st_size = (*env)->GetFieldID(env, clazz, "st_size", "J"); + CHECK_NULL_RETURN(attrs_st_size, 0); attrs_st_atime_sec = (*env)->GetFieldID(env, clazz, "st_atime_sec", "J"); + CHECK_NULL_RETURN(attrs_st_atime_sec, 0); attrs_st_atime_nsec = (*env)->GetFieldID(env, clazz, "st_atime_nsec", "J"); + CHECK_NULL_RETURN(attrs_st_atime_nsec, 0); attrs_st_mtime_sec = (*env)->GetFieldID(env, clazz, "st_mtime_sec", "J"); + CHECK_NULL_RETURN(attrs_st_mtime_sec, 0); attrs_st_mtime_nsec = (*env)->GetFieldID(env, clazz, "st_mtime_nsec", "J"); + CHECK_NULL_RETURN(attrs_st_mtime_nsec, 0); attrs_st_ctime_sec = (*env)->GetFieldID(env, clazz, "st_ctime_sec", "J"); + CHECK_NULL_RETURN(attrs_st_ctime_sec, 0); attrs_st_ctime_nsec = (*env)->GetFieldID(env, clazz, "st_ctime_nsec", "J"); + CHECK_NULL_RETURN(attrs_st_ctime_nsec, 0); #ifdef _DARWIN_FEATURE_64_BIT_INODE attrs_st_birthtime_sec = (*env)->GetFieldID(env, clazz, "st_birthtime_sec", "J"); + CHECK_NULL_RETURN(attrs_st_birthtime_sec, 0); #endif clazz = (*env)->FindClass(env, "sun/nio/fs/UnixFileStoreAttributes"); - if (clazz == NULL) { - return 0; - } + CHECK_NULL_RETURN(clazz, 0); attrs_f_frsize = (*env)->GetFieldID(env, clazz, "f_frsize", "J"); + CHECK_NULL_RETURN(attrs_f_frsize, 0); attrs_f_blocks = (*env)->GetFieldID(env, clazz, "f_blocks", "J"); + CHECK_NULL_RETURN(attrs_f_blocks, 0); attrs_f_bfree = (*env)->GetFieldID(env, clazz, "f_bfree", "J"); + CHECK_NULL_RETURN(attrs_f_bfree, 0); attrs_f_bavail = (*env)->GetFieldID(env, clazz, "f_bavail", "J"); + CHECK_NULL_RETURN(attrs_f_bavail, 0); clazz = (*env)->FindClass(env, "sun/nio/fs/UnixMountEntry"); - if (clazz == NULL) { - return 0; - } + CHECK_NULL_RETURN(clazz, 0); entry_name = (*env)->GetFieldID(env, clazz, "name", "[B"); + CHECK_NULL_RETURN(entry_name, 0); entry_dir = (*env)->GetFieldID(env, clazz, "dir", "[B"); + CHECK_NULL_RETURN(entry_dir, 0); entry_fstype = (*env)->GetFieldID(env, clazz, "fstype", "[B"); + CHECK_NULL_RETURN(entry_fstype, 0); entry_options = (*env)->GetFieldID(env, clazz, "opts", "[B"); + CHECK_NULL_RETURN(entry_options, 0); entry_dev = (*env)->GetFieldID(env, clazz, "dev", "J"); + CHECK_NULL_RETURN(entry_dev, 0); /* system calls that might not be available at run time */ diff --git a/jdk/src/windows/native/java/io/FileDescriptor_md.c b/jdk/src/windows/native/java/io/FileDescriptor_md.c index 221bf1d9217..db04cd47653 100644 --- a/jdk/src/windows/native/java/io/FileDescriptor_md.c +++ b/jdk/src/windows/native/java/io/FileDescriptor_md.c @@ -48,8 +48,8 @@ jfieldID IO_handle_fdID; JNIEXPORT void JNICALL Java_java_io_FileDescriptor_initIDs(JNIEnv *env, jclass fdClass) { - IO_fd_fdID = (*env)->GetFieldID(env, fdClass, "fd", "I"); - IO_handle_fdID = (*env)->GetFieldID(env, fdClass, "handle", "J"); + CHECK_NULL(IO_fd_fdID = (*env)->GetFieldID(env, fdClass, "fd", "I")); + CHECK_NULL(IO_handle_fdID = (*env)->GetFieldID(env, fdClass, "handle", "J")); } JNIEXPORT jlong JNICALL diff --git a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c index 3c8b821e027..ec7d9d7294b 100644 --- a/jdk/src/windows/native/java/io/WinNTFileSystem_md.c +++ b/jdk/src/windows/native/java/io/WinNTFileSystem_md.c @@ -59,10 +59,12 @@ JNIEXPORT void JNICALL Java_java_io_WinNTFileSystem_initIDs(JNIEnv *env, jclass cls) { HMODULE handle; - jclass fileClass = (*env)->FindClass(env, "java/io/File"); - if (!fileClass) return; - ids.path = - (*env)->GetFieldID(env, fileClass, "path", "Ljava/lang/String;"); + jclass fileClass; + + fileClass = (*env)->FindClass(env, "java/io/File"); + CHECK_NULL(fileClass); + ids.path = (*env)->GetFieldID(env, fileClass, "path", "Ljava/lang/String;"); + CHECK_NULL(ids.path); // GetFinalPathNameByHandle requires Windows Vista or newer if (GetModuleHandleExW((GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | @@ -243,8 +245,8 @@ Java_java_io_WinNTFileSystem_canonicalize0(JNIEnv *env, jobject this, WCHAR canonicalPath[MAX_PATH_LENGTH]; WITH_UNICODE_STRING(env, pathname, path) { - /*we estimate the max length of memory needed as - "currentDir. length + pathname.length" + /* we estimate the max length of memory needed as + "currentDir. length + pathname.length" */ int len = (int)wcslen(path); len += currentDirLength(path, len); @@ -256,12 +258,11 @@ Java_java_io_WinNTFileSystem_canonicalize0(JNIEnv *env, jobject this, } free(cp); } - } else - if (wcanonicalize(path, canonicalPath, MAX_PATH_LENGTH) >= 0) { + } else if (wcanonicalize(path, canonicalPath, MAX_PATH_LENGTH) >= 0) { rv = (*env)->NewString(env, canonicalPath, (jsize)wcslen(canonicalPath)); } } END_UNICODE_STRING(env, path); - if (rv == NULL) { + if (rv == NULL && !(*env)->ExceptionCheck(env)) { JNU_ThrowIOExceptionWithLastError(env, "Bad pathname"); } return rv; @@ -288,15 +289,14 @@ Java_java_io_WinNTFileSystem_canonicalizeWithPrefix0(JNIEnv *env, jobject this, } free(cp); } - } else - if (wcanonicalizeWithPrefix(canonicalPrefix, - pathWithCanonicalPrefix, - canonicalPath, MAX_PATH_LENGTH) >= 0) { + } else if (wcanonicalizeWithPrefix(canonicalPrefix, + pathWithCanonicalPrefix, + canonicalPath, MAX_PATH_LENGTH) >= 0) { rv = (*env)->NewString(env, canonicalPath, (jsize)wcslen(canonicalPath)); } } END_UNICODE_STRING(env, pathWithCanonicalPrefix); } END_UNICODE_STRING(env, canonicalPrefix); - if (rv == NULL) { + if (rv == NULL && !(*env)->ExceptionCheck(env)) { JNU_ThrowIOExceptionWithLastError(env, "Bad pathname"); } return rv; @@ -616,8 +616,13 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file) jobjectArray rv, old; DWORD fattr; jstring name; + jclass str_class; + WCHAR *pathbuf; - WCHAR *pathbuf = fileToNTPath(env, file, ids.path); + str_class = JNU_ClassString(env); + CHECK_NULL_RETURN(str_class, NULL); + + pathbuf = fileToNTPath(env, file, ids.path); if (pathbuf == NULL) return NULL; search_path = (WCHAR*)malloc(2*wcslen(pathbuf) + 6); @@ -664,7 +669,7 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file) return NULL; } else { // No files found - return an empty array - rv = (*env)->NewObjectArray(env, 0, JNU_ClassString(env), NULL); + rv = (*env)->NewObjectArray(env, 0, str_class, NULL); return rv; } } @@ -672,7 +677,7 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file) /* Allocate an initial String array */ len = 0; maxlen = 16; - rv = (*env)->NewObjectArray(env, maxlen, JNU_ClassString(env), NULL); + rv = (*env)->NewObjectArray(env, maxlen, str_class, NULL); if (rv == NULL) // Couldn't allocate an array return NULL; /* Scan the directory */ @@ -686,10 +691,8 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file) return NULL; // error; if (len == maxlen) { old = rv; - rv = (*env)->NewObjectArray(env, maxlen <<= 1, - JNU_ClassString(env), NULL); - if ( rv == NULL - || JNU_CopyObjectArray(env, rv, old, len) < 0) + rv = (*env)->NewObjectArray(env, maxlen <<= 1, str_class, NULL); + if (rv == NULL || JNU_CopyObjectArray(env, rv, old, len) < 0) return NULL; // error (*env)->DeleteLocalRef(env, old); } @@ -704,7 +707,7 @@ Java_java_io_WinNTFileSystem_list(JNIEnv *env, jobject this, jobject file) /* Copy the final results into an appropriately-sized array */ old = rv; - rv = (*env)->NewObjectArray(env, len, JNU_ClassString(env), NULL); + rv = (*env)->NewObjectArray(env, len, str_class, NULL); if (rv == NULL) return NULL; /* error */ if (JNU_CopyObjectArray(env, rv, old, len) < 0) diff --git a/jdk/src/windows/native/sun/nio/ch/DatagramChannelImpl.c b/jdk/src/windows/native/sun/nio/ch/DatagramChannelImpl.c index ab46f8d7faa..ecc96a1d8bb 100644 --- a/jdk/src/windows/native/sun/nio/ch/DatagramChannelImpl.c +++ b/jdk/src/windows/native/sun/nio/ch/DatagramChannelImpl.c @@ -45,18 +45,28 @@ JNIEXPORT void JNICALL Java_sun_nio_ch_DatagramChannelImpl_initIDs(JNIEnv *env, jclass clazz) { clazz = (*env)->FindClass(env, "java/net/InetSocketAddress"); + CHECK_NULL(clazz); isa_class = (*env)->NewGlobalRef(env, clazz); + if (isa_class == NULL) { + JNU_ThrowOutOfMemoryError(env, NULL); + return; + } isa_ctorID = (*env)->GetMethodID(env, clazz, "", "(Ljava/net/InetAddress;I)V"); + CHECK_NULL(isa_ctorID); clazz = (*env)->FindClass(env, "sun/nio/ch/DatagramChannelImpl"); + CHECK_NULL(clazz); dci_senderID = (*env)->GetFieldID(env, clazz, "sender", "Ljava/net/SocketAddress;"); + CHECK_NULL(dci_senderID); dci_senderAddrID = (*env)->GetFieldID(env, clazz, "cachedSenderInetAddress", "Ljava/net/InetAddress;"); + CHECK_NULL(dci_senderAddrID); dci_senderPortID = (*env)->GetFieldID(env, clazz, "cachedSenderPort", "I"); + CHECK_NULL(dci_senderPortID); } /* @@ -185,17 +195,11 @@ Java_sun_nio_ch_DatagramChannelImpl_receive0(JNIEnv *env, jobject this, if (senderAddr == NULL) { jobject isa = NULL; int port; - jobject ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, - &port); - + jobject ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, &port); if (ia != NULL) { isa = (*env)->NewObject(env, isa_class, isa_ctorID, ia, port); } - - if (isa == NULL) { - JNU_ThrowOutOfMemoryError(env, "heap allocation failed"); - return IOS_THROWN; - } + CHECK_NULL_RETURN(isa, IOS_THROWN); // update cachedSenderInetAddress/cachedSenderPort (*env)->SetObjectField(env, this, dci_senderAddrID, ia); diff --git a/jdk/src/windows/native/sun/nio/ch/FileKey.c b/jdk/src/windows/native/sun/nio/ch/FileKey.c index e095296abeb..65306d1d639 100644 --- a/jdk/src/windows/native/sun/nio/ch/FileKey.c +++ b/jdk/src/windows/native/sun/nio/ch/FileKey.c @@ -38,9 +38,9 @@ static jfieldID key_indexLow; /* id for FileKey.nFileIndexLow */ JNIEXPORT void JNICALL Java_sun_nio_ch_FileKey_initIDs(JNIEnv *env, jclass clazz) { - key_volumeSN = (*env)->GetFieldID(env, clazz, "dwVolumeSerialNumber", "J"); - key_indexHigh = (*env)->GetFieldID(env, clazz, "nFileIndexHigh", "J"); - key_indexLow = (*env)->GetFieldID(env, clazz, "nFileIndexLow", "J"); + CHECK_NULL(key_volumeSN = (*env)->GetFieldID(env, clazz, "dwVolumeSerialNumber", "J")); + CHECK_NULL(key_indexHigh = (*env)->GetFieldID(env, clazz, "nFileIndexHigh", "J")); + CHECK_NULL(key_indexLow = (*env)->GetFieldID(env, clazz, "nFileIndexLow", "J")); } diff --git a/jdk/src/windows/native/sun/nio/ch/IOUtil.c b/jdk/src/windows/native/sun/nio/ch/IOUtil.c index 10c72e4682f..370dcf5e23f 100644 --- a/jdk/src/windows/native/sun/nio/ch/IOUtil.c +++ b/jdk/src/windows/native/sun/nio/ch/IOUtil.c @@ -52,9 +52,9 @@ Java_sun_security_provider_NativeSeedGenerator_nativeGenerateSeed JNIEXPORT void JNICALL Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz) { - clazz = (*env)->FindClass(env, "java/io/FileDescriptor"); - fd_fdID = (*env)->GetFieldID(env, clazz, "fd", "I"); - handle_fdID = (*env)->GetFieldID(env, clazz, "handle", "J"); + CHECK_NULL(clazz = (*env)->FindClass(env, "java/io/FileDescriptor")); + CHECK_NULL(fd_fdID = (*env)->GetFieldID(env, clazz, "fd", "I")); + CHECK_NULL(handle_fdID = (*env)->GetFieldID(env, clazz, "handle", "J")); } /************************************************************** diff --git a/jdk/src/windows/native/sun/nio/ch/Iocp.c b/jdk/src/windows/native/sun/nio/ch/Iocp.c index 8f87a8937f7..f9556234075 100644 --- a/jdk/src/windows/native/sun/nio/ch/Iocp.c +++ b/jdk/src/windows/native/sun/nio/ch/Iocp.c @@ -46,16 +46,15 @@ Java_sun_nio_ch_Iocp_initIDs(JNIEnv* env, jclass this) jclass clazz; clazz = (*env)->FindClass(env, "sun/nio/ch/Iocp$CompletionStatus"); - if (clazz == NULL) { - return; - } + CHECK_NULL(clazz); completionStatus_error = (*env)->GetFieldID(env, clazz, "error", "I"); - if (completionStatus_error == NULL) return; + CHECK_NULL(completionStatus_error); completionStatus_bytesTransferred = (*env)->GetFieldID(env, clazz, "bytesTransferred", "I"); - if (completionStatus_bytesTransferred == NULL) return; + CHECK_NULL(completionStatus_bytesTransferred); completionStatus_completionKey = (*env)->GetFieldID(env, clazz, "completionKey", "I"); - if (completionStatus_completionKey == NULL) return; + CHECK_NULL(completionStatus_completionKey); completionStatus_overlapped = (*env)->GetFieldID(env, clazz, "overlapped", "J"); + CHECK_NULL(completionStatus_overlapped); } JNIEXPORT jint JNICALL diff --git a/jdk/src/windows/native/sun/nio/ch/ServerSocketChannelImpl.c b/jdk/src/windows/native/sun/nio/ch/ServerSocketChannelImpl.c index 2af833c2eb7..30d6d641645 100644 --- a/jdk/src/windows/native/sun/nio/ch/ServerSocketChannelImpl.c +++ b/jdk/src/windows/native/sun/nio/ch/ServerSocketChannelImpl.c @@ -56,12 +56,20 @@ JNIEXPORT void JNICALL Java_sun_nio_ch_ServerSocketChannelImpl_initIDs(JNIEnv *env, jclass cls) { cls = (*env)->FindClass(env, "java/io/FileDescriptor"); + CHECK_NULL(cls); fd_fdID = (*env)->GetFieldID(env, cls, "fd", "I"); + CHECK_NULL(fd_fdID); cls = (*env)->FindClass(env, "java/net/InetSocketAddress"); + CHECK_NULL(cls); isa_class = (*env)->NewGlobalRef(env, cls); + if (isa_class == NULL) { + JNU_ThrowOutOfMemoryError(env, NULL); + return; + } isa_ctorID = (*env)->GetMethodID(env, cls, "", "(Ljava/net/InetAddress;I)V"); + CHECK_NULL(isa_ctorID); } JNIEXPORT void JNICALL @@ -99,10 +107,10 @@ Java_sun_nio_ch_ServerSocketChannelImpl_accept0(JNIEnv *env, jobject this, (*env)->SetIntField(env, newfdo, fd_fdID, newfd); remote_ia = NET_SockaddrToInetAddress(env, (struct sockaddr *)&sa, (int *)&remote_port); + CHECK_NULL_RETURN(remote_ia, IOS_THROWN); - isa = (*env)->NewObject(env, isa_class, isa_ctorID, - remote_ia, remote_port); + isa = (*env)->NewObject(env, isa_class, isa_ctorID, remote_ia, remote_port); + CHECK_NULL_RETURN(isa, IOS_THROWN); (*env)->SetObjectArrayElement(env, isaa, 0, isa); - return 1; } diff --git a/jdk/src/windows/native/sun/nio/ch/SocketChannelImpl.c b/jdk/src/windows/native/sun/nio/ch/SocketChannelImpl.c index be50fd69439..5f9fc5000e1 100644 --- a/jdk/src/windows/native/sun/nio/ch/SocketChannelImpl.c +++ b/jdk/src/windows/native/sun/nio/ch/SocketChannelImpl.c @@ -42,8 +42,8 @@ static jfieldID ia_addrID; /* java.net.InetAddress.address */ JNIEXPORT void JNICALL Java_sun_nio_ch_SocketChannelImpl_initIDs(JNIEnv *env, jclass cls) { - cls = (*env)->FindClass(env, "java/net/InetAddress"); - ia_addrID = (*env)->GetFieldID(env, cls, "address", "I"); + CHECK_NULL(cls = (*env)->FindClass(env, "java/net/InetAddress")); + CHECK_NULL(ia_addrID = (*env)->GetFieldID(env, cls, "address", "I")); } jint diff --git a/jdk/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c b/jdk/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c index 62d8a892b05..3b981f3760b 100644 --- a/jdk/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c +++ b/jdk/src/windows/native/sun/nio/fs/WindowsNativeDispatcher.c @@ -111,65 +111,70 @@ Java_sun_nio_fs_WindowsNativeDispatcher_initIDs(JNIEnv* env, jclass this) HMODULE h; clazz = (*env)->FindClass(env, "sun/nio/fs/WindowsNativeDispatcher$FirstFile"); - if (clazz == NULL) { - return; - } + CHECK_NULL(clazz); findFirst_handle = (*env)->GetFieldID(env, clazz, "handle", "J"); + CHECK_NULL(findFirst_handle); findFirst_name = (*env)->GetFieldID(env, clazz, "name", "Ljava/lang/String;"); + CHECK_NULL(findFirst_name); findFirst_attributes = (*env)->GetFieldID(env, clazz, "attributes", "I"); + CHECK_NULL(findFirst_attributes); clazz = (*env)->FindClass(env, "sun/nio/fs/WindowsNativeDispatcher$FirstStream"); - if (clazz == NULL) { - return; - } + CHECK_NULL(clazz); findStream_handle = (*env)->GetFieldID(env, clazz, "handle", "J"); + CHECK_NULL(findStream_handle); findStream_name = (*env)->GetFieldID(env, clazz, "name", "Ljava/lang/String;"); + CHECK_NULL(findStream_name); clazz = (*env)->FindClass(env, "sun/nio/fs/WindowsNativeDispatcher$VolumeInformation"); - if (clazz == NULL) { - return; - } + CHECK_NULL(clazz); volumeInfo_fsName = (*env)->GetFieldID(env, clazz, "fileSystemName", "Ljava/lang/String;"); + CHECK_NULL(volumeInfo_fsName); volumeInfo_volName = (*env)->GetFieldID(env, clazz, "volumeName", "Ljava/lang/String;"); + CHECK_NULL(volumeInfo_volName); volumeInfo_volSN = (*env)->GetFieldID(env, clazz, "volumeSerialNumber", "I"); + CHECK_NULL(volumeInfo_volSN); volumeInfo_flags = (*env)->GetFieldID(env, clazz, "flags", "I"); + CHECK_NULL(volumeInfo_flags); clazz = (*env)->FindClass(env, "sun/nio/fs/WindowsNativeDispatcher$DiskFreeSpace"); - if (clazz == NULL) { - return; - } + CHECK_NULL(clazz); diskSpace_bytesAvailable = (*env)->GetFieldID(env, clazz, "freeBytesAvailable", "J"); + CHECK_NULL(diskSpace_bytesAvailable); diskSpace_totalBytes = (*env)->GetFieldID(env, clazz, "totalNumberOfBytes", "J"); + CHECK_NULL(diskSpace_totalBytes); diskSpace_totalFree = (*env)->GetFieldID(env, clazz, "totalNumberOfFreeBytes", "J"); + CHECK_NULL(diskSpace_totalFree); clazz = (*env)->FindClass(env, "sun/nio/fs/WindowsNativeDispatcher$Account"); - if (clazz == NULL) { - return; - } + CHECK_NULL(clazz); account_domain = (*env)->GetFieldID(env, clazz, "domain", "Ljava/lang/String;"); + CHECK_NULL(account_domain); account_name = (*env)->GetFieldID(env, clazz, "name", "Ljava/lang/String;"); + CHECK_NULL(account_name); account_use = (*env)->GetFieldID(env, clazz, "use", "I"); + CHECK_NULL(account_use); clazz = (*env)->FindClass(env, "sun/nio/fs/WindowsNativeDispatcher$AclInformation"); - if (clazz == NULL) { - return; - } + CHECK_NULL(clazz); aclInfo_aceCount = (*env)->GetFieldID(env, clazz, "aceCount", "I"); + CHECK_NULL(aclInfo_aceCount); clazz = (*env)->FindClass(env, "sun/nio/fs/WindowsNativeDispatcher$CompletionStatus"); - if (clazz == NULL) { - return; - } + CHECK_NULL(clazz); completionStatus_error = (*env)->GetFieldID(env, clazz, "error", "I"); + CHECK_NULL(completionStatus_error); completionStatus_bytesTransferred = (*env)->GetFieldID(env, clazz, "bytesTransferred", "I"); + CHECK_NULL(completionStatus_bytesTransferred); completionStatus_completionKey = (*env)->GetFieldID(env, clazz, "completionKey", "J"); + CHECK_NULL(completionStatus_completionKey); clazz = (*env)->FindClass(env, "sun/nio/fs/WindowsNativeDispatcher$BackupResult"); - if (clazz == NULL) { - return; - } + CHECK_NULL(clazz); backupResult_bytesTransferred = (*env)->GetFieldID(env, clazz, "bytesTransferred", "I"); + CHECK_NULL(backupResult_bytesTransferred); backupResult_context = (*env)->GetFieldID(env, clazz, "context", "J"); + CHECK_NULL(backupResult_context); // get handle to kernel32 if (GetModuleHandleExW((GET_MODULE_HANDLE_EX_FLAG_FROM_ADDRESS | From 0abb2b14edd9f7b4de461efa47fe31b4cbfb92c1 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Mon, 3 Feb 2014 14:18:45 +0000 Subject: [PATCH 090/159] 8030795: java/nio/file/Files/probeContentType/ForceLoad.java failing with ServiceConfigurationError without jtreg -agentvm option Reviewed-by: michaelm --- jdk/test/java/nio/file/Files/probeContentType/ForceLoad.java | 2 ++ 1 file changed, 2 insertions(+) diff --git a/jdk/test/java/nio/file/Files/probeContentType/ForceLoad.java b/jdk/test/java/nio/file/Files/probeContentType/ForceLoad.java index 5bb19ddaaa0..4a4edb26eb8 100644 --- a/jdk/test/java/nio/file/Files/probeContentType/ForceLoad.java +++ b/jdk/test/java/nio/file/Files/probeContentType/ForceLoad.java @@ -25,6 +25,8 @@ * @bug 4313887 * @summary Test library dependencies by invoking Files.probeContentType * before other methods that would cause nio.dll to be loaded. + * @build ForceLoad SimpleFileTypeDetector + * @run main/othervm ForceLoad */ import java.nio.file.*; From b2af3087a436f146c58752433a7ba2170c79d515 Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Mon, 3 Feb 2014 14:40:28 +0000 Subject: [PATCH 091/159] 8033425: Delay loading of net library in PortConfig initialization (workaround for for 8033367) Reviewed-by: alanb, chegar --- .../share/classes/java/net/SocketPermission.java | 15 ++++++++------- 1 file changed, 8 insertions(+), 7 deletions(-) diff --git a/jdk/src/share/classes/java/net/SocketPermission.java b/jdk/src/share/classes/java/net/SocketPermission.java index 70b004af3bc..0f720c52283 100644 --- a/jdk/src/share/classes/java/net/SocketPermission.java +++ b/jdk/src/share/classes/java/net/SocketPermission.java @@ -235,13 +235,11 @@ public final class SocketPermission extends Permission private static Debug debug = null; private static boolean debugInit = false; - // ephemeral port range for this system - private static final int ephemeralLow = initEphemeralPorts( - "low", DEF_EPH_LOW - ); - private static final int ephemeralHigh = initEphemeralPorts( - "high", PORT_MAX - ); + // lazy initializer + private static class EphemeralRange { + static final int low = initEphemeralPorts("low", DEF_EPH_LOW); + static final int high = initEphemeralPorts("high", PORT_MAX); + }; static { Boolean tmp = java.security.AccessController.doPrivileged( @@ -1235,6 +1233,9 @@ public final class SocketPermission extends Permission int policyLow, int policyHigh, int targetLow, int targetHigh ) { + final int ephemeralLow = EphemeralRange.low; + final int ephemeralHigh = EphemeralRange.high; + if (targetLow == 0) { // check policy includes ephemeral range if (!inRange(policyLow, policyHigh, ephemeralLow, ephemeralHigh)) { From 1c571143473e30c79d62cec3959916a3eae0bd2d Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 3 Feb 2014 09:52:36 -0800 Subject: [PATCH 092/159] 8033416: Remove sun.misc.FpUtils Reviewed-by: alanb, bpb, psandoz --- jdk/src/share/classes/java/lang/Double.java | 3 +- .../share/classes/sun/misc/DoubleConsts.java | 6 +- .../share/classes/sun/misc/FloatConsts.java | 5 +- jdk/src/share/classes/sun/misc/FpUtils.java | 931 ------------------ jdk/test/java/lang/Math/HypotTests.java | 5 +- .../java/lang/Math/IeeeRecommendedTests.java | 40 +- jdk/test/java/lang/Math/Log1pTests.java | 5 +- jdk/test/java/lang/Math/Tests.java | 177 +++- 8 files changed, 203 insertions(+), 969 deletions(-) delete mode 100644 jdk/src/share/classes/sun/misc/FpUtils.java diff --git a/jdk/src/share/classes/java/lang/Double.java b/jdk/src/share/classes/java/lang/Double.java index 9ba150e7156..d76c934bc62 100644 --- a/jdk/src/share/classes/java/lang/Double.java +++ b/jdk/src/share/classes/java/lang/Double.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1994, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1994, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -26,7 +26,6 @@ package java.lang; import sun.misc.FloatingDecimal; -import sun.misc.FpUtils; import sun.misc.DoubleConsts; /** diff --git a/jdk/src/share/classes/sun/misc/DoubleConsts.java b/jdk/src/share/classes/sun/misc/DoubleConsts.java index 2c5964b7885..6ee80490102 100644 --- a/jdk/src/share/classes/sun/misc/DoubleConsts.java +++ b/jdk/src/share/classes/sun/misc/DoubleConsts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -77,9 +77,7 @@ public class DoubleConsts { /** * The exponent the smallest positive double - * subnormal value would have if it could be normalized. It is - * equal to the value returned by - * FpUtils.ilogb(Double.MIN_VALUE). + * subnormal value would have if it could be normalized.. */ public static final int MIN_SUB_EXPONENT = MIN_EXPONENT - (SIGNIFICAND_WIDTH - 1); diff --git a/jdk/src/share/classes/sun/misc/FloatConsts.java b/jdk/src/share/classes/sun/misc/FloatConsts.java index 4345c19fcf3..07396f8bca9 100644 --- a/jdk/src/share/classes/sun/misc/FloatConsts.java +++ b/jdk/src/share/classes/sun/misc/FloatConsts.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -73,8 +73,7 @@ public class FloatConsts { /** * The exponent the smallest positive float subnormal - * value would have if it could be normalized. It is equal to the - * value returned by FpUtils.ilogb(Float.MIN_VALUE). + * value would have if it could be normalized. */ public static final int MIN_SUB_EXPONENT = MIN_EXPONENT - (SIGNIFICAND_WIDTH - 1); diff --git a/jdk/src/share/classes/sun/misc/FpUtils.java b/jdk/src/share/classes/sun/misc/FpUtils.java deleted file mode 100644 index a874c80f628..00000000000 --- a/jdk/src/share/classes/sun/misc/FpUtils.java +++ /dev/null @@ -1,931 +0,0 @@ -/* - * 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 - * under the terms of the GNU General Public License version 2 only, as - * published by the Free Software Foundation. Oracle designates this - * particular file as subject to the "Classpath" exception as provided - * by Oracle in the LICENSE file that accompanied this code. - * - * This code is distributed in the hope that it will be useful, but WITHOUT - * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or - * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License - * version 2 for more details (a copy is included in the LICENSE file that - * accompanied this code). - * - * You should have received a copy of the GNU General Public License version - * 2 along with this work; if not, write to the Free Software Foundation, - * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. - * - * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA - * or visit www.oracle.com if you need additional information or have any - * questions. - */ - -package sun.misc; - -import sun.misc.FloatConsts; -import sun.misc.DoubleConsts; - -/** - * The class {@code FpUtils} contains static utility methods for - * manipulating and inspecting {@code float} and - * {@code double} floating-point numbers. These methods include - * functionality recommended or required by the IEEE 754 - * floating-point standard. - * - * @author Joseph D. Darcy - */ - -public class FpUtils { - /* - * The methods in this class are reasonably implemented using - * direct or indirect bit-level manipulation of floating-point - * values. However, having access to the IEEE 754 recommended - * functions would obviate the need for most programmers to engage - * in floating-point bit-twiddling. - * - * An IEEE 754 number has three fields, from most significant bit - * to to least significant, sign, exponent, and significand. - * - * msb lsb - * [sign|exponent| fractional_significand] - * - * Using some encoding cleverness, explained below, the high order - * bit of the logical significand does not need to be explicitly - * stored, thus "fractional_significand" instead of simply - * "significand" in the figure above. - * - * For finite normal numbers, the numerical value encoded is - * - * (-1)^sign * 2^(exponent)*(1.fractional_significand) - * - * Most finite floating-point numbers are normalized; the exponent - * value is reduced until the leading significand bit is 1. - * Therefore, the leading 1 is redundant and is not explicitly - * stored. If a numerical value is so small it cannot be - * normalized, it has a subnormal representation. Subnormal - * numbers don't have a leading 1 in their significand; subnormals - * are encoding using a special exponent value. In other words, - * the high-order bit of the logical significand can be elided in - * from the representation in either case since the bit's value is - * implicit from the exponent value. - * - * The exponent field uses a biased representation; if the bits of - * the exponent are interpreted as a unsigned integer E, the - * exponent represented is E - E_bias where E_bias depends on the - * floating-point format. E can range between E_min and E_max, - * constants which depend on the floating-point format. E_min and - * E_max are -126 and +127 for float, -1022 and +1023 for double. - * - * The 32-bit float format has 1 sign bit, 8 exponent bits, and 23 - * bits for the significand (which is logically 24 bits wide - * because of the implicit bit). The 64-bit double format has 1 - * sign bit, 11 exponent bits, and 52 bits for the significand - * (logically 53 bits). - * - * Subnormal numbers and zero have the special exponent value - * E_min -1; the numerical value represented by a subnormal is: - * - * (-1)^sign * 2^(E_min)*(0.fractional_significand) - * - * Zero is represented by all zero bits in the exponent and all - * zero bits in the significand; zero can have either sign. - * - * Infinity and NaN are encoded using the exponent value E_max + - * 1. Signed infinities have all significand bits zero; NaNs have - * at least one non-zero significand bit. - * - * The details of IEEE 754 floating-point encoding will be used in - * the methods below without further comment. For further - * exposition on IEEE 754 numbers, see "IEEE Standard for Binary - * Floating-Point Arithmetic" ANSI/IEEE Std 754-1985 or William - * Kahan's "Lecture Notes on the Status of IEEE Standard 754 for - * Binary Floating-Point Arithmetic", - * http://www.cs.berkeley.edu/~wkahan/ieee754status/ieee754.ps. - * - * Many of this class's methods are members of the set of IEEE 754 - * recommended functions or similar functions recommended or - * required by IEEE 754R. Discussion of various implementation - * techniques for these functions have occurred in: - * - * W.J. Cody and Jerome T. Coonen, "Algorithm 772 Functions to - * Support the IEEE Standard for Binary Floating-Point - * Arithmetic," ACM Transactions on Mathematical Software, - * vol. 19, no. 4, December 1993, pp. 443-451. - * - * Joseph D. Darcy, "Writing robust IEEE recommended functions in - * ``100% Pure Java''(TM)," University of California, Berkeley - * technical report UCB//CSD-98-1009. - */ - - /** - * Don't let anyone instantiate this class. - */ - private FpUtils() {} - - // Helper Methods - - // The following helper methods are used in the implementation of - // the public recommended functions; they generally omit certain - // tests for exception cases. - - /** - * Returns unbiased exponent of a {@code double}. - * @deprecated Use Math.getExponent. - */ - @Deprecated - public static int getExponent(double d){ - return Math.getExponent(d); - } - - /** - * Returns unbiased exponent of a {@code float}. - * @deprecated Use Math.getExponent. - */ - @Deprecated - public static int getExponent(float f){ - return Math.getExponent(f); - } - - - /** - * Returns the first floating-point argument with the sign of the - * second floating-point argument. Note that unlike the {@link - * FpUtils#copySign(double, double) copySign} method, this method - * does not require NaN {@code sign} arguments to be treated - * as positive values; implementations are permitted to treat some - * NaN arguments as positive and other NaN arguments as negative - * to allow greater performance. - * - * @param magnitude the parameter providing the magnitude of the result - * @param sign the parameter providing the sign of the result - * @return a value with the magnitude of {@code magnitude} - * and the sign of {@code sign}. - * @author Joseph D. Darcy - * @deprecated Use Math.copySign. - */ - @Deprecated - public static double rawCopySign(double magnitude, double sign) { - return Math.copySign(magnitude, sign); - } - - /** - * Returns the first floating-point argument with the sign of the - * second floating-point argument. Note that unlike the {@link - * FpUtils#copySign(float, float) copySign} method, this method - * does not require NaN {@code sign} arguments to be treated - * as positive values; implementations are permitted to treat some - * NaN arguments as positive and other NaN arguments as negative - * to allow greater performance. - * - * @param magnitude the parameter providing the magnitude of the result - * @param sign the parameter providing the sign of the result - * @return a value with the magnitude of {@code magnitude} - * and the sign of {@code sign}. - * @author Joseph D. Darcy - * @deprecated Use Math.copySign. - */ - @Deprecated - public static float rawCopySign(float magnitude, float sign) { - return Math.copySign(magnitude, sign); - } - - /* ***************************************************************** */ - - /** - * Returns {@code true} if the argument is a finite - * floating-point value; returns {@code false} otherwise (for - * NaN and infinity arguments). - * - * @param d the {@code double} value to be tested - * @return {@code true} if the argument is a finite - * floating-point value, {@code false} otherwise. - * @deprecated Use Double.isFinite. - */ - @Deprecated - public static boolean isFinite(double d) { - return Double.isFinite(d); - } - - /** - * Returns {@code true} if the argument is a finite - * floating-point value; returns {@code false} otherwise (for - * NaN and infinity arguments). - * - * @param f the {@code float} value to be tested - * @return {@code true} if the argument is a finite - * floating-point value, {@code false} otherwise. - * @deprecated Use Float.isFinite. - */ - @Deprecated - public static boolean isFinite(float f) { - return Float.isFinite(f); - } - - /** - * Returns {@code true} if the specified number is infinitely - * large in magnitude, {@code false} otherwise. - * - *

      Note that this method is equivalent to the {@link - * Double#isInfinite(double) Double.isInfinite} method; the - * functionality is included in this class for convenience. - * - * @param d the value to be tested. - * @return {@code true} if the value of the argument is positive - * infinity or negative infinity; {@code false} otherwise. - */ - public static boolean isInfinite(double d) { - return Double.isInfinite(d); - } - - /** - * Returns {@code true} if the specified number is infinitely - * large in magnitude, {@code false} otherwise. - * - *

      Note that this method is equivalent to the {@link - * Float#isInfinite(float) Float.isInfinite} method; the - * functionality is included in this class for convenience. - * - * @param f the value to be tested. - * @return {@code true} if the argument is positive infinity or - * negative infinity; {@code false} otherwise. - */ - public static boolean isInfinite(float f) { - return Float.isInfinite(f); - } - - /** - * Returns {@code true} if the specified number is a - * Not-a-Number (NaN) value, {@code false} otherwise. - * - *

      Note that this method is equivalent to the {@link - * Double#isNaN(double) Double.isNaN} method; the functionality is - * included in this class for convenience. - * - * @param d the value to be tested. - * @return {@code true} if the value of the argument is NaN; - * {@code false} otherwise. - */ - public static boolean isNaN(double d) { - return Double.isNaN(d); - } - - /** - * Returns {@code true} if the specified number is a - * Not-a-Number (NaN) value, {@code false} otherwise. - * - *

      Note that this method is equivalent to the {@link - * Float#isNaN(float) Float.isNaN} method; the functionality is - * included in this class for convenience. - * - * @param f the value to be tested. - * @return {@code true} if the argument is NaN; - * {@code false} otherwise. - */ - public static boolean isNaN(float f) { - return Float.isNaN(f); - } - - /** - * Returns {@code true} if the unordered relation holds - * between the two arguments. When two floating-point values are - * unordered, one value is neither less than, equal to, nor - * greater than the other. For the unordered relation to be true, - * at least one argument must be a {@code NaN}. - * - * @param arg1 the first argument - * @param arg2 the second argument - * @return {@code true} if at least one argument is a NaN, - * {@code false} otherwise. - */ - public static boolean isUnordered(double arg1, double arg2) { - return isNaN(arg1) || isNaN(arg2); - } - - /** - * Returns {@code true} if the unordered relation holds - * between the two arguments. When two floating-point values are - * unordered, one value is neither less than, equal to, nor - * greater than the other. For the unordered relation to be true, - * at least one argument must be a {@code NaN}. - * - * @param arg1 the first argument - * @param arg2 the second argument - * @return {@code true} if at least one argument is a NaN, - * {@code false} otherwise. - */ - public static boolean isUnordered(float arg1, float arg2) { - return isNaN(arg1) || isNaN(arg2); - } - - /** - * Returns unbiased exponent of a {@code double}; for - * subnormal values, the number is treated as if it were - * normalized. That is for all finite, non-zero, positive numbers - * x, scalb(x, -ilogb(x)) is - * always in the range [1, 2). - *

      - * Special cases: - *

        - *
      • If the argument is NaN, then the result is 230. - *
      • If the argument is infinite, then the result is 228. - *
      • If the argument is zero, then the result is -(228). - *
      - * - * @param d floating-point number whose exponent is to be extracted - * @return unbiased exponent of the argument. - * @author Joseph D. Darcy - */ - public static int ilogb(double d) { - int exponent = getExponent(d); - - switch (exponent) { - case DoubleConsts.MAX_EXPONENT+1: // NaN or infinity - if( isNaN(d) ) - return (1<<30); // 2^30 - else // infinite value - return (1<<28); // 2^28 - - case DoubleConsts.MIN_EXPONENT-1: // zero or subnormal - if(d == 0.0) { - return -(1<<28); // -(2^28) - } - else { - long transducer = Double.doubleToRawLongBits(d); - - /* - * To avoid causing slow arithmetic on subnormals, - * the scaling to determine when d's significand - * is normalized is done in integer arithmetic. - * (there must be at least one "1" bit in the - * significand since zero has been screened out. - */ - - // isolate significand bits - transducer &= DoubleConsts.SIGNIF_BIT_MASK; - assert(transducer != 0L); - - // This loop is simple and functional. We might be - // able to do something more clever that was faster; - // e.g. number of leading zero detection on - // (transducer << (# exponent and sign bits). - while (transducer < - (1L << (DoubleConsts.SIGNIFICAND_WIDTH - 1))) { - transducer *= 2; - exponent--; - } - exponent++; - assert( exponent >= - DoubleConsts.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH-1) && - exponent < DoubleConsts.MIN_EXPONENT); - return exponent; - } - - default: - assert( exponent >= DoubleConsts.MIN_EXPONENT && - exponent <= DoubleConsts.MAX_EXPONENT); - return exponent; - } - } - - /** - * Returns unbiased exponent of a {@code float}; for - * subnormal values, the number is treated as if it were - * normalized. That is for all finite, non-zero, positive numbers - * x, scalb(x, -ilogb(x)) is - * always in the range [1, 2). - *

      - * Special cases: - *

        - *
      • If the argument is NaN, then the result is 230. - *
      • If the argument is infinite, then the result is 228. - *
      • If the argument is zero, then the result is -(228). - *
      - * - * @param f floating-point number whose exponent is to be extracted - * @return unbiased exponent of the argument. - * @author Joseph D. Darcy - */ - public static int ilogb(float f) { - int exponent = getExponent(f); - - switch (exponent) { - case FloatConsts.MAX_EXPONENT+1: // NaN or infinity - if( isNaN(f) ) - return (1<<30); // 2^30 - else // infinite value - return (1<<28); // 2^28 - - case FloatConsts.MIN_EXPONENT-1: // zero or subnormal - if(f == 0.0f) { - return -(1<<28); // -(2^28) - } - else { - int transducer = Float.floatToRawIntBits(f); - - /* - * To avoid causing slow arithmetic on subnormals, - * the scaling to determine when f's significand - * is normalized is done in integer arithmetic. - * (there must be at least one "1" bit in the - * significand since zero has been screened out. - */ - - // isolate significand bits - transducer &= FloatConsts.SIGNIF_BIT_MASK; - assert(transducer != 0); - - // This loop is simple and functional. We might be - // able to do something more clever that was faster; - // e.g. number of leading zero detection on - // (transducer << (# exponent and sign bits). - while (transducer < - (1 << (FloatConsts.SIGNIFICAND_WIDTH - 1))) { - transducer *= 2; - exponent--; - } - exponent++; - assert( exponent >= - FloatConsts.MIN_EXPONENT - (FloatConsts.SIGNIFICAND_WIDTH-1) && - exponent < FloatConsts.MIN_EXPONENT); - return exponent; - } - - default: - assert( exponent >= FloatConsts.MIN_EXPONENT && - exponent <= FloatConsts.MAX_EXPONENT); - return exponent; - } - } - - - /* - * The scalb operation should be reasonably fast; however, there - * are tradeoffs in writing a method to minimize the worst case - * performance and writing a method to minimize the time for - * expected common inputs. Some processors operate very slowly on - * subnormal operands, taking hundreds or thousands of cycles for - * one floating-point add or multiply as opposed to, say, four - * cycles for normal operands. For processors with very slow - * subnormal execution, scalb would be fastest if written entirely - * with integer operations; in other words, scalb would need to - * include the logic of performing correct rounding of subnormal - * values. This could be reasonably done in at most a few hundred - * cycles. However, this approach may penalize normal operations - * since at least the exponent of the floating-point argument must - * be examined. - * - * The approach taken in this implementation is a compromise. - * Floating-point multiplication is used to do most of the work; - * but knowingly multiplying by a subnormal scaling factor is - * avoided. However, the floating-point argument is not examined - * to see whether or not it is subnormal since subnormal inputs - * are assumed to be rare. At most three multiplies are needed to - * scale from the largest to smallest exponent ranges (scaling - * down, at most two multiplies are needed if subnormal scaling - * factors are allowed). However, in this implementation an - * expensive integer remainder operation is avoided at the cost of - * requiring five floating-point multiplies in the worst case, - * which should still be a performance win. - * - * If scaling of entire arrays is a concern, it would probably be - * more efficient to provide a double[] scalb(double[], int) - * version of scalb to avoid having to recompute the needed - * scaling factors for each floating-point value. - */ - - /** - * Return {@code d} × - * 2{@code scale_factor} rounded as if performed - * by a single correctly rounded floating-point multiply to a - * member of the double value set. See section 4.2.3 of - * The Java™ Language Specification - * for a discussion of floating-point - * value sets. If the exponent of the result is between the - * {@code double}'s minimum exponent and maximum exponent, - * the answer is calculated exactly. If the exponent of the - * result would be larger than {@code doubles}'s maximum - * exponent, an infinity is returned. Note that if the result is - * subnormal, precision may be lost; that is, when {@code scalb(x, - * n)} is subnormal, {@code scalb(scalb(x, n), -n)} may - * not equal x. When the result is non-NaN, the result has - * the same sign as {@code d}. - * - *

      - * Special cases: - *

        - *
      • If the first argument is NaN, NaN is returned. - *
      • If the first argument is infinite, then an infinity of the - * same sign is returned. - *
      • If the first argument is zero, then a zero of the same - * sign is returned. - *
      - * - * @param d number to be scaled by a power of two. - * @param scale_factor power of 2 used to scale {@code d} - * @return {@code d * }2{@code scale_factor} - * @author Joseph D. Darcy - * @deprecated Use Math.scalb. - */ - @Deprecated - public static double scalb(double d, int scale_factor) { - return Math.scalb(d, scale_factor); - } - - /** - * Return {@code f} × - * 2{@code scale_factor} rounded as if performed - * by a single correctly rounded floating-point multiply to a - * member of the float value set. See section 4.2.3 of - * The Java™ Language Specification - * for a discussion of floating-point - * value sets. If the exponent of the result is between the - * {@code float}'s minimum exponent and maximum exponent, the - * answer is calculated exactly. If the exponent of the result - * would be larger than {@code float}'s maximum exponent, an - * infinity is returned. Note that if the result is subnormal, - * precision may be lost; that is, when {@code scalb(x, n)} - * is subnormal, {@code scalb(scalb(x, n), -n)} may not equal - * x. When the result is non-NaN, the result has the same - * sign as {@code f}. - * - *

      - * Special cases: - *

        - *
      • If the first argument is NaN, NaN is returned. - *
      • If the first argument is infinite, then an infinity of the - * same sign is returned. - *
      • If the first argument is zero, then a zero of the same - * sign is returned. - *
      - * - * @param f number to be scaled by a power of two. - * @param scale_factor power of 2 used to scale {@code f} - * @return {@code f * }2{@code scale_factor} - * @author Joseph D. Darcy - * @deprecated Use Math.scalb. - */ - @Deprecated - public static float scalb(float f, int scale_factor) { - return Math.scalb(f, scale_factor); - } - - /** - * Returns the floating-point number adjacent to the first - * argument in the direction of the second argument. If both - * arguments compare as equal the second argument is returned. - * - *

      - * Special cases: - *

        - *
      • If either argument is a NaN, then NaN is returned. - * - *
      • If both arguments are signed zeros, {@code direction} - * is returned unchanged (as implied by the requirement of - * returning the second argument if the arguments compare as - * equal). - * - *
      • If {@code start} is - * ±{@code Double.MIN_VALUE} and {@code direction} - * has a value such that the result should have a smaller - * magnitude, then a zero with the same sign as {@code start} - * is returned. - * - *
      • If {@code start} is infinite and - * {@code direction} has a value such that the result should - * have a smaller magnitude, {@code Double.MAX_VALUE} with the - * same sign as {@code start} is returned. - * - *
      • If {@code start} is equal to ± - * {@code Double.MAX_VALUE} and {@code direction} has a - * value such that the result should have a larger magnitude, an - * infinity with same sign as {@code start} is returned. - *
      - * - * @param start starting floating-point value - * @param direction value indicating which of - * {@code start}'s neighbors or {@code start} should - * be returned - * @return The floating-point number adjacent to {@code start} in the - * direction of {@code direction}. - * @author Joseph D. Darcy - * @deprecated Use Math.nextAfter - */ - @Deprecated - public static double nextAfter(double start, double direction) { - return Math.nextAfter(start, direction); - } - - /** - * Returns the floating-point number adjacent to the first - * argument in the direction of the second argument. If both - * arguments compare as equal, the second argument is returned. - * - *

      - * Special cases: - *

        - *
      • If either argument is a NaN, then NaN is returned. - * - *
      • If both arguments are signed zeros, a {@code float} - * zero with the same sign as {@code direction} is returned - * (as implied by the requirement of returning the second argument - * if the arguments compare as equal). - * - *
      • If {@code start} is - * ±{@code Float.MIN_VALUE} and {@code direction} - * has a value such that the result should have a smaller - * magnitude, then a zero with the same sign as {@code start} - * is returned. - * - *
      • If {@code start} is infinite and - * {@code direction} has a value such that the result should - * have a smaller magnitude, {@code Float.MAX_VALUE} with the - * same sign as {@code start} is returned. - * - *
      • If {@code start} is equal to ± - * {@code Float.MAX_VALUE} and {@code direction} has a - * value such that the result should have a larger magnitude, an - * infinity with same sign as {@code start} is returned. - *
      - * - * @param start starting floating-point value - * @param direction value indicating which of - * {@code start}'s neighbors or {@code start} should - * be returned - * @return The floating-point number adjacent to {@code start} in the - * direction of {@code direction}. - * @author Joseph D. Darcy - * @deprecated Use Math.nextAfter. - */ - @Deprecated - public static float nextAfter(float start, double direction) { - return Math.nextAfter(start, direction); - } - - /** - * Returns the floating-point value adjacent to {@code d} in - * the direction of positive infinity. This method is - * semantically equivalent to {@code nextAfter(d, - * Double.POSITIVE_INFINITY)}; however, a {@code nextUp} - * implementation may run faster than its equivalent - * {@code nextAfter} call. - * - *

      Special Cases: - *

        - *
      • If the argument is NaN, the result is NaN. - * - *
      • If the argument is positive infinity, the result is - * positive infinity. - * - *
      • If the argument is zero, the result is - * {@code Double.MIN_VALUE} - * - *
      - * - * @param d starting floating-point value - * @return The adjacent floating-point value closer to positive - * infinity. - * @author Joseph D. Darcy - * @deprecated use Math.nextUp. - */ - @Deprecated - public static double nextUp(double d) { - return Math.nextUp(d); - } - - /** - * Returns the floating-point value adjacent to {@code f} in - * the direction of positive infinity. This method is - * semantically equivalent to {@code nextAfter(f, - * Double.POSITIVE_INFINITY)}; however, a {@code nextUp} - * implementation may run faster than its equivalent - * {@code nextAfter} call. - * - *

      Special Cases: - *

        - *
      • If the argument is NaN, the result is NaN. - * - *
      • If the argument is positive infinity, the result is - * positive infinity. - * - *
      • If the argument is zero, the result is - * {@code Float.MIN_VALUE} - * - *
      - * - * @param f starting floating-point value - * @return The adjacent floating-point value closer to positive - * infinity. - * @author Joseph D. Darcy - * @deprecated Use Math.nextUp. - */ - @Deprecated - public static float nextUp(float f) { - return Math.nextUp(f); - } - - /** - * Returns the floating-point value adjacent to {@code d} in - * the direction of negative infinity. This method is - * semantically equivalent to {@code nextAfter(d, - * Double.NEGATIVE_INFINITY)}; however, a - * {@code nextDown} implementation may run faster than its - * equivalent {@code nextAfter} call. - * - *

      Special Cases: - *

        - *
      • If the argument is NaN, the result is NaN. - * - *
      • If the argument is negative infinity, the result is - * negative infinity. - * - *
      • If the argument is zero, the result is - * {@code -Double.MIN_VALUE} - * - *
      - * - * @param d starting floating-point value - * @return The adjacent floating-point value closer to negative - * infinity. - * @author Joseph D. Darcy - * @deprecated Use Math.nextDown. - */ - @Deprecated - public static double nextDown(double d) { - return Math.nextDown(d); - } - - /** - * Returns the floating-point value adjacent to {@code f} in - * the direction of negative infinity. This method is - * semantically equivalent to {@code nextAfter(f, - * Float.NEGATIVE_INFINITY)}; however, a - * {@code nextDown} implementation may run faster than its - * equivalent {@code nextAfter} call. - * - *

      Special Cases: - *

        - *
      • If the argument is NaN, the result is NaN. - * - *
      • If the argument is negative infinity, the result is - * negative infinity. - * - *
      • If the argument is zero, the result is - * {@code -Float.MIN_VALUE} - * - *
      - * - * @param f starting floating-point value - * @return The adjacent floating-point value closer to negative - * infinity. - * @author Joseph D. Darcy - * @deprecated Use Math.nextDown. - */ - @Deprecated - public static double nextDown(float f) { - return Math.nextDown(f); - } - - /** - * Returns the first floating-point argument with the sign of the - * second floating-point argument. For this method, a NaN - * {@code sign} argument is always treated as if it were - * positive. - * - * @param magnitude the parameter providing the magnitude of the result - * @param sign the parameter providing the sign of the result - * @return a value with the magnitude of {@code magnitude} - * and the sign of {@code sign}. - * @author Joseph D. Darcy - * @since 1.5 - * @deprecated Use StrictMath.copySign. - */ - @Deprecated - public static double copySign(double magnitude, double sign) { - return StrictMath.copySign(magnitude, sign); - } - - /** - * Returns the first floating-point argument with the sign of the - * second floating-point argument. For this method, a NaN - * {@code sign} argument is always treated as if it were - * positive. - * - * @param magnitude the parameter providing the magnitude of the result - * @param sign the parameter providing the sign of the result - * @return a value with the magnitude of {@code magnitude} - * and the sign of {@code sign}. - * @author Joseph D. Darcy - * @deprecated Use StrictMath.copySign. - */ - @Deprecated - public static float copySign(float magnitude, float sign) { - return StrictMath.copySign(magnitude, sign); - } - - /** - * Returns the size of an ulp of the argument. An ulp of a - * {@code double} value is the positive distance between this - * floating-point value and the {@code double} value next - * larger in magnitude. Note that for non-NaN x, - * ulp(-x) == ulp(x). - * - *

      Special Cases: - *

        - *
      • If the argument is NaN, then the result is NaN. - *
      • If the argument is positive or negative infinity, then the - * result is positive infinity. - *
      • If the argument is positive or negative zero, then the result is - * {@code Double.MIN_VALUE}. - *
      • If the argument is ±{@code Double.MAX_VALUE}, then - * the result is equal to 2971. - *
      - * - * @param d the floating-point value whose ulp is to be returned - * @return the size of an ulp of the argument - * @author Joseph D. Darcy - * @since 1.5 - * @deprecated Use Math.ulp. - */ - @Deprecated - public static double ulp(double d) { - return Math.ulp(d); - } - - /** - * Returns the size of an ulp of the argument. An ulp of a - * {@code float} value is the positive distance between this - * floating-point value and the {@code float} value next - * larger in magnitude. Note that for non-NaN x, - * ulp(-x) == ulp(x). - * - *

      Special Cases: - *

        - *
      • If the argument is NaN, then the result is NaN. - *
      • If the argument is positive or negative infinity, then the - * result is positive infinity. - *
      • If the argument is positive or negative zero, then the result is - * {@code Float.MIN_VALUE}. - *
      • If the argument is ±{@code Float.MAX_VALUE}, then - * the result is equal to 2104. - *
      - * - * @param f the floating-point value whose ulp is to be returned - * @return the size of an ulp of the argument - * @author Joseph D. Darcy - * @since 1.5 - * @deprecated Use Math.ulp. - */ - @Deprecated - public static float ulp(float f) { - return Math.ulp(f); - } - - /** - * Returns the signum function of the argument; zero if the argument - * is zero, 1.0 if the argument is greater than zero, -1.0 if the - * argument is less than zero. - * - *

      Special Cases: - *

        - *
      • If the argument is NaN, then the result is NaN. - *
      • If the argument is positive zero or negative zero, then the - * result is the same as the argument. - *
      - * - * @param d the floating-point value whose signum is to be returned - * @return the signum function of the argument - * @author Joseph D. Darcy - * @since 1.5 - * @deprecated Use Math.signum. - */ - @Deprecated - public static double signum(double d) { - return Math.signum(d); - } - - /** - * Returns the signum function of the argument; zero if the argument - * is zero, 1.0f if the argument is greater than zero, -1.0f if the - * argument is less than zero. - * - *

      Special Cases: - *

        - *
      • If the argument is NaN, then the result is NaN. - *
      • If the argument is positive zero or negative zero, then the - * result is the same as the argument. - *
      - * - * @param f the floating-point value whose signum is to be returned - * @return the signum function of the argument - * @author Joseph D. Darcy - * @since 1.5 - * @deprecated Use Math.signum. - */ - @Deprecated - public static float signum(float f) { - return Math.signum(f); - } -} diff --git a/jdk/test/java/lang/Math/HypotTests.java b/jdk/test/java/lang/Math/HypotTests.java index d48a6f938a0..9582c83daf8 100644 --- a/jdk/test/java/lang/Math/HypotTests.java +++ b/jdk/test/java/lang/Math/HypotTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ */ import sun.misc.DoubleConsts; -import sun.misc.FpUtils; public class HypotTests { private HypotTests(){} @@ -127,7 +126,7 @@ public class HypotTests { double d = rand.nextDouble(); // Scale d to have an exponent equal to MAX_EXPONENT -15 d = Math.scalb(d, DoubleConsts.MAX_EXPONENT - -15 - FpUtils.ilogb(d)); + -15 - Tests.ilogb(d)); for(int j = 0; j <= 13; j += 1) { failures += testHypotCase(3*d, 4*d, 5*d, 2.5); d *= 2.0; // increase exponent by 1 diff --git a/jdk/test/java/lang/Math/IeeeRecommendedTests.java b/jdk/test/java/lang/Math/IeeeRecommendedTests.java index f776bbf5b1c..ce4c6595b4b 100644 --- a/jdk/test/java/lang/Math/IeeeRecommendedTests.java +++ b/jdk/test/java/lang/Math/IeeeRecommendedTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,7 +28,6 @@ * @author Joseph D. Darcy */ -import sun.misc.FpUtils; import sun.misc.DoubleConsts; import sun.misc.FloatConsts; @@ -708,21 +707,21 @@ public class IeeeRecommendedTests { for(int i = 0; i < testCases.length; i++) { // isNaN - failures+=Tests.test("FpUtils.isNaN(float)", testCases[i], - FpUtils.isNaN(testCases[i]), (i ==0)); + failures+=Tests.test("Float.isNaN(float)", testCases[i], + Float.isNaN(testCases[i]), (i ==0)); // isFinite failures+=Tests.test("Float.isFinite(float)", testCases[i], Float.isFinite(testCases[i]), (i >= 3)); // isInfinite - failures+=Tests.test("FpUtils.isInfinite(float)", testCases[i], - FpUtils.isInfinite(testCases[i]), (i==1 || i==2)); + failures+=Tests.test("Float.isInfinite(float)", testCases[i], + Float.isInfinite(testCases[i]), (i==1 || i==2)); // isUnorderd for(int j = 0; j < testCases.length; j++) { - failures+=Tests.test("FpUtils.isUnordered(float, float)", testCases[i],testCases[j], - FpUtils.isUnordered(testCases[i],testCases[j]), (i==0 || j==0)); + failures+=Tests.test("Tests.isUnordered(float, float)", testCases[i],testCases[j], + Tests.isUnordered(testCases[i],testCases[j]), (i==0 || j==0)); } } @@ -758,21 +757,21 @@ public class IeeeRecommendedTests { for(int i = 0; i < testCases.length; i++) { // isNaN - failures+=Tests.test("FpUtils.isNaN(double)", testCases[i], - FpUtils.isNaN(testCases[i]), (i ==0)); + failures+=Tests.test("Double.isNaN(double)", testCases[i], + Double.isNaN(testCases[i]), (i ==0)); // isFinite failures+=Tests.test("Double.isFinite(double)", testCases[i], Double.isFinite(testCases[i]), (i >= 3)); // isInfinite - failures+=Tests.test("FpUtils.isInfinite(double)", testCases[i], - FpUtils.isInfinite(testCases[i]), (i==1 || i==2)); + failures+=Tests.test("Double.isInfinite(double)", testCases[i], + Double.isInfinite(testCases[i]), (i==1 || i==2)); // isUnorderd for(int j = 0; j < testCases.length; j++) { - failures+=Tests.test("FpUtils.isUnordered(double, double)", testCases[i],testCases[j], - FpUtils.isUnordered(testCases[i],testCases[j]), (i==0 || j==0)); + failures+=Tests.test("Tests.isUnordered(double, double)", testCases[i],testCases[j], + Tests.isUnordered(testCases[i],testCases[j]), (i==0 || j==0)); } } @@ -1023,8 +1022,8 @@ public class IeeeRecommendedTests { 2*FloatConsts.MIN_EXPONENT, // -252 2*FloatConsts.MIN_EXPONENT+1, // -251 - FpUtils.ilogb(Float.MIN_VALUE)-1, // -150 - FpUtils.ilogb(Float.MIN_VALUE), // -149 + FloatConsts.MIN_EXPONENT - FloatConsts.SIGNIFICAND_WIDTH, + FloatConsts.MIN_SUB_EXPONENT, -FloatConsts.MAX_EXPONENT, // -127 FloatConsts.MIN_EXPONENT, // -126 @@ -1100,7 +1099,7 @@ public class IeeeRecommendedTests { failures+=testScalbCase(value, scaleFactor, - (FpUtils.ilogb(value) +j > FloatConsts.MAX_EXPONENT ) ? + (Tests.ilogb(value) +j > FloatConsts.MAX_EXPONENT ) ? Math.copySign(infinityF, value) : // overflow // calculate right answer twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) ); @@ -1230,8 +1229,9 @@ public class IeeeRecommendedTests { 2*DoubleConsts.MIN_EXPONENT, // -2044 2*DoubleConsts.MIN_EXPONENT+1, // -2043 - FpUtils.ilogb(Double.MIN_VALUE)-1, // -1076 - FpUtils.ilogb(Double.MIN_VALUE), // -1075 + DoubleConsts.MIN_EXPONENT, // -1022 + DoubleConsts.MIN_EXPONENT - DoubleConsts.SIGNIFICAND_WIDTH, + DoubleConsts.MIN_SUB_EXPONENT, -DoubleConsts.MAX_EXPONENT, // -1023 DoubleConsts.MIN_EXPONENT, // -1022 @@ -1307,7 +1307,7 @@ public class IeeeRecommendedTests { failures+=testScalbCase(value, scaleFactor, - (FpUtils.ilogb(value) +j > DoubleConsts.MAX_EXPONENT ) ? + (Tests.ilogb(value) +j > DoubleConsts.MAX_EXPONENT ) ? Math.copySign(infinityD, value) : // overflow // calculate right answer twoToTheMaxExp*(twoToTheMaxExp*(scale*value)) ); diff --git a/jdk/test/java/lang/Math/Log1pTests.java b/jdk/test/java/lang/Math/Log1pTests.java index 56a80047aa9..5fe373edc78 100644 --- a/jdk/test/java/lang/Math/Log1pTests.java +++ b/jdk/test/java/lang/Math/Log1pTests.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,7 +29,6 @@ */ import sun.misc.DoubleConsts; -import sun.misc.FpUtils; public class Log1pTests { private Log1pTests(){} @@ -105,7 +104,7 @@ public class Log1pTests { for(int i = 0; i < 1000; i++) { double d = rand.nextDouble(); - d = Math.scalb(d, -53 - FpUtils.ilogb(d)); + d = Math.scalb(d, -53 - Tests.ilogb(d)); for(int j = -53; j <= 52; j++) { failures += testLog1pCaseWithUlpDiff(d, hp15cLogp(d), 5); diff --git a/jdk/test/java/lang/Math/Tests.java b/jdk/test/java/lang/Math/Tests.java index 7dd6d68075f..c06c4ed79e3 100644 --- a/jdk/test/java/lang/Math/Tests.java +++ b/jdk/test/java/lang/Math/Tests.java @@ -30,7 +30,8 @@ * and finally the expected result. */ -import sun.misc.FpUtils; +import sun.misc.FloatConsts; +import sun.misc.DoubleConsts; public class Tests { private Tests(){}; // do not instantiate @@ -59,6 +60,176 @@ public class Tests { return -Math.nextUp(-d); } + /** + * Returns unbiased exponent of a {@code float}; for + * subnormal values, the number is treated as if it were + * normalized. That is for all finite, non-zero, positive numbers + * x, scalb(x, -ilogb(x)) is + * always in the range [1, 2). + *

      + * Special cases: + *

        + *
      • If the argument is NaN, then the result is 230. + *
      • If the argument is infinite, then the result is 228. + *
      • If the argument is zero, then the result is -(228). + *
      + * + * @param f floating-point number whose exponent is to be extracted + * @return unbiased exponent of the argument. + */ + public static int ilogb(double d) { + int exponent = Math.getExponent(d); + + switch (exponent) { + case DoubleConsts.MAX_EXPONENT+1: // NaN or infinity + if( Double.isNaN(d) ) + return (1<<30); // 2^30 + else // infinite value + return (1<<28); // 2^28 + + case DoubleConsts.MIN_EXPONENT-1: // zero or subnormal + if(d == 0.0) { + return -(1<<28); // -(2^28) + } + else { + long transducer = Double.doubleToRawLongBits(d); + + /* + * To avoid causing slow arithmetic on subnormals, + * the scaling to determine when d's significand + * is normalized is done in integer arithmetic. + * (there must be at least one "1" bit in the + * significand since zero has been screened out. + */ + + // isolate significand bits + transducer &= DoubleConsts.SIGNIF_BIT_MASK; + assert(transducer != 0L); + + // This loop is simple and functional. We might be + // able to do something more clever that was faster; + // e.g. number of leading zero detection on + // (transducer << (# exponent and sign bits). + while (transducer < + (1L << (DoubleConsts.SIGNIFICAND_WIDTH - 1))) { + transducer *= 2; + exponent--; + } + exponent++; + assert( exponent >= + DoubleConsts.MIN_EXPONENT - (DoubleConsts.SIGNIFICAND_WIDTH-1) && + exponent < DoubleConsts.MIN_EXPONENT); + return exponent; + } + + default: + assert( exponent >= DoubleConsts.MIN_EXPONENT && + exponent <= DoubleConsts.MAX_EXPONENT); + return exponent; + } + } + + /** + * Returns unbiased exponent of a {@code float}; for + * subnormal values, the number is treated as if it were + * normalized. That is for all finite, non-zero, positive numbers + * x, scalb(x, -ilogb(x)) is + * always in the range [1, 2). + *

      + * Special cases: + *

        + *
      • If the argument is NaN, then the result is 230. + *
      • If the argument is infinite, then the result is 228. + *
      • If the argument is zero, then the result is -(228). + *
      + * + * @param f floating-point number whose exponent is to be extracted + * @return unbiased exponent of the argument. + */ + public static int ilogb(float f) { + int exponent = Math.getExponent(f); + + switch (exponent) { + case FloatConsts.MAX_EXPONENT+1: // NaN or infinity + if( Float.isNaN(f) ) + return (1<<30); // 2^30 + else // infinite value + return (1<<28); // 2^28 + + case FloatConsts.MIN_EXPONENT-1: // zero or subnormal + if(f == 0.0f) { + return -(1<<28); // -(2^28) + } + else { + int transducer = Float.floatToRawIntBits(f); + + /* + * To avoid causing slow arithmetic on subnormals, + * the scaling to determine when f's significand + * is normalized is done in integer arithmetic. + * (there must be at least one "1" bit in the + * significand since zero has been screened out. + */ + + // isolate significand bits + transducer &= FloatConsts.SIGNIF_BIT_MASK; + assert(transducer != 0); + + // This loop is simple and functional. We might be + // able to do something more clever that was faster; + // e.g. number of leading zero detection on + // (transducer << (# exponent and sign bits). + while (transducer < + (1 << (FloatConsts.SIGNIFICAND_WIDTH - 1))) { + transducer *= 2; + exponent--; + } + exponent++; + assert( exponent >= + FloatConsts.MIN_EXPONENT - (FloatConsts.SIGNIFICAND_WIDTH-1) && + exponent < FloatConsts.MIN_EXPONENT); + return exponent; + } + + default: + assert( exponent >= FloatConsts.MIN_EXPONENT && + exponent <= FloatConsts.MAX_EXPONENT); + return exponent; + } + } + + /** + * Returns {@code true} if the unordered relation holds + * between the two arguments. When two floating-point values are + * unordered, one value is neither less than, equal to, nor + * greater than the other. For the unordered relation to be true, + * at least one argument must be a {@code NaN}. + * + * @param arg1 the first argument + * @param arg2 the second argument + * @return {@code true} if at least one argument is a NaN, + * {@code false} otherwise. + */ + public static boolean isUnordered(float arg1, float arg2) { + return Float.isNaN(arg1) || Float.isNaN(arg2); + } + + /** + * Returns {@code true} if the unordered relation holds + * between the two arguments. When two floating-point values are + * unordered, one value is neither less than, equal to, nor + * greater than the other. For the unordered relation to be true, + * at least one argument must be a {@code NaN}. + * + * @param arg1 the first argument + * @param arg2 the second argument + * @return {@code true} if at least one argument is a NaN, + * {@code false} otherwise. + */ + public static boolean isUnordered(double arg1, double arg2) { + return Double.isNaN(arg1) || Double.isNaN(arg2); + } + public static int test(String testName, float input, boolean result, boolean expected) { if (expected != result) { @@ -237,7 +408,7 @@ public class Tests { return 1; } else { double difference = expected - result; - if (FpUtils.isUnordered(expected, result) || + if (isUnordered(expected, result) || Double.isNaN(difference) || // fail if greater than or unordered !(Math.abs( difference/Math.ulp(expected) ) <= Math.abs(ulps)) ) { @@ -332,7 +503,7 @@ public class Tests { double result, double expected, double tolerance) { if (Double.compare(expected, result ) != 0) { double difference = expected - result; - if (FpUtils.isUnordered(expected, result) || + if (isUnordered(expected, result) || Double.isNaN(difference) || // fail if greater than or unordered !(Math.abs((difference)/expected) <= StrictMath.pow(10, -tolerance)) ) { From b0082203739bdb64715ac624242e0779c7f1c07a Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 3 Feb 2014 10:05:56 -0800 Subject: [PATCH 093/159] 8033181: Fix doclint missing issues in java.awt.{peer, im[.spi]} Reviewed-by: alanb --- jdk/src/share/classes/java/awt/im/InputContext.java | 3 ++- .../classes/java/awt/im/InputMethodHighlight.java | 5 ++++- .../classes/java/awt/im/spi/InputMethodContext.java | 10 +++++++++- .../classes/java/awt/im/spi/InputMethodDescriptor.java | 7 ++++++- jdk/src/share/classes/java/awt/peer/CanvasPeer.java | 4 +++- jdk/src/share/classes/java/awt/peer/ComponentPeer.java | 6 ++++-- jdk/src/share/classes/java/awt/peer/MouseInfoPeer.java | 9 ++++++++- jdk/src/share/classes/java/awt/peer/WindowPeer.java | 7 ++++--- 8 files changed, 40 insertions(+), 11 deletions(-) diff --git a/jdk/src/share/classes/java/awt/im/InputContext.java b/jdk/src/share/classes/java/awt/im/InputContext.java index 615029120dd..9d6122d2781 100644 --- a/jdk/src/share/classes/java/awt/im/InputContext.java +++ b/jdk/src/share/classes/java/awt/im/InputContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -87,6 +87,7 @@ public class InputContext { /** * Returns a new InputContext instance. + * @return a new InputContext instance */ public static InputContext getInstance() { return new sun.awt.im.InputMethodContext(); diff --git a/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java b/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java index 55905d97708..df09076410d 100644 --- a/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java +++ b/jdk/src/share/classes/java/awt/im/InputMethodHighlight.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -157,6 +157,7 @@ public class InputMethodHighlight { /** * Returns whether the text range is selected. + * @return whether the text range is selected */ public boolean isSelected() { return selected; @@ -174,6 +175,7 @@ public class InputMethodHighlight { /** * Returns the variation of the text range. + * @return the variation of the text range */ public int getVariation() { return variation; @@ -181,6 +183,7 @@ public class InputMethodHighlight { /** * Returns the rendering style attributes for the text range, or null. + * @return the rendering style attributes for the text range, or null * @since 1.3 */ public Map getStyle() { diff --git a/jdk/src/share/classes/java/awt/im/spi/InputMethodContext.java b/jdk/src/share/classes/java/awt/im/spi/InputMethodContext.java index 8e06c39299b..45517c37b23 100644 --- a/jdk/src/share/classes/java/awt/im/spi/InputMethodContext.java +++ b/jdk/src/share/classes/java/awt/im/spi/InputMethodContext.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -52,6 +52,14 @@ public interface InputMethodContext extends InputMethodRequests { * Creates an input method event from the arguments given * and dispatches it to the client component. For arguments, * see {@link java.awt.event.InputMethodEvent#InputMethodEvent}. + * @param id the event type + * @param text the combined committed and composed text + * @param committedCharacterCount the number of committed characters in the text + * @param caret the caret (a.k.a. insertion point); null if + * there's no caret within current composed text + * @param visiblePosition the position that's most important to be + * visible; null if there's no recommendation for a visible + * position within current composed text */ public void dispatchInputMethodEvent(int id, AttributedCharacterIterator text, int committedCharacterCount, diff --git a/jdk/src/share/classes/java/awt/im/spi/InputMethodDescriptor.java b/jdk/src/share/classes/java/awt/im/spi/InputMethodDescriptor.java index d462095bb8f..885e7ad4e09 100644 --- a/jdk/src/share/classes/java/awt/im/spi/InputMethodDescriptor.java +++ b/jdk/src/share/classes/java/awt/im/spi/InputMethodDescriptor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -72,6 +72,8 @@ public interface InputMethodDescriptor { * Returns whether the list of available locales can change * at runtime. This may be the case, for example, for adapters * that access real input methods over the network. + * @return whether the list of available locales can change at + * runtime */ boolean hasDynamicLocaleList(); @@ -92,6 +94,9 @@ public interface InputMethodDescriptor { * * @param inputLocale the locale for which text input is supported, or null * @param displayLanguage the language in which the name will be displayed + * @return the user-visible name of the corresponding input method + * for the given input locale in the language in which the name + * will be displayed */ String getInputMethodDisplayName(Locale inputLocale, Locale displayLanguage); diff --git a/jdk/src/share/classes/java/awt/peer/CanvasPeer.java b/jdk/src/share/classes/java/awt/peer/CanvasPeer.java index ba17df0252c..da1c4c0fe5a 100644 --- a/jdk/src/share/classes/java/awt/peer/CanvasPeer.java +++ b/jdk/src/share/classes/java/awt/peer/CanvasPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2007, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -42,6 +42,8 @@ public interface CanvasPeer extends ComponentPeer { * from the requested GC passed as the argument to this method. This method * must return a non-null value (given the argument is non-null as well). * + * @param gc the requested graphics configuration + * @return a graphics configuration that best suits this Canvas * @since 1.7 */ GraphicsConfiguration getAppropriateGraphicsConfiguration( diff --git a/jdk/src/share/classes/java/awt/peer/ComponentPeer.java b/jdk/src/share/classes/java/awt/peer/ComponentPeer.java index b34f40f1cdd..8f0366711e5 100644 --- a/jdk/src/share/classes/java/awt/peer/ComponentPeer.java +++ b/jdk/src/share/classes/java/awt/peer/ComponentPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -516,6 +516,7 @@ public interface ComponentPeer { /** * Applies the shape to the native component window. + * @param shape the shape to apply * @since 1.7 * * @see Component#applyCompoundShape @@ -525,12 +526,13 @@ public interface ComponentPeer { /** * Lowers this component at the bottom of the above HW peer. If the above parameter * is null then the method places this component at the top of the Z-order. + * @param above the peer to lower this component with respect to */ void setZOrder(ComponentPeer above); /** * Updates internal data structures related to the component's GC. - * + * @param gc the reference graphics configuration * @return if the peer needs to be recreated for the changes to take effect * @since 1.7 */ diff --git a/jdk/src/share/classes/java/awt/peer/MouseInfoPeer.java b/jdk/src/share/classes/java/awt/peer/MouseInfoPeer.java index 0594bda78bb..9087810b37d 100644 --- a/jdk/src/share/classes/java/awt/peer/MouseInfoPeer.java +++ b/jdk/src/share/classes/java/awt/peer/MouseInfoPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -55,6 +55,10 @@ public interface MouseInfoPeer { * is located. * See java.awt.GraphicsConfiguration documentation for more * details about virtual screen devices. + * @param point holder for the current coordinates of the mouse + * cursor + * @return the number of the screen device where the pointer is + * located */ int fillPointWithCoords(Point point); @@ -63,6 +67,9 @@ public interface MouseInfoPeer { * pointer. The window is considered to be under the mouse pointer * if it is showing on the screen, and the mouse pointer is above * the part of the window that is not obscured by any other windows. + * @param w the window to check + * @return whether or not the window is located under the mouse + * pointer */ boolean isWindowUnderMouse(Window w); diff --git a/jdk/src/share/classes/java/awt/peer/WindowPeer.java b/jdk/src/share/classes/java/awt/peer/WindowPeer.java index e181b5b3018..65346489990 100644 --- a/jdk/src/share/classes/java/awt/peer/WindowPeer.java +++ b/jdk/src/share/classes/java/awt/peer/WindowPeer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -94,14 +94,15 @@ public interface WindowPeer extends ContainerPeer { /** * Sets the level of opacity for the window. - * + * @param opacity the level of opacity * @see Window#setOpacity(float) */ void setOpacity(float opacity); /** * Enables the per-pixel alpha support for the window. - * + * @param isOpaque whether or not per-pixel alpha support is + * enabled * @see Window#setBackground(Color) */ void setOpaque(boolean isOpaque); From 6261c40dcaa64104fb4ee2ce6d01b8d6e368dfeb Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 3 Feb 2014 10:21:58 -0800 Subject: [PATCH 094/159] 8033222: Fix serial lint warnings in sun.awt.* Reviewed-by: alanb --- jdk/src/share/classes/sun/awt/CustomCursor.java | 3 ++- jdk/src/share/classes/sun/awt/FontConfiguration.java | 1 + jdk/src/share/classes/sun/awt/TimedWindowEvent.java | 3 ++- jdk/src/share/classes/sun/awt/dnd/SunDropTargetEvent.java | 3 ++- jdk/src/share/classes/sun/awt/event/IgnorePaintEvent.java | 3 ++- jdk/src/share/classes/sun/awt/image/BadDepthException.java | 3 ++- jdk/src/share/classes/sun/awt/image/ImageAccessException.java | 3 ++- jdk/src/share/classes/sun/awt/image/ImageFormatException.java | 3 ++- jdk/src/share/classes/sun/awt/image/PNGImageDecoder.java | 3 ++- jdk/src/share/classes/sun/awt/shell/DefaultShellFolder.java | 4 ++-- jdk/src/share/classes/sun/awt/shell/ShellFolder.java | 4 ++-- 11 files changed, 21 insertions(+), 12 deletions(-) diff --git a/jdk/src/share/classes/sun/awt/CustomCursor.java b/jdk/src/share/classes/sun/awt/CustomCursor.java index a3863e9b6bd..6dad03c8c71 100644 --- a/jdk/src/share/classes/sun/awt/CustomCursor.java +++ b/jdk/src/share/classes/sun/awt/CustomCursor.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ import java.awt.image.*; * * @author ThomasBall */ +@SuppressWarnings("serial") // JDK-implementation class public abstract class CustomCursor extends Cursor { protected Image image; diff --git a/jdk/src/share/classes/sun/awt/FontConfiguration.java b/jdk/src/share/classes/sun/awt/FontConfiguration.java index 5d8b35ebe39..4cdc3d80c94 100644 --- a/jdk/src/share/classes/sun/awt/FontConfiguration.java +++ b/jdk/src/share/classes/sun/awt/FontConfiguration.java @@ -2109,6 +2109,7 @@ public abstract class FontConfiguration { return ret; } + @SuppressWarnings("serial") // JDK-implementation class class FontProperties extends Properties { public synchronized Object put(Object k, Object v) { parseProperty((String)k, (String)v); diff --git a/jdk/src/share/classes/sun/awt/TimedWindowEvent.java b/jdk/src/share/classes/sun/awt/TimedWindowEvent.java index 21353f789d7..780b3d572e6 100644 --- a/jdk/src/share/classes/sun/awt/TimedWindowEvent.java +++ b/jdk/src/share/classes/sun/awt/TimedWindowEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -28,6 +28,7 @@ package sun.awt; import java.awt.event.WindowEvent; import java.awt.Window; +@SuppressWarnings("serial") // JDK-implementation class public class TimedWindowEvent extends WindowEvent { private long time; diff --git a/jdk/src/share/classes/sun/awt/dnd/SunDropTargetEvent.java b/jdk/src/share/classes/sun/awt/dnd/SunDropTargetEvent.java index aff7b8a80d6..64685e571a2 100644 --- a/jdk/src/share/classes/sun/awt/dnd/SunDropTargetEvent.java +++ b/jdk/src/share/classes/sun/awt/dnd/SunDropTargetEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -29,6 +29,7 @@ import java.awt.Component; import java.awt.dnd.InvalidDnDOperationException; import java.awt.event.MouseEvent; +@SuppressWarnings("serial") // JDK-implementation class public class SunDropTargetEvent extends MouseEvent { public static final int MOUSE_DROPPED = MouseEvent.MOUSE_RELEASED; diff --git a/jdk/src/share/classes/sun/awt/event/IgnorePaintEvent.java b/jdk/src/share/classes/sun/awt/event/IgnorePaintEvent.java index c0d38694381..1f59869027d 100644 --- a/jdk/src/share/classes/sun/awt/event/IgnorePaintEvent.java +++ b/jdk/src/share/classes/sun/awt/event/IgnorePaintEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,7 @@ import java.awt.event.PaintEvent; * Look at javax.swing.SwingPaintEventDispatcher for more. * */ +@SuppressWarnings("serial") // JDK-implementation class public class IgnorePaintEvent extends PaintEvent { public IgnorePaintEvent(Component source, int id, Rectangle updateRect) { super(source, id, updateRect); diff --git a/jdk/src/share/classes/sun/awt/image/BadDepthException.java b/jdk/src/share/classes/sun/awt/image/BadDepthException.java index 19adf69fbe6..f9d264f22fb 100644 --- a/jdk/src/share/classes/sun/awt/image/BadDepthException.java +++ b/jdk/src/share/classes/sun/awt/image/BadDepthException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.awt.image; +@SuppressWarnings("serial") // JDK-implementation class public class BadDepthException extends Exception { public BadDepthException() { } diff --git a/jdk/src/share/classes/sun/awt/image/ImageAccessException.java b/jdk/src/share/classes/sun/awt/image/ImageAccessException.java index 43602f64b66..402e2a26caa 100644 --- a/jdk/src/share/classes/sun/awt/image/ImageAccessException.java +++ b/jdk/src/share/classes/sun/awt/image/ImageAccessException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.awt.image; +@SuppressWarnings("serial") // JDK-implementation class public class ImageAccessException extends Exception { public ImageAccessException(String s) { super(s); diff --git a/jdk/src/share/classes/sun/awt/image/ImageFormatException.java b/jdk/src/share/classes/sun/awt/image/ImageFormatException.java index 4812efe37c2..6a70d728f8f 100644 --- a/jdk/src/share/classes/sun/awt/image/ImageFormatException.java +++ b/jdk/src/share/classes/sun/awt/image/ImageFormatException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1995, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1995, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -25,6 +25,7 @@ package sun.awt.image; +@SuppressWarnings("serial") // JDK-implementation class public class ImageFormatException extends Exception { public ImageFormatException(String s) { super(s); diff --git a/jdk/src/share/classes/sun/awt/image/PNGImageDecoder.java b/jdk/src/share/classes/sun/awt/image/PNGImageDecoder.java index 69bb984c514..adbdb766da1 100644 --- a/jdk/src/share/classes/sun/awt/image/PNGImageDecoder.java +++ b/jdk/src/share/classes/sun/awt/image/PNGImageDecoder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -231,6 +231,7 @@ public class PNGImageDecoder extends ImageDecoder } return true; } + @SuppressWarnings("serial") // JDK-implementation class public class PNGException extends IOException { PNGException(String s) { super(s); } } diff --git a/jdk/src/share/classes/sun/awt/shell/DefaultShellFolder.java b/jdk/src/share/classes/sun/awt/shell/DefaultShellFolder.java index 860c980d6aa..b44776228d8 100644 --- a/jdk/src/share/classes/sun/awt/shell/DefaultShellFolder.java +++ b/jdk/src/share/classes/sun/awt/shell/DefaultShellFolder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -34,7 +34,7 @@ import sun.security.action.GetPropertyAction; * @author Michael Martak * @since 1.4 */ - +@SuppressWarnings("serial") // JDK-implementation class class DefaultShellFolder extends ShellFolder { /** diff --git a/jdk/src/share/classes/sun/awt/shell/ShellFolder.java b/jdk/src/share/classes/sun/awt/shell/ShellFolder.java index 630d4faa9cd..cb9459f1d41 100644 --- a/jdk/src/share/classes/sun/awt/shell/ShellFolder.java +++ b/jdk/src/share/classes/sun/awt/shell/ShellFolder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2009, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -37,7 +37,7 @@ import java.util.concurrent.Callable; * @author Michael Martak * @since 1.4 */ - +@SuppressWarnings("serial") // JDK-implementation class public abstract class ShellFolder extends File { private static final String COLUMN_NAME = "FileChooser.fileNameHeaderText"; private static final String COLUMN_SIZE = "FileChooser.fileSizeHeaderText"; From c4f2b88d813409eff4a9a72358ccc260c429c29b Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Mon, 3 Feb 2014 16:58:02 -0500 Subject: [PATCH 095/159] 8031737: CHECK_NULL and CHECK_EXCEPTION macros cleanup Rename CHECK_EXCEPTION macros with JNU prefix; use the defensive do {...} while (0) macro definition Reviewed-by: chegar, mchung, ksrini, lancea, alanb --- jdk/src/share/native/common/jni_util.h | 33 +++++++++++++++++++++---- jdk/src/share/native/sun/misc/Version.c | 20 +++++++-------- 2 files changed, 38 insertions(+), 15 deletions(-) diff --git a/jdk/src/share/native/common/jni_util.h b/jdk/src/share/native/common/jni_util.h index 0dab24c3392..b8d23cd1c21 100644 --- a/jdk/src/share/native/common/jni_util.h +++ b/jdk/src/share/native/common/jni_util.h @@ -279,14 +279,37 @@ JNU_NotifyAll(JNIEnv *env, jobject object); #define JNU_IsNull(env,obj) ((obj) == NULL) /************************************************************************ - * Miscellaneous utilities used by the class libraries to check for exceptions + * Miscellaneous utilities used by the class libraries to return from + * a function if a value is NULL or an exception is pending. */ -#define CHECK_NULL(x) if ((x) == NULL) return; -#define CHECK_NULL_RETURN(x, y) if ((x) == NULL) return (y); +#define CHECK_NULL(x) \ + do { \ + if ((x) == NULL) { \ + return; \ + } \ + } while (0) \ -#define CHECK_EXCEPTION(env) if ((*env)->ExceptionCheck(env)) return; -#define CHECK_EXCEPTION_RETURN(env, y) if ((*env)->ExceptionCheck(env)) return (y); +#define CHECK_NULL_RETURN(x, y) \ + do { \ + if ((x) == NULL) { \ + return (y); \ + } \ + } while (0) \ + +#define JNU_CHECK_EXCEPTION(env) \ + do { \ + if ((*env)->ExceptionCheck(env)) { \ + return; \ + } \ + } while (0) \ + +#define JNU_CHECK_EXCEPTION_RETURN(env, y) \ + do { \ + if ((*env)->ExceptionCheck(env)) { \ + return (y); \ + } \ + } while (0) /************************************************************************ * Debugging utilities diff --git a/jdk/src/share/native/sun/misc/Version.c b/jdk/src/share/native/sun/misc/Version.c index d37010e15d5..4dbcf1c8089 100644 --- a/jdk/src/share/native/sun/misc/Version.c +++ b/jdk/src/share/native/sun/misc/Version.c @@ -60,15 +60,15 @@ Java_sun_misc_Version_getJvmVersionInfo(JNIEnv *env, jclass cls) (*func_p)(env, &info, sizeof(info)); setStaticIntField(env, cls, "jvm_major_version", JVM_VERSION_MAJOR(info.jvm_version)); - CHECK_EXCEPTION_RETURN(env, JNI_FALSE); + JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE); setStaticIntField(env, cls, "jvm_minor_version", JVM_VERSION_MINOR(info.jvm_version)); - CHECK_EXCEPTION_RETURN(env, JNI_FALSE); + JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE); setStaticIntField(env, cls, "jvm_micro_version", JVM_VERSION_MICRO(info.jvm_version)); - CHECK_EXCEPTION_RETURN(env, JNI_FALSE); + JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE); setStaticIntField(env, cls, "jvm_build_number", JVM_VERSION_BUILD(info.jvm_version)); - CHECK_EXCEPTION_RETURN(env, JNI_FALSE); + JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE); setStaticIntField(env, cls, "jvm_update_version", info.update_version); - CHECK_EXCEPTION_RETURN(env, JNI_FALSE); + JNU_CHECK_EXCEPTION_RETURN(env, JNI_FALSE); jvm_special_version = info.special_update_version; return JNI_TRUE; @@ -91,15 +91,15 @@ Java_sun_misc_Version_getJdkVersionInfo(JNIEnv *env, jclass cls) JDK_GetVersionInfo0(&info, sizeof(info)); setStaticIntField(env, cls, "jdk_major_version", JDK_VERSION_MAJOR(info.jdk_version)); - CHECK_EXCEPTION(env); + JNU_CHECK_EXCEPTION(env); setStaticIntField(env, cls, "jdk_minor_version", JDK_VERSION_MINOR(info.jdk_version)); - CHECK_EXCEPTION(env); + JNU_CHECK_EXCEPTION(env); setStaticIntField(env, cls, "jdk_micro_version", JDK_VERSION_MICRO(info.jdk_version)); - CHECK_EXCEPTION(env); + JNU_CHECK_EXCEPTION(env); setStaticIntField(env, cls, "jdk_build_number", JDK_VERSION_BUILD(info.jdk_version)); - CHECK_EXCEPTION(env); + JNU_CHECK_EXCEPTION(env); setStaticIntField(env, cls, "jdk_update_version", info.update_version); - CHECK_EXCEPTION(env); + JNU_CHECK_EXCEPTION(env); jdk_special_version = info.special_update_version; } From 3bd9bdd993475b81dc10f1739d29c33072c48a34 Mon Sep 17 00:00:00 2001 From: Eric McCorkle Date: Mon, 3 Feb 2014 17:19:15 -0500 Subject: [PATCH 096/159] 8033004: Make base TypeAnnotationPosition data immutable, create better methods for creating base TypeAnnotationPositions First of a series of major fixes to type annotations; cleans up interface with TypeAnnotationPosition Reviewed-by: jjg --- .../sun/tools/javac/code/SymbolMetadata.java | 12 +- .../javac/code/TypeAnnotationPosition.java | 871 +++++++++++++++++- .../sun/tools/javac/code/TypeAnnotations.java | 508 +++++----- .../com/sun/tools/javac/comp/Annotate.java | 8 +- .../com/sun/tools/javac/jvm/ClassReader.java | 205 +++-- .../com/sun/tools/javac/tree/JCTree.java | 3 + 6 files changed, 1311 insertions(+), 296 deletions(-) diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java b/langtools/src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java index 3622c5a45a8..f41dae9f5cf 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/SymbolMetadata.java @@ -425,11 +425,15 @@ public class SymbolMetadata { private final List placeholderFor; private final Symbol on; - public Placeholder(Annotate.AnnotateRepeatedContext ctx, List placeholderFor, Symbol on) { + public Placeholder(Annotate.AnnotateRepeatedContext ctx, + List placeholderFor, Symbol on) { super(on.type, List.>nil(), - ctx.isTypeCompound ? - ((Attribute.TypeCompound)placeholderFor.head).position : - new TypeAnnotationPosition()); + ctx.isTypeCompound ? + ((Attribute.TypeCompound)placeholderFor.head).position : + // TODO: Eventually, we will need to get rid of this + // use of unknown, either by using null, or by + // throwing an assertion failure here. + TypeAnnotationPosition.unknown); this.ctx = ctx; this.placeholderFor = placeholderFor; this.on = on; diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java index c481ea5d3e0..0845f121ab8 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotationPosition.java @@ -119,13 +119,20 @@ public class TypeAnnotationPosition { } } - public TargetType type = TargetType.UNKNOWN; + public static final List emptyPath = List.nil(); + + // NOTE: All of these will be converted to final fields eventually. + + public final TargetType type; // For generic/array types. - public List location = List.nil(); + + // This field is in the process of being made final. Do not + // introduce new mutations. + public List location; // Tree position. - public int pos = -1; + public final int pos; // For type casts, type tests, new, locals (as start_pc), // and method and constructor reference type arguments. @@ -138,13 +145,17 @@ public class TypeAnnotationPosition { public int[] lvarIndex = null; // For type parameter bound - public int bound_index = Integer.MIN_VALUE; + public final int bound_index; // For type parameter and method parameter - public int parameter_index = Integer.MIN_VALUE; + public final int parameter_index; // For class extends, implements, and throws clauses - public int type_index = Integer.MIN_VALUE; + + // This field is effectively final. However, it needs to be + // modified by Gen for the time being. Do not introduce new + // mutations. + public int type_index; // For exception parameters, index into exception table. // In com.sun.tools.javac.jvm.Gen.genCatch we first set the type_index @@ -156,9 +167,10 @@ public class TypeAnnotationPosition { // If this type annotation is within a lambda expression, // store a pointer to the lambda expression tree in order // to allow a later translation to the right method. - public JCLambda onLambda = null; + public final JCLambda onLambda; - public TypeAnnotationPosition() {} + // NOTE: This constructor will eventually go away, and be replaced + // by static builder methods. @Override public String toString() { @@ -323,4 +335,847 @@ public class TypeAnnotationPosition { } return loc.toList(); } + + // These methods are the new preferred way to create + // TypeAnnotationPositions + + // Never make this a public constructor without creating a builder. + private TypeAnnotationPosition(final TargetType ttype, + final int pos, + final int parameter_index, + final JCLambda onLambda, + final int type_index, + final int bound_index, + final List location) { + Assert.checkNonNull(location); + this.type = ttype; + this.pos = pos; + this.parameter_index = parameter_index; + this.onLambda = onLambda; + this.type_index = type_index; + this.bound_index = bound_index; + this.location = location; + } + + /** + * Create a {@code TypeAnnotationPosition} for a method return. + * + * @param location The type path. + * @param onLambda The lambda for this parameter. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodReturn(final List location, + final JCLambda onLambda, + final int pos) { + return new TypeAnnotationPosition(TargetType.METHOD_RETURN, pos, + Integer.MIN_VALUE, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method return. + * + * @param location The type path. + */ + public static TypeAnnotationPosition + methodReturn(final List location) { + return methodReturn(location, null, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method return. + * + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition methodReturn(final int pos) { + return methodReturn(emptyPath, null, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method receiver. + * + * @param location The type path. + * @param onLambda The lambda for this parameter. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodReceiver(final List location, + final JCLambda onLambda, + final int pos) { + return new TypeAnnotationPosition(TargetType.METHOD_RECEIVER, pos, + Integer.MIN_VALUE, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method receiver. + * + * @param location The type path. + */ + public static TypeAnnotationPosition + methodReceiver(final List location) { + return methodReceiver(location, null, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method receiver. + * + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition methodReceiver(final int pos) { + return methodReceiver(emptyPath, null, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method formal parameter. + * + * @param location The type path. + * @param onLambda The lambda for this parameter. + * @param index The index of the parameter. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodParameter(final List location, + final JCLambda onLambda, + final int parameter_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.METHOD_FORMAL_PARAMETER, + pos, parameter_index, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method formal parameter. + * + * @param onLambda The lambda for this parameter. + * @param index The index of the parameter. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodParameter(final JCLambda onLambda, + final int parameter_index, + final int pos) { + return methodParameter(emptyPath, onLambda, + parameter_index, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method formal parameter. + * + * @param index The index of the parameter. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodParameter(final int parameter_index, + final int pos) { + return methodParameter(null, parameter_index, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method formal parameter. + * + * @param location The type path. + * @param index The index of the parameter. + */ + public static TypeAnnotationPosition + methodParameter(final List location, + final int parameter_index) { + return methodParameter(location, null, parameter_index, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method reference. + * + * @param location The type path. + * @param onLambda The lambda for this method reference. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodRef(final List location, + final JCLambda onLambda, + final int pos) { + return new TypeAnnotationPosition(TargetType.METHOD_REFERENCE, pos, + Integer.MIN_VALUE, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method reference. + * + * @param location The type path. + * @param onLambda The lambda for this method reference. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodRef(final List location) { + return methodRef(location, null, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a constructor reference. + * + * @param location The type path. + * @param onLambda The lambda for this constructor reference. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + constructorRef(final List location, + final JCLambda onLambda, + final int pos) { + return new TypeAnnotationPosition(TargetType.CONSTRUCTOR_REFERENCE, pos, + Integer.MIN_VALUE, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a constructor reference. + * + * @param location The type path. + * @param onLambda The lambda for this constructor reference. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + constructorRef(final List location) { + return constructorRef(location, null, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a field. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + field(final List location, + final JCLambda onLambda, + final int pos) { + return new TypeAnnotationPosition(TargetType.FIELD, pos, + Integer.MIN_VALUE, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a field. + * + * @param location The type path. + */ + public static TypeAnnotationPosition + field(final List location) { + return field(location, null, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a field. + * + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition field(final int pos) { + return field(emptyPath, null, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for a local variable. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + localVariable(final List location, + final JCLambda onLambda, + final int pos) { + return new TypeAnnotationPosition(TargetType.LOCAL_VARIABLE, pos, + Integer.MIN_VALUE, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a local variable. + * + * @param onLambda The lambda for this variable. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + localVariable(final JCLambda onLambda, + final int pos) { + return localVariable(emptyPath, onLambda, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for a local variable. + * + * @param location The type path. + */ + public static TypeAnnotationPosition + localVariable(final List location) { + return localVariable(location, null, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for an exception parameter. + * + * @param location The type path. + * @param onLambda The lambda for this parameter. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + exceptionParameter(final List location, + final JCLambda onLambda, + final int pos) { + return new TypeAnnotationPosition(TargetType.EXCEPTION_PARAMETER, pos, + Integer.MIN_VALUE, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for an exception parameter. + * + * @param onLambda The lambda for this parameter. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + exceptionParameter(final JCLambda onLambda, + final int pos) { + return exceptionParameter(emptyPath, onLambda, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for an exception parameter. + * + * @param location The type path. + */ + public static TypeAnnotationPosition + exceptionParameter(final List location) { + return exceptionParameter(location, null, -1); + } + + + /** + * Create a {@code TypeAnnotationPosition} for a resource variable. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + resourceVariable(final List location, + final JCLambda onLambda, + final int pos) { + return new TypeAnnotationPosition(TargetType.RESOURCE_VARIABLE, pos, + Integer.MIN_VALUE, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a resource variable. + * + * @param onLambda The lambda for this variable. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + resourceVariable(final JCLambda onLambda, + final int pos) { + return resourceVariable(emptyPath, onLambda, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for a resource variable. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + resourceVariable(final List location) { + return resourceVariable(location, null, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a new. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + newObj(final List location, + final JCLambda onLambda, + final int pos) { + return new TypeAnnotationPosition(TargetType.NEW, pos, + Integer.MIN_VALUE, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a new. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition newObj(final int pos) { + return newObj(emptyPath, null, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for a new. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + newObj(final List location) { + return newObj(location, null, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a class extension. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param type_index The index of the interface. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + classExtends(final List location, + final JCLambda onLambda, + final int type_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.CLASS_EXTENDS, pos, + Integer.MIN_VALUE, onLambda, + type_index, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a class extension. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param type_index The index of the interface. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + classExtends(final List location, + final JCLambda onLambda, + final int pos) { + return classExtends(location, onLambda, -1, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for a class extension. + * + * @param location The type path. + * @param type_index The index of the interface. + */ + public static TypeAnnotationPosition + classExtends(final List location, + final int type_index) { + return classExtends(location, null, type_index, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a class extension. + * + * @param type_index The index of the interface. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition classExtends(final int type_index, + final int pos) { + return classExtends(emptyPath, null, type_index, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for a class extension. + * + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition classExtends(final int pos) { + return classExtends(-1, pos); + } + + /** + * Create a {@code TypeAnnotationPosition} for an instanceof. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + instanceOf(final List location, + final JCLambda onLambda, + final int pos) { + return new TypeAnnotationPosition(TargetType.INSTANCEOF, pos, + Integer.MIN_VALUE, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + /** + * Create a {@code TypeAnnotationPosition} for an instanceof. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + instanceOf(final List location) { + return instanceOf(location, null, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a type cast. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param type_index The index into an intersection type. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + typeCast(final List location, + final JCLambda onLambda, + final int type_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.CAST, pos, + Integer.MIN_VALUE, onLambda, + type_index, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a type cast. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param type_index The index into an intersection type. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + typeCast(final List location, + final int type_index) { + return typeCast(location, null, type_index, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method + * invocation type argument. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param type_index The index of the type argument. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodInvocationTypeArg(final List location, + final JCLambda onLambda, + final int type_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.METHOD_INVOCATION_TYPE_ARGUMENT, + pos, Integer.MIN_VALUE, onLambda, + type_index, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method + * invocation type argument. + * + * @param location The type path. + * @param type_index The index of the type argument. + */ + public static TypeAnnotationPosition + methodInvocationTypeArg(final List location, + final int type_index) { + return methodInvocationTypeArg(location, null, type_index, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a constructor + * invocation type argument. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param type_index The index of the type argument. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + constructorInvocationTypeArg(final List location, + final JCLambda onLambda, + final int type_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT, + pos, Integer.MIN_VALUE, onLambda, + type_index, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a constructor + * invocation type argument. + * + * @param location The type path. + * @param type_index The index of the type argument. + */ + public static TypeAnnotationPosition + constructorInvocationTypeArg(final List location, + final int type_index) { + return constructorInvocationTypeArg(location, null, type_index, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a type parameter. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param parameter_index The index of the type parameter. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + typeParameter(final List location, + final JCLambda onLambda, + final int parameter_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.CLASS_TYPE_PARAMETER, pos, + parameter_index, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a type parameter. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param parameter_index The index of the type parameter. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + typeParameter(final List location, + final int parameter_index) { + return typeParameter(location, null, parameter_index, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method type parameter. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param parameter_index The index of the type parameter. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodTypeParameter(final List location, + final JCLambda onLambda, + final int parameter_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.METHOD_TYPE_PARAMETER, + pos, parameter_index, onLambda, + Integer.MIN_VALUE, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method type parameter. + * + * @param location The type path. + * @param parameter_index The index of the type parameter. + */ + public static TypeAnnotationPosition + methodTypeParameter(final List location, + final int parameter_index) { + return methodTypeParameter(location, null, parameter_index, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a throws clause. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param type_index The index of the exception. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodThrows(final List location, + final JCLambda onLambda, + final int type_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.THROWS, pos, + Integer.MIN_VALUE, onLambda, + type_index, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a throws clause. + * + * @param location The type path. + * @param type_index The index of the exception. + */ + public static TypeAnnotationPosition + methodThrows(final List location, + final int type_index) { + return methodThrows(location, null, type_index, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method reference + * type argument. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param parameter_index The index of the type argument. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodRefTypeArg(final List location, + final JCLambda onLambda, + final int type_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.METHOD_REFERENCE_TYPE_ARGUMENT, + pos, Integer.MIN_VALUE, onLambda, + type_index, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method reference + * type argument. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param parameter_index The index of the type argument. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodRefTypeArg(final List location, + final int type_index) { + return methodRefTypeArg(location, null, type_index, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a constructor reference + * type argument. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param parameter_index The index of the type argument. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + constructorRefTypeArg(final List location, + final JCLambda onLambda, + final int type_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT, + pos, Integer.MIN_VALUE, onLambda, + type_index, Integer.MIN_VALUE, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a constructor reference + * type argument. + * + * @param location The type path. + * @param parameter_index The index of the type argument. + */ + public static TypeAnnotationPosition + constructorRefTypeArg(final List location, + final int type_index) { + return constructorRefTypeArg(location, null, type_index, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a type parameter bound. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param parameter_index The index of the type parameter. + * @param bound_index The index of the type parameter bound. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + typeParameterBound(final List location, + final JCLambda onLambda, + final int parameter_index, + final int bound_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.CLASS_TYPE_PARAMETER_BOUND, + pos, parameter_index, onLambda, + Integer.MIN_VALUE, bound_index, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a type parameter bound. + * + * @param location The type path. + * @param parameter_index The index of the type parameter. + * @param bound_index The index of the type parameter bound. + */ + public static TypeAnnotationPosition + typeParameterBound(final List location, + final int parameter_index, + final int bound_index) { + return typeParameterBound(location, null, parameter_index, + bound_index, -1); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method type + * parameter bound. + * + * @param location The type path. + * @param onLambda The lambda for this variable. + * @param parameter_index The index of the type parameter. + * @param bound_index The index of the type parameter bound. + * @param pos The position from the associated tree node. + */ + public static TypeAnnotationPosition + methodTypeParameterBound(final List location, + final JCLambda onLambda, + final int parameter_index, + final int bound_index, + final int pos) { + return new TypeAnnotationPosition(TargetType.METHOD_TYPE_PARAMETER_BOUND, + pos, parameter_index, onLambda, + Integer.MIN_VALUE, bound_index, + location); + } + + /** + * Create a {@code TypeAnnotationPosition} for a method type + * parameter bound. + * + * @param location The type path. + * @param parameter_index The index of the type parameter. + * @param bound_index The index of the type parameter bound. + */ + public static TypeAnnotationPosition + methodTypeParameterBound(final List location, + final int parameter_index, + final int bound_index) { + return methodTypeParameterBound(location, null, parameter_index, + bound_index, -1); + } + + // Consider this deprecated on arrival. We eventually want to get + // rid of this value altogether. Do not use it for anything new. + public static final TypeAnnotationPosition unknown = + new TypeAnnotationPosition(TargetType.UNKNOWN, -1, + Integer.MIN_VALUE, null, + Integer.MIN_VALUE, Integer.MIN_VALUE, + emptyPath); } diff --git a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java index 35ccc58a14e..88bbf4b7830 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java +++ b/langtools/src/share/classes/com/sun/tools/javac/code/TypeAnnotations.java @@ -663,8 +663,15 @@ public class TypeAnnotations { * type annotations: determine the type annotation positions. */ - private void resolveFrame(JCTree tree, JCTree frame, - List path, TypeAnnotationPosition p) { + // This method is considered deprecated, and will be removed + // in the near future. Don't use it for anything new. + private TypeAnnotationPosition + resolveFrame(JCTree tree, + JCTree frame, + List path, + JCLambda currentLambda, + int outer_type_index, + ListBuffer location) { /* System.out.println("Resolving tree: " + tree + " kind: " + tree.getKind()); System.out.println(" Framing tree: " + frame + " kind: " + frame.getKind()); @@ -675,87 +682,101 @@ public class TypeAnnotations { switch (frame.getKind()) { case TYPE_CAST: - JCTypeCast frameTC = (JCTypeCast) frame; - p.type = TargetType.CAST; - if (frameTC.clazz.hasTag(Tag.TYPEINTERSECTION)) { - // This case was already handled by INTERSECTION_TYPE - } else { - p.type_index = 0; - } - p.pos = frame.pos; - return; + return TypeAnnotationPosition.typeCast(location.toList(), + currentLambda, + outer_type_index, + frame.pos); case INSTANCE_OF: - p.type = TargetType.INSTANCEOF; - p.pos = frame.pos; - return; + return TypeAnnotationPosition.instanceOf(location.toList(), + currentLambda, + frame.pos); case NEW_CLASS: - JCNewClass frameNewClass = (JCNewClass) frame; + final JCNewClass frameNewClass = (JCNewClass) frame; if (frameNewClass.def != null) { // Special handling for anonymous class instantiations - JCClassDecl frameClassDecl = frameNewClass.def; + final JCClassDecl frameClassDecl = frameNewClass.def; if (frameClassDecl.extending == tree) { - p.type = TargetType.CLASS_EXTENDS; - p.type_index = -1; + return TypeAnnotationPosition + .classExtends(location.toList(), currentLambda, + frame.pos); } else if (frameClassDecl.implementing.contains(tree)) { - p.type = TargetType.CLASS_EXTENDS; - p.type_index = frameClassDecl.implementing.indexOf(tree); + final int type_index = + frameClassDecl.implementing.indexOf(tree); + return TypeAnnotationPosition + .classExtends(location.toList(), currentLambda, + type_index, frame.pos); } else { // In contrast to CLASS below, typarams cannot occur here. - Assert.error("Could not determine position of tree " + tree + - " within frame " + frame); + throw new AssertionError("Could not determine position of tree " + tree + + " within frame " + frame); } } else if (frameNewClass.typeargs.contains(tree)) { - p.type = TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT; - p.type_index = frameNewClass.typeargs.indexOf(tree); + final int type_index = + frameNewClass.typeargs.indexOf(tree); + return TypeAnnotationPosition + .constructorInvocationTypeArg(location.toList(), + currentLambda, + type_index, + frame.pos); } else { - p.type = TargetType.NEW; + return TypeAnnotationPosition + .newObj(location.toList(), currentLambda, + frame.pos); } - p.pos = frame.pos; - return; case NEW_ARRAY: - p.type = TargetType.NEW; - p.pos = frame.pos; - return; + return TypeAnnotationPosition + .newObj(location.toList(), currentLambda, frame.pos); case ANNOTATION_TYPE: case CLASS: case ENUM: case INTERFACE: - p.pos = frame.pos; if (((JCClassDecl)frame).extending == tree) { - p.type = TargetType.CLASS_EXTENDS; - p.type_index = -1; + return TypeAnnotationPosition + .classExtends(location.toList(), currentLambda, + frame.pos); } else if (((JCClassDecl)frame).implementing.contains(tree)) { - p.type = TargetType.CLASS_EXTENDS; - p.type_index = ((JCClassDecl)frame).implementing.indexOf(tree); + final int type_index = + ((JCClassDecl)frame).implementing.indexOf(tree); + return TypeAnnotationPosition + .classExtends(location.toList(), currentLambda, + type_index, frame.pos); } else if (((JCClassDecl)frame).typarams.contains(tree)) { - p.type = TargetType.CLASS_TYPE_PARAMETER; - p.parameter_index = ((JCClassDecl)frame).typarams.indexOf(tree); + final int parameter_index = + ((JCClassDecl)frame).typarams.indexOf(tree); + return TypeAnnotationPosition + .typeParameter(location.toList(), currentLambda, + parameter_index, frame.pos); } else { - Assert.error("Could not determine position of tree " + tree + - " within frame " + frame); + throw new AssertionError("Could not determine position of tree " + + tree + " within frame " + frame); } - return; case METHOD: { - JCMethodDecl frameMethod = (JCMethodDecl) frame; - p.pos = frame.pos; + final JCMethodDecl frameMethod = (JCMethodDecl) frame; if (frameMethod.thrown.contains(tree)) { - p.type = TargetType.THROWS; - p.type_index = frameMethod.thrown.indexOf(tree); + final int type_index = frameMethod.thrown.indexOf(tree); + return TypeAnnotationPosition + .methodThrows(location.toList(), currentLambda, + type_index, frame.pos); } else if (frameMethod.restype == tree) { - p.type = TargetType.METHOD_RETURN; + return TypeAnnotationPosition + .methodReturn(location.toList(), currentLambda, + frame.pos); } else if (frameMethod.typarams.contains(tree)) { - p.type = TargetType.METHOD_TYPE_PARAMETER; - p.parameter_index = frameMethod.typarams.indexOf(tree); + final int parameter_index = + frameMethod.typarams.indexOf(tree); + return TypeAnnotationPosition + .methodTypeParameter(location.toList(), + currentLambda, + parameter_index, frame.pos); } else { - Assert.error("Could not determine position of tree " + tree + - " within frame " + frame); + throw new AssertionError("Could not determine position of tree " + tree + + " within frame " + frame); } - return; } case PARAMETERIZED_TYPE: { @@ -766,25 +787,30 @@ public class TypeAnnotations { } else if (((JCTypeApply)frame).arguments.contains(tree)) { JCTypeApply taframe = (JCTypeApply) frame; int arg = taframe.arguments.indexOf(tree); - p.location = p.location.prepend(new TypePathEntry(TypePathEntryKind.TYPE_ARGUMENT, arg)); + location = location.prepend( + new TypePathEntry(TypePathEntryKind.TYPE_ARGUMENT, + arg)); Type typeToUse; - if (newPath.tail != null && newPath.tail.head.hasTag(Tag.NEWCLASS)) { - // If we are within an anonymous class instantiation, use its type, - // because it contains a correctly nested type. + if (newPath.tail != null && + newPath.tail.head.hasTag(Tag.NEWCLASS)) { + // If we are within an anonymous class + // instantiation, use its type, because it + // contains a correctly nested type. typeToUse = newPath.tail.head.type; } else { typeToUse = taframe.type; } - locateNestedTypes(typeToUse, p); + location = locateNestedTypes(typeToUse, location); } else { - Assert.error("Could not determine type argument position of tree " + tree + - " within frame " + frame); + throw new AssertionError("Could not determine type argument position of tree " + tree + + " within frame " + frame); } - resolveFrame(newPath.head, newPath.tail.head, newPath, p); - return; + return resolveFrame(newPath.head, newPath.tail.head, + newPath, currentLambda, + outer_type_index, location); } case MEMBER_REFERENCE: { @@ -793,117 +819,140 @@ public class TypeAnnotations { if (mrframe.expr == tree) { switch (mrframe.mode) { case INVOKE: - p.type = TargetType.METHOD_REFERENCE; - break; + return TypeAnnotationPosition + .methodRef(location.toList(), currentLambda, + frame.pos); case NEW: - p.type = TargetType.CONSTRUCTOR_REFERENCE; - break; + return TypeAnnotationPosition + .constructorRef(location.toList(), + currentLambda, + frame.pos); default: - Assert.error("Unknown method reference mode " + mrframe.mode + - " for tree " + tree + " within frame " + frame); + throw new AssertionError("Unknown method reference mode " + mrframe.mode + + " for tree " + tree + " within frame " + frame); } - p.pos = frame.pos; } else if (mrframe.typeargs != null && mrframe.typeargs.contains(tree)) { - int arg = mrframe.typeargs.indexOf(tree); - p.type_index = arg; + final int type_index = mrframe.typeargs.indexOf(tree); switch (mrframe.mode) { case INVOKE: - p.type = TargetType.METHOD_REFERENCE_TYPE_ARGUMENT; - break; + return TypeAnnotationPosition + .methodRefTypeArg(location.toList(), + currentLambda, + type_index, frame.pos); case NEW: - p.type = TargetType.CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT; - break; + return TypeAnnotationPosition + .constructorRefTypeArg(location.toList(), + currentLambda, + type_index, frame.pos); default: - Assert.error("Unknown method reference mode " + mrframe.mode + - " for tree " + tree + " within frame " + frame); + throw new AssertionError("Unknown method reference mode " + mrframe.mode + + " for tree " + tree + " within frame " + frame); } - p.pos = frame.pos; } else { - Assert.error("Could not determine type argument position of tree " + tree + - " within frame " + frame); + throw new AssertionError("Could not determine type argument position of tree " + tree + + " within frame " + frame); } - return; } case ARRAY_TYPE: { - ListBuffer index = new ListBuffer<>(); - index = index.append(TypePathEntry.ARRAY); + location = location.prepend(TypePathEntry.ARRAY); List newPath = path.tail; while (true) { JCTree npHead = newPath.tail.head; if (npHead.hasTag(JCTree.Tag.TYPEARRAY)) { newPath = newPath.tail; - index = index.append(TypePathEntry.ARRAY); + location = location.prepend(TypePathEntry.ARRAY); } else if (npHead.hasTag(JCTree.Tag.ANNOTATED_TYPE)) { newPath = newPath.tail; } else { break; } } - p.location = p.location.prependList(index.toList()); - resolveFrame(newPath.head, newPath.tail.head, newPath, p); - return; + return resolveFrame(newPath.head, newPath.tail.head, + newPath, currentLambda, + outer_type_index, location); } case TYPE_PARAMETER: if (path.tail.tail.head.hasTag(JCTree.Tag.CLASSDEF)) { - JCClassDecl clazz = (JCClassDecl)path.tail.tail.head; - p.type = TargetType.CLASS_TYPE_PARAMETER_BOUND; - p.parameter_index = clazz.typarams.indexOf(path.tail.head); - p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree); - if (((JCTypeParameter)frame).bounds.get(0).type.isInterface()) { - // Account for an implicit Object as bound 0 - p.bound_index += 1; - } + final JCClassDecl clazz = + (JCClassDecl)path.tail.tail.head; + final int parameter_index = + clazz.typarams.indexOf(path.tail.head); + final int bound_index = + ((JCTypeParameter)frame).bounds.get(0) + .type.isInterface() ? + ((JCTypeParameter)frame).bounds.indexOf(tree) + 1: + ((JCTypeParameter)frame).bounds.indexOf(tree); + return TypeAnnotationPosition + .typeParameterBound(location.toList(), + currentLambda, + parameter_index, bound_index, + frame.pos); } else if (path.tail.tail.head.hasTag(JCTree.Tag.METHODDEF)) { - JCMethodDecl method = (JCMethodDecl)path.tail.tail.head; - p.type = TargetType.METHOD_TYPE_PARAMETER_BOUND; - p.parameter_index = method.typarams.indexOf(path.tail.head); - p.bound_index = ((JCTypeParameter)frame).bounds.indexOf(tree); - if (((JCTypeParameter)frame).bounds.get(0).type.isInterface()) { - // Account for an implicit Object as bound 0 - p.bound_index += 1; - } + final JCMethodDecl method = + (JCMethodDecl)path.tail.tail.head; + final int parameter_index = + method.typarams.indexOf(path.tail.head); + final int bound_index = + ((JCTypeParameter)frame).bounds.get(0) + .type.isInterface() ? + ((JCTypeParameter)frame).bounds.indexOf(tree) + 1: + ((JCTypeParameter)frame).bounds.indexOf(tree); + return TypeAnnotationPosition + .methodTypeParameterBound(location.toList(), + currentLambda, + parameter_index, + bound_index, + frame.pos); } else { - Assert.error("Could not determine position of tree " + tree + - " within frame " + frame); + throw new AssertionError("Could not determine position of tree " + tree + + " within frame " + frame); } - p.pos = frame.pos; - return; case VARIABLE: VarSymbol v = ((JCVariableDecl)frame).sym; - p.pos = frame.pos; - switch (v.getKind()) { - case LOCAL_VARIABLE: - p.type = TargetType.LOCAL_VARIABLE; - break; - case FIELD: - p.type = TargetType.FIELD; - break; - case PARAMETER: - if (v.getQualifiedName().equals(names._this)) { - // TODO: Intro a separate ElementKind? - p.type = TargetType.METHOD_RECEIVER; - } else { - p.type = TargetType.METHOD_FORMAL_PARAMETER; - p.parameter_index = methodParamIndex(path, frame); - } - break; - case EXCEPTION_PARAMETER: - p.type = TargetType.EXCEPTION_PARAMETER; - break; - case RESOURCE_VARIABLE: - p.type = TargetType.RESOURCE_VARIABLE; - break; - default: - Assert.error("Found unexpected type annotation for variable: " + v + " with kind: " + v.getKind()); - } if (v.getKind() != ElementKind.FIELD) { v.owner.appendUniqueTypeAttributes(v.getRawTypeAttributes()); } - return; + switch (v.getKind()) { + case LOCAL_VARIABLE: + return TypeAnnotationPosition + .localVariable(location.toList(), currentLambda, + frame.pos); + case FIELD: + return TypeAnnotationPosition.field(location.toList(), + currentLambda, + frame.pos); + case PARAMETER: + if (v.getQualifiedName().equals(names._this)) { + return TypeAnnotationPosition + .methodReceiver(location.toList(), + currentLambda, + frame.pos); + } else { + final int parameter_index = + methodParamIndex(path, frame); + return TypeAnnotationPosition + .methodParameter(location.toList(), + currentLambda, + parameter_index, + frame.pos); + } + case EXCEPTION_PARAMETER: + return TypeAnnotationPosition + .exceptionParameter(location.toList(), + currentLambda, + frame.pos); + case RESOURCE_VARIABLE: + return TypeAnnotationPosition + .resourceVariable(location.toList(), + currentLambda, + frame.pos); + default: + throw new AssertionError("Found unexpected type annotation for variable: " + v + " with kind: " + v.getKind()); + } case ANNOTATED_TYPE: { if (frame == tree) { @@ -921,83 +970,89 @@ public class TypeAnnotations { // class/method as enclosing elements. // There is actually nothing to do for them. } else { - locateNestedTypes(utype, p); + location = locateNestedTypes(utype, location); } } List newPath = path.tail; - resolveFrame(newPath.head, newPath.tail.head, newPath, p); - return; + return resolveFrame(newPath.head, newPath.tail.head, + newPath, currentLambda, + outer_type_index, location); } case UNION_TYPE: { List newPath = path.tail; - resolveFrame(newPath.head, newPath.tail.head, newPath, p); - return; + return resolveFrame(newPath.head, newPath.tail.head, + newPath, currentLambda, + outer_type_index, location); } case INTERSECTION_TYPE: { JCTypeIntersection isect = (JCTypeIntersection)frame; - p.type_index = isect.bounds.indexOf(tree); - List newPath = path.tail; - resolveFrame(newPath.head, newPath.tail.head, newPath, p); - return; + final List newPath = path.tail; + return resolveFrame(newPath.head, newPath.tail.head, + newPath, currentLambda, + isect.bounds.indexOf(tree), location); } case METHOD_INVOCATION: { JCMethodInvocation invocation = (JCMethodInvocation)frame; if (!invocation.typeargs.contains(tree)) { - Assert.error("{" + tree + "} is not an argument in the invocation: " + invocation); + throw new AssertionError("{" + tree + "} is not an argument in the invocation: " + invocation); } MethodSymbol exsym = (MethodSymbol) TreeInfo.symbol(invocation.getMethodSelect()); + final int type_index = invocation.typeargs.indexOf(tree); if (exsym == null) { - Assert.error("could not determine symbol for {" + invocation + "}"); + throw new AssertionError("could not determine symbol for {" + invocation + "}"); } else if (exsym.isConstructor()) { - p.type = TargetType.CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT; + return TypeAnnotationPosition + .constructorInvocationTypeArg(location.toList(), + currentLambda, + type_index, + invocation.pos); } else { - p.type = TargetType.METHOD_INVOCATION_TYPE_ARGUMENT; + return TypeAnnotationPosition + .methodInvocationTypeArg(location.toList(), + currentLambda, + type_index, + invocation.pos); } - p.pos = invocation.pos; - p.type_index = invocation.typeargs.indexOf(tree); - return; } case EXTENDS_WILDCARD: case SUPER_WILDCARD: { // Annotations in wildcard bounds - p.location = p.location.prepend(TypePathEntry.WILDCARD); - List newPath = path.tail; - resolveFrame(newPath.head, newPath.tail.head, newPath, p); - return; + final List newPath = path.tail; + return resolveFrame(newPath.head, newPath.tail.head, + newPath, currentLambda, + outer_type_index, + location.prepend(TypePathEntry.WILDCARD)); } case MEMBER_SELECT: { - List newPath = path.tail; - resolveFrame(newPath.head, newPath.tail.head, newPath, p); - return; + final List newPath = path.tail; + return resolveFrame(newPath.head, newPath.tail.head, + newPath, currentLambda, + outer_type_index, location); } default: - Assert.error("Unresolved frame: " + frame + " of kind: " + frame.getKind() + - "\n Looking for tree: " + tree); - return; + throw new AssertionError("Unresolved frame: " + frame + + " of kind: " + frame.getKind() + + "\n Looking for tree: " + tree); } } - private void locateNestedTypes(Type type, TypeAnnotationPosition p) { - // The number of "steps" to get from the full type to the - // left-most outer type. - ListBuffer depth = new ListBuffer<>(); - + private ListBuffer + locateNestedTypes(Type type, + ListBuffer depth) { Type encl = type.getEnclosingType(); while (encl != null && encl.getKind() != TypeKind.NONE && encl.getKind() != TypeKind.ERROR) { - depth = depth.append(TypePathEntry.INNER_TYPE); + depth = depth.prepend(TypePathEntry.INNER_TYPE); encl = encl.getEnclosingType(); } - if (depth.nonEmpty()) { - p.location = p.location.prependList(depth.toList()); - } + return depth; } private int methodParamIndex(List path, JCTree param) { @@ -1048,18 +1103,18 @@ public class TypeAnnotations { } if (sigOnly) { if (!tree.mods.annotations.isEmpty()) { - // Nothing to do for separateAnnotationsKinds if - // there are no annotations of either kind. - TypeAnnotationPosition pos = new TypeAnnotationPosition(); - pos.type = TargetType.METHOD_RETURN; if (tree.sym.isConstructor()) { - pos.pos = tree.pos; - // Use null to mark that the annotations go with the symbol. + final TypeAnnotationPosition pos = + TypeAnnotationPosition.methodReturn(tree.pos); + // Use null to mark that the annotations go + // with the symbol. separateAnnotationsKinds(tree, null, tree.sym, pos); } else { - pos.pos = tree.restype.pos; - separateAnnotationsKinds(tree.restype, tree.sym.type.getReturnType(), - tree.sym, pos); + final TypeAnnotationPosition pos = + TypeAnnotationPosition.methodReturn(tree.restype.pos); + separateAnnotationsKinds(tree.restype, + tree.sym.type.getReturnType(), + tree.sym, pos); } } if (tree.recvparam != null && tree.recvparam.sym != null && @@ -1067,22 +1122,22 @@ public class TypeAnnotations { // Nothing to do for separateAnnotationsKinds if // there are no annotations of either kind. // TODO: make sure there are no declaration annotations. - TypeAnnotationPosition pos = new TypeAnnotationPosition(); - pos.type = TargetType.METHOD_RECEIVER; - pos.pos = tree.recvparam.vartype.pos; - separateAnnotationsKinds(tree.recvparam.vartype, tree.recvparam.sym.type, - tree.recvparam.sym, pos); + final TypeAnnotationPosition pos = + TypeAnnotationPosition.methodReceiver(tree.recvparam.vartype.pos); + separateAnnotationsKinds(tree.recvparam.vartype, + tree.recvparam.sym.type, + tree.recvparam.sym, pos); } int i = 0; for (JCVariableDecl param : tree.params) { if (!param.mods.annotations.isEmpty()) { // Nothing to do for separateAnnotationsKinds if // there are no annotations of either kind. - TypeAnnotationPosition pos = new TypeAnnotationPosition(); - pos.type = TargetType.METHOD_FORMAL_PARAMETER; - pos.parameter_index = i; - pos.pos = param.vartype.pos; - separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos); + final TypeAnnotationPosition pos = + TypeAnnotationPosition.methodParameter(i, param.vartype.pos); + separateAnnotationsKinds(param.vartype, + param.sym.type, + param.sym, pos); } ++i; } @@ -1119,11 +1174,9 @@ public class TypeAnnotations { if (!param.mods.annotations.isEmpty()) { // Nothing to do for separateAnnotationsKinds if // there are no annotations of either kind. - TypeAnnotationPosition pos = new TypeAnnotationPosition(); - pos.type = TargetType.METHOD_FORMAL_PARAMETER; - pos.parameter_index = i; - pos.pos = param.vartype.pos; - pos.onLambda = tree; + final TypeAnnotationPosition pos = + TypeAnnotationPosition.methodParameter(tree, i, + param.vartype.pos); separateAnnotationsKinds(param.vartype, param.sym.type, param.sym, pos); } ++i; @@ -1153,28 +1206,24 @@ public class TypeAnnotations { // Parameters are handled in visitMethodDef or visitLambda. } else if (tree.sym.getKind() == ElementKind.FIELD) { if (sigOnly) { - TypeAnnotationPosition pos = new TypeAnnotationPosition(); - pos.type = TargetType.FIELD; - pos.pos = tree.pos; + TypeAnnotationPosition pos = + TypeAnnotationPosition.field(tree.pos); separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos); } } else if (tree.sym.getKind() == ElementKind.LOCAL_VARIABLE) { - TypeAnnotationPosition pos = new TypeAnnotationPosition(); - pos.type = TargetType.LOCAL_VARIABLE; - pos.pos = tree.pos; - pos.onLambda = currentLambda; + final TypeAnnotationPosition pos = + TypeAnnotationPosition.localVariable(currentLambda, + tree.pos); separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos); } else if (tree.sym.getKind() == ElementKind.EXCEPTION_PARAMETER) { - TypeAnnotationPosition pos = new TypeAnnotationPosition(); - pos.type = TargetType.EXCEPTION_PARAMETER; - pos.pos = tree.pos; - pos.onLambda = currentLambda; + final TypeAnnotationPosition pos = + TypeAnnotationPosition.exceptionParameter(currentLambda, + tree.pos); separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos); } else if (tree.sym.getKind() == ElementKind.RESOURCE_VARIABLE) { - TypeAnnotationPosition pos = new TypeAnnotationPosition(); - pos.type = TargetType.RESOURCE_VARIABLE; - pos.pos = tree.pos; - pos.onLambda = currentLambda; + final TypeAnnotationPosition pos = + TypeAnnotationPosition.resourceVariable(currentLambda, + tree.pos); separateAnnotationsKinds(tree.vartype, tree.sym.type, tree.sym, pos); } else if (tree.sym.getKind() == ElementKind.ENUM_CONSTANT) { // No type annotations can occur here. @@ -1218,7 +1267,8 @@ public class TypeAnnotations { private void copyNewClassAnnotationsToOwner(JCNewClass tree) { Symbol sym = tree.def.sym; - TypeAnnotationPosition pos = new TypeAnnotationPosition(); + final TypeAnnotationPosition pos = + TypeAnnotationPosition.newObj(tree.pos); ListBuffer newattrs = new ListBuffer<>(); for (Attribute.TypeCompound old : sym.getRawTypeAttributes()) { @@ -1226,8 +1276,6 @@ public class TypeAnnotations { pos)); } - pos.type = TargetType.NEW; - pos.pos = tree.pos; sym.owner.appendUniqueTypeAttributes(newattrs.toList()); } @@ -1236,16 +1284,16 @@ public class TypeAnnotations { if (tree.def != null && !tree.def.mods.annotations.isEmpty()) { JCClassDecl classdecl = tree.def; - TypeAnnotationPosition pos = new TypeAnnotationPosition(); - pos.type = TargetType.CLASS_EXTENDS; - pos.pos = tree.pos; + TypeAnnotationPosition pos; + if (classdecl.extending == tree.clazz) { - pos.type_index = -1; + pos = TypeAnnotationPosition.classExtends(tree.pos); } else if (classdecl.implementing.contains(tree.clazz)) { - pos.type_index = classdecl.implementing.indexOf(tree.clazz); + final int index = classdecl.implementing.indexOf(tree.clazz); + pos = TypeAnnotationPosition.classExtends(index, tree.pos); } else { // In contrast to CLASS elsewhere, typarams cannot occur here. - Assert.error("Could not determine position of tree " + tree); + throw new AssertionError("Could not determine position of tree " + tree); } Type before = classdecl.sym.type; separateAnnotationsKinds(classdecl, tree.clazz.type, classdecl.sym, pos); @@ -1273,14 +1321,16 @@ public class TypeAnnotations { // handle annotations associated with dimensions for (int i = 0; i < dimAnnosCount; ++i) { - TypeAnnotationPosition p = new TypeAnnotationPosition(); - p.pos = tree.pos; - p.onLambda = currentLambda; - p.type = TargetType.NEW; + ListBuffer location = + new ListBuffer(); if (i != 0) { depth = depth.append(TypePathEntry.ARRAY); - p.location = p.location.appendList(depth.toList()); + location = location.appendList(depth.toList()); } + final TypeAnnotationPosition p = + TypeAnnotationPosition.newObj(location.toList(), + currentLambda, + tree.pos); setTypeAnnotationPos(tree.dimAnnotations.get(i), p); } @@ -1293,12 +1343,14 @@ public class TypeAnnotations { while (elemType != null) { if (elemType.hasTag(JCTree.Tag.ANNOTATED_TYPE)) { JCAnnotatedType at = (JCAnnotatedType)elemType; - TypeAnnotationPosition p = new TypeAnnotationPosition(); - p.type = TargetType.NEW; - p.pos = tree.pos; - p.onLambda = currentLambda; - locateNestedTypes(elemType.type, p); - p.location = p.location.prependList(depth.toList()); + final ListBuffer locationbuf = + locateNestedTypes(elemType.type, + new ListBuffer()); + final List location = + locationbuf.toList().prependList(depth.toList()); + final TypeAnnotationPosition p = + TypeAnnotationPosition.newObj(location, currentLambda, + tree.pos); setTypeAnnotationPos(at.annotations, p); elemType = at.underlyingType; } else if (elemType.hasTag(JCTree.Tag.TYPEARRAY)) { @@ -1320,9 +1372,9 @@ public class TypeAnnotations { System.err.println(" tree: " + tree + " kind: " + tree.getKind()); System.err.println(" frame: " + frame + " kind: " + frame.getKind()); */ - TypeAnnotationPosition p = new TypeAnnotationPosition(); - p.onLambda = currentLambda; - resolveFrame(tree, frame, frames.toList(), p); + final TypeAnnotationPosition p = + resolveFrame(tree, frame, frames.toList(), currentLambda, 0, + new ListBuffer()); setTypeAnnotationPos(annotations, p); } } diff --git a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java index 981d94f4250..fe0b39a885b 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java +++ b/langtools/src/share/classes/com/sun/tools/javac/comp/Annotate.java @@ -299,7 +299,13 @@ public class Annotate { if (typeAnnotation) { if (a.attribute == null || !(a.attribute instanceof Attribute.TypeCompound)) { // Create a new TypeCompound - Attribute.TypeCompound tc = new Attribute.TypeCompound(a.type, buf.toList(), new TypeAnnotationPosition()); + + Attribute.TypeCompound tc = + new Attribute.TypeCompound(a.type, buf.toList(), + // TODO: Eventually, we will get rid of this use of + // unknown, because we'll get a position from + // MemberEnter (task 8027262). + TypeAnnotationPosition.unknown); a.attribute = tc; return tc; } else { diff --git a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java index 76a81f72e70..ba6fc9e4cf1 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java +++ b/langtools/src/share/classes/com/sun/tools/javac/jvm/ClassReader.java @@ -1469,26 +1469,46 @@ public class ClassReader { if (!TargetType.isValidTargetTypeValue(tag)) throw this.badClassFile("bad.type.annotation.value", String.format("0x%02X", tag)); - TypeAnnotationPosition position = new TypeAnnotationPosition(); TargetType type = TargetType.fromTargetTypeValue(tag); - position.type = type; - switch (type) { // instanceof - case INSTANCEOF: + case INSTANCEOF: { + final int offset = nextChar(); + final TypeAnnotationPosition position = + TypeAnnotationPosition.instanceOf(readTypePath()); + position.offset = offset; + return position; + } // new expression - case NEW: + case NEW: { + final int offset = nextChar(); + final TypeAnnotationPosition position = + TypeAnnotationPosition.newObj(readTypePath()); + position.offset = offset; + return position; + } // constructor/method reference receiver - case CONSTRUCTOR_REFERENCE: - case METHOD_REFERENCE: - position.offset = nextChar(); - break; + case CONSTRUCTOR_REFERENCE: { + final int offset = nextChar(); + final TypeAnnotationPosition position = + TypeAnnotationPosition.constructorRef(readTypePath()); + position.offset = offset; + return position; + } + case METHOD_REFERENCE: { + final int offset = nextChar(); + final TypeAnnotationPosition position = + TypeAnnotationPosition.methodRef(readTypePath()); + position.offset = offset; + return position; + } // local variable - case LOCAL_VARIABLE: - // resource variable - case RESOURCE_VARIABLE: - int table_length = nextChar(); + case LOCAL_VARIABLE: { + final int table_length = nextChar(); + final TypeAnnotationPosition position = + TypeAnnotationPosition.localVariable(readTypePath()); + position.lvarOffset = new int[table_length]; position.lvarLength = new int[table_length]; position.lvarIndex = new int[table_length]; @@ -1498,67 +1518,142 @@ public class ClassReader { position.lvarLength[i] = nextChar(); position.lvarIndex[i] = nextChar(); } - break; + return position; + } + // resource variable + case RESOURCE_VARIABLE: { + final int table_length = nextChar(); + final TypeAnnotationPosition position = + TypeAnnotationPosition.resourceVariable(readTypePath()); + + position.lvarOffset = new int[table_length]; + position.lvarLength = new int[table_length]; + position.lvarIndex = new int[table_length]; + + for (int i = 0; i < table_length; ++i) { + position.lvarOffset[i] = nextChar(); + position.lvarLength[i] = nextChar(); + position.lvarIndex[i] = nextChar(); + } + return position; + } // exception parameter - case EXCEPTION_PARAMETER: - position.exception_index = nextChar(); - break; + case EXCEPTION_PARAMETER: { + final int exception_index = nextChar(); + final TypeAnnotationPosition position = + TypeAnnotationPosition.exceptionParameter(readTypePath()); + position.exception_index = exception_index; + return position; + } // method receiver case METHOD_RECEIVER: - // Do nothing - break; + return TypeAnnotationPosition.methodReceiver(readTypePath()); // type parameter - case CLASS_TYPE_PARAMETER: - case METHOD_TYPE_PARAMETER: - position.parameter_index = nextByte(); - break; + case CLASS_TYPE_PARAMETER: { + final int parameter_index = nextByte(); + return TypeAnnotationPosition + .typeParameter(readTypePath(), parameter_index); + } + case METHOD_TYPE_PARAMETER: { + final int parameter_index = nextByte(); + return TypeAnnotationPosition + .methodTypeParameter(readTypePath(), parameter_index); + } // type parameter bound - case CLASS_TYPE_PARAMETER_BOUND: - case METHOD_TYPE_PARAMETER_BOUND: - position.parameter_index = nextByte(); - position.bound_index = nextByte(); - break; + case CLASS_TYPE_PARAMETER_BOUND: { + final int parameter_index = nextByte(); + final int bound_index = nextByte(); + return TypeAnnotationPosition + .typeParameterBound(readTypePath(), parameter_index, + bound_index); + } + case METHOD_TYPE_PARAMETER_BOUND: { + final int parameter_index = nextByte(); + final int bound_index = nextByte(); + return TypeAnnotationPosition + .methodTypeParameterBound(readTypePath(), parameter_index, + bound_index); + } // class extends or implements clause - case CLASS_EXTENDS: - position.type_index = nextChar(); - break; + case CLASS_EXTENDS: { + final int type_index = nextChar(); + return TypeAnnotationPosition.classExtends(readTypePath(), + type_index); + } // throws - case THROWS: - position.type_index = nextChar(); - break; + case THROWS: { + final int type_index = nextChar(); + return TypeAnnotationPosition.methodThrows(readTypePath(), + type_index); + } // method parameter - case METHOD_FORMAL_PARAMETER: - position.parameter_index = nextByte(); - break; + case METHOD_FORMAL_PARAMETER: { + final int parameter_index = nextByte(); + return TypeAnnotationPosition.methodParameter(readTypePath(), + parameter_index); + } // type cast - case CAST: + case CAST: { + final int offset = nextChar(); + final int type_index = nextByte(); + final TypeAnnotationPosition position = + TypeAnnotationPosition.typeCast(readTypePath(), type_index); + position.offset = offset; + return position; + } // method/constructor/reference type argument - case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT: - case METHOD_INVOCATION_TYPE_ARGUMENT: - case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT: - case METHOD_REFERENCE_TYPE_ARGUMENT: - position.offset = nextChar(); - position.type_index = nextByte(); - break; + case CONSTRUCTOR_INVOCATION_TYPE_ARGUMENT: { + final int offset = nextChar(); + final int type_index = nextByte(); + final TypeAnnotationPosition position = TypeAnnotationPosition + .constructorInvocationTypeArg(readTypePath(), type_index); + position.offset = offset; + return position; + } + case METHOD_INVOCATION_TYPE_ARGUMENT: { + final int offset = nextChar(); + final int type_index = nextByte(); + final TypeAnnotationPosition position = TypeAnnotationPosition + .methodInvocationTypeArg(readTypePath(), type_index); + position.offset = offset; + return position; + } + case CONSTRUCTOR_REFERENCE_TYPE_ARGUMENT: { + final int offset = nextChar(); + final int type_index = nextByte(); + final TypeAnnotationPosition position = TypeAnnotationPosition + .constructorRefTypeArg(readTypePath(), type_index); + position.offset = offset; + return position; + } + case METHOD_REFERENCE_TYPE_ARGUMENT: { + final int offset = nextChar(); + final int type_index = nextByte(); + final TypeAnnotationPosition position = TypeAnnotationPosition + .methodRefTypeArg(readTypePath(), type_index); + position.offset = offset; + return position; + } // We don't need to worry about these case METHOD_RETURN: + return TypeAnnotationPosition.methodReturn(readTypePath()); case FIELD: - break; + return TypeAnnotationPosition.field(readTypePath()); case UNKNOWN: throw new AssertionError("jvm.ClassReader: UNKNOWN target type should never occur!"); default: - throw new AssertionError("jvm.ClassReader: Unknown target type for position: " + position); + throw new AssertionError("jvm.ClassReader: Unknown target type for position: " + type); } + } - { // See whether there is location info and read it - int len = nextByte(); - ListBuffer loc = new ListBuffer<>(); - for (int i = 0; i < len * TypeAnnotationPosition.TypePathEntry.bytesPerEntry; ++i) - loc = loc.append(nextByte()); - position.location = TypeAnnotationPosition.getTypePathFromBinary(loc.toList()); - } + List readTypePath() { + int len = nextByte(); + ListBuffer loc = new ListBuffer<>(); + for (int i = 0; i < len * TypeAnnotationPosition.TypePathEntry.bytesPerEntry; ++i) + loc = loc.append(nextByte()); + + return TypeAnnotationPosition.getTypePathFromBinary(loc.toList()); - return position; } Attribute readAttributeValue() { diff --git a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java index ccaa833e461..10eae9fcf87 100644 --- a/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/JCTree.java @@ -2299,6 +2299,9 @@ public abstract class JCTree implements Tree, Cloneable, DiagnosticPosition { // Attribute.Compound if tag is ANNOTATION // Attribute.TypeCompound if tag is TYPE_ANNOTATION + // + // NOTE: This field is slated for removal in the future. Do + // not use it for anything new. public Attribute.Compound attribute; protected JCAnnotation(Tag tag, JCTree annotationType, List args) { From a80e3ed0ee72e396578df5bdfce82041780d8035 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 3 Feb 2014 22:26:26 -0800 Subject: [PATCH 097/159] 8033527: Fix raw type lint warning in sun.nio.ch Reviewed-by: henryjen, mchung --- jdk/src/share/classes/sun/nio/ch/Reflect.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/src/share/classes/sun/nio/ch/Reflect.java b/jdk/src/share/classes/sun/nio/ch/Reflect.java index 3ef3d9309f0..fc5276c53c4 100644 --- a/jdk/src/share/classes/sun/nio/ch/Reflect.java +++ b/jdk/src/share/classes/sun/nio/ch/Reflect.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -75,7 +75,7 @@ class Reflect { // package-private static Method lookupMethod(String className, String methodName, - Class... paramTypes) + Class... paramTypes) { try { Class cl = Class.forName(className); From 6c54a7ef11b18d547db38372ab0490f6ab7acde4 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Tue, 4 Feb 2014 10:00:24 +0100 Subject: [PATCH 098/159] 8033236: Update GensrcCharsetMapping.gmk to build-infra standards Reviewed-by: erikj, mduigou, sherman --- jdk/make/GenerateSources.gmk | 1 + jdk/make/Tools.gmk | 2 +- .../data/charsetmapping}/standard-charsets | 7 +- jdk/make/gensrc/GensrcCharsetMapping.gmk | 181 ++++++++++++------ jdk/make/scripts/genCharsetProvider.sh | 131 ------------- .../classes/build/tools/hasher/Hasher.java | 15 +- .../sun/nio/cs/StandardCharsets.java.template | 48 +++++ 7 files changed, 184 insertions(+), 201 deletions(-) rename jdk/{src/share/classes/sun/nio/cs => make/data/charsetmapping}/standard-charsets (97%) delete mode 100644 jdk/make/scripts/genCharsetProvider.sh create mode 100644 jdk/src/share/classes/sun/nio/cs/StandardCharsets.java.template diff --git a/jdk/make/GenerateSources.gmk b/jdk/make/GenerateSources.gmk index ba443f7da52..732c0c83f8a 100644 --- a/jdk/make/GenerateSources.gmk +++ b/jdk/make/GenerateSources.gmk @@ -29,6 +29,7 @@ include $(SPEC) include MakeBase.gmk include JavaCompilation.gmk include NativeCompilation.gmk +include TextFileProcessing.gmk # Setup the java compilers for the JDK build. include Setup.gmk diff --git a/jdk/make/Tools.gmk b/jdk/make/Tools.gmk index 1c3b791f621..2336ed4ce98 100644 --- a/jdk/make/Tools.gmk +++ b/jdk/make/Tools.gmk @@ -102,7 +102,7 @@ TOOL_JDWPGEN = $(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses build.tools.jdwpgen.Main # TODO: Lots of files in jdk/make/tools/CharsetMapping dir TOOL_CHARSETMAPPING = $(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \ - build.tools.charsetmapping.Main + build.tools.charsetmapping.Main $(LOG_INFO) TOOL_SPP = $(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses build.tools.spp.Spp diff --git a/jdk/src/share/classes/sun/nio/cs/standard-charsets b/jdk/make/data/charsetmapping/standard-charsets similarity index 97% rename from jdk/src/share/classes/sun/nio/cs/standard-charsets rename to jdk/make/data/charsetmapping/standard-charsets index 0785a4edafc..f9f4db12c6a 100644 --- a/jdk/src/share/classes/sun/nio/cs/standard-charsets +++ b/jdk/make/data/charsetmapping/standard-charsets @@ -1,5 +1,5 @@ # -# Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -34,11 +34,6 @@ # compared to the charsets packaged in "ExtendedCharsets" provider, # which is lazy initialized. -# This year should only change if the generated source is modified. -copyright 2000, 2007, -package sun.nio.cs -class StandardCharsets - charset US-ASCII US_ASCII # IANA aliases diff --git a/jdk/make/gensrc/GensrcCharsetMapping.gmk b/jdk/make/gensrc/GensrcCharsetMapping.gmk index 5624ebfae4b..821f4e03071 100644 --- a/jdk/make/gensrc/GensrcCharsetMapping.gmk +++ b/jdk/make/gensrc/GensrcCharsetMapping.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2012, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -25,80 +25,151 @@ GENSRC_CHARSETMAPPING := -GENSRC_TMP := $(JDK_OUTPUTDIR)/gensrc -GENSRC_DST := $(JDK_OUTPUTDIR)/gensrc/sun/nio/cs - -GENSRC_DATA := $(JDK_TOPDIR)/make/data/charsetmapping -GENSRC_JAVA_SRC := $(JDK_TOPDIR)/make/src/classes/build/tools/charsetmapping - -GENSRC_TEMPLATES := $(GENSRC_DATA)/SingleByte-X.java.template $(GENSRC_DATA)/DoubleByte-X.java.template +CHARSET_DATA_DIR := $(JDK_TOPDIR)/make/data/charsetmapping ### - -$(GENSRC_TMP)/_the.charsetmapping.dir: - $(ECHO) Generating charsetmapping classes - $(MKDIR) -p $(GENSRC_DST)/ext - $(TOUCH) $@ - +### Generate files using the charsetmapping tool ### -GENSRC_SB := $(GENSRC_TMP)/_the.charsetmapping.sbcs +CHARSET_GENSRC_JAVA_DIR := $(JDK_OUTPUTDIR)/gensrc/sun/nio/cs +CHARSET_DONE := $(CHARSET_GENSRC_JAVA_DIR)/_the.charsetmapping +CHARSET_COPYRIGHT_HEADER_BASE := $(JDK_TOPDIR)/make/src/classes/build/tools/charsetmapping +CHARSET_TEMPLATES := \ + $(CHARSET_DATA_DIR)/SingleByte-X.java.template \ + $(CHARSET_DATA_DIR)/DoubleByte-X.java.template -$(GENSRC_SB): $(GENSRC_DATA)/sbcs $(GENSRC_TEMPLATES) $(GENSRC_TMP)/_the.charsetmapping.dir - $(TOOL_CHARSETMAPPING) $(LOG_INFO) $(GENSRC_DATA) $(GENSRC_DST) sbcs - $(TOUCH) $@ +# This target should be referenced using the order-only operator (|) +$(CHARSET_GENSRC_JAVA_DIR)/ext: + $(ECHO) "Generating charset mappings" + $(MKDIR) -p $(CHARSET_GENSRC_JAVA_DIR)/ext -GENSRC_CHARSETMAPPING += $(GENSRC_SB) +$(CHARSET_DONE)-sbcs: $(CHARSET_DATA_DIR)/sbcs \ + $(CHARSET_TEMPLATES) $(BUILD_TOOLS) | $(CHARSET_GENSRC_JAVA_DIR)/ext + $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR) sbcs + $(TOUCH) '$@' + +$(CHARSET_DONE)-extsbcs: $(CHARSET_DATA_DIR)/extsbcs \ + $(CHARSET_DONE)-sbcs $(CHARSET_TEMPLATES) $(BUILD_TOOLS) + $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR)/ext extsbcs + $(TOUCH) '$@' + +$(CHARSET_DONE)-dbcs: $(CHARSET_DATA_DIR)/dbcs \ + $(CHARSET_DONE)-sbcs $(CHARSET_TEMPLATES) $(BUILD_TOOLS) + $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR)/ext dbcs + $(TOUCH) '$@' + +$(CHARSET_DONE)-hkscs: $(CHARSET_COPYRIGHT_HEADER_BASE)/HKSCS.java \ + $(CHARSET_DONE)-sbcs $(BUILD_TOOLS) + $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR)/ext hkscs '$<' + $(TOUCH) '$@' + +$(CHARSET_DONE)-euctw: $(CHARSET_COPYRIGHT_HEADER_BASE)/EUC_TW.java \ + $(CHARSET_DONE)-sbcs $(BUILD_TOOLS) + $(TOOL_CHARSETMAPPING) $(CHARSET_DATA_DIR) $(CHARSET_GENSRC_JAVA_DIR)/ext euctw '$<' + $(TOUCH) '$@' + +$(CHARSET_GENSRC_JAVA_DIR)/ext/sjis0213.dat: $(CHARSET_DATA_DIR)/sjis0213.map \ + $(CHARSET_DONE)-sbcs $(BUILD_TOOLS) + $(TOOL_CHARSETMAPPING) '$<' '$@' sjis0213 + +GENSRC_CHARSETMAPPING += \ + $(CHARSET_DONE)-sbcs \ + $(CHARSET_DONE)-extsbcs \ + $(CHARSET_DONE)-dbcs \ + $(CHARSET_DONE)-hkscs \ + $(CHARSET_DONE)-euctw \ + $(CHARSET_GENSRC_JAVA_DIR)/ext/sjis0213.dat \ + # ### - -$(GENSRC_DST)/ext/sjis0213.dat: $(GENSRC_DATA)/sjis0213.map $(GENSRC_SB) - $(TOOL_CHARSETMAPPING) $(LOG_INFO) $< $@ sjis0213 - -GENSRC_CHARSETMAPPING += $(GENSRC_DST)/ext/sjis0213.dat - +### Generate the sun/nio/cs/StandardCharsets.java file ### -$(GENSRC_DST)/ext/EUC_TWMapping.java: $(GENSRC_JAVA_SRC)/EUC_TW.java $(GENSRC_SB) - $(TOOL_CHARSETMAPPING) $(LOG_INFO) $(GENSRC_DATA) $(GENSRC_DST)/ext euctw $(GENSRC_JAVA_SRC)/EUC_TW.java +CHARSET_STANDARD_GENSRC_DIR := $(JDK_OUTPUTDIR)/gensrc/standardcharsets +CHARSET_STANDARD_DATA := $(CHARSET_DATA_DIR)/standard-charsets +CHARSET_STANDARD_JAVA := sun/nio/cs/StandardCharsets.java -GENSRC_CHARSETMAPPING += $(GENSRC_DST)/ext/EUC_TWMapping.java +CHARSET_ALIASES_TABLES_AWK := ' \ + BEGIN { n = 1; m = 1; } \ + /^[ \t]*charset / { \ + csn = $$2; cln = $$3; \ + lcsn = tolower(csn); \ + lcsns[n++] = lcsn; \ + csns[lcsn] = csn; \ + classMap[lcsn] = cln; \ + if (n > 2) \ + printf " };\n\n"; \ + printf " static final String[] aliases_%s = new String[] {\n", cln; \ + } \ + /^[ \t]*alias / { \ + acsns[m++] = tolower($$2); \ + aliasMap[tolower($$2)] = lcsn; \ + printf " \"%s\",\n", $$2; \ + } \ + END { \ + printf " };\n\n"; \ + } ' -### +CHARSET_ALIASES_MAP_AWK := ' \ + /^[ \t]*charset / { \ + csn = $$2; \ + lcsn = tolower(csn); \ + } \ + /^[ \t]*alias / { \ + an = tolower($$2); \ + printf "%-20s \"%s\"\n", an, lcsn; \ + } ' -$(GENSRC_DST)/ext/HKSCSMapping.java: $(GENSRC_JAVA_SRC)/HKSCS.java $(GENSRC_SB) - $(TOOL_CHARSETMAPPING) $(LOG_INFO) $(GENSRC_DATA) $(GENSRC_DST)/ext hkscs $(GENSRC_JAVA_SRC)/HKSCS.java +CHARSET_CLASSES_MAP_AWK := ' \ + /^[ \t]*charset / { \ + csn = $$2; cln = $$3; \ + lcsn = tolower(csn); \ + printf "%-20s \"%s\"\n", lcsn, cln; \ + } ' -GENSRC_CHARSETMAPPING += $(GENSRC_DST)/ext/HKSCSMapping.java +# This target should be referenced using the order-only operator (|) +$(CHARSET_STANDARD_GENSRC_DIR): + $(MKDIR) -p '$@' -### +$(CHARSET_STANDARD_GENSRC_DIR)/aliases-tables.java.snippet: $(CHARSET_STANDARD_DATA) \ + | $(CHARSET_STANDARD_GENSRC_DIR) + $(NAWK) < '$<' > '$@' $(CHARSET_ALIASES_TABLES_AWK) -$(GENSRC_TMP)/gensrc_the.charsetmapping.extsbcs: $(GENSRC_DATA)/extsbcs $(GENSRC_TEMPLATES) $(GENSRC_SB) - $(TOOL_CHARSETMAPPING) $(GENSRC_DATA) $(LOG_INFO) $(GENSRC_DST)/ext extsbcs - $(TOUCH) $@ +$(CHARSET_STANDARD_GENSRC_DIR)/aliases-map: $(CHARSET_STANDARD_DATA) \ + | $(CHARSET_STANDARD_GENSRC_DIR) + $(NAWK) < '$<' > '$@' $(CHARSET_ALIASES_MAP_AWK) -GENSRC_CHARSETMAPPING += $(GENSRC_TMP)/gensrc_the.charsetmapping.extsbcs +$(CHARSET_STANDARD_GENSRC_DIR)/classes-map: $(CHARSET_STANDARD_DATA) \ + | $(CHARSET_STANDARD_GENSRC_DIR) + $(NAWK) < '$<' > '$@' $(CHARSET_CLASSES_MAP_AWK) -### +$(CHARSET_STANDARD_GENSRC_DIR)/aliases-map.java.snippet: $(CHARSET_STANDARD_GENSRC_DIR)/aliases-map \ + $(BUILD_TOOLS) | $(CHARSET_STANDARD_GENSRC_DIR) + $(TOOL_HASHER) -i Aliases < '$<' > '$@' -$(GENSRC_TMP)/gensrc_the.charsetmapping.dbcs: $(GENSRC_DATA)/dbcs $(GENSRC_TEMPLATES) $(GENSRC_SB) - $(TOOL_CHARSETMAPPING) $(GENSRC_DATA) $(LOG_INFO) $(GENSRC_DST)/ext dbcs - $(TOUCH) $@ +$(CHARSET_STANDARD_GENSRC_DIR)/classes-map.java.snippet: $(CHARSET_STANDARD_GENSRC_DIR)/classes-map \ + $(BUILD_TOOLS) | $(CHARSET_STANDARD_GENSRC_DIR) + $(TOOL_HASHER) -i Classes < '$<' > '$@' -GENSRC_CHARSETMAPPING += $(GENSRC_TMP)/gensrc_the.charsetmapping.dbcs +$(CHARSET_STANDARD_GENSRC_DIR)/cache-map.java.snippet: $(CHARSET_STANDARD_GENSRC_DIR)/classes-map \ + $(BUILD_TOOLS) | $(CHARSET_STANDARD_GENSRC_DIR) + $(TOOL_HASHER) -i -e Cache -t Charset < '$<' > '$@' -### +$(eval $(call SetupTextFileProcessing, BUILD_CHARSET_STANDARD, \ + SOURCE_FILES := $(JDK_TOPDIR)/src/share/classes/$(CHARSET_STANDARD_JAVA).template, \ + OUTPUT_FILE := $(JDK_OUTPUTDIR)/gensrc/$(CHARSET_STANDARD_JAVA), \ + INCLUDES := \ + _INCLUDE_ALIASES_TABLES_ => $(CHARSET_STANDARD_GENSRC_DIR)/aliases-tables.java.snippet ; \ + _INCLUDE_ALIASES_MAP_ => $(CHARSET_STANDARD_GENSRC_DIR)/aliases-map.java.snippet ; \ + _INCLUDE_CLASSES_MAP_ => $(CHARSET_STANDARD_GENSRC_DIR)/classes-map.java.snippet ; \ + _INCLUDE_CACHE_MAP_ => $(CHARSET_STANDARD_GENSRC_DIR)/cache-map.java.snippet ; , \ +)) -GENSRC_CHARSET_PROVIDER_CMD := $(JDK_TOPDIR)/make/scripts/genCharsetProvider.sh +# Processing of template depends on the snippets being generated first +$(BUILD_CHARSET_STANDARD): \ + $(CHARSET_STANDARD_GENSRC_DIR)/aliases-tables.java.snippet \ + $(CHARSET_STANDARD_GENSRC_DIR)/aliases-map.java.snippet \ + $(CHARSET_STANDARD_GENSRC_DIR)/classes-map.java.snippet \ + $(CHARSET_STANDARD_GENSRC_DIR)/cache-map.java.snippet -$(GENSRC_DST)/StandardCharsets.java: $(JDK_TOPDIR)/src/share/classes/sun/nio/cs/standard-charsets \ - $(GENSRC_CHARSET_PROVIDER_CMD) \ - $(GENSRC_TMP)/_the.charsetmapping.dir - NAWK="$(NAWK)" TEMPDIR="$(GENSRC_TMP)" SH="$(SH)" \ - HASHER="$(TOOL_HASHER)" \ - SCRIPTS="$(JDK_TOPDIR)/make/scripts" \ - $(SH) -e $(GENSRC_CHARSET_PROVIDER_CMD) $(LOG_INFO) $< $(@D) - -GENSRC_CHARSETMAPPING += $(GENSRC_DST)/StandardCharsets.java - -$(GENSRC_CHARSETMAPPING): $(BUILD_TOOLS) +GENSRC_CHARSETMAPPING += $(BUILD_CHARSET_STANDARD) diff --git a/jdk/make/scripts/genCharsetProvider.sh b/jdk/make/scripts/genCharsetProvider.sh deleted file mode 100644 index d14527483a4..00000000000 --- a/jdk/make/scripts/genCharsetProvider.sh +++ /dev/null @@ -1,131 +0,0 @@ -#! /bin/sh - -# -# Copyright (c) 2004, 2012, Oracle and/or its affiliates. All rights reserved. -# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. -# -# This code is free software; you can redistribute it and/or modify it -# under the terms of the GNU General Public License version 2 only, as -# published by the Free Software Foundation. Oracle designates this -# particular file as subject to the "Classpath" exception as provided -# by Oracle in the LICENSE file that accompanied this code. -# -# This code is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or -# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License -# version 2 for more details (a copy is included in the LICENSE file that -# accompanied this code). -# -# You should have received a copy of the GNU General Public License version -# 2 along with this work; if not, write to the Free Software Foundation, -# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. -# -# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA -# or visit www.oracle.com if you need additional information or have any -# questions. -# - -# Generate a charset provider class - -# Required environment variables -# NAWK awk tool -# TEMPDIR temporary directory -# HASHER Hasher program - -SPEC=$1; shift -DST=$1; shift - -eval `$NAWK <$SPEC ' - /^[ \t]*copyright / { printf "COPYRIGHT_YEARS=\"%s %s\"\n", $2, $3; } - /^[ \t]*package / { printf "PKG=%s\n", $2; } - /^[ \t]*class / { printf "CLASS=%s\n", $2; } -'` - -OUT=$DST/$CLASS.java -echo '-->' $OUT - - -# Header -# - -$SH ${SCRIPTS}/addNotices.sh "$COPYRIGHT_YEARS" > $OUT - -cat <<__END__ >>$OUT - -// -- This file was mechanically generated: Do not edit! -- // - -package $PKG; - -import java.nio.charset.*; - - -public class $CLASS - extends FastCharsetProvider -{ - -__END__ - - -# Alias tables -# -$NAWK <$SPEC >>$OUT ' - BEGIN { n = 1; m = 1; } - - /^[ \t]*charset / { - csn = $2; cln = $3; - lcsn = tolower(csn); - lcsns[n++] = lcsn; - csns[lcsn] = csn; - classMap[lcsn] = cln; - if (n > 2) - printf " };\n\n"; - printf " static final String[] aliases_%s = new String[] {\n", cln; - } - - /^[ \t]*alias / { - acsns[m++] = tolower($2); - aliasMap[tolower($2)] = lcsn; - printf " \"%s\",\n", $2; - } - - END { - printf " };\n\n"; - } -' - - -# Prehashed alias and class maps -# -$NAWK <$SPEC >$TEMPDIR/aliases ' - /^[ \t]*charset / { - csn = $2; - lcsn = tolower(csn); - } - /^[ \t]*alias / { - an = tolower($2); - printf "%-20s \"%s\"\n", an, lcsn; - } -' - -$NAWK <$SPEC >$TEMPDIR/classes ' - /^[ \t]*charset / { - csn = $2; cln = $3; - lcsn = tolower(csn); - printf "%-20s \"%s\"\n", lcsn, cln; - } -' - -${HASHER} -i Aliases <$TEMPDIR/aliases >>$OUT -${HASHER} -i Classes <$TEMPDIR/classes >>$OUT -${HASHER} -i -e Cache -t Charset <$TEMPDIR/classes >>$OUT - - -# Constructor -# -cat <<__END__ >>$OUT - public $CLASS() { - super("$PKG", new Aliases(), new Classes(), new Cache()); - } - -} -__END__ diff --git a/jdk/make/src/classes/build/tools/hasher/Hasher.java b/jdk/make/src/classes/build/tools/hasher/Hasher.java index bf041976ef2..058655e767c 100644 --- a/jdk/make/src/classes/build/tools/hasher/Hasher.java +++ b/jdk/make/src/classes/build/tools/hasher/Hasher.java @@ -43,9 +43,6 @@ import java.util.*; public class Hasher { - // This class cannot, sadly, make use of 1.5 features since it must be - // compiled and run with the bootstrap JDK, which is 1.4.2. - static final PrintStream out = System.out; static final PrintStream err = System.err; @@ -184,11 +181,13 @@ public class Hasher { if (md <= maxDepth) { // Success out.flush(); - if (cln != null) - err.print(cln + ": "); - err.println("Table size " + (1 << nb) + " (" + nb + " bits)" - + ", shift " + shift - + ", max chain depth " + md); + if (verbose) { + if (cln != null) + err.print(cln + ": "); + err.println("Table size " + (1 << nb) + " (" + nb + " bits)" + + ", shift " + shift + + ", max chain depth " + md); + } return this; } } diff --git a/jdk/src/share/classes/sun/nio/cs/StandardCharsets.java.template b/jdk/src/share/classes/sun/nio/cs/StandardCharsets.java.template new file mode 100644 index 00000000000..468934b017a --- /dev/null +++ b/jdk/src/share/classes/sun/nio/cs/StandardCharsets.java.template @@ -0,0 +1,48 @@ +/* + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. Oracle designates this + * particular file as subject to the "Classpath" exception as provided + * by Oracle in the LICENSE file that accompanied this code. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +// -- This file was mechanically generated: Do not edit! -- // + +package sun.nio.cs; + +import java.nio.charset.*; + + +public class StandardCharsets + extends FastCharsetProvider +{ + + _INCLUDE_ALIASES_TABLES_ + _INCLUDE_ALIASES_MAP_ + _INCLUDE_CLASSES_MAP_ + _INCLUDE_CACHE_MAP_ + + public StandardCharsets() { + super("sun.nio.cs", new Aliases(), new Classes(), new Cache()); + } + +} From f9c28e97a25ae0a75dd77ffd2b11c81f0a32e321 Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Tue, 4 Feb 2014 10:01:20 +0100 Subject: [PATCH 099/159] 8033236: Update GensrcCharsetMapping.gmk to build-infra standards Reviewed-by: erikj, mduigou, sherman --- common/autoconf/spec.gmk.in | 2 + make/common/TextFileProcessing.gmk | 234 +++++++++++++++++++++++++++++ 2 files changed, 236 insertions(+) create mode 100644 make/common/TextFileProcessing.gmk diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index 4342d1517ee..b92db9125da 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -37,6 +37,8 @@ X:= SPACE:=$(X) $(X) COMMA:=, HASH:=\# +LEFT_PAREN:=( +RIGHT_PAREN:=) SQUOTE:=' #' DQUOTE:=" diff --git a/make/common/TextFileProcessing.gmk b/make/common/TextFileProcessing.gmk new file mode 100644 index 00000000000..f5101626b0d --- /dev/null +++ b/make/common/TextFileProcessing.gmk @@ -0,0 +1,234 @@ +# +# Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +define EvalDebugWrapper + $(if $(DEBUG_$1), + $(info -------- <<< Begin expansion of $1) + $(info $2) + $(info -------- >>> End expansion of $1) + ) + + $2 +endef + +# Helper function for SetupTextFileProcessing; adds a rule for a single file +# to be processed. +# param 1 = The namespace argument, e.g. BUILD_VERSION_FILE +# param 2 = the source file name (full path) +# param 3 = the target base directory +# param 4 = the target file name (possibly with a partial path) +define SetupSingleTextFileForProcessing + $(strip $3)/$(strip $4): $2 + $(ECHO) $(LOG_INFO) "Processing $(strip $4)" + $(MKDIR) -p '$$(@D)' + $(RM) '$$@' '$$@.includes.tmp' '$$@.replacements.tmp' + $$($1_INCLUDES_COMMAND_LINE) < '$$<' > '$$@.includes.tmp' + $$($1_REPLACEMENTS_COMMAND_LINE) < '$$@.includes.tmp' > '$$@.replacements.tmp' + $(RM) '$$@.includes.tmp' + $(MV) '$$@.replacements.tmp' '$$@' + + $1 += $(strip $3)/$(strip $4) +endef + +# Setup a text file for processing, in which specified markers are replaced with +# a given text, or with the contents of a given file. +# +# param 1 is the name space for this setup, e.g. BUILD_VERSION_FILE +# param 2, 3, .. etc are named args: +# SOURCE_DIRS one or more directory roots to search for files to process +# SOURCE_FILES complete paths to one or more files to process +# OUTPUT_DIR the directory where we store the processed files. +# OUTPUT_FILE the name of the resulting file. Only allowed if processing a +# single file. +# SOURCE_BASE_DIR a common root to all SOURCE_DIRS. +# If specified, files will keep the path relative to the base in the +# OUTPUT_DIR. Otherwise, the hierarchy will be flattened into the OUTPUT_DIR. +# INCLUDE_FILES only include files matching these patterns (used only with +# SOURCE_DIRS) +# EXCLUDE_FILES exclude files matching these patterns (used only with +# SOURCE_DIRS) +# INCLUDES replace the occurances of a pattern with the contents of a file; +# one or more such include pattern, using the syntax: +# PLACEHOLDER => FILE_TO_INCLUDE ; ... +# Each PLACEHOLDER must be on a single, otherwise empty line (whitespace +# padding is allowed). +# REPLACEMENTS one or more text replacement patterns, using the syntax: +# PATTERN => REPLACEMENT_TEXT ; ... +# +# At least one of INCLUDES or REPLACEMENTS must be present. If both are +# present, then the includes will be processed first, and replacements will be +# done on the included fragments as well. +# +define SetupTextFileProcessing + $(if $(16),$(error Internal makefile error: Too many arguments to SetupTextFileProcessing, please update TextFileProcessing.gmk)) + $(call EvalDebugWrapper,$(strip $1),$(call SetupTextFileProcessingInner,$(strip $1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15))) +endef + +define SetupTextFileProcessingInner + $(foreach i,2 3 4 5 6 7 8 9 10 11 12 13 14 15, $(if $(strip $($i)),$1_$(strip $($i)))$(NEWLINE)) + $(call LogSetupMacroEntry,SetupTextFileProcessing($1),$2,$3,$4,$5,$6,$7,$8,$9,$(10),$(11),$(12),$(13),$(14),$(15)) + $(if $(16),$(error Internal makefile error: Too many arguments to SetupTextFileProcessing, please update TextFileProcessing.gmk)) + + ifeq ($$($1_REPLACEMENTS)$$($1_INCLUDES),) + $$(error At least one of REPLACEMENTS or INCLUDES are required for $1) + endif + + ifneq ($$($1_SOURCE_FILES),) + ifneq ($$($1_SOURCE_DIRS),) + $$(error Cannot use both SOURCE_FILES and SOURCE_DIRS (in $1)) + endif + ifneq ($$($1_SOURCE_BASE_DIR),) + $$(error Cannot use SOURCE_BASE_DIR without SOURCE_DIRS (in $1)) + endif + ifneq ($$($1_EXCLUDE_FILES)$$($1_INCLUDE_FILES),) + $$(error Cannot INCLUDE/EXCLUDE_FILES with SOURCE_FILES (in $1)) + endif + else + # Find all files in the source trees. Sort to remove duplicates. + $$(foreach src, $$($1_SOURCE_DIRS), $$(if $$(wildcard $$(src)), , \ + $$(error SOURCE_DIRS contains missing directory $$(src) (in $1)))) + ifneq ($$($1_SOURCE_BASE_DIR),) + $$(foreach src, $$($1_SOURCE_DIRS), \ + $$(if $$(findstring $$($1_SOURCE_BASE_DIR), $$(src)), , \ + $$(error SOURCE_DIRS contains directory $$(src) outside \ + SOURCE_BASE_DIR $$($1_SOURCE_BASE_DIR) (in $1)))) + endif + $1_SOURCE_FILES := $$(sort $$(call CacheFind,$$($1_SOURCE_DIRS))) + $1_EXCLUDE_FILES:=$$(foreach i,$$($1_SOURCE_DIRS),$$(addprefix $$i/,$$($1_EXCLUDE_FILES))) + $1_INCLUDE_FILES:=$$(foreach i,$$($1_SOURCE_DIRS),$$(addprefix $$i/,$$($1_INCLUDE_FILES))) + $1_SOURCE_FILES := $$(filter-out $$($1_EXCLUDE_FILES),$$($1_SOURCE_FILES)) + ifneq (,$$(strip $$($1_INCLUDE_FILES))) + $1_SOURCE_FILES := $$(filter $$($1_INCLUDE_FILES),$$($1_SOURCE_FILES)) + endif + ifeq (,$$($1_SOURCE_FILES)) + $$(info No sources found for $1 when looking inside the dirs $$($1_SRC)) + endif + endif + + ifneq ($$($1_REPLACEMENTS),) + # We have a replacement request, prepare it for the recipe + ifneq ($$(findstring /,$$($1_REPLACEMENTS)),) + # Cannot use / as separator + ifneq ($$(findstring @,$$($1_REPLACEMENTS)),) + # Cannot use @ as separator + ifneq ($$(findstring |,$$($1_REPLACEMENTS)),) + # Cannot use | as separator + ifneq ($$(findstring !,$$($1_REPLACEMENTS)),) + # Cannot use ! as separator. Give up. + $$(error No suitable sed separator can be found for $1. Tested /, @, | and !) + else + $1_SEP := ! + endif + else + $1_SEP := | + endif + else + $1_SEP := @ + endif + else + $1_SEP := / + endif + + # If we have a trailing "=>" (i.e. last rule replaces with empty, and is not + # terminated by a ;), add a trailing ; to minimize the number of corner + # cases in the hairy subst expression.. + ifeq ($$(lastword $$($1_REPLACEMENTS)), =>) + $1_REPLACEMENTS += ; + endif + + # If we have a trailing ";", add a dummy replacement, since there is no easy + # way to delete the last word in make. + ifeq ($$(lastword $$($1_REPLACEMENTS)), ;) + $1_REPLACEMENTS += DUMMY_REPLACEMENT => DUMMY_REPLACEMENT + endif + + # Convert the REPLACEMENTS syntax ( A => B ; C => D ; ...) to a sed command + # line (-e "s/A/B/" -e "s/C/D/" ...), basically by replacing '=>' with '/' + # and ';' with '/" -e "s/', and adjusting for edge cases. + $1_REPLACEMENTS_COMMAND_LINE := $(SED) -e "s$$($1_SEP)$$(subst $$(SPACE);$$(SPACE),$$($1_SEP)" \ + -e "s$$($1_SEP),$$(subst $$(SPACE)=>$$(SPACE),$$($1_SEP),$$(subst $$(SPACE)=>$$(SPACE);$$(SPACE),//" \ + -e "s$$($1_SEP),$$(strip $$($1_REPLACEMENTS)))))$$($1_SEP)" + else + # We don't have any replacements, just pipe the file through cat. + $1_REPLACEMENTS_COMMAND_LINE := $(CAT) + endif + + ifneq ($$($1_INCLUDES),) + # We have a include request, prepare it for the recipe. + # Convert an INCLUDE like this PATTERN_1 => file1 ; PATTERN_2 => file2 ; + # into an awk script fragment like this: + # { + # if (matches("PATTERN_1")) { include("file1") } else + # if (matches("PATTERN_2")) { include("file2") } else + # print + # } + + $1_INCLUDES_HEADER_AWK := \ + function matches(pattern) { return ($$$$0 ~ "^[ \t]*" pattern "[ \t]*$$$$") } \ + function include(filename) { while ((getline < filename) == 1) print ; close(filename) } + $1_INCLUDES_PARTIAL_AWK := $$(subst $$(SPACE);,,$$(subst $$(SPACE)=>$$(SPACE),"$$(RIGHT_PAREN)$$(RIGHT_PAREN) \ + { include$$(LEFT_PAREN)",$$(subst $$(SPACE);$$(SPACE),"$$(RIGHT_PAREN) } \ + else if $$(LEFT_PAREN)matches$$(LEFT_PAREN)",$$(strip $$($1_INCLUDES))))) + $1_INCLUDES_COMMAND_LINE := $(NAWK) '$$($1_INCLUDES_HEADER_AWK) \ + { if (matches("$$($1_INCLUDES_PARTIAL_AWK)") } else print }' + else + # We don't have any includes, just pipe the file through cat. + $1_INCLUDES_COMMAND_LINE := $(CAT) + endif + + # Reset target list before populating it + $1 := + + ifneq ($$($1_OUTPUT_FILE),) + ifneq ($$(words $$($1_SOURCE_FILES)), 1) + $$(error Cannot use OUTPUT_FILE for more than one source file (in $1)) + endif + + # Note that $1 is space sensitive and must disobey whitespace rules + $$(eval $$(call SetupSingleTextFileForProcessing,$1, $$($1_SOURCE_FILES), \ + $$(dir $$($1_OUTPUT_FILE)), $$(notdir $$($1_OUTPUT_FILE)))) + else + ifeq ($$($1_OUTPUT_DIR),) + $$(error Neither OUTPUT_FILE nor OUTPUT_DIR was specified (in $1)) + endif + + # Now call add_native_source for each source file we are going to process. + ifeq ($$($1_SOURCE_BASE_DIR),) + # With no base dir specified, put all files in target dir, flattening any + # hierarchies. Note that $1 is space sensitive and must disobey whitespace + # rules. + $$(foreach src, $$($1_SOURCE_FILES), \ + $$(eval $$(call SetupSingleTextFileForProcessing,$1, $$(src), \ + $$($1_OUTPUT_DIR), $$(notdir $$(src))))) + else + # With a base dir, extract the relative portion of the path. Note that $1 + # is space sensitive and must disobey whitespace rules, and so is the + # arguments to patsubst. + $$(foreach src, $$($1_SOURCE_FILES), \ + $$(eval $$(call SetupSingleTextFileForProcessing,$1, $$(src), \ + $$($1_OUTPUT_DIR), $$(patsubst $$($1_SOURCE_BASE_DIR)/%,%,$$(src))))) + endif + endif +endef From fbe3b00b09724cae6edb1f15b77636c09605717b Mon Sep 17 00:00:00 2001 From: Michael McMahon Date: Tue, 4 Feb 2014 11:31:27 +0000 Subject: [PATCH 100/159] 8028725: [Parfait] warnings from b116 for jdk.src.solaris.native.java.net: JNI pending exceptions Reviewed-by: alanb --- jdk/src/solaris/native/java/net/Inet6AddressImpl.c | 2 ++ jdk/src/windows/native/java/net/Inet6AddressImpl.c | 1 + 2 files changed, 3 insertions(+) diff --git a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c index 7ac26c0cbb6..1e4e7d684d1 100644 --- a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c +++ b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c @@ -196,6 +196,7 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6) } name = (*env)->NewStringUTF(env, hostname); + CHECK_NULL(name); /* Iterate over the interfaces, and total up the number of IPv4 and IPv6 * addresses we have. Also keep a count of loopback addresses. We need to @@ -548,6 +549,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this, if (!error) { ret = (*env)->NewStringUTF(env, host); + CHECK_NULL(ret); } #endif /* AF_INET6 */ diff --git a/jdk/src/windows/native/java/net/Inet6AddressImpl.c b/jdk/src/windows/native/java/net/Inet6AddressImpl.c index f77d5ab79c7..24176b29278 100644 --- a/jdk/src/windows/native/java/net/Inet6AddressImpl.c +++ b/jdk/src/windows/native/java/net/Inet6AddressImpl.c @@ -347,6 +347,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this, if (!error) { ret = (*env)->NewStringUTF(env, host); + CHECK_NULL(ret); } if (ret == NULL) { From 28e1b6ccf23461bc43840e72826f977bcf379a48 Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Tue, 4 Feb 2014 12:05:13 +0000 Subject: [PATCH 101/159] 8033372: Check jdk/src/share/native/java/lang for JNI pending exception issues 8033371: jdk/src/solaris/native/java/lang/ProcessEnvironment.c environ doesn't check for JNI pending exceptions 8030116: (process) Check Parfait warnings in src/solaris/native/java/lang/* 8028769: Check src/share/native/java/lang/*.c for cases when JNI calls are used with pending warnings Reviewed-by: chegar --- jdk/src/share/native/java/io/io_util.c | 1 + jdk/src/share/native/java/lang/ClassLoader.c | 3 - jdk/src/share/native/java/lang/System.c | 109 +++++++++++------- .../native/java/lang/ProcessEnvironment_md.c | 7 +- .../solaris/native/java/lang/UNIXProcess_md.c | 1 + .../solaris/native/java/lang/java_props_md.c | 3 + .../native/java/lang/ProcessEnvironment_md.c | 11 +- 7 files changed, 82 insertions(+), 53 deletions(-) diff --git a/jdk/src/share/native/java/io/io_util.c b/jdk/src/share/native/java/io/io_util.c index 5dd822382f0..f256af4074b 100644 --- a/jdk/src/share/native/java/io/io_util.c +++ b/jdk/src/share/native/java/io/io_util.c @@ -216,6 +216,7 @@ throwFileNotFoundException(JNIEnv *env, jstring path) #else why = JNU_NewStringPlatform(env, buf); #endif + CHECK_NULL(why); } x = JNU_NewObjectByName(env, "java/io/FileNotFoundException", diff --git a/jdk/src/share/native/java/lang/ClassLoader.c b/jdk/src/share/native/java/lang/ClassLoader.c index f6d0583990c..8e0b950406a 100644 --- a/jdk/src/share/native/java/lang/ClassLoader.c +++ b/jdk/src/share/native/java/lang/ClassLoader.c @@ -132,7 +132,6 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env, if (name != NULL) { utfName = getUTF(env, name, buf, sizeof(buf)); if (utfName == NULL) { - JNU_ThrowOutOfMemoryError(env, NULL); goto free_body; } VerifyFixClassname(utfName); @@ -143,7 +142,6 @@ Java_java_lang_ClassLoader_defineClass1(JNIEnv *env, if (source != NULL) { utfSource = getUTF(env, source, sourceBuf, sizeof(sourceBuf)); if (utfSource == NULL) { - JNU_ThrowOutOfMemoryError(env, NULL); goto free_utfName; } } else { @@ -519,7 +517,6 @@ Java_java_lang_ClassLoader_00024NativeLibrary_findBuiltinLib procHandle = getProcessHandle(); cname = JNU_GetStringPlatformChars(env, name, 0); if (cname == NULL) { - JNU_ThrowOutOfMemoryError(env, NULL); return NULL; } // Copy name Skipping PREFIX diff --git a/jdk/src/share/native/java/lang/System.c b/jdk/src/share/native/java/lang/System.c index 660b21e68e1..9c2f591fab4 100644 --- a/jdk/src/share/native/java/lang/System.c +++ b/jdk/src/share/native/java/lang/System.c @@ -56,44 +56,56 @@ Java_java_lang_System_identityHashCode(JNIEnv *env, jobject this, jobject x) return JVM_IHashCode(env, x); } -#define PUTPROP(props, key, val) \ - if (1) { \ - jstring jkey = (*env)->NewStringUTF(env, key); \ - jstring jval = (*env)->NewStringUTF(env, val); \ - jobject r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \ - if ((*env)->ExceptionOccurred(env)) return NULL; \ - (*env)->DeleteLocalRef(env, jkey); \ - (*env)->DeleteLocalRef(env, jval); \ - (*env)->DeleteLocalRef(env, r); \ +#define PUTPROP(props, key, val) \ + if (1) { \ + jstring jkey, jval; \ + jobject r; \ + jkey = (*env)->NewStringUTF(env, key); \ + if (jkey == NULL) return NULL; \ + jval = (*env)->NewStringUTF(env, val); \ + if (jval == NULL) return NULL; \ + r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \ + if ((*env)->ExceptionOccurred(env)) return NULL; \ + (*env)->DeleteLocalRef(env, jkey); \ + (*env)->DeleteLocalRef(env, jval); \ + (*env)->DeleteLocalRef(env, r); \ } else ((void) 0) /* "key" is a char type string with only ASCII character in it. "val" is a nchar (typedefed in java_props.h) type string */ -#define PUTPROP_ForPlatformNString(props, key, val) \ - if (1) { \ - jstring jkey = (*env)->NewStringUTF(env, key); \ - jstring jval = GetStringPlatform(env, val); \ - jobject r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \ - if ((*env)->ExceptionOccurred(env)) return NULL; \ - (*env)->DeleteLocalRef(env, jkey); \ - (*env)->DeleteLocalRef(env, jval); \ - (*env)->DeleteLocalRef(env, r); \ +#define PUTPROP_ForPlatformNString(props, key, val) \ + if (1) { \ + jstring jkey, jval; \ + jobject r; \ + jkey = (*env)->NewStringUTF(env, key); \ + if (jkey == NULL) return NULL; \ + jval = GetStringPlatform(env, val); \ + if (jval == NULL) return NULL; \ + r = (*env)->CallObjectMethod(env, props, putID, jkey, jval); \ + if ((*env)->ExceptionOccurred(env)) return NULL; \ + (*env)->DeleteLocalRef(env, jkey); \ + (*env)->DeleteLocalRef(env, jval); \ + (*env)->DeleteLocalRef(env, r); \ } else ((void) 0) -#define REMOVEPROP(props, key) \ - if (1) { \ - jstring jkey = JNU_NewStringPlatform(env, key); \ - jobject r = (*env)->CallObjectMethod(env, props, removeID, jkey); \ - if ((*env)->ExceptionOccurred(env)) return NULL; \ - (*env)->DeleteLocalRef(env, jkey); \ - (*env)->DeleteLocalRef(env, r); \ +#define REMOVEPROP(props, key) \ + if (1) { \ + jstring jkey; \ + jobject r; \ + jkey = JNU_NewStringPlatform(env, key); \ + if (jkey == NULL) return NULL; \ + r = (*env)->CallObjectMethod(env, props, removeID, jkey); \ + if ((*env)->ExceptionOccurred(env)) return NULL; \ + (*env)->DeleteLocalRef(env, jkey); \ + (*env)->DeleteLocalRef(env, r); \ } else ((void) 0) -#define GETPROP(props, key, jret) \ - if (1) { \ - jstring jkey = JNU_NewStringPlatform(env, key); \ +#define GETPROP(props, key, jret) \ + if (1) { \ + jstring jkey = JNU_NewStringPlatform(env, key); \ + if (jkey == NULL) return NULL; \ jret = (*env)->CallObjectMethod(env, props, getPropID, jkey); \ - if ((*env)->ExceptionOccurred(env)) return NULL; \ - (*env)->DeleteLocalRef(env, jkey); \ + if ((*env)->ExceptionOccurred(env)) return NULL; \ + (*env)->DeleteLocalRef(env, jkey); \ } else ((void) 0) #ifndef VENDOR /* Third party may overwrite this. */ @@ -169,23 +181,31 @@ JNIEXPORT jobject JNICALL Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props) { char buf[128]; - java_props_t *sprops = GetJavaProperties(env); - jmethodID putID = (*env)->GetMethodID(env, - (*env)->GetObjectClass(env, props), - "put", - "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); - jmethodID removeID = (*env)->GetMethodID(env, - (*env)->GetObjectClass(env, props), - "remove", - "(Ljava/lang/Object;)Ljava/lang/Object;"); - jmethodID getPropID = (*env)->GetMethodID(env, - (*env)->GetObjectClass(env, props), - "getProperty", - "(Ljava/lang/String;)Ljava/lang/String;"); + java_props_t *sprops; + jmethodID putID, removeID, getPropID; jobject ret = NULL; jstring jVMVal = NULL; - if (sprops == NULL || putID == NULL ) return NULL; + sprops = GetJavaProperties(env); + CHECK_NULL_RETURN(sprops, NULL); + + putID = (*env)->GetMethodID(env, + (*env)->GetObjectClass(env, props), + "put", + "(Ljava/lang/Object;Ljava/lang/Object;)Ljava/lang/Object;"); + CHECK_NULL_RETURN(putID, NULL); + + removeID = (*env)->GetMethodID(env, + (*env)->GetObjectClass(env, props), + "remove", + "(Ljava/lang/Object;)Ljava/lang/Object;"); + CHECK_NULL_RETURN(removeID, NULL); + + getPropID = (*env)->GetMethodID(env, + (*env)->GetObjectClass(env, props), + "getProperty", + "(Ljava/lang/String;)Ljava/lang/String;"); + CHECK_NULL_RETURN(getPropID, NULL); PUTPROP(props, "java.specification.version", JDK_MAJOR_VERSION "." JDK_MINOR_VERSION); @@ -382,6 +402,7 @@ Java_java_lang_System_initProperties(JNIEnv *env, jclass cla, jobject props) GETPROP(props, "sun.locale.formatasdefault", jVMVal); if (jVMVal) { const char * val = (*env)->GetStringUTFChars(env, jVMVal, 0); + CHECK_NULL_RETURN(val, NULL); fmtdefault = !strcmp(val, "true"); (*env)->ReleaseStringUTFChars(env, jVMVal, val); (*env)->DeleteLocalRef(env, jVMVal); diff --git a/jdk/src/solaris/native/java/lang/ProcessEnvironment_md.c b/jdk/src/solaris/native/java/lang/ProcessEnvironment_md.c index f597bff742d..54aa7142a36 100644 --- a/jdk/src/solaris/native/java/lang/ProcessEnvironment_md.c +++ b/jdk/src/solaris/native/java/lang/ProcessEnvironment_md.c @@ -53,6 +53,7 @@ Java_java_lang_ProcessEnvironment_environ(JNIEnv *env, jclass ign) jsize i, j; jobjectArray result; jclass byteArrCls = (*env)->FindClass(env, "[B"); + CHECK_NULL_RETURN(byteArrCls, NULL); for (i = 0; environ[i]; i++) { /* Ignore corrupted environment variables */ @@ -61,7 +62,7 @@ Java_java_lang_ProcessEnvironment_environ(JNIEnv *env, jclass ign) } result = (*env)->NewObjectArray(env, 2*count, byteArrCls, 0); - if (result == NULL) return NULL; + CHECK_NULL_RETURN(result, NULL); for (i = 0, j = 0; environ[i]; i++) { const char * varEnd = strchr(environ[i], '='); @@ -72,9 +73,9 @@ Java_java_lang_ProcessEnvironment_environ(JNIEnv *env, jclass ign) jsize varLength = varEnd - environ[i]; jsize valLength = strlen(valBeg); var = (*env)->NewByteArray(env, varLength); - if (var == NULL) return NULL; + CHECK_NULL_RETURN(var, NULL); val = (*env)->NewByteArray(env, valLength); - if (val == NULL) return NULL; + CHECK_NULL_RETURN(val, NULL); (*env)->SetByteArrayRegion(env, var, 0, varLength, (jbyte*) environ[i]); (*env)->SetByteArrayRegion(env, val, 0, valLength, diff --git a/jdk/src/solaris/native/java/lang/UNIXProcess_md.c b/jdk/src/solaris/native/java/lang/UNIXProcess_md.c index ec85b685dc6..da5be2257d0 100644 --- a/jdk/src/solaris/native/java/lang/UNIXProcess_md.c +++ b/jdk/src/solaris/native/java/lang/UNIXProcess_md.c @@ -206,6 +206,7 @@ JNIEXPORT void JNICALL Java_java_lang_UNIXProcess_init(JNIEnv *env, jclass clazz) { parentPathv = effectivePathv(env); + CHECK_NULL(parentPathv); setSIGCHLDHandler(env); } diff --git a/jdk/src/solaris/native/java/lang/java_props_md.c b/jdk/src/solaris/native/java/lang/java_props_md.c index 1830b20fd0c..df55fd32b5b 100644 --- a/jdk/src/solaris/native/java/lang/java_props_md.c +++ b/jdk/src/solaris/native/java/lang/java_props_md.c @@ -546,6 +546,9 @@ GetJavaProperties(JNIEnv *env) sprops.display_country = sprops.country; sprops.display_variant = sprops.variant; + /* ParseLocale failed with OOME */ + JNU_CHECK_EXCEPTION_RETURN(env, NULL); + #ifdef MACOSX sprops.sun_jnu_encoding = "UTF-8"; #else diff --git a/jdk/src/windows/native/java/lang/ProcessEnvironment_md.c b/jdk/src/windows/native/java/lang/ProcessEnvironment_md.c index e64d30b74af..3b73dd1d326 100644 --- a/jdk/src/windows/native/java/lang/ProcessEnvironment_md.c +++ b/jdk/src/windows/native/java/lang/ProcessEnvironment_md.c @@ -32,10 +32,15 @@ static jstring environmentBlock9x(JNIEnv *env) { int i; - jmethodID String_init_ID = - (*env)->GetMethodID(env, JNU_ClassString(env), "", "([B)V"); + jmethodID String_init_ID; jbyteArray bytes; - jbyte *blockA = (jbyte *) GetEnvironmentStringsA(); + jbyte *blockA; + + String_init_ID = + (*env)->GetMethodID(env, JNU_ClassString(env), "", "([B)V"); + CHECK_NULL_RETURN(String_init_ID, NULL); + + blockA = (jbyte *) GetEnvironmentStringsA(); if (blockA == NULL) { /* Both GetEnvironmentStringsW and GetEnvironmentStringsA * failed. Out of memory is our best guess. */ From 579b11a884524a6895985ee7ae210e7e3d245160 Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Tue, 4 Feb 2014 15:25:10 +0100 Subject: [PATCH 102/159] 8029808: com/sun/jdi/ProcessAttachTest.sh times out Reviewed-by: alanb, dsamersoff --- jdk/test/com/sun/jdi/ProcessAttachTest.sh | 68 ++++++++++++++--------- 1 file changed, 43 insertions(+), 25 deletions(-) diff --git a/jdk/test/com/sun/jdi/ProcessAttachTest.sh b/jdk/test/com/sun/jdi/ProcessAttachTest.sh index 76a531bad38..739b53abb10 100644 --- a/jdk/test/com/sun/jdi/ProcessAttachTest.sh +++ b/jdk/test/com/sun/jdi/ProcessAttachTest.sh @@ -29,7 +29,7 @@ # @summary Unit test for ProcessAttachingConnector # # @build ProcessAttachDebugger ProcessAttachDebuggee ShutdownDebuggee -# @run shell ProcessAttachTest.sh +# @run shell/timeout=120 ProcessAttachTest.sh if [ "${TESTJAVA}" = "" ] then @@ -69,8 +69,8 @@ esac startDebuggee() { - OUTPUTFILE=${TESTCLASSES}/Debuggee.out - ${JAVA} "$@" > ${OUTPUTFILE} & + rm -f ${OUTPUTFILE} + ${JAVA} "$@" > ${OUTPUTFILE} 2>&1 & startpid="$!" pid="${startpid}" @@ -93,11 +93,11 @@ startDebuggee() echo "Waiting for Debuggee to initialize..." attempts=0 while true; do - sleep 1 out=`tail -1 ${OUTPUTFILE}` if [ ! -z "$out" ]; then break fi + sleep 1 attempts=`expr $attempts + 1` echo "Waiting $attempts second(s) ..." done @@ -107,9 +107,23 @@ startDebuggee() stopDebuggee() { - $JAVA -classpath "${TESTCLASSES}" ShutdownDebuggee $1 + # We have to make sure the debuggee has written the portfile before + # trying to read it. + + echo "Waiting for port file to be written..." + attempts=0 + while true; do + attempts=`expr $attempts + 1` + if [ -f ${PORTFILE} ]; then + break + fi + sleep 1 + echo "Waiting $attempts second(s) ..." + done + + $JAVA -classpath "${TESTCLASSES}" ShutdownDebuggee $1 2>&1 if [ $? != 0 ] ; then - echo "Error: ShutdownDebuggee failed" + echo "Error: ShutdownDebuggee failed: $?" failures=`expr $failures + 1` kill -9 ${startpid} fi @@ -120,7 +134,8 @@ failures=0 ######################################################### echo "Test 1: Debuggee start with suspend=n" -PORTFILE="${TESTCLASSES}"/shutdown1.port +PORTFILE=shutdown1.port +OUTPUTFILE=Debuggee1.out DEBUGGEEFLAGS= if [ -r $TESTCLASSES/@debuggeeVMOptions ] ; then @@ -136,17 +151,27 @@ startDebuggee \ $JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \ ProcessAttachDebugger $pid 2>&1 -if [ $? != 0 ]; then failures=`expr $failures + 1`; fi + +if [ $? != 0 ]; then + echo "Error: ProcessAttachDebugger failed: $?" + failures=`expr $failures + 1` +fi # Note that when the debugger disconnects, the debuggee picks another # port and outputs another 'Listening for transport ... ' msg. stopDebuggee "${PORTFILE}" +echo "${OUTPUTFILE}:" +cat $OUTPUTFILE +echo "-----" + ######################################################### echo "\nTest 2: Debuggee start with suspend=y" -PORTFILE="${TESTCLASSES}"/shutdown2.port +PORTFILE=shutdown2.port +OUTPUTFILE=Debuggee2.out + startDebuggee \ $DEBUGGEEFLAGS \ -agentlib:jdwp=transport=dt_socket,server=y,suspend=y \ @@ -155,27 +180,20 @@ startDebuggee \ $JAVA -classpath "${TESTCLASSES}${PS}${TESTJAVA}/lib/tools.jar" \ ProcessAttachDebugger $pid 2>&1 -# The debuggee is suspended and doesn't run until the debugger -# disconnects. We have to give it time to write the port number -# to ${PORTFILE} +if [ $? != 0 ]; then + echo "Error: ProcessAttachDebugger failed: $?" + failures=`expr $failures + 1` +fi -echo "Waiting for port file to be written..." -attempts=0 -while true; do - sleep 1 - attempts=`expr $attempts + 1` - if [ -f ${PORTFILE} ]; then - break - fi - echo "Waiting $attempts second(s) ..." -done - -if [ $? != 0 ]; then failures=`expr $failures + 1`; fi stopDebuggee "${PORTFILE}" +echo $OUTPUTFILE : +cat $OUTPUTFILE +echo ----- + ### if [ $failures = 0 ]; then echo "All tests passed."; - else echo "$failures test(s) failed:"; cat ${OUTPUTFILE}; + else echo "$failures test(s) failed." fi exit $failures From 5fc6cd2aa9fc755ace96d48fc12fefe8cd5628fd Mon Sep 17 00:00:00 2001 From: Sean Coffey Date: Tue, 4 Feb 2014 15:39:40 +0000 Subject: [PATCH 103/159] 8029020: Check src/share/native/java/util/zip code for JNI pending exceptions Reviewed-by: alanb, chegar --- jdk/src/share/native/java/util/zip/Deflater.c | 16 ++++++++++++---- jdk/src/share/native/java/util/zip/Inflater.c | 13 +++++++++---- jdk/src/share/native/java/util/zip/ZipFile.c | 14 +++++++++----- 3 files changed, 30 insertions(+), 13 deletions(-) diff --git a/jdk/src/share/native/java/util/zip/Deflater.c b/jdk/src/share/native/java/util/zip/Deflater.c index a9f403db172..d7f751d37a9 100644 --- a/jdk/src/share/native/java/util/zip/Deflater.c +++ b/jdk/src/share/native/java/util/zip/Deflater.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -49,13 +49,21 @@ JNIEXPORT void JNICALL Java_java_util_zip_Deflater_initIDs(JNIEnv *env, jclass cls) { levelID = (*env)->GetFieldID(env, cls, "level", "I"); + CHECK_NULL(levelID); strategyID = (*env)->GetFieldID(env, cls, "strategy", "I"); + CHECK_NULL(strategyID); setParamsID = (*env)->GetFieldID(env, cls, "setParams", "Z"); + CHECK_NULL(setParamsID); finishID = (*env)->GetFieldID(env, cls, "finish", "Z"); + CHECK_NULL(finishID); finishedID = (*env)->GetFieldID(env, cls, "finished", "Z"); + CHECK_NULL(finishedID); bufID = (*env)->GetFieldID(env, cls, "buf", "[B"); + CHECK_NULL(bufID); offID = (*env)->GetFieldID(env, cls, "off", "I"); + CHECK_NULL(offID); lenID = (*env)->GetFieldID(env, cls, "len", "I"); + CHECK_NULL(lenID); } JNIEXPORT jlong JNICALL @@ -132,14 +140,14 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr, in_buf = (*env)->GetPrimitiveArrayCritical(env, this_buf, 0); if (in_buf == NULL) { // Throw OOME only when length is not zero - if (this_len != 0) + if (this_len != 0 && (*env)->ExceptionOccurred(env) == NULL) JNU_ThrowOutOfMemoryError(env, 0); return 0; } out_buf = (*env)->GetPrimitiveArrayCritical(env, b, 0); if (out_buf == NULL) { (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0); - if (len != 0) + if (len != 0 && (*env)->ExceptionOccurred(env) == NULL) JNU_ThrowOutOfMemoryError(env, 0); return 0; } @@ -158,7 +166,7 @@ Java_java_util_zip_Deflater_deflateBytes(JNIEnv *env, jobject this, jlong addr, this_off += this_len - strm->avail_in; (*env)->SetIntField(env, this, offID, this_off); (*env)->SetIntField(env, this, lenID, strm->avail_in); - return len - strm->avail_out; + return (jint) (len - strm->avail_out); case Z_BUF_ERROR: (*env)->SetBooleanField(env, this, setParamsID, JNI_FALSE); return 0; diff --git a/jdk/src/share/native/java/util/zip/Inflater.c b/jdk/src/share/native/java/util/zip/Inflater.c index 3778ff4e40c..2e21d084b39 100644 --- a/jdk/src/share/native/java/util/zip/Inflater.c +++ b/jdk/src/share/native/java/util/zip/Inflater.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -50,10 +50,15 @@ JNIEXPORT void JNICALL Java_java_util_zip_Inflater_initIDs(JNIEnv *env, jclass cls) { needDictID = (*env)->GetFieldID(env, cls, "needDict", "Z"); + CHECK_NULL(needDictID); finishedID = (*env)->GetFieldID(env, cls, "finished", "Z"); + CHECK_NULL(finishedID); bufID = (*env)->GetFieldID(env, cls, "buf", "[B"); + CHECK_NULL(bufID); offID = (*env)->GetFieldID(env, cls, "off", "I"); + CHECK_NULL(offID); lenID = (*env)->GetFieldID(env, cls, "len", "I"); + CHECK_NULL(lenID); } JNIEXPORT jlong JNICALL @@ -127,14 +132,14 @@ Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this, jlong addr, in_buf = (*env)->GetPrimitiveArrayCritical(env, this_buf, 0); if (in_buf == NULL) { - if (this_len != 0) + if (this_len != 0 && (*env)->ExceptionOccurred(env) == NULL) JNU_ThrowOutOfMemoryError(env, 0); return 0; } out_buf = (*env)->GetPrimitiveArrayCritical(env, b, 0); if (out_buf == NULL) { (*env)->ReleasePrimitiveArrayCritical(env, this_buf, in_buf, 0); - if (len != 0) + if (len != 0 && (*env)->ExceptionOccurred(env) == NULL) JNU_ThrowOutOfMemoryError(env, 0); return 0; } @@ -154,7 +159,7 @@ Java_java_util_zip_Inflater_inflateBytes(JNIEnv *env, jobject this, jlong addr, this_off += this_len - strm->avail_in; (*env)->SetIntField(env, this, offID, this_off); (*env)->SetIntField(env, this, lenID, strm->avail_in); - return len - strm->avail_out; + return (jint) (len - strm->avail_out); case Z_NEED_DICT: (*env)->SetBooleanField(env, this, needDictID, JNI_TRUE); /* Might have consumed some input here! */ diff --git a/jdk/src/share/native/java/util/zip/ZipFile.c b/jdk/src/share/native/java/util/zip/ZipFile.c index d66cccb747a..5fd4936a803 100644 --- a/jdk/src/share/native/java/util/zip/ZipFile.c +++ b/jdk/src/share/native/java/util/zip/ZipFile.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -71,11 +71,13 @@ ThrowZipException(JNIEnv *env, const char *msg) if (msg != NULL) { s = JNU_NewStringPlatform(env, msg); } - x = JNU_NewObjectByName(env, + if (s != NULL) { + x = JNU_NewObjectByName(env, "java/util/zip/ZipException", "(Ljava/lang/String;)V", s); - if (x != NULL) { - (*env)->Throw(env, x); + if (x != NULL) { + (*env)->Throw(env, x); + } } } @@ -367,8 +369,10 @@ Java_java_util_jar_JarFile_getMetaInfEntryNames(JNIEnv *env, jobject obj) /* If some names were found then build array of java strings */ if (count > 0) { - jclass cls = (*env)->FindClass(env, "java/lang/String"); + jclass cls = JNU_ClassString(env); + CHECK_NULL_RETURN(cls, NULL); result = (*env)->NewObjectArray(env, count, cls, 0); + CHECK_NULL_RETURN(result, NULL); if (result != 0) { for (i = 0; i < count; i++) { jstring str = (*env)->NewStringUTF(env, zip->metanames[i]); From 8d903056f3403ccb6742b169350d5191c4c30063 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Tue, 4 Feb 2014 08:58:06 -0800 Subject: [PATCH 104/159] 8033525: Fix raw and unchecked lint warnings in sun.swing.* Reviewed-by: alexsch --- .../classes/sun/swing/BakedArrayList.java | 4 +-- jdk/src/share/classes/sun/swing/FilePane.java | 31 ++++++++++--------- .../classes/sun/swing/SwingLazyValue.java | 12 +++---- .../classes/sun/swing/SwingUtilities2.java | 16 +++++----- .../swing/plaf/synth/DefaultSynthStyle.java | 28 ++++++++--------- .../plaf/synth/SynthFileChooserUIImpl.java | 4 +-- 6 files changed, 48 insertions(+), 47 deletions(-) diff --git a/jdk/src/share/classes/sun/swing/BakedArrayList.java b/jdk/src/share/classes/sun/swing/BakedArrayList.java index 0d4670878db..8f9377b81fe 100644 --- a/jdk/src/share/classes/sun/swing/BakedArrayList.java +++ b/jdk/src/share/classes/sun/swing/BakedArrayList.java @@ -44,7 +44,7 @@ import java.util.*; * @author Scott Violet */ @SuppressWarnings("serial") // JDK-implementation class -public class BakedArrayList extends ArrayList { +public class BakedArrayList extends ArrayList { /** * The cached hashCode. */ @@ -54,7 +54,7 @@ public class BakedArrayList extends ArrayList { super(size); } - public BakedArrayList(java.util.List data) { + public BakedArrayList(java.util.List data) { this(data.size()); for (int counter = 0, max = data.size(); counter < max; counter++){ add(data.get(counter)); diff --git a/jdk/src/share/classes/sun/swing/FilePane.java b/jdk/src/share/classes/sun/swing/FilePane.java index 9b21815469d..763c027a2ab 100644 --- a/jdk/src/share/classes/sun/swing/FilePane.java +++ b/jdk/src/share/classes/sun/swing/FilePane.java @@ -240,7 +240,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { } } - private void repaintListSelection(JList list) { + private void repaintListSelection(JList list) { int[] indices = list.getSelectedIndices(); for (int i : indices) { Rectangle bounds = list.getCellBounds(i, i); @@ -272,7 +272,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { private boolean fullRowSelection = false; private ListSelectionModel listSelectionModel; - private JList list; + private JList list; private JTable detailsTable; private static final int COLUMN_FILENAME = 0; @@ -332,7 +332,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { createdViewPanel = createList(); } - list = (JList) findChildComponent(createdViewPanel, JList.class); + list = findChildComponent(createdViewPanel, JList.class); if (listSelectionModel == null) { listSelectionModel = list.getSelectionModel(); if (detailsTable != null) { @@ -353,7 +353,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { createdViewPanel = createDetailsView(); } - detailsTable = (JTable) findChildComponent(createdViewPanel, JTable.class); + detailsTable = findChildComponent(createdViewPanel, JTable.class); detailsTable.setRowHeight(Math.max(detailsTable.getFont().getSize() + 4, 16 + 1)); if (listSelectionModel != null) { detailsTable.setSelectionModel(listSelectionModel); @@ -569,7 +569,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { } - private void updateListRowCount(JList list) { + private void updateListRowCount(JList list) { if (smallIconsView) { list.setVisibleRowCount(getModel().getSize() / 3); } else { @@ -584,7 +584,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { @SuppressWarnings("serial") // anonymous class final JList list = new JList() { public int getNextMatch(String prefix, int startIndex, Position.Bias bias) { - ListModel model = getModel(); + ListModel model = getModel(); int max = model.getSize(); if (prefix == null || startIndex < 0 || startIndex >= max) { throw new IllegalArgumentException(); @@ -918,7 +918,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { public void updateComparators(ShellFolderColumnInfo [] columns) { for (int i = 0; i < columns.length; i++) { - Comparator c = columns[i].getComparator(); + Comparator c = columns[i].getComparator(); if (c != null) { c = new DirectoriesFirstComparatorWrapper(i, c); } @@ -969,12 +969,13 @@ public class FilePane extends JPanel implements PropertyChangeListener { * directory and file to file using the wrapped comparator. */ private class DirectoriesFirstComparatorWrapper implements Comparator { - private Comparator comparator; + private Comparator comparator; private int column; - public DirectoriesFirstComparatorWrapper(int column, Comparator comparator) { + @SuppressWarnings("unchecked") + public DirectoriesFirstComparatorWrapper(int column, Comparator comparator) { this.column = column; - this.comparator = comparator; + this.comparator = (Comparator)comparator; } public int compare(File f1, File f2) { @@ -1492,7 +1493,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { @SuppressWarnings("serial") // JDK-implementation class protected class FileRenderer extends DefaultListCellRenderer { - public Component getListCellRendererComponent(JList list, Object value, + public Component getListCellRendererComponent(JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) { @@ -1968,14 +1969,14 @@ public class FilePane extends JPanel implements PropertyChangeListener { return fileChooserUIAccessor.getDirectory(); } - private Component findChildComponent(Container container, Class cls) { + private T findChildComponent(Container container, Class cls) { int n = container.getComponentCount(); for (int i = 0; i < n; i++) { Component comp = container.getComponent(i); if (cls.isInstance(comp)) { - return comp; + return cls.cast(comp); } else if (comp instanceof Container) { - Component c = findChildComponent((Container)comp, cls); + T c = findChildComponent((Container)comp, cls); if (c != null) { return c; } @@ -2029,7 +2030,7 @@ public class FilePane extends JPanel implements PropertyChangeListener { public Action getApproveSelectionAction(); public Action getChangeToParentDirectoryAction(); public Action getNewFolderAction(); - public MouseListener createDoubleClickListener(JList list); + public MouseListener createDoubleClickListener(JList list); public ListSelectionListener createListSelectionListener(); } } diff --git a/jdk/src/share/classes/sun/swing/SwingLazyValue.java b/jdk/src/share/classes/sun/swing/SwingLazyValue.java index a9e6f2c1bc8..87205f3398c 100644 --- a/jdk/src/share/classes/sun/swing/SwingLazyValue.java +++ b/jdk/src/share/classes/sun/swing/SwingLazyValue.java @@ -67,13 +67,13 @@ public class SwingLazyValue implements UIDefaults.LazyValue { ReflectUtil.checkPackageAccess(className); Class c = Class.forName(className, true, null); if (methodName != null) { - Class[] types = getClassArray(args); + Class[] types = getClassArray(args); Method m = c.getMethod(methodName, types); makeAccessible(m); return m.invoke(c, args); } else { - Class[] types = getClassArray(args); - Constructor constructor = c.getConstructor(types); + Class[] types = getClassArray(args); + Constructor constructor = c.getConstructor(types); makeAccessible(constructor); return constructor.newInstance(args); } @@ -96,10 +96,10 @@ public class SwingLazyValue implements UIDefaults.LazyValue { }); } - private Class[] getClassArray(Object[] args) { - Class[] types = null; + private Class[] getClassArray(Object[] args) { + Class[] types = null; if (args!=null) { - types = new Class[args.length]; + types = new Class[args.length]; for (int i = 0; i< args.length; i++) { /* PENDING(ges): At present only the primitive types used are handled correctly; this should eventually diff --git a/jdk/src/share/classes/sun/swing/SwingUtilities2.java b/jdk/src/share/classes/sun/swing/SwingUtilities2.java index 9e410ed3977..75a0a4f9b72 100644 --- a/jdk/src/share/classes/sun/swing/SwingUtilities2.java +++ b/jdk/src/share/classes/sun/swing/SwingUtilities2.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -127,7 +127,7 @@ public class SwingUtilities2 { */ public static class AATextInfo { - private static AATextInfo getAATextInfoFromMap(Map hints) { + private static AATextInfo getAATextInfoFromMap(Map hints) { Object aaHint = hints.get(KEY_TEXT_ANTIALIASING); Object contHint = hints.get(KEY_TEXT_LCD_CONTRAST); @@ -141,12 +141,13 @@ public class SwingUtilities2 { } } + @SuppressWarnings("unchecked") public static AATextInfo getAATextInfo(boolean lafCondition) { SunToolkit.setAAFontSettingsCondition(lafCondition); Toolkit tk = Toolkit.getDefaultToolkit(); Object map = tk.getDesktopProperty(SunToolkit.DESKTOPFONTHINTS); if (map instanceof Map) { - return getAATextInfoFromMap((Map)map); + return getAATextInfoFromMap((Map)map); } else { return null; } @@ -663,7 +664,7 @@ public class SwingUtilities2 { * Otherwise, this method returns -1. * This is used to make WindowsL&F JFileChooser act like native dialogs. */ - public static int loc2IndexFileList(JList list, Point point) { + public static int loc2IndexFileList(JList list, Point point) { int index = list.locationToIndex(point); if (index != -1) { Object bySize = list.getClientProperty("List.isFileList"); @@ -680,11 +681,10 @@ public class SwingUtilities2 { * Returns true if the given point is within the actual bounds of the * JList item at index (not just inside the cell). */ - private static boolean pointIsInActualBounds(JList list, int index, + private static boolean pointIsInActualBounds(JList list, int index, Point point) { - ListCellRenderer renderer = list.getCellRenderer(); - ListModel dataModel = list.getModel(); - Object value = dataModel.getElementAt(index); + ListCellRenderer renderer = list.getCellRenderer(); + T value = list.getModel().getElementAt(index); Component item = renderer.getListCellRendererComponent(list, value, index, false, false); Dimension itemSize = item.getPreferredSize(); diff --git a/jdk/src/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java b/jdk/src/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java index 3da946bcb2f..1297bcd26a5 100644 --- a/jdk/src/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java +++ b/jdk/src/share/classes/sun/swing/plaf/synth/DefaultSynthStyle.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -61,7 +61,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { /** * User specific data. */ - private Map data; + private Map data; /** * Font to use if there is no matching StateInfo, or the StateInfo doesn't @@ -106,7 +106,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { } } if (style.data != null) { - data = new HashMap(); + data = new HashMap<>(); data.putAll(style.data); } font = style.font; @@ -124,7 +124,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { * @param data Style specific data. */ public DefaultSynthStyle(Insets insets, boolean opaque, - StateInfo[] states, Map data) { + StateInfo[] states, Map data) { this.insets = insets; this.opaque = opaque; this.states = states; @@ -366,7 +366,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { * * @param data Style specific values */ - public void setData(Map data) { + public void setData(Map data) { this.data = data; } @@ -375,7 +375,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { * * @return Style specific data. */ - public Map getData() { + public Map getData() { return data; } @@ -402,7 +402,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { } - private Object getKeyFromData(Map stateData, Object key) { + private Object getKeyFromData(Map stateData, Object key) { Object value = null; if (stateData != null) { @@ -462,7 +462,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { } } if (data != null) { - style.data = new HashMap(); + style.data = new HashMap<>(); style.data.putAll(data); } return style; @@ -570,7 +570,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { } if (data != null) { if (style.data == null) { - style.data = new HashMap(); + style.data = new HashMap<>(); } style.data.putAll(data); } @@ -708,7 +708,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { * a component. */ public static class StateInfo { - private Map data; + private Map data; private Font font; private Color[] colors; private int state; @@ -746,7 +746,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { this.font = info.font; if(info.data != null) { if(data == null) { - data = new HashMap(); + data = new HashMap<>(); } data.putAll(info.data); } @@ -756,11 +756,11 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { } } - public Map getData() { + public Map getData() { return data; } - public void setData(Map data) { + public void setData(Map data) { this.data = data; } @@ -836,7 +836,7 @@ public class DefaultSynthStyle extends SynthStyle implements Cloneable { } if(data != null) { if(info.data == null) { - info.data = new HashMap(); + info.data = new HashMap<>(); } info.data.putAll(data); } diff --git a/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java b/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java index a933377d995..f0d0ac31c14 100644 --- a/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java +++ b/jdk/src/share/classes/sun/swing/plaf/synth/SynthFileChooserUIImpl.java @@ -175,7 +175,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI { return SynthFileChooserUIImpl.this.getNewFolderAction(); } - public MouseListener createDoubleClickListener(JList list) { + public MouseListener createDoubleClickListener(JList list) { return SynthFileChooserUIImpl.this.createDoubleClickListener(getFileChooser(), list); } @@ -563,7 +563,7 @@ public class SynthFileChooserUIImpl extends SynthFileChooserUI { if (currentDirectory != null) { JComponent cb = getDirectoryComboBox(); if (cb instanceof JComboBox) { - ComboBoxModel model = ((JComboBox)cb).getModel(); + ComboBoxModel model = ((JComboBox)cb).getModel(); if (model instanceof DirectoryComboBoxModel) { ((DirectoryComboBoxModel)model).addItem(currentDirectory); } From 60f386c8bb9f9aa219d63119ce1c2447b52586ea Mon Sep 17 00:00:00 2001 From: Vinnie Ryan Date: Tue, 4 Feb 2014 18:37:12 +0000 Subject: [PATCH 105/159] 8028727: [parfait] warnings from b116 for jdk.src.share.native.sun.security.ec: JNI pending exceptions Reviewed-by: alanb --- .../share/native/sun/security/ec/ECC_JNI.cpp | 47 +++++++++++++++++-- 1 file changed, 43 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/native/sun/security/ec/ECC_JNI.cpp b/jdk/src/share/native/sun/security/ec/ECC_JNI.cpp index dff675f9500..8273e7f8dbb 100644 --- a/jdk/src/share/native/sun/security/ec/ECC_JNI.cpp +++ b/jdk/src/share/native/sun/security/ec/ECC_JNI.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,9 @@ extern "C" { void ThrowException(JNIEnv *env, const char *exceptionName) { jclass exceptionClazz = env->FindClass(exceptionName); - env->ThrowNew(exceptionClazz, NULL); + if (exceptionClazz != NULL) { + env->ThrowNew(exceptionClazz, NULL); + } } /* @@ -73,7 +75,7 @@ JNIEXPORT jlongArray JNICALL Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair (JNIEnv *env, jclass clazz, jint keySize, jbyteArray encodedParams, jbyteArray seed) { - ECPrivateKey *privKey; /* contains both public and private values */ + ECPrivateKey *privKey = NULL; /* contains both public and private values */ ECParams *ecparams = NULL; SECKEYECParams params_item; jint jSeedLength; @@ -85,6 +87,9 @@ JNICALL Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair params_item.len = env->GetArrayLength(encodedParams); params_item.data = (unsigned char *) env->GetByteArrayElements(encodedParams, 0); + if (params_item.data == NULL) { + goto cleanup; + } // Fill a new ECParams using the supplied OID if (EC_DecodeParams(¶ms_item, &ecparams, 0) != SECSuccess) { @@ -107,7 +112,14 @@ JNICALL Java_sun_security_ec_ECKeyPairGenerator_generateECKeyPair jboolean isCopy; result = env->NewLongArray(2); + if (result == NULL) { + goto cleanup; + } + resultElements = env->GetLongArrayElements(result, &isCopy); + if (resultElements == NULL) { + goto cleanup; + } resultElements[0] = (jlong) &(privKey->privateValue); // private big integer resultElements[1] = (jlong) &(privKey->publicValue); // encoded ec point @@ -150,6 +162,9 @@ JNICALL Java_sun_security_ec_ECKeyPairGenerator_getEncodedBytes { SECItem *s = (SECItem *)hSECItem; jbyteArray jEncodedBytes = env->NewByteArray(s->len); + if (jEncodedBytes == NULL) { + return NULL; + } // Copy bytes from a native SECItem buffer to Java byte array env->SetByteArrayRegion(jEncodedBytes, 0, s->len, (jbyte *)s->data); @@ -195,6 +210,9 @@ JNICALL Java_sun_security_ec_ECDSASignature_signDigest params_item.len = env->GetArrayLength(encodedParams); params_item.data = (unsigned char *) env->GetByteArrayElements(encodedParams, 0); + if (params_item.data == NULL) { + goto cleanup; + } // Fill a new ECParams using the supplied OID if (EC_DecodeParams(¶ms_item, &ecparams, 0) != SECSuccess) { @@ -208,6 +226,9 @@ JNICALL Java_sun_security_ec_ECDSASignature_signDigest privKey.privateValue.len = env->GetArrayLength(privateKey); privKey.privateValue.data = (unsigned char *) env->GetByteArrayElements(privateKey, 0); + if (privKey.privateValue.data == NULL) { + goto cleanup; + } // Prepare a buffer for the signature (twice the key length) pSignedDigestBuffer = new jbyte[ecparams->order.len * 2]; @@ -227,6 +248,9 @@ JNICALL Java_sun_security_ec_ECDSASignature_signDigest // Create new byte array temp = env->NewByteArray(signature_item.len); + if (temp == NULL) { + goto cleanup; + } // Copy data from native buffer env->SetByteArrayRegion(temp, 0, signature_item.len, pSignedDigestBuffer); @@ -294,6 +318,9 @@ JNICALL Java_sun_security_ec_ECDSASignature_verifySignedDigest params_item.len = env->GetArrayLength(encodedParams); params_item.data = (unsigned char *) env->GetByteArrayElements(encodedParams, 0); + if (params_item.data == NULL) { + goto cleanup; + } // Fill a new ECParams using the supplied OID if (EC_DecodeParams(¶ms_item, &ecparams, 0) != SECSuccess) { @@ -346,25 +373,34 @@ JNICALL Java_sun_security_ec_ECDHKeyAgreement_deriveKey (JNIEnv *env, jclass clazz, jbyteArray privateKey, jbyteArray publicKey, jbyteArray encodedParams) { jbyteArray jSecret = NULL; + ECParams *ecparams = NULL; // Extract private key value SECItem privateValue_item; privateValue_item.len = env->GetArrayLength(privateKey); privateValue_item.data = (unsigned char *) env->GetByteArrayElements(privateKey, 0); + if (privateValue_item.data == NULL) { + goto cleanup; + } // Extract public key value SECItem publicValue_item; publicValue_item.len = env->GetArrayLength(publicKey); publicValue_item.data = (unsigned char *) env->GetByteArrayElements(publicKey, 0); + if (publicValue_item.data == NULL) { + goto cleanup; + } // Initialize the ECParams struct - ECParams *ecparams = NULL; SECKEYECParams params_item; params_item.len = env->GetArrayLength(encodedParams); params_item.data = (unsigned char *) env->GetByteArrayElements(encodedParams, 0); + if (params_item.data == NULL) { + goto cleanup; + } // Fill a new ECParams using the supplied OID if (EC_DecodeParams(¶ms_item, &ecparams, 0) != SECSuccess) { @@ -386,6 +422,9 @@ JNICALL Java_sun_security_ec_ECDHKeyAgreement_deriveKey // Create new byte array jSecret = env->NewByteArray(secret_item.len); + if (jSecret == NULL) { + goto cleanup; + } // Copy bytes from the SECItem buffer to a Java byte array env->SetByteArrayRegion(jSecret, 0, secret_item.len, From 20e35aed8fb6e7ad0a116962765ce1752eee00d4 Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Tue, 4 Feb 2014 23:40:23 +0000 Subject: [PATCH 106/159] 8025306: Inet[4|6]Address class and fieldID initialization in networking native code Reviewed-by: alanb, michaelm --- jdk/make/mapfiles/libnet/mapfile-vers | 1 + jdk/src/share/native/java/net/Inet4Address.c | 16 ++-- jdk/src/share/native/java/net/Inet6Address.c | 46 +++++----- jdk/src/share/native/java/net/InetAddress.c | 38 ++++---- jdk/src/share/native/java/net/net_util.c | 89 ++++--------------- jdk/src/share/native/java/net/net_util.h | 2 + .../native/java/net/Inet4AddressImpl.c | 39 ++------ .../native/java/net/Inet6AddressImpl.c | 63 +++---------- .../native/java/net/NetworkInterface.c | 33 ++----- .../native/java/net/PlainDatagramSocketImpl.c | 5 +- .../solaris/native/java/net/PlainSocketImpl.c | 3 + jdk/src/solaris/native/sun/nio/ch/IOUtil.c | 2 + .../solaris/native/sun/nio/ch/sctp/SctpNet.c | 1 + .../native/java/net/Inet4AddressImpl.c | 28 ++---- .../native/java/net/Inet6AddressImpl.c | 49 ++-------- .../native/java/net/NetworkInterface.c | 38 ++------ .../native/java/net/NetworkInterface.h | 10 --- .../native/java/net/NetworkInterface_winXP.c | 8 +- jdk/src/windows/native/sun/nio/ch/IOUtil.c | 2 + 19 files changed, 141 insertions(+), 332 deletions(-) diff --git a/jdk/make/mapfiles/libnet/mapfile-vers b/jdk/make/mapfiles/libnet/mapfile-vers index cdd98f8cce6..e3e7ce91fcf 100644 --- a/jdk/make/mapfiles/libnet/mapfile-vers +++ b/jdk/make/mapfiles/libnet/mapfile-vers @@ -105,6 +105,7 @@ SUNWprivate_1.1 { NET_MapSocketOption; NET_Wait; ipv6_available; + initInetAddressIDs; local: *; diff --git a/jdk/src/share/native/java/net/Inet4Address.c b/jdk/src/share/native/java/net/Inet4Address.c index b2f25416133..9fb0f342c00 100644 --- a/jdk/src/share/native/java/net/Inet4Address.c +++ b/jdk/src/share/native/java/net/Inet4Address.c @@ -34,6 +34,8 @@ jclass ia4_class; jmethodID ia4_ctrID; +static int ia4_initialized = 0; + /* * Class: java_net_Inet4Address * Method: init @@ -41,9 +43,13 @@ jmethodID ia4_ctrID; */ JNIEXPORT void JNICALL Java_java_net_Inet4Address_init(JNIEnv *env, jclass cls) { - jclass c = (*env)->FindClass(env, "java/net/Inet4Address"); - CHECK_NULL(c); - ia4_class = (*env)->NewGlobalRef(env, c); - CHECK_NULL(ia4_class); - ia4_ctrID = (*env)->GetMethodID(env, ia4_class, "", "()V"); + if (!ia4_initialized) { + jclass c = (*env)->FindClass(env, "java/net/Inet4Address"); + CHECK_NULL(c); + ia4_class = (*env)->NewGlobalRef(env, c); + CHECK_NULL(ia4_class); + ia4_ctrID = (*env)->GetMethodID(env, ia4_class, "", "()V"); + CHECK_NULL(ia4_ctrID); + ia4_initialized = 1; + } } diff --git a/jdk/src/share/native/java/net/Inet6Address.c b/jdk/src/share/native/java/net/Inet6Address.c index 729fe78281d..8d34918386d 100644 --- a/jdk/src/share/native/java/net/Inet6Address.c +++ b/jdk/src/share/native/java/net/Inet6Address.c @@ -42,6 +42,8 @@ jfieldID ia6_scopeidsetID; jfieldID ia6_scopeifnameID; jmethodID ia6_ctrID; +static int ia6_initialized = 0; + /* * Class: java_net_Inet6Address * Method: init @@ -49,24 +51,28 @@ jmethodID ia6_ctrID; */ JNIEXPORT void JNICALL Java_java_net_Inet6Address_init(JNIEnv *env, jclass cls) { - jclass ia6h_class; - jclass c = (*env)->FindClass(env, "java/net/Inet6Address"); - CHECK_NULL(c); - ia6_class = (*env)->NewGlobalRef(env, c); - CHECK_NULL(ia6_class); - ia6h_class = (*env)->FindClass(env, "java/net/Inet6Address$Inet6AddressHolder"); - CHECK_NULL(ia6h_class); - ia6_holder6ID = (*env)->GetFieldID(env, ia6_class, "holder6", "Ljava/net/Inet6Address$Inet6AddressHolder;"); - CHECK_NULL(ia6_holder6ID); - ia6_ipaddressID = (*env)->GetFieldID(env, ia6h_class, "ipaddress", "[B"); - CHECK_NULL(ia6_ipaddressID); - ia6_scopeidID = (*env)->GetFieldID(env, ia6h_class, "scope_id", "I"); - CHECK_NULL(ia6_scopeidID); - ia6_cachedscopeidID = (*env)->GetFieldID(env, ia6_class, "cached_scope_id", "I"); - CHECK_NULL(ia6_cachedscopeidID); - ia6_scopeidsetID = (*env)->GetFieldID(env, ia6h_class, "scope_id_set", "Z"); - CHECK_NULL(ia6_scopeidsetID); - ia6_scopeifnameID = (*env)->GetFieldID(env, ia6h_class, "scope_ifname", "Ljava/net/NetworkInterface;"); - CHECK_NULL(ia6_scopeifnameID); - ia6_ctrID = (*env)->GetMethodID(env, ia6_class, "", "()V"); + if (!ia6_initialized) { + jclass ia6h_class; + jclass c = (*env)->FindClass(env, "java/net/Inet6Address"); + CHECK_NULL(c); + ia6_class = (*env)->NewGlobalRef(env, c); + CHECK_NULL(ia6_class); + ia6h_class = (*env)->FindClass(env, "java/net/Inet6Address$Inet6AddressHolder"); + CHECK_NULL(ia6h_class); + ia6_holder6ID = (*env)->GetFieldID(env, ia6_class, "holder6", "Ljava/net/Inet6Address$Inet6AddressHolder;"); + CHECK_NULL(ia6_holder6ID); + ia6_ipaddressID = (*env)->GetFieldID(env, ia6h_class, "ipaddress", "[B"); + CHECK_NULL(ia6_ipaddressID); + ia6_scopeidID = (*env)->GetFieldID(env, ia6h_class, "scope_id", "I"); + CHECK_NULL(ia6_scopeidID); + ia6_cachedscopeidID = (*env)->GetFieldID(env, ia6_class, "cached_scope_id", "I"); + CHECK_NULL(ia6_cachedscopeidID); + ia6_scopeidsetID = (*env)->GetFieldID(env, ia6h_class, "scope_id_set", "Z"); + CHECK_NULL(ia6_scopeidsetID); + ia6_scopeifnameID = (*env)->GetFieldID(env, ia6h_class, "scope_ifname", "Ljava/net/NetworkInterface;"); + CHECK_NULL(ia6_scopeifnameID); + ia6_ctrID = (*env)->GetMethodID(env, ia6_class, "", "()V"); + CHECK_NULL(ia6_ctrID); + ia6_initialized = 1; + } } diff --git a/jdk/src/share/native/java/net/InetAddress.c b/jdk/src/share/native/java/net/InetAddress.c index e9fd0979cb8..a712dd9b1d1 100644 --- a/jdk/src/share/native/java/net/InetAddress.c +++ b/jdk/src/share/native/java/net/InetAddress.c @@ -40,6 +40,8 @@ jfieldID iac_familyID; jfieldID iac_hostNameID; jfieldID ia_preferIPv6AddressID; +static int ia_initialized = 0; + /* * Class: java_net_InetAddress * Method: init @@ -47,21 +49,25 @@ jfieldID ia_preferIPv6AddressID; */ JNIEXPORT void JNICALL Java_java_net_InetAddress_init(JNIEnv *env, jclass cls) { - jclass c = (*env)->FindClass(env,"java/net/InetAddress"); - CHECK_NULL(c); - ia_class = (*env)->NewGlobalRef(env, c); - CHECK_NULL(ia_class); - c = (*env)->FindClass(env,"java/net/InetAddress$InetAddressHolder"); - CHECK_NULL(c); - iac_class = (*env)->NewGlobalRef(env, c); - ia_holderID = (*env)->GetFieldID(env, ia_class, "holder", "Ljava/net/InetAddress$InetAddressHolder;"); - CHECK_NULL(ia_holderID); - ia_preferIPv6AddressID = (*env)->GetStaticFieldID(env, ia_class, "preferIPv6Address", "Z"); - CHECK_NULL(ia_preferIPv6AddressID); + if (!ia_initialized) { + jclass c = (*env)->FindClass(env,"java/net/InetAddress"); + CHECK_NULL(c); + ia_class = (*env)->NewGlobalRef(env, c); + CHECK_NULL(ia_class); + c = (*env)->FindClass(env,"java/net/InetAddress$InetAddressHolder"); + CHECK_NULL(c); + iac_class = (*env)->NewGlobalRef(env, c); + ia_holderID = (*env)->GetFieldID(env, ia_class, "holder", "Ljava/net/InetAddress$InetAddressHolder;"); + CHECK_NULL(ia_holderID); + ia_preferIPv6AddressID = (*env)->GetStaticFieldID(env, ia_class, "preferIPv6Address", "Z"); + CHECK_NULL(ia_preferIPv6AddressID); - iac_addressID = (*env)->GetFieldID(env, iac_class, "address", "I"); - CHECK_NULL(iac_addressID); - iac_familyID = (*env)->GetFieldID(env, iac_class, "family", "I"); - CHECK_NULL(iac_familyID); - iac_hostNameID = (*env)->GetFieldID(env, iac_class, "hostName", "Ljava/lang/String;"); + iac_addressID = (*env)->GetFieldID(env, iac_class, "address", "I"); + CHECK_NULL(iac_addressID); + iac_familyID = (*env)->GetFieldID(env, iac_class, "family", "I"); + CHECK_NULL(iac_familyID); + iac_hostNameID = (*env)->GetFieldID(env, iac_class, "hostName", "Ljava/lang/String;"); + CHECK_NULL(iac_hostNameID); + ia_initialized = 1; + } } diff --git a/jdk/src/share/native/java/net/net_util.c b/jdk/src/share/native/java/net/net_util.c index f8a0e90b532..dd93b1375bc 100644 --- a/jdk/src/share/native/java/net/net_util.c +++ b/jdk/src/share/native/java/net/net_util.c @@ -75,11 +75,14 @@ JNI_OnLoad(JavaVM *vm, void *reserved) static int initialized = 0; -static void initInetAddrs(JNIEnv *env) { +JNIEXPORT void JNICALL initInetAddressIDs(JNIEnv *env) { if (!initialized) { Java_java_net_InetAddress_init(env, 0); + JNU_CHECK_EXCEPTION(env); Java_java_net_Inet4Address_init(env, 0); + JNU_CHECK_EXCEPTION(env); Java_java_net_Inet6Address_init(env, 0); + JNU_CHECK_EXCEPTION(env); initialized = 1; } } @@ -100,47 +103,32 @@ extern jfieldID iac_familyID; * get_ methods that return objects return NULL on error. */ jobject getInet6Address_scopeifname(JNIEnv *env, jobject iaObj) { - jobject holder; - - initInetAddrs(env); - holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); + jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); CHECK_NULL_RETURN(holder, NULL); return (*env)->GetObjectField(env, holder, ia6_scopeifnameID); } int setInet6Address_scopeifname(JNIEnv *env, jobject iaObj, jobject scopeifname) { - jobject holder; - - initInetAddrs(env); - holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); + jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); CHECK_NULL_RETURN(holder, JNI_FALSE); (*env)->SetObjectField(env, holder, ia6_scopeifnameID, scopeifname); return JNI_TRUE; } int getInet6Address_scopeid_set(JNIEnv *env, jobject iaObj) { - jobject holder; - - initInetAddrs(env); - holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); + jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); CHECK_NULL_RETURN(holder, -1); return (*env)->GetBooleanField(env, holder, ia6_scopeidsetID); } int getInet6Address_scopeid(JNIEnv *env, jobject iaObj) { - jobject holder; - - initInetAddrs(env); - holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); + jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); CHECK_NULL_RETURN(holder, -1); return (*env)->GetIntField(env, holder, ia6_scopeidID); } int setInet6Address_scopeid(JNIEnv *env, jobject iaObj, int scopeid) { - jobject holder; - - initInetAddrs(env); - holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); + jobject holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); CHECK_NULL_RETURN(holder, JNI_FALSE); (*env)->SetIntField(env, holder, ia6_scopeidID, scopeid); if (scopeid > 0) { @@ -154,7 +142,6 @@ int getInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *dest) { jobject holder, addr; jbyteArray barr; - initInetAddrs(env); holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); CHECK_NULL_RETURN(holder, JNI_FALSE); addr = (*env)->GetObjectField(env, holder, ia6_ipaddressID); @@ -167,7 +154,6 @@ int setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) { jobject holder; jbyteArray addr; - initInetAddrs(env); holder = (*env)->GetObjectField(env, iaObj, ia6_holder6ID); CHECK_NULL_RETURN(holder, JNI_FALSE); addr = (jbyteArray)(*env)->GetObjectField(env, holder, ia6_ipaddressID); @@ -181,52 +167,38 @@ int setInet6Address_ipaddress(JNIEnv *env, jobject iaObj, char *address) { } void setInetAddress_addr(JNIEnv *env, jobject iaObj, int address) { - jobject holder; - initInetAddrs(env); - holder = (*env)->GetObjectField(env, iaObj, ia_holderID); + jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID); (*env)->SetIntField(env, holder, iac_addressID, address); } void setInetAddress_family(JNIEnv *env, jobject iaObj, int family) { - jobject holder; - initInetAddrs(env); - holder = (*env)->GetObjectField(env, iaObj, ia_holderID); + jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID); (*env)->SetIntField(env, holder, iac_familyID, family); } void setInetAddress_hostName(JNIEnv *env, jobject iaObj, jobject host) { - jobject holder; - initInetAddrs(env); - holder = (*env)->GetObjectField(env, iaObj, ia_holderID); + jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID); (*env)->SetObjectField(env, holder, iac_hostNameID, host); } int getInetAddress_addr(JNIEnv *env, jobject iaObj) { - jobject holder; - initInetAddrs(env); - holder = (*env)->GetObjectField(env, iaObj, ia_holderID); + jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID); return (*env)->GetIntField(env, holder, iac_addressID); } int getInetAddress_family(JNIEnv *env, jobject iaObj) { - jobject holder; - - initInetAddrs(env); - holder = (*env)->GetObjectField(env, iaObj, ia_holderID); + jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID); return (*env)->GetIntField(env, holder, iac_familyID); } jobject getInetAddress_hostName(JNIEnv *env, jobject iaObj) { - jobject holder; - initInetAddrs(env); - holder = (*env)->GetObjectField(env, iaObj, ia_holderID); + jobject holder = (*env)->GetObjectField(env, iaObj, ia_holderID); return (*env)->GetObjectField(env, holder, iac_hostNameID); } JNIEXPORT jobject JNICALL NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { jobject iaObj; - initInetAddrs(env); #ifdef AF_INET6 if (him->sa_family == AF_INET6) { jbyteArray ipaddress; @@ -238,31 +210,15 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { jbyte *caddr = (jbyte *)&(him6->sin6_addr); if (NET_IsIPv4Mapped(caddr)) { int address; - static jclass inet4Cls = 0; - if (inet4Cls == 0) { - jclass c = (*env)->FindClass(env, "java/net/Inet4Address"); - CHECK_NULL_RETURN(c, NULL); - inet4Cls = (*env)->NewGlobalRef(env, c); - CHECK_NULL_RETURN(inet4Cls, NULL); - (*env)->DeleteLocalRef(env, c); - } - iaObj = (*env)->NewObject(env, inet4Cls, ia4_ctrID); + iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); CHECK_NULL_RETURN(iaObj, NULL); address = NET_IPv4MappedToIPv4(caddr); setInetAddress_addr(env, iaObj, address); setInetAddress_family(env, iaObj, IPv4); } else { - static jclass inet6Cls = 0; jint scope; int ret; - if (inet6Cls == 0) { - jclass c = (*env)->FindClass(env, "java/net/Inet6Address"); - CHECK_NULL_RETURN(c, NULL); - inet6Cls = (*env)->NewGlobalRef(env, c); - CHECK_NULL_RETURN(inet6Cls, NULL); - (*env)->DeleteLocalRef(env, c); - } - iaObj = (*env)->NewObject(env, inet6Cls, ia6_ctrID); + iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); CHECK_NULL_RETURN(iaObj, NULL); ret = setInet6Address_ipaddress(env, iaObj, (char *)&(him6->sin6_addr)); CHECK_NULL_RETURN(ret, NULL); @@ -275,16 +231,7 @@ NET_SockaddrToInetAddress(JNIEnv *env, struct sockaddr *him, int *port) { #endif /* AF_INET6 */ { struct sockaddr_in *him4 = (struct sockaddr_in *)him; - static jclass inet4Cls = 0; - - if (inet4Cls == 0) { - jclass c = (*env)->FindClass(env, "java/net/Inet4Address"); - CHECK_NULL_RETURN(c, NULL); - inet4Cls = (*env)->NewGlobalRef(env, c); - CHECK_NULL_RETURN(inet4Cls, NULL); - (*env)->DeleteLocalRef(env, c); - } - iaObj = (*env)->NewObject(env, inet4Cls, ia4_ctrID); + iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); CHECK_NULL_RETURN(iaObj, NULL); setInetAddress_family(env, iaObj, IPv4); setInetAddress_addr(env, iaObj, ntohl(him4->sin_addr.s_addr)); diff --git a/jdk/src/share/native/java/net/net_util.h b/jdk/src/share/native/java/net/net_util.h index f0f242eb632..b77d02b2fad 100644 --- a/jdk/src/share/native/java/net/net_util.h +++ b/jdk/src/share/native/java/net/net_util.h @@ -55,6 +55,8 @@ extern jfieldID iac_familyID; extern jfieldID iac_hostNameID; extern jfieldID ia_preferIPv6AddressID; +JNIEXPORT void JNICALL initInetAddressIDs(JNIEnv *env); + /** (Inet6Address accessors) * set_ methods return JNI_TRUE on success JNI_FALSE on error * get_ methods that return int/boolean, return -1 on error diff --git a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c index ea67245f0fe..9d79d3eb80a 100644 --- a/jdk/src/solaris/native/java/net/Inet4AddressImpl.c +++ b/jdk/src/solaris/native/java/net/Inet4AddressImpl.c @@ -51,29 +51,6 @@ #define HAS_GLIBC_GETHOSTBY_R 1 #endif -static jclass ni_iacls; -static jclass ni_ia4cls; -static jmethodID ni_ia4ctrID; - -static jboolean initializeInetClasses(JNIEnv *env) -{ - static int initialized = 0; - if (!initialized) { - ni_iacls = (*env)->FindClass(env, "java/net/InetAddress"); - CHECK_NULL_RETURN(ni_iacls, JNI_FALSE); - ni_iacls = (*env)->NewGlobalRef(env, ni_iacls); - CHECK_NULL_RETURN(ni_iacls, JNI_FALSE); - ni_ia4cls = (*env)->FindClass(env, "java/net/Inet4Address"); - CHECK_NULL_RETURN(ni_ia4cls, JNI_FALSE); - ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls); - CHECK_NULL_RETURN(ni_ia4cls, JNI_FALSE); - ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "", "()V"); - CHECK_NULL_RETURN(ni_ia4ctrID, JNI_FALSE); - initialized = 1; - } - return JNI_TRUE; -} - #if defined(_ALLBSD_SOURCE) && !defined(HAS_GLIBC_GETHOSTBY_R) extern jobjectArray lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6); @@ -147,8 +124,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, int error=0; struct addrinfo hints, *res, *resNew = NULL; - if (!initializeInetClasses(env)) - return NULL; + initInetAddressIDs(env); + JNU_CHECK_EXCEPTION_RETURN(env, NULL); if (IS_NULL(host)) { JNU_ThrowNullPointerException(env, "host is null"); @@ -241,7 +218,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, goto cleanupAndReturn; } - ret = (*env)->NewObjectArray(env, retLen, ni_iacls, NULL); + ret = (*env)->NewObjectArray(env, retLen, ia_class, NULL); if (IS_NULL(ret)) { /* we may have memory to free at the end of this */ goto cleanupAndReturn; @@ -251,7 +228,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, /* We need 4 bytes to store ipv4 address; */ int len = 4; - jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); + jobject iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (IS_NULL(iaObj)) { /* we may have memory to free at the end of this */ ret = NULL; @@ -407,8 +384,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, int error = 0; struct addrinfo hints, *res, *resNew = NULL; - if (!initializeInetClasses(env)) - return NULL; + initInetAddressIDs(env); + JNU_CHECK_EXCEPTION_RETURN(env, NULL); if (IS_NULL(host)) { JNU_ThrowNullPointerException(env, "host is null"); @@ -486,7 +463,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, retLen = i; iterator = resNew; - ret = (*env)->NewObjectArray(env, retLen, ni_iacls, NULL); + ret = (*env)->NewObjectArray(env, retLen, ia_class, NULL); if (IS_NULL(ret)) { /* we may have memory to free at the end of this */ @@ -495,7 +472,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, i = 0; while (iterator != NULL) { - jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); + jobject iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (IS_NULL(iaObj)) { ret = NULL; goto cleanupAndReturn; diff --git a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c index 1e4e7d684d1..8de5a9bea1b 100644 --- a/jdk/src/solaris/native/java/net/Inet6AddressImpl.c +++ b/jdk/src/solaris/native/java/net/Inet6AddressImpl.c @@ -117,44 +117,6 @@ Java_java_net_Inet6AddressImpl_getLocalHostName(JNIEnv *env, jobject this) { return (*env)->NewStringUTF(env, hostname); } -static jclass ni_iacls; -static jclass ni_ia4cls; -static jclass ni_ia6cls; -static jmethodID ni_ia4ctrID; -static jmethodID ni_ia6ctrID; -static jboolean preferIPv6Address; - -static jboolean initializeInetClasses(JNIEnv *env) -{ - jfieldID ni_preferIPv6AddressID; - static int initialized = 0; - if (!initialized) { - ni_iacls = (*env)->FindClass(env, "java/net/InetAddress"); - CHECK_NULL_RETURN(ni_iacls, JNI_FALSE); - ni_iacls = (*env)->NewGlobalRef(env, ni_iacls); - CHECK_NULL_RETURN(ni_iacls, JNI_FALSE); - ni_ia4cls = (*env)->FindClass(env, "java/net/Inet4Address"); - CHECK_NULL_RETURN(ni_ia4cls, JNI_FALSE); - ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls); - CHECK_NULL_RETURN(ni_ia4cls, JNI_FALSE); - ni_ia6cls = (*env)->FindClass(env, "java/net/Inet6Address"); - CHECK_NULL_RETURN(ni_ia6cls, JNI_FALSE); - ni_ia6cls = (*env)->NewGlobalRef(env, ni_ia6cls); - CHECK_NULL_RETURN(ni_ia6cls, JNI_FALSE); - ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "", "()V"); - CHECK_NULL_RETURN(ni_ia4ctrID, JNI_FALSE); - ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "", "()V"); - CHECK_NULL_RETURN(ni_ia6ctrID, JNI_FALSE); - ni_preferIPv6AddressID = - (*env)->GetStaticFieldID(env, ni_iacls, "preferIPv6Address", "Z"); - CHECK_NULL_RETURN(ni_preferIPv6AddressID, JNI_FALSE); - preferIPv6Address = - (*env)->GetStaticBooleanField(env, ia_class, ia_preferIPv6AddressID); - initialized = 1; - } - return JNI_TRUE; -} - #ifdef MACOSX /* also called from Inet4AddressImpl.c */ __private_extern__ jobjectArray @@ -169,9 +131,8 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6) jboolean includeLoopback = JNI_FALSE; jobject name; - // Make sure static variables we need are set. - if (!initializeInetClasses(env)) - return NULL; + initInetAddressIDs(env); + JNU_CHECK_EXCEPTION_RETURN(env, NULL); /* If the requested name matches this host's hostname, return IP addresses * from all attached interfaces. (#2844683 et al) This prevents undesired @@ -196,7 +157,7 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6) } name = (*env)->NewStringUTF(env, hostname); - CHECK_NULL(name); + CHECK_NULL_RETURN(name, NULL); /* Iterate over the interfaces, and total up the number of IPv4 and IPv6 * addresses we have. Also keep a count of loopback addresses. We need to @@ -231,10 +192,10 @@ lookupIfLocalhost(JNIEnv *env, const char *hostname, jboolean includeV6) /* Create and fill the Java array. */ int arraySize = addrs4 + addrs6 - (includeLoopback ? 0 : (numV4Loopbacks + numV6Loopbacks)); - result = (*env)->NewObjectArray(env, arraySize, ni_iacls, NULL); + result = (*env)->NewObjectArray(env, arraySize, ia_class, NULL); if (!result) goto done; - if (preferIPv6Address) { + if ((*env)->GetStaticBooleanField(env, ia_class, ia_preferIPv6AddressID)) { i = includeLoopback ? addrs6 : (addrs6 - numV6Loopbacks); j = 0; } else { @@ -298,8 +259,8 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, struct addrinfo hints, *res, *resNew = NULL; #endif /* AF_INET6 */ - if (!initializeInetClasses(env)) - return NULL; + initInetAddressIDs(env); + JNU_CHECK_EXCEPTION_RETURN(env, NULL); if (IS_NULL(host)) { JNU_ThrowNullPointerException(env, "host is null"); @@ -423,14 +384,14 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, retLen = i; iterator = resNew; - ret = (*env)->NewObjectArray(env, retLen, ni_iacls, NULL); + ret = (*env)->NewObjectArray(env, retLen, ia_class, NULL); if (IS_NULL(ret)) { /* we may have memory to free at the end of this */ goto cleanupAndReturn; } - if (preferIPv6Address) { + if ((*env)->GetStaticBooleanField(env, ia_class, ia_preferIPv6AddressID)) { /* AF_INET addresses will be offset by inet6Count */ inetIndex = inet6Count; inet6Index = 0; @@ -443,7 +404,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, while (iterator != NULL) { int ret1; if (iterator->ai_family == AF_INET) { - jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); + jobject iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (IS_NULL(iaObj)) { ret = NULL; goto cleanupAndReturn; @@ -455,7 +416,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, } else if (iterator->ai_family == AF_INET6) { jint scope = 0; - jobject iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID); + jobject iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); if (IS_NULL(iaObj)) { ret = NULL; goto cleanupAndReturn; @@ -549,7 +510,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this, if (!error) { ret = (*env)->NewStringUTF(env, host); - CHECK_NULL(ret); + CHECK_NULL_RETURN(ret, NULL); } #endif /* AF_INET6 */ diff --git a/jdk/src/solaris/native/java/net/NetworkInterface.c b/jdk/src/solaris/native/java/net/NetworkInterface.c index 16acf07a269..380dff19cc8 100644 --- a/jdk/src/solaris/native/java/net/NetworkInterface.c +++ b/jdk/src/solaris/native/java/net/NetworkInterface.c @@ -118,12 +118,7 @@ jfieldID ni_parentID; jfieldID ni_defaultIndexID; jmethodID ni_ctrID; -static jclass ni_iacls; -static jclass ni_ia4cls; -static jclass ni_ia6cls; static jclass ni_ibcls; -static jmethodID ni_ia4ctrID; -static jmethodID ni_ia6ctrID; static jmethodID ni_ibctrID; static jfieldID ni_ibaddressID; static jfieldID ni_ib4broadcastID; @@ -198,27 +193,10 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls) { CHECK_NULL(ni_parentID); ni_ctrID = (*env)->GetMethodID(env, ni_class, "", "()V"); CHECK_NULL(ni_ctrID); - - ni_iacls = (*env)->FindClass(env, "java/net/InetAddress"); - CHECK_NULL(ni_iacls); - ni_iacls = (*env)->NewGlobalRef(env, ni_iacls); - CHECK_NULL(ni_iacls); - ni_ia4cls = (*env)->FindClass(env, "java/net/Inet4Address"); - CHECK_NULL(ni_ia4cls); - ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls); - CHECK_NULL(ni_ia4cls); - ni_ia6cls = (*env)->FindClass(env, "java/net/Inet6Address"); - CHECK_NULL(ni_ia6cls); - ni_ia6cls = (*env)->NewGlobalRef(env, ni_ia6cls); - CHECK_NULL(ni_ia6cls); ni_ibcls = (*env)->FindClass(env, "java/net/InterfaceAddress"); CHECK_NULL(ni_ibcls); ni_ibcls = (*env)->NewGlobalRef(env, ni_ibcls); CHECK_NULL(ni_ibcls); - ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "", "()V"); - CHECK_NULL(ni_ia4ctrID); - ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "", "()V"); - CHECK_NULL(ni_ia6ctrID); ni_ibctrID = (*env)->GetMethodID(env, ni_ibcls, "", "()V"); CHECK_NULL(ni_ibctrID); ni_ibaddressID = (*env)->GetFieldID(env, ni_ibcls, "address", "Ljava/net/InetAddress;"); @@ -228,6 +206,9 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls) { ni_ib4maskID = (*env)->GetFieldID(env, ni_ibcls, "maskLength", "S"); CHECK_NULL(ni_ib4maskID); ni_defaultIndexID = (*env)->GetStaticFieldID(env, ni_class, "defaultIndex", "I"); + CHECK_NULL(ni_defaultIndexID); + + initInetAddressIDs(env); } @@ -654,7 +635,7 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs) { /* * Create the array of InetAddresses */ - addrArr = (*env)->NewObjectArray(env, addr_count, ni_iacls, NULL); + addrArr = (*env)->NewObjectArray(env, addr_count, ia_class, NULL); if (addrArr == NULL) { return NULL; } @@ -671,7 +652,7 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs) { jobject ibObj = NULL; if (addrP->family == AF_INET) { - iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); + iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (iaObj) { setInetAddress_addr(env, iaObj, htonl(((struct sockaddr_in*)addrP->addr)->sin_addr.s_addr)); } @@ -680,7 +661,7 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs) { (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj); if (addrP->brdcast) { jobject ia2Obj = NULL; - ia2Obj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); + ia2Obj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (ia2Obj) { setInetAddress_addr(env, ia2Obj, htonl(((struct sockaddr_in*)addrP->brdcast)->sin_addr.s_addr)); (*env)->SetObjectField(env, ibObj, ni_ib4broadcastID, ia2Obj); @@ -694,7 +675,7 @@ jobject createNetworkInterface(JNIEnv *env, netif *ifs) { #ifdef AF_INET6 if (addrP->family == AF_INET6) { int scope=0; - iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID); + iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); if (iaObj) { int ret = setInet6Address_ipaddress(env, iaObj, (char *)&(((struct sockaddr_in6*)addrP->addr)->sin6_addr)); if (ret == JNI_FALSE) { diff --git a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c index 53d8fae2751..3df46c85171 100644 --- a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c +++ b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c @@ -166,9 +166,8 @@ Java_java_net_PlainDatagramSocketImpl_init(JNIEnv *env, jclass cls) { IO_fd_fdID = NET_GetFileDescriptorID(env); CHECK_NULL(IO_fd_fdID); - Java_java_net_InetAddress_init(env, 0); - Java_java_net_Inet4Address_init(env, 0); - Java_java_net_Inet6Address_init(env, 0); + initInetAddressIDs(env); + JNU_CHECK_EXCEPTION(env); Java_java_net_NetworkInterface_init(env, 0); } diff --git a/jdk/src/solaris/native/java/net/PlainSocketImpl.c b/jdk/src/solaris/native/java/net/PlainSocketImpl.c index a4958efc512..ef6421397af 100644 --- a/jdk/src/solaris/native/java/net/PlainSocketImpl.c +++ b/jdk/src/solaris/native/java/net/PlainSocketImpl.c @@ -162,6 +162,9 @@ Java_java_net_PlainSocketImpl_initProto(JNIEnv *env, jclass cls) { IO_fd_fdID = NET_GetFileDescriptorID(env); CHECK_NULL(IO_fd_fdID); + initInetAddressIDs(env); + JNU_CHECK_EXCEPTION(env); + /* Create the marker fd used for dup2 */ marker_fd = getMarkerFD(); } diff --git a/jdk/src/solaris/native/sun/nio/ch/IOUtil.c b/jdk/src/solaris/native/sun/nio/ch/IOUtil.c index 438bf41ddea..d8bbe849252 100644 --- a/jdk/src/solaris/native/sun/nio/ch/IOUtil.c +++ b/jdk/src/solaris/native/sun/nio/ch/IOUtil.c @@ -35,6 +35,7 @@ #include "java_lang_Integer.h" #include "nio.h" #include "nio_util.h" +#include "net_util.h" static jfieldID fd_fdID; /* for jint 'fd' in java.io.FileDescriptor */ @@ -44,6 +45,7 @@ Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz) { CHECK_NULL(clazz = (*env)->FindClass(env, "java/io/FileDescriptor")); CHECK_NULL(fd_fdID = (*env)->GetFieldID(env, clazz, "fd", "I")); + initInetAddressIDs(env); } JNIEXPORT jboolean JNICALL diff --git a/jdk/src/solaris/native/sun/nio/ch/sctp/SctpNet.c b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpNet.c index f03be57b5d0..db97c948ee6 100644 --- a/jdk/src/solaris/native/sun/nio/ch/sctp/SctpNet.c +++ b/jdk/src/solaris/native/sun/nio/ch/sctp/SctpNet.c @@ -157,6 +157,7 @@ Java_sun_nio_ch_sctp_SctpNet_init } preCloseFD = sp[0]; close(sp[1]); + initInetAddressIDs(env); } /* diff --git a/jdk/src/windows/native/java/net/Inet4AddressImpl.c b/jdk/src/windows/native/java/net/Inet4AddressImpl.c index f34b5e12431..f21f2de3245 100644 --- a/jdk/src/windows/native/java/net/Inet4AddressImpl.c +++ b/jdk/src/windows/native/java/net/Inet4AddressImpl.c @@ -111,11 +111,6 @@ Java_java_net_Inet4AddressImpl_getLocalHostName (JNIEnv *env, jobject this) { return JNU_NewStringPlatform(env, hostname); } -static jclass ni_iacls; -static jclass ni_ia4cls; -static jmethodID ni_ia4ctrID; -static int initialized = 0; - /* * Find an internet address for a given hostname. Not this this * code only works for addresses of type INET. The translation @@ -140,19 +135,8 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, jobjectArray ret = NULL; - if (!initialized) { - ni_iacls = (*env)->FindClass(env, "java/net/InetAddress"); - CHECK_NULL_RETURN(ni_iacls, NULL); - ni_iacls = (*env)->NewGlobalRef(env, ni_iacls); - CHECK_NULL_RETURN(ni_iacls, NULL); - ni_ia4cls = (*env)->FindClass(env, "java/net/Inet4Address"); - CHECK_NULL_RETURN(ni_ia4cls, NULL); - ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls); - CHECK_NULL_RETURN(ni_ia4cls, NULL); - ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "", "()V"); - CHECK_NULL_RETURN(ni_ia4ctrID, NULL); - initialized = 1; - } + initInetAddressIDs(env); + JNU_CHECK_EXCEPTION_RETURN(env, NULL); if (IS_NULL(host)) { JNU_ThrowNullPointerException(env, "host argument"); @@ -196,13 +180,13 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, address |= (addr[1]<<8) & 0xff00; address |= addr[0]; - ret = (*env)->NewObjectArray(env, 1, ni_iacls, NULL); + ret = (*env)->NewObjectArray(env, 1, ia_class, NULL); if (IS_NULL(ret)) { goto cleanupAndReturn; } - iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); + iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (IS_NULL(iaObj)) { ret = NULL; goto cleanupAndReturn; @@ -226,7 +210,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, addrp++; } - ret = (*env)->NewObjectArray(env, i, ni_iacls, NULL); + ret = (*env)->NewObjectArray(env, i, ia_class, NULL); if (IS_NULL(ret)) { goto cleanupAndReturn; @@ -235,7 +219,7 @@ Java_java_net_Inet4AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, addrp = (struct in_addr **) hp->h_addr_list; i = 0; while (*addrp != (struct in_addr *) 0) { - jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); + jobject iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (IS_NULL(iaObj)) { ret = NULL; goto cleanupAndReturn; diff --git a/jdk/src/windows/native/java/net/Inet6AddressImpl.c b/jdk/src/windows/native/java/net/Inet6AddressImpl.c index 24176b29278..cac70b34dfa 100644 --- a/jdk/src/windows/native/java/net/Inet6AddressImpl.c +++ b/jdk/src/windows/native/java/net/Inet6AddressImpl.c @@ -72,13 +72,6 @@ Java_java_net_Inet6AddressImpl_getLocalHostName (JNIEnv *env, jobject this) { return JNU_NewStringPlatform (env, hostname); } -static jclass ni_iacls; -static jclass ni_ia4cls; -static jclass ni_ia6cls; -static jmethodID ni_ia4ctrID; -static jmethodID ni_ia6ctrID; -static int initialized = 0; - JNIEXPORT jobjectArray JNICALL Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, jstring host) { @@ -86,30 +79,13 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, jobjectArray ret = 0; int retLen = 0; jboolean preferIPv6Address; - static jfieldID ia_preferIPv6AddressID; int error=0; struct addrinfo hints, *res, *resNew = NULL; - if (!initialized) { - ni_iacls = (*env)->FindClass(env, "java/net/InetAddress"); - CHECK_NULL_RETURN(ni_iacls, NULL); - ni_iacls = (*env)->NewGlobalRef(env, ni_iacls); - CHECK_NULL_RETURN(ni_iacls, NULL); - ni_ia4cls = (*env)->FindClass(env, "java/net/Inet4Address"); - CHECK_NULL_RETURN(ni_ia4cls, NULL); - ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls); - CHECK_NULL_RETURN(ni_ia4cls, NULL); - ni_ia6cls = (*env)->FindClass(env, "java/net/Inet6Address"); - CHECK_NULL_RETURN(ni_ia6cls, NULL); - ni_ia6cls = (*env)->NewGlobalRef(env, ni_ia6cls); - CHECK_NULL_RETURN(ni_ia6cls, NULL); - ni_ia4ctrID = (*env)->GetMethodID(env, ni_ia4cls, "", "()V"); - CHECK_NULL_RETURN(ni_ia4ctrID, NULL); - ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "", "()V"); - CHECK_NULL_RETURN(ni_ia6ctrID, NULL); - initialized = 1; - } + initInetAddressIDs(env); + JNU_CHECK_EXCEPTION_RETURN(env, NULL); + if (IS_NULL(host)) { JNU_ThrowNullPointerException(env, "host is null"); return 0; @@ -117,17 +93,6 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, hostname = JNU_GetStringPlatformChars(env, host, JNI_FALSE); CHECK_NULL_RETURN(hostname, NULL); - if (ia_preferIPv6AddressID == NULL) { - jclass c = (*env)->FindClass(env,"java/net/InetAddress"); - if (c) { - ia_preferIPv6AddressID = - (*env)->GetStaticFieldID(env, c, "preferIPv6Address", "Z"); - } - if (ia_preferIPv6AddressID == NULL) { - JNU_ReleaseStringPlatformChars(env, host, hostname); - return NULL; - } - } /* get the address preference */ preferIPv6Address = (*env)->GetStaticBooleanField(env, ia_class, ia_preferIPv6AddressID); @@ -229,7 +194,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, retLen = i; iterator = resNew; i = 0; - ret = (*env)->NewObjectArray(env, retLen, ni_iacls, NULL); + ret = (*env)->NewObjectArray(env, retLen, ia_class, NULL); if (IS_NULL(ret)) { /* we may have memory to free at the end of this */ @@ -246,7 +211,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, while (iterator != NULL) { if (iterator->ai_family == AF_INET) { - jobject iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4ctrID); + jobject iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (IS_NULL(iaObj)) { ret = NULL; goto cleanupAndReturn; @@ -257,7 +222,7 @@ Java_java_net_Inet6AddressImpl_lookupAllHostAddr(JNIEnv *env, jobject this, inetIndex ++; } else if (iterator->ai_family == AF_INET6) { jint scope = 0, ret1; - jobject iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID); + jobject iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); if (IS_NULL(iaObj)) { ret = NULL; goto cleanupAndReturn; @@ -347,7 +312,7 @@ Java_java_net_Inet6AddressImpl_getHostByAddr(JNIEnv *env, jobject this, if (!error) { ret = (*env)->NewStringUTF(env, host); - CHECK_NULL(ret); + CHECK_NULL_RETURN(ret, NULL); } if (ret == NULL) { diff --git a/jdk/src/windows/native/java/net/NetworkInterface.c b/jdk/src/windows/native/java/net/NetworkInterface.c index fee86874771..44e9a61636b 100644 --- a/jdk/src/windows/native/java/net/NetworkInterface.c +++ b/jdk/src/windows/native/java/net/NetworkInterface.c @@ -65,13 +65,6 @@ jfieldID ni_bindsID; /* NetworkInterface.bindings */ jfieldID ni_nameID; /* NetworkInterface.name */ jfieldID ni_displayNameID; /* NetworkInterface.displayName */ jfieldID ni_childsID; /* NetworkInterface.childs */ -jclass ni_iacls; /* InetAddress */ - -jclass ni_ia4cls; /* Inet4Address */ -jmethodID ni_ia4Ctor; /* Inet4Address() */ - -jclass ni_ia6cls; /* Inet6Address */ -jmethodID ni_ia6ctrID; /* Inet6Address() */ jclass ni_ibcls; /* InterfaceAddress */ jmethodID ni_ibctrID; /* InterfaceAddress() */ @@ -515,26 +508,6 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls) CHECK_NULL(ni_childsID); ni_ctor = (*env)->GetMethodID(env, ni_class, "", "()V"); CHECK_NULL(ni_ctor); - - ni_iacls = (*env)->FindClass(env, "java/net/InetAddress"); - CHECK_NULL(ni_iacls); - ni_iacls = (*env)->NewGlobalRef(env, ni_iacls); - CHECK_NULL(ni_iacls); - - ni_ia4cls = (*env)->FindClass(env, "java/net/Inet4Address"); - CHECK_NULL(ni_ia4cls); - ni_ia4cls = (*env)->NewGlobalRef(env, ni_ia4cls); - CHECK_NULL(ni_ia4cls); - ni_ia4Ctor = (*env)->GetMethodID(env, ni_ia4cls, "", "()V"); - CHECK_NULL(ni_ia4Ctor); - - ni_ia6cls = (*env)->FindClass(env, "java/net/Inet6Address"); - CHECK_NULL(ni_ia6cls); - ni_ia6cls = (*env)->NewGlobalRef(env, ni_ia6cls); - CHECK_NULL(ni_ia6cls); - ni_ia6ctrID = (*env)->GetMethodID(env, ni_ia6cls, "", "()V"); - CHECK_NULL(ni_ia6ctrID); - ni_ibcls = (*env)->FindClass(env, "java/net/InterfaceAddress"); CHECK_NULL(ni_ibcls); ni_ibcls = (*env)->NewGlobalRef(env, ni_ibcls); @@ -546,6 +519,9 @@ Java_java_net_NetworkInterface_init(JNIEnv *env, jclass cls) ni_ibbroadcastID = (*env)->GetFieldID(env, ni_ibcls, "broadcast", "Ljava/net/Inet4Address;"); CHECK_NULL(ni_ibbroadcastID); ni_ibmaskID = (*env)->GetFieldID(env, ni_ibcls, "maskLength", "S"); + CHECK_NULL(ni_ibmaskID); + + initInetAddressIDs(env); } /* @@ -591,7 +567,7 @@ jobject createNetworkInterface return NULL; } } - addrArr = (*env)->NewObjectArray(env, netaddrCount, ni_iacls, NULL); + addrArr = (*env)->NewObjectArray(env, netaddrCount, ia_class, NULL); if (addrArr == NULL) { free_netaddr(netaddrP); return NULL; @@ -609,7 +585,7 @@ jobject createNetworkInterface jobject iaObj, ia2Obj; jobject ibObj = NULL; if (addrs->addr.him.sa_family == AF_INET) { - iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4Ctor); + iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (iaObj == NULL) { free_netaddr(netaddrP); return NULL; @@ -624,7 +600,7 @@ jobject createNetworkInterface return NULL; } (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj); - ia2Obj = (*env)->NewObject(env, ni_ia4cls, ni_ia4Ctor); + ia2Obj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (ia2Obj == NULL) { free_netaddr(netaddrP); return NULL; @@ -636,7 +612,7 @@ jobject createNetworkInterface } } else /* AF_INET6 */ { int scope; - iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID); + iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); if (iaObj) { int ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr)); if (ret == JNI_FALSE) { diff --git a/jdk/src/windows/native/java/net/NetworkInterface.h b/jdk/src/windows/native/java/net/NetworkInterface.h index a73c62c66b3..929ac507f89 100644 --- a/jdk/src/windows/native/java/net/NetworkInterface.h +++ b/jdk/src/windows/native/java/net/NetworkInterface.h @@ -70,16 +70,6 @@ extern jfieldID ni_nameID; /* NetworkInterface.name */ extern jfieldID ni_displayNameID; /* NetworkInterface.displayName */ extern jfieldID ni_childsID; /* NetworkInterface.childs */ -extern jclass ni_iacls; /* InetAddress */ - -extern jclass ni_ia4cls; /* Inet4Address */ -extern jmethodID ni_ia4Ctor; /* Inet4Address() */ - -extern jclass ni_ia6cls; /* Inet6Address */ -extern jmethodID ni_ia6ctrID; /* Inet6Address() */ -extern jfieldID ni_ia6ipaddressID; -extern jfieldID ni_ia6ipaddressID; - extern jclass ni_ibcls; /* InterfaceAddress */ extern jmethodID ni_ibctrID; /* InterfaceAddress() */ extern jfieldID ni_ibaddressID; /* InterfaceAddress.address */ diff --git a/jdk/src/windows/native/java/net/NetworkInterface_winXP.c b/jdk/src/windows/native/java/net/NetworkInterface_winXP.c index 7e3e79d1f49..4d29e7f799d 100644 --- a/jdk/src/windows/native/java/net/NetworkInterface_winXP.c +++ b/jdk/src/windows/native/java/net/NetworkInterface_winXP.c @@ -504,7 +504,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs) } } - addrArr = (*env)->NewObjectArray(env, netaddrCount, ni_iacls, NULL); + addrArr = (*env)->NewObjectArray(env, netaddrCount, ia_class, NULL); if (addrArr == NULL) { return NULL; } @@ -522,7 +522,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs) jobject iaObj, ia2Obj; jobject ibObj = NULL; if (addrs->addr.him.sa_family == AF_INET) { - iaObj = (*env)->NewObject(env, ni_ia4cls, ni_ia4Ctor); + iaObj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (iaObj == NULL) { return NULL; } @@ -536,7 +536,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs) return NULL; } (*env)->SetObjectField(env, ibObj, ni_ibaddressID, iaObj); - ia2Obj = (*env)->NewObject(env, ni_ia4cls, ni_ia4Ctor); + ia2Obj = (*env)->NewObject(env, ia4_class, ia4_ctrID); if (ia2Obj == NULL) { free_netaddr(netaddrP); return NULL; @@ -547,7 +547,7 @@ static jobject createNetworkInterfaceXP(JNIEnv *env, netif *ifs) (*env)->SetObjectArrayElement(env, bindsArr, bind_index++, ibObj); } else /* AF_INET6 */ { int scope; - iaObj = (*env)->NewObject(env, ni_ia6cls, ni_ia6ctrID); + iaObj = (*env)->NewObject(env, ia6_class, ia6_ctrID); if (iaObj) { int ret = setInet6Address_ipaddress(env, iaObj, (jbyte *)&(addrs->addr.him6.sin6_addr.s6_addr)); if (ret == JNI_FALSE) { diff --git a/jdk/src/windows/native/sun/nio/ch/IOUtil.c b/jdk/src/windows/native/sun/nio/ch/IOUtil.c index 370dcf5e23f..49de1eb89d7 100644 --- a/jdk/src/windows/native/sun/nio/ch/IOUtil.c +++ b/jdk/src/windows/native/sun/nio/ch/IOUtil.c @@ -33,6 +33,7 @@ #include "nio.h" #include "nio_util.h" +#include "net_util.h" #include "sun_nio_ch_IOUtil.h" /* field id for jlong 'handle' in java.io.FileDescriptor used for file fds */ @@ -55,6 +56,7 @@ Java_sun_nio_ch_IOUtil_initIDs(JNIEnv *env, jclass clazz) CHECK_NULL(clazz = (*env)->FindClass(env, "java/io/FileDescriptor")); CHECK_NULL(fd_fdID = (*env)->GetFieldID(env, clazz, "fd", "I")); CHECK_NULL(handle_fdID = (*env)->GetFieldID(env, clazz, "handle", "J")); + initInetAddressIDs(env); } /************************************************************** From 23cc62f593e5cddd762b222a5fb4ac9d907cea6b Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 5 Feb 2014 11:03:54 +0100 Subject: [PATCH 107/159] 8026773: Failing compilation in Corba does not fail the build Reviewed-by: ihse, tbell --- common/autoconf/spec.gmk.in | 11 +++++++---- make/common/JavaCompilation.gmk | 12 +++++++++++- 2 files changed, 18 insertions(+), 5 deletions(-) diff --git a/common/autoconf/spec.gmk.in b/common/autoconf/spec.gmk.in index b92db9125da..ee18cb1b07a 100644 --- a/common/autoconf/spec.gmk.in +++ b/common/autoconf/spec.gmk.in @@ -456,10 +456,13 @@ NATIVE2ASCII:=@FIXPATH@ @NATIVE2ASCII@ JARSIGNER:=@FIXPATH@ @JARSIGNER@ # You run the new javac using the boot jdk with $(BOOT_JDK)/bin/java $(NEW_JAVAC) ... -BOOTSTRAP_JAVAC_JAR:=$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar -BOOTSTRAP_JAVAC_ARGS:="-Xbootclasspath/p:$(BOOTSTRAP_JAVAC_JAR)" -cp $(BOOTSTRAP_JAVAC_JAR) -NEW_JAVAC = $(BOOTSTRAP_JAVAC_ARGS) com.sun.tools.javac.Main -NEW_JAVADOC = $(BOOTSTRAP_JAVAC_ARGS) com.sun.tools.javadoc.Main +INTERIM_LANGTOOLS_JAR := $(LANGTOOLS_OUTPUTDIR)/dist/interim_langtools.jar +INTERIM_LANGTOOLS_ARGS := "-Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR)" -cp $(INTERIM_LANGTOOLS_JAR) +NEW_JAVAC = $(INTERIM_LANGTOOLS_ARGS) com.sun.tools.javac.Main +NEW_JAVADOC = $(INTERIM_LANGTOOLS_ARGS) com.sun.tools.javadoc.Main + +# The interim corba jar is needed for running rmic +INTERIM_CORBA_JAR := $(CORBA_OUTPUTDIR)/dist/interim_corba.jar # Base flags for RC # Guarding this against resetting value. Legacy make files include spec multiple diff --git a/make/common/JavaCompilation.gmk b/make/common/JavaCompilation.gmk index d192c66cdd6..fe4ff3e5eb1 100644 --- a/make/common/JavaCompilation.gmk +++ b/make/common/JavaCompilation.gmk @@ -247,6 +247,8 @@ define SetupArchive $$($1_SUPDATE_CONTENTS) \ $$($1_JARINDEX) && true ) + # Add jar to target list + $1 += $$($1_JAR) endef define SetupZipArchive @@ -307,6 +309,9 @@ define SetupZipArchive $(ECHO) Updating $$($1_NAME) $$(foreach i,$$($1_SRC),(cd $$i && $(ZIP) -qru $$@ . $$($1_ZIP_INCLUDES) $$($1_ZIP_EXCLUDES) -x \*_the.\* $$(addprefix -x$(SPACE),$$(patsubst $$i/%,%,$$($1_EXCLUDE_FILES))) || test "$$$$?" = "12" )$$(NEWLINE)) true $(TOUCH) $$@ + + # Add zip to target list + $1 += $$($1_ZIP) endef define add_file_to_copy @@ -579,6 +584,9 @@ define SetupJavaCompilation JARINDEX:=$$($1_JARINDEX), \ HEADERS:=$$($1_HEADERS), \ SETUP:=$$($1_SETUP))) + + # Add jar to target list + $1 += $$($1_JAR) endif # Check if a srczip was specified, then setup the rules for the srczip. @@ -589,6 +597,8 @@ define SetupJavaCompilation INCLUDES:=$$($1_INCLUDES), \ EXCLUDES:=$$($1_EXCLUDES), \ EXCLUDE_FILES:=$$($1_EXCLUDE_FILES))) - endif + # Add zip to target list + $1 += $$($1_SRCZIP) + endif endef From 961e7da0a4ec7625288cdf81e29a904e6b7f341a Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 5 Feb 2014 11:04:04 +0100 Subject: [PATCH 108/159] 8026773: Failing compilation in Corba does not fail the build Reviewed-by: ihse, tbell --- langtools/make/BuildLangtools.gmk | 180 ++------------------------- langtools/make/CommonLangtools.gmk | 35 ++++++ langtools/make/CompileInterim.gmk | 50 ++++++++ langtools/make/CompileLangtools.gmk | 62 +++++++++ langtools/make/GensrcLangtools.gmk | 111 +++++++++++++++++ langtools/make/GenstubsLangtools.gmk | 70 +++++++++++ 6 files changed, 339 insertions(+), 169 deletions(-) create mode 100644 langtools/make/CommonLangtools.gmk create mode 100644 langtools/make/CompileInterim.gmk create mode 100644 langtools/make/CompileLangtools.gmk create mode 100644 langtools/make/GensrcLangtools.gmk create mode 100644 langtools/make/GenstubsLangtools.gmk diff --git a/langtools/make/BuildLangtools.gmk b/langtools/make/BuildLangtools.gmk index 0ffcb31bcca..f59ef574f4d 100644 --- a/langtools/make/BuildLangtools.gmk +++ b/langtools/make/BuildLangtools.gmk @@ -27,179 +27,21 @@ default: all include $(SPEC) -include MakeBase.gmk -include JavaCompilation.gmk -# The BOOT_JAVAC setup uses the bootdir compiler to compile the tools -# and the bootstrap javac, to be run by the bootdir jvm. -$(eval $(call SetupJavaCompiler,BOOT_JAVAC, \ - JAVAC := $(JAVAC), \ - SERVER_DIR := $(SJAVAC_SERVER_DIR), \ - SERVER_JVM := $(SJAVAC_SERVER_JAVA), \ - FLAGS := -XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror)) +gensrc-langtools: + +$(MAKE) -f $(LANGTOOLS_TOPDIR)/make/GensrcLangtools.gmk -# javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied. -RESOURCE_SUFFIXES := .gif .xml .css .js javax.tools.JavaCompilerTool +interim-langtools: gensrc-langtools + +$(MAKE) -f $(LANGTOOLS_TOPDIR)/make/CompileInterim.gmk -# Now setup the compilation of the properties compilation tool. You can depend -# upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we -# add src/share/classes to the sourcepath. This is necessary since the GenStubs -# program needs to be linked and run towards the new javac sources. -$(eval $(call SetupJavaCompilation,BUILD_TOOLS, \ - SETUP := BOOT_JAVAC, \ - DISABLE_SJAVAC := true, \ - ADD_JAVAC_FLAGS := -Xprefer:source, \ - SRC := $(LANGTOOLS_TOPDIR)/make/tools $(LANGTOOLS_TOPDIR)/src/share/classes, \ - INCLUDES := compileproperties genstubs, \ - BIN := $(LANGTOOLS_OUTPUTDIR)/btclasses)) +genstubs-langtools: interim-langtools + +$(MAKE) -f $(LANGTOOLS_TOPDIR)/make/GenstubsLangtools.gmk -# The compileprops tools compiles a properties file into a resource bundle. -TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/btclasses compileproperties.CompileProperties -quiet +compile-langtools: gensrc-langtools interim-langtools genstubs-langtools + +$(MAKE) -f $(LANGTOOLS_TOPDIR)/make/CompileLangtools.gmk -# Lookup the properties that need to be compiled into resource bundles. -PROPSOURCES := $(shell $(FIND) $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties") +all: compile-langtools -# Strip away prefix and suffix, leaving for example only: "com/sun/tools/javac/resources/javac_zh_CN" -PROPPATHS := $(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties, %, $(PROPSOURCES)) +.PHONY: default all +.PHONY: gensrc-langtools interim-langtools genstubs-langtools compile-langtools -# Generate the list of java files to be created. -PROPJAVAS := $(patsubst %, $(LANGTOOLS_OUTPUTDIR)/gensrc/%.java, $(PROPPATHS)) - -# Generate the package dirs for the tobe generated java files. -PROPDIRS := $(dir $(PROPJAVAS)) - -# Now generate a sequence of "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle" -# suitable to be fed into the CompileProperties command. -PROPCMDLINE := $(subst _SPACE_, $(SPACE), $(join $(addprefix -compile_SPACE_, $(PROPSOURCES)), \ - $(addsuffix _SPACE_java.util.ListResourceBundle, $(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/, $(addsuffix .java, $(PROPPATHS)))))) - -# Now setup the rule for the generation of the resource bundles. -$(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d: $(PROPSOURCES) $(BUILD_TOOLS) - $(RM) -r $(@D)/* - $(MKDIR) -p $(@D) $(PROPDIRS) - $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties - $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties - $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties - $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties - $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties - $(ECHO) Compiling $(words $(PROPSOURCES) v1 v2 v3) properties into resource bundles - $(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \ - -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \ - $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \ - java.util.ListResourceBundle \ - -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \ - $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \ - java.util.ListResourceBundle \ - -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \ - $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \ - java.util.ListResourceBundle \ - -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties \ - $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.java \ - java.util.ListResourceBundle \ - -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties \ - $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.java \ - java.util.ListResourceBundle - $(ECHO) PROPS_ARE_CREATED = yes > $@ - -# Trigger the generation of the resource bundles. After the resource bundles have -# been compiled, then the makefile will restart and the newly created java files -# will become part of the build further along in the makefile. --include $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d - -ifeq ($(PROPS_ARE_CREATED), yes) - # Setup the rules to build a dist/bootstrap/lib/javac.jar, ie a smaller intermediate javac - # that can be compiled with an old javac. The intermediate javac is then used - # to compile javac again and to build the complete new jdk. - $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_LANGTOOLS, \ - SETUP := BOOT_JAVAC, \ - DISABLE_SJAVAC := true, \ - SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \ - EXCLUDES := com/sun/tools/javac/nio, \ - COPY := $(RESOURCE_SUFFIXES), \ - BIN := $(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap)) - - $(eval $(call SetupArchive,ARCHIVE_BOOTSTRAP_JAVAC, $(BUILD_BOOTSTRAP_LANGTOOLS), \ - SRCS := $(LANGTOOLS_OUTPUTDIR)/btclasses/bootstrap, \ - JAR := $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar, \ - SUFFIXES := .class $(RESOURCE_SUFFIXES))) - - # GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not - # yet built. It is currently not needed but might be again in the future. The following - # exercises the functionality to verify that it works. - TOOL_GENSTUBS_CMD = $(JAVA) \ - "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ - -classpath $(LANGTOOLS_OUTPUTDIR)/btclasses \ - genstubs.GenStubs - - # We fetch source from the JDK... - JDKS = $(JDK_TOPDIR)/src/share/classes - - # Build the list of classes to generate stubs from. java/util/function/Predicate.java isn't - # currently needed, but is used as a demo for now. - - STUBSOURCES := $(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \ - -e "$(JDKS)/java/util/function/Predicate.java") - - # Rewrite the file names into class names because the GenStubs tool require this. - STUBCLASSES := $(subst /,., $(patsubst $(JDKS)/%.java, %, $(STUBSOURCES))) - - # Now setup the build recipe for genstubs. - $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d: $(STUBSOURCES) $(BUILD_TOOLS) \ - $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ - $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props.d - $(MKDIR) -p $(@D) - $(MKDIR) -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs - $(ECHO) $(LOG_INFO) Generating stubs from JDK sources. - ($(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES) && $(ECHO) STUBS_ARE_CREATED = yes > $@) - if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs > /dev/null 2>&1; then \ - $(ECHO) $(LOG_INFO) No changes in the stubs!; \ - $(RM) -r $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \ - else \ - $(ECHO) $(LOG_INFO) Changes in stubs detected!; \ - $(RM) -r $(@D); \ - $(MV) $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \ - fi - $(ECHO) STUBS_ARE_CREATED = yes > $@ - - # Trigger a generation of the genstubs java source code and a restart - # of the makefile to make sure that the following build setup use the - # newly created java files. - -include $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs.d - - ifeq ($(STUBS_ARE_CREATED), yes) - # Setup a compiler configuration using the intermediate javac in dist/bootstrap/lib/javac.jar - # that generates code for the new jdk that is being built. - # The code compiled by this compiler setup, cannot necessarily be run with the bootstrap jvm. - $(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE, \ - JVM := $(JAVA), \ - JAVAC := "-Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar" \ - -cp $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ - com.sun.tools.javac.Main, \ - FLAGS := -XDignore.symbol.file=true -Xlint:all$(COMMA)-deprecation -Werror, \ - SERVER_DIR := $(SJAVAC_SERVER_DIR), \ - SERVER_JVM := $(SJAVAC_SERVER_JAVA))) - - $(eval $(call SetupJavaCompilation,BUILD_FULL_JAVAC, \ - SETUP := GENERATE_NEWBYTECODE, \ - SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc \ - $(LANGTOOLS_OUTPUTDIR)/genstubs, \ - EXCLUDES := java/util java/io java/nio, \ - COPY := $(RESOURCE_SUFFIXES), \ - BIN := $(LANGTOOLS_OUTPUTDIR)/classes)) - - $(eval $(call SetupArchive,ARCHIVE_FULL_JAVAC, $(BUILD_FULL_JAVAC), \ - SETUP := GENERATE_NEWBYTECODE, \ - SRCS := $(LANGTOOLS_OUTPUTDIR)/classes, \ - SUFFIXES := .class $(RESOURCE_SUFFIXES), \ - JAR := $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar)) - - $(eval $(call SetupZipArchive,ZIP_FULL_JAVAC_SOURCE, \ - SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \ - ZIP := $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip)) - - all: $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar \ - $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip \ - $(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar - - endif -endif diff --git a/langtools/make/CommonLangtools.gmk b/langtools/make/CommonLangtools.gmk new file mode 100644 index 00000000000..f32a0ac2ab7 --- /dev/null +++ b/langtools/make/CommonLangtools.gmk @@ -0,0 +1,35 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# The BOOT_JAVAC setup uses the boot jdk compiler to compile the tools +# and the interim javac, to be run by the boot jdk. +$(eval $(call SetupJavaCompiler,BOOT_JAVAC, \ + JAVAC := $(JAVAC), \ + SERVER_DIR := $(SJAVAC_SERVER_DIR), \ + SERVER_JVM := $(SJAVAC_SERVER_JAVA), \ + FLAGS := -XDignore.symbol.file=true -g -Xlint:all$(COMMA)-deprecation -Werror)) + +# javax.tools.JavaCompilerTool isn't really a suffix but this gets the file copied. +RESOURCE_SUFFIXES := .gif .xml .css .js javax.tools.JavaCompilerTool diff --git a/langtools/make/CompileInterim.gmk b/langtools/make/CompileInterim.gmk new file mode 100644 index 00000000000..b425dc932b5 --- /dev/null +++ b/langtools/make/CompileInterim.gmk @@ -0,0 +1,50 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# This must be the first rule +default: all + +include $(SPEC) +include MakeBase.gmk +include JavaCompilation.gmk + +include CommonLangtools.gmk + +# Setup the rules to build the interim langtools jar, which is compiled by +# the boot javac and can be run on the boot jdk. This will be used to compile +# the rest of the product. Include the Genstubs build tool in this compilation +# as it will be used together with the interim javac. +$(eval $(call SetupJavaCompilation,BUILD_INTERIM_LANGTOOLS, \ + SETUP := BOOT_JAVAC, \ + DISABLE_SJAVAC := true, \ + SRC := $(LANGTOOLS_TOPDIR)/src/share/classes \ + $(LANGTOOLS_OUTPUTDIR)/gensrc \ + $(LANGTOOLS_TOPDIR)/make/tools, \ + EXCLUDES := com/sun/tools/javac/nio compileproperties anttasks crules, \ + COPY := $(RESOURCE_SUFFIXES), \ + BIN := $(LANGTOOLS_OUTPUTDIR)/interim_classes, \ + JAR := $(INTERIM_LANGTOOLS_JAR))) + +all: $(BUILD_INTERIM_LANGTOOLS) diff --git a/langtools/make/CompileLangtools.gmk b/langtools/make/CompileLangtools.gmk new file mode 100644 index 00000000000..d15be9dde6a --- /dev/null +++ b/langtools/make/CompileLangtools.gmk @@ -0,0 +1,62 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# This must be the first rule +default: all + +include $(SPEC) +include MakeBase.gmk +include JavaCompilation.gmk + +include CommonLangtools.gmk + +# Setup a compiler configuration using javac from the interim langtools jar +# that generates code for the new jdk that is being built. The code compiled +# by this compiler setup, cannot necessarily be run with the bootstrap jvm. +$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE, \ + JVM := $(JAVA), \ + JAVAC := $(NEW_JAVAC), \ + FLAGS := -XDignore.symbol.file=true -Xlint:all$(COMMA)-deprecation -Werror, \ + SERVER_DIR := $(SJAVAC_SERVER_DIR), \ + SERVER_JVM := $(SJAVAC_SERVER_JAVA))) + +$(eval $(call SetupJavaCompilation,BUILD_FULL_LANGTOOLS, \ + SETUP := GENERATE_NEWBYTECODE, \ + SRC := $(LANGTOOLS_TOPDIR)/src/share/classes \ + $(LANGTOOLS_OUTPUTDIR)/gensrc \ + $(LANGTOOLS_OUTPUTDIR)/genstubs, \ + EXCLUDES := java/util java/io java/nio, \ + COPY := $(RESOURCE_SUFFIXES), \ + BIN := $(LANGTOOLS_OUTPUTDIR)/classes, \ + JAR := $(LANGTOOLS_OUTPUTDIR)/dist/lib/classes.jar)) + +# Construct the source zip separately to avoid picking up the genstubs sources. +$(eval $(call SetupZipArchive,ZIP_FULL_LANGTOOLS_SOURCE, \ + SRC := $(LANGTOOLS_TOPDIR)/src/share/classes $(LANGTOOLS_OUTPUTDIR)/gensrc, \ + ZIP := $(LANGTOOLS_OUTPUTDIR)/dist/lib/src.zip)) + +all: \ + $(BUILD_FULL_LANGTOOLS) \ + $(ZIP_FULL_LANGTOOLS_SOURCE) diff --git a/langtools/make/GensrcLangtools.gmk b/langtools/make/GensrcLangtools.gmk new file mode 100644 index 00000000000..e361a18cb10 --- /dev/null +++ b/langtools/make/GensrcLangtools.gmk @@ -0,0 +1,111 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# This must be the first rule +default: all + +include $(SPEC) +include MakeBase.gmk +include JavaCompilation.gmk + +include CommonLangtools.gmk + +################################################################################ +# Setup the compilation of the properties compilation tool. You can depend +# upon $(BUILD_TOOLS) to trigger a compilation of the tools. Note that we +# add src/share/classes to the sourcepath. This is necessary since the GenStubs +# program needs to be linked and run with the new javac sources. +$(eval $(call SetupJavaCompilation,BUILD_TOOLS, \ + SETUP := BOOT_JAVAC, \ + DISABLE_SJAVAC := true, \ + ADD_JAVAC_FLAGS := -Xprefer:source, \ + SRC := $(LANGTOOLS_TOPDIR)/make/tools, \ + INCLUDES := compileproperties, \ + BIN := $(LANGTOOLS_OUTPUTDIR)/buildtools_classes)) + +################################################################################ +# The compileprops tools compiles a properties file into a resource bundle. +TOOL_COMPILEPROPS_CMD := $(JAVA) -cp $(LANGTOOLS_OUTPUTDIR)/buildtools_classes \ + compileproperties.CompileProperties -quiet + +# Lookup the properties that need to be compiled into resource bundles. +PROPSOURCES := $(shell $(FIND) $(LANGTOOLS_TOPDIR)/src/share/classes -name "*.properties") + +# Strip away prefix and suffix, leaving for example only: +# "com/sun/tools/javac/resources/javac_zh_CN" +PROPPATHS := $(patsubst $(LANGTOOLS_TOPDIR)/src/share/classes/%.properties, %, $(PROPSOURCES)) + +# Generate the list of java files to be created. +PROPJAVAS := $(patsubst %, $(LANGTOOLS_OUTPUTDIR)/gensrc/%.java, $(PROPPATHS)) + +# Generate the package dirs for the tobe generated java files. +PROPDIRS := $(dir $(PROPJAVAS)) + +# Now generate a sequence of: +# "-compile ...javac_zh_CN.properties ...javac_zh_CN.java java.util.ListResourceBundle" +# suitable to be fed into the CompileProperties command. +PROPCMDLINE := $(subst _SPACE_, $(SPACE), \ + $(join $(addprefix -compile_SPACE_, $(PROPSOURCES)), \ + $(addsuffix _SPACE_java.util.ListResourceBundle, \ + $(addprefix _SPACE_$(LANGTOOLS_OUTPUTDIR)/gensrc/, \ + $(addsuffix .java, $(PROPPATHS)))))) + +# Now setup the rule for the generation of the resource bundles. +$(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props: $(PROPSOURCES) $(BUILD_TOOLS) + $(RM) -r $(@D)/* + $(MKDIR) -p $(@D) $(PROPDIRS) + $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \ + > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties + $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \ + > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties + $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \ + > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties + $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \ + > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties + $(PRINTF) "jdk=$(JDK_VERSION)\nfull=$(FULL_VERSION)\nrelease=$(RELEASE)\n" \ + > $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties + $(ECHO) Compiling $(words $(PROPSOURCES) javah javap javac jdeps javadoc) \ + properties into resource bundles + $(TOOL_COMPILEPROPS_CMD) $(PROPCMDLINE) \ + -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.properties \ + $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javah/resources/version.java \ + java.util.ListResourceBundle \ + -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.properties \ + $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javap/resources/version.java \ + java.util.ListResourceBundle \ + -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.properties \ + $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javac/resources/version.java \ + java.util.ListResourceBundle \ + -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.properties \ + $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/jdeps/resources/version.java \ + java.util.ListResourceBundle \ + -compile $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.properties \ + $(LANGTOOLS_OUTPUTDIR)/gensrc/com/sun/tools/javadoc/resources/version.java \ + java.util.ListResourceBundle + $(TOUCH) $@ + +all: $(LANGTOOLS_OUTPUTDIR)/gensrc/_the_props + +################################################################################ diff --git a/langtools/make/GenstubsLangtools.gmk b/langtools/make/GenstubsLangtools.gmk new file mode 100644 index 00000000000..f7605ffc4f2 --- /dev/null +++ b/langtools/make/GenstubsLangtools.gmk @@ -0,0 +1,70 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# This must be the first rule +default: all + +include $(SPEC) +include MakeBase.gmk + +include CommonLangtools.gmk + +# GenStubs is used to bootstrap any dependencies from javac to the new JDK that is not +# yet built. It is currently not needed but might be again in the future. The following +# exercises the functionality to verify that it works. +TOOL_GENSTUBS_CMD = $(JAVA) \ + "-Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR)" \ + genstubs.GenStubs + +# We fetch source from the JDK... +JDKS := $(JDK_TOPDIR)/src/share/classes + +# Build the list of classes to generate stubs from. java/util/function/Predicate.java isn't +# currently needed, but is used as a demo for now. + +STUBSOURCES := $(shell $(FIND) $(JDKS) -name "*.java" | $(GREP) \ + -e "$(JDKS)/java/util/function/Predicate.java") + +# Rewrite the file names into class names because the GenStubs tool require this. +STUBCLASSES := $(subst /,., $(patsubst $(JDKS)/%.java, %, $(STUBSOURCES))) + +# Now setup the build recipe for genstubs. +$(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs: $(STUBSOURCES) + $(MKDIR) -p $(@D) + $(MKDIR) -p $(LANGTOOLS_OUTPUTDIR)/tmpstubs + $(ECHO) $(LOG_INFO) Generating stubs from JDK sources. + $(TOOL_GENSTUBS_CMD) -s $(LANGTOOLS_OUTPUTDIR)/tmpstubs -sourcepath $(JDKS) $(STUBCLASSES) + if $(DIFF) -x "_the*" -rq $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(LANGTOOLS_OUTPUTDIR)/genstubs \ + > /dev/null 2>&1; then \ + $(ECHO) $(LOG_INFO) No changes in the stubs!; \ + $(RM) -r $(LANGTOOLS_OUTPUTDIR)/tmpstubs; \ + else \ + $(ECHO) $(LOG_INFO) Changes in stubs detected!; \ + $(RM) -r $(@D); \ + $(MV) $(LANGTOOLS_OUTPUTDIR)/tmpstubs $(@D); \ + fi + $(TOUCH) $@ + +all: $(LANGTOOLS_OUTPUTDIR)/genstubs/_the_stubs From 08b547c9abdbb8d7740bf049f8fd66a7fbddd7d3 Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 5 Feb 2014 11:04:21 +0100 Subject: [PATCH 109/159] 8026773: Failing compilation in Corba does not fail the build Reviewed-by: ihse, tbell --- corba/make/BuildCorba.gmk | 236 ++---------------------------------- corba/make/CommonCorba.gmk | 53 ++++++++ corba/make/CompileCorba.gmk | 87 +++++++++++++ corba/make/GensrcCorba.gmk | 153 +++++++++++++++++++++++ 4 files changed, 301 insertions(+), 228 deletions(-) create mode 100644 corba/make/CommonCorba.gmk create mode 100644 corba/make/CompileCorba.gmk create mode 100644 corba/make/GensrcCorba.gmk diff --git a/corba/make/BuildCorba.gmk b/corba/make/BuildCorba.gmk index 3190ce899cf..05bcbe31337 100644 --- a/corba/make/BuildCorba.gmk +++ b/corba/make/BuildCorba.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -31,235 +31,15 @@ default: all include $(SPEC) -include MakeBase.gmk -include JavaCompilation.gmk -include IdlCompilation.gmk -# The Corba sources are old and generates a LOT of warnings. -# Disable these using Xlint, until someone cares to fix them. -DISABLE_CORBA_WARNINGS := -Xlint:all,-deprecation,-unchecked,-serial,-fallthrough,-cast,-rawtypes,-static,-dep-ann +gensrc-corba: + +$(MAKE) -f $(CORBA_TOPDIR)/make/GensrcCorba.gmk -# The "generate old bytecode" javac setup uses the new compiler to compile for the -# boot jdk to generate tools that need to be run with the boot jdk. -# Thus we force the target bytecode to the boot jdk bytecode. -$(eval $(call SetupJavaCompiler,GENERATE_OLDBYTECODE, \ - JVM := $(JAVA), \ - JAVAC := $(NEW_JAVAC), \ - FLAGS := $(BOOT_JDK_SOURCETARGET) \ - -bootclasspath "$(BOOT_RTJAR)$(PATH_SEP)$(BOOT_TOOLSJAR)" \ - $(DISABLE_CORBA_WARNINGS), \ - SERVER_DIR := $(SJAVAC_SERVER_DIR), \ - SERVER_JVM := $(SJAVAC_SERVER_JAVA))) +compile-corba: gensrc-corba + +$(MAKE) -f $(CORBA_TOPDIR)/make/CompileCorba.gmk -# The "generate new bytecode" uses the new compiler to generate bytecode -# for the new jdk that is being built. The code compiled by this setup -# cannot necessarily be run with the boot jdk. -$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE, \ - JVM := $(JAVA), \ - JAVAC := $(NEW_JAVAC), \ - FLAGS := -cp $(BOOT_TOOLSJAR) -XDignore.symbol.file=true $(DISABLE_CORBA_WARNINGS), \ - SERVER_DIR := $(SJAVAC_SERVER_DIR), \ - SERVER_JVM := $(SJAVAC_SERVER_JAVA))) - -$(eval $(call SetupJavaCompilation,BUILD_STRIPPROP, \ - SETUP := GENERATE_OLDBYTECODE, \ - SRC := $(CORBA_TOPDIR)/make/tools/src, \ - BIN := $(CORBA_OUTPUTDIR)/btclasses/stripprop_classes)) - -$(eval $(call SetupArchive,ARCHIVE_STRIPPROP, $(BUILD_STRIPPROP), \ - SRCS := $(CORBA_OUTPUTDIR)/btclasses/stripprop_classes, \ - JAR := $(CORBA_OUTPUTDIR)/btjars/stripproperties.jar, \ - JARMAIN := build.tools.stripproperties.StripPropertiesCorba)) - -$(eval $(call SetupJavaCompilation,BUILD_IDLJ, \ - SETUP := GENERATE_OLDBYTECODE, \ - SRC := $(CORBA_TOPDIR)/src/share/classes, \ - BIN := $(CORBA_OUTPUTDIR)/btclasses/idlj_classes, \ - COPY := .prp, \ - INCLUDES := com/sun/tools/corba/se/idl, \ - EXCLUDE_FILES := ResourceBundleUtil.java)) - -$(eval $(call SetupArchive,ARCHIVE_IDLJ, $(BUILD_IDLJ), \ - SRCS := $(CORBA_OUTPUTDIR)/btclasses/idlj_classes, \ - SUFFIXES := .class .prp, \ - JAR := $(CORBA_OUTPUTDIR)/btjars/idlj.jar, \ - JARMAIN := com.sun.tools.corba.se.idl.toJavaPortable.Compile)) - -$(eval $(call SetupJavaCompilation,BUILD_LOGUTIL, \ - SETUP := GENERATE_OLDBYTECODE, \ - SRC := $(CORBA_TOPDIR)/src/share/classes, \ - BIN := $(CORBA_OUTPUTDIR)/btclasses/logutil_classes, \ - INCLUDES := com/sun/tools/corba/se/logutil)) - -$(eval $(call SetupArchive,ARCHIVE_LOGUTIL, $(BUILD_LOGUTIL), \ - SRCS := $(CORBA_OUTPUTDIR)/btclasses/logutil_classes, \ - JAR := $(CORBA_OUTPUTDIR)/btjars/logutil.jar, \ - JARMAIN := com.sun.tools.corba.se.logutil.MC)) - -# Generate LogWrapper classes -$(CORBA_OUTPUTDIR)/logwrappers/com/sun/corba/se/impl/logging/%SystemException.java: \ - $(CORBA_TOPDIR)/src/share/classes/com/sun/corba/se/spi/logging/data/%.mc \ - $(CORBA_OUTPUTDIR)/btjars/logutil.jar - $(MKDIR) -p $(@D) - $(RM) -f $(@D)/_the_wrappers.d - $(ECHO) $(LOG_INFO) Generating class file from $*.mc - $(JAVA) -jar $(CORBA_OUTPUTDIR)/btjars/logutil.jar make-class $< $(@D) - -# Generate LogWrapper properties file by concatening resource files -$(CORBA_OUTPUTDIR)/logwrappers/com/sun/corba/se/impl/logging/LogStrings.properties: \ - $(CORBA_OUTPUTDIR)/logwrappers/ActivationSystemException.resource \ - $(CORBA_OUTPUTDIR)/logwrappers/IORSystemException.resource \ - $(CORBA_OUTPUTDIR)/logwrappers/InterceptorsSystemException.resource \ - $(CORBA_OUTPUTDIR)/logwrappers/NamingSystemException.resource \ - $(CORBA_OUTPUTDIR)/logwrappers/OMGSystemException.resource \ - $(CORBA_OUTPUTDIR)/logwrappers/ORBUtilSystemException.resource \ - $(CORBA_OUTPUTDIR)/logwrappers/POASystemException.resource \ - $(CORBA_OUTPUTDIR)/logwrappers/UtilSystemException.resource - $(MKDIR) -p $(@D) - $(ECHO) $(LOG_INFO) Concatenating 8 resource files into $(@F) - $(CAT) $^ > $@ - -# The resources files are generated from lisp-like .mc files. -$(CORBA_OUTPUTDIR)/logwrappers/%SystemException.resource: $(CORBA_TOPDIR)/src/share/classes/com/sun/corba/se/spi/logging/data/%.mc $(CORBA_OUTPUTDIR)/btjars/logutil.jar - $(MKDIR) -p $(@D) - $(RM) -f $(@D)/_the_wrappers.d - $(ECHO) $(LOG_INFO) Generating resource file from $*.mc - $(JAVA) -jar $(CORBA_OUTPUTDIR)/btjars/logutil.jar make-resource $< $(@D) +all: compile-corba -$(CORBA_OUTPUTDIR)/logwrappers/_the_wrappers.d: $(CORBA_OUTPUTDIR)/btjars/logutil.jar \ - $(CORBA_OUTPUTDIR)/logwrappers/com/sun/corba/se/impl/logging/ActivationSystemException.java \ - $(CORBA_OUTPUTDIR)/logwrappers/com/sun/corba/se/impl/logging/IORSystemException.java \ - $(CORBA_OUTPUTDIR)/logwrappers/com/sun/corba/se/impl/logging/InterceptorsSystemException.java \ - $(CORBA_OUTPUTDIR)/logwrappers/com/sun/corba/se/impl/logging/NamingSystemException.java \ - $(CORBA_OUTPUTDIR)/logwrappers/com/sun/corba/se/impl/logging/OMGSystemException.java \ - $(CORBA_OUTPUTDIR)/logwrappers/com/sun/corba/se/impl/logging/ORBUtilSystemException.java \ - $(CORBA_OUTPUTDIR)/logwrappers/com/sun/corba/se/impl/logging/POASystemException.java \ - $(CORBA_OUTPUTDIR)/logwrappers/com/sun/corba/se/impl/logging/UtilSystemException.java \ - $(CORBA_OUTPUTDIR)/logwrappers/com/sun/corba/se/impl/logging/LogStrings.properties - $(MKDIR) -p $(@D) - $(ECHO) LOGWRAPPERS_ARE_CREATED = yes > $@ - -# Trigger the generation of the logwrappers. After the logwrapper classes and -# resources have been created, then the makefile will restart and the newly -# created java files will become part of the build further along in the makefile. --include $(CORBA_OUTPUTDIR)/logwrappers/_the_wrappers.d - -ifeq ($(LOGWRAPPERS_ARE_CREATED), yes) - - $(eval $(call SetupIdlCompilation,BUILD_IDLS, \ - IDLJ := $(JAVA) -jar $(CORBA_OUTPUTDIR)/btjars/idlj.jar, \ - SRC := $(CORBA_TOPDIR)/src/share/classes, \ - BIN := $(CORBA_OUTPUTDIR)/gensrc, \ - EXCLUDES := com/sun/tools/corba/se/idl/% \ - org/omg/CORBA/% \ - com/sun/corba/se/GiopIDL/% \ - org/omg/PortableServer/corba.idl, \ - INCLUDES := %, \ - OLDIMPLBASES := com/sun/corba/se/PortableActivationIDL/activation.idl \ - com/sun/corba/se/spi/activation/activation.idl, \ - DELETES := DYNANYDELETEFILES org/omg/DynamicAny/*POA* org/omg/DynamicAny/*Holder* org/omg/DynamicAny/DynValueBoxHelper.java org/omg/DynamicAny/DynValueCommonHelper.java org/omg/DynamicAny/_DynValueCommonStub.java org/omg/DynamicAny/_DynValueBoxStub.java org/omg/DynamicAny/DynAnyPackage/TypeMismatchHolder.java org/omg/DynamicAny/DynAnyPackage/InvalidValueHolder.java org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHolder.java IOPDELETEFILES org/omg/IOP/BI_DIR_IIOP.java org/omg/IOP/ChainBypassCheck.java org/omg/IOP/ChainBypassInfo.java org/omg/IOP/FORWARDED_IDENTITY.java org/omg/IOP/INVOCATION_POLICIES.java org/omg/IOP/LogicalThreadId.java org/omg/IOP/SendingContextRunTime.java org/omg/IOP/UnknownExceptionInfo.java org/omg/IOP/TaggedComponentSeqHolder.java POAHELHOLFILES org/omg/PortableServer/CurrentPackage/NoContextHolder.java org/omg/PortableServer/ForwardRequestHolder.java org/omg/PortableServer/IdAssignmentPolicyValueHelper.java org/omg/PortableServer/IdAssignmentPolicyValueHolder.java org/omg/PortableServer/IdUniquenessPolicyValueHelper.java org/omg/PortableServer/IdUniquenessPolicyValueHolder.java org/omg/PortableServer/ImplicitActivationPolicyValueHelper.java org/omg/PortableServer/ImplicitActivationPolicyValueHolder.java org/omg/PortableServer/LifespanPolicyValueHelper.java org/omg/PortableServer/LifespanPolicyValueHolder.java org/omg/PortableServer/ServantRetentionPolicyValueHelper.java org/omg/PortableServer/ServantRetentionPolicyValueHolder.java org/omg/PortableServer/ObjectIdHelper.java org/omg/PortableServer/ObjectIdHolder.java org/omg/PortableServer/POAListHelper.java org/omg/PortableServer/POAListHolder.java org/omg/PortableServer/POAManagerPackage/AdapterInactiveHolder.java org/omg/PortableServer/POAManagerPackage/StateHelper.java org/omg/PortableServer/POAManagerPackage/StateHolder.java org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHolder.java org/omg/PortableServer/POAPackage/AdapterNonExistentHolder.java org/omg/PortableServer/POAPackage/InvalidPolicyHolder.java org/omg/PortableServer/POAPackage/NoServantHolder.java org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHolder.java org/omg/PortableServer/POAPackage/ObjectNotActiveHolder.java org/omg/PortableServer/POAPackage/ServantAlreadyActiveHolder.java org/omg/PortableServer/POAPackage/ServantNotActiveHolder.java org/omg/PortableServer/POAPackage/WrongAdapterHolder.java org/omg/PortableServer/POAPackage/WrongPolicyHolder.java org/omg/PortableServer/RequestProcessingPolicyValueHelper.java org/omg/PortableServer/RequestProcessingPolicyValueHolder.java org/omg/PortableServer/ServantActivatorHolder.java org/omg/PortableServer/ServantLocatorHolder.java org/omg/PortableServer/ThreadPolicyValueHelper.java org/omg/PortableServer/ThreadPolicyValueHolder.java PIHELHOLFILES org/omg/PortableInterceptor/ClientRequestInfoHelper.java org/omg/PortableInterceptor/ClientRequestInterceptorHelper.java org/omg/PortableInterceptor/IORInfoHelper.java org/omg/PortableInterceptor/IORInterceptorHelper.java org/omg/PortableInterceptor/InterceptorHelper.java org/omg/PortableInterceptor/ORBInitInfoHelper.java org/omg/PortableInterceptor/ORBInitializerHelper.java org/omg/PortableInterceptor/PolicyFactoryHelper.java org/omg/PortableInterceptor/ReplyStatusHelper.java org/omg/PortableInterceptor/RequestInfoHelper.java org/omg/PortableInterceptor/ServerRequestInfoHelper.java org/omg/PortableInterceptor/ServerRequestInterceptorHelper.java org/omg/PortableInterceptor/SlotIdHelper.java org/omg/PortableInterceptor/ClientRequestInfoHolder.java org/omg/PortableInterceptor/ClientRequestInterceptorHolder.java org/omg/PortableInterceptor/CurrentHolder.java org/omg/PortableInterceptor/ForwardRequestHolder.java org/omg/PortableInterceptor/IORInfoHolder.java org/omg/PortableInterceptor/IORInterceptorHolder.java org/omg/PortableInterceptor/InterceptorHolder.java org/omg/PortableInterceptor/InvalidSlotHolder.java org/omg/PortableInterceptor/ORBInitInfoHolder.java org/omg/PortableInterceptor/ORBInitializerHolder.java org/omg/PortableInterceptor/PolicyFactoryHolder.java org/omg/PortableInterceptor/RequestInfoHolder.java org/omg/PortableInterceptor/ServerRequestInfoHolder.java org/omg/PortableInterceptor/ServerRequestInterceptorHolder.java org/omg/PortableInterceptor/TaggedComponentSeqHolder.java org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHolder.java org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHolder.java org/omg/IOP/CodecPackage/FormatMismatchHolder.java org/omg/IOP/CodecPackage/InvalidTypeForEncodingHolder.java org/omg/IOP/CodecPackage/TypeMismatchHolder.java org/omg/IOP/CodecHelper.java org/omg/IOP/EncodingFormatHelper.java org/omg/IOP/EncodingHelper.java org/omg/IOP/CodecFactoryPackage/UnknownEncodingHolder.java org/omg/IOP/CodecFactoryHolder.java org/omg/IOP/CodecHolder.java org/omg/IOP/EncodingHolder.java org/omg/IOP/TaggedComponentSeqHelper.java org/omg/Dynamic/ContextListHelper.java org/omg/Dynamic/ExceptionListHelper.java org/omg/Dynamic/ParameterHolder.java org/omg/Dynamic/ParameterListHolder.java org/omg/Dynamic/ExceptionListHolder.java org/omg/Dynamic/ParameterHelper.java org/omg/Dynamic/ParameterListHelper.java org/omg/Dynamic/RequestContextHelper.java CORBAX org/omg/CORBA/OctetSeqHelper.java org/omg/CORBA/OctetSeqHolder.java org/omg/CORBA/PolicyError.java org/omg/CORBA/RepositoryIdHelper.java)) - - $(BUILD_IDLS): $(CORBA_OUTPUTDIR)/btjars/idlj.jar - - $(CORBA_OUTPUTDIR)/gensrc/_the_idls.d: $(BUILD_IDLS) $(CORBA_OUTPUTDIR)/btjars/idlj.jar - $(MKDIR) -p $(@D) - $(ECHO) IDLS_ARE_CREATED = yes > $@ - - -include $(CORBA_OUTPUTDIR)/gensrc/_the_idls.d - - ifeq ($(IDLS_ARE_CREATED), yes) - - $(eval $(call SetupJavaCompilation,BUILD_CORBA, \ - SETUP := GENERATE_NEWBYTECODE, \ - SRC := $(CORBA_TOPDIR)/src/share/classes $(CORBA_OUTPUTDIR)/gensrc $(CORBA_OUTPUTDIR)/logwrappers, \ - EXCLUDES := com/sun/corba/se/PortableActivationIDL \ - com/sun/tools/corba/se/logutil, \ - EXCLUDE_FILES := com/sun/corba/se/impl/presentation/rmi/JNDIStateFactoryImpl.java \ - com/sun/corba/se/spi/presentation/rmi/StubWrapper.java \ - com/sun/org/omg/CORBA/IDLTypeOperations.java \ - com/sun/org/omg/CORBA/IRObjectOperations.java \ - org/omg/PortableInterceptor/UNKNOWN.java \ - com/sun/tools/corba/se/idl/ResourceBundleUtil.java \ - com/sun/corba/se/impl/presentation/rmi/jndi.properties, \ - COPY := .prp LogStrings.properties, \ - BIN := $(CORBA_OUTPUTDIR)/classes)) - - $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_CORBA, \ - SETUP := GENERATE_OLDBYTECODE, \ - SRC := $(BUILD_CORBA_SRC), \ - EXCLUDES := $(BUILD_CORBA_EXCLUDES), \ - EXCLUDE_FILES := $(BUILD_CORBA_EXCLUDE_FILES), \ - COPY := $(BUILD_CORBA_COPY), \ - BIN := $(CORBA_OUTPUTDIR)/btclasses/corba_classes, \ - JAR := $(CORBA_OUTPUTDIR)/btjars/btcorba.jar)) - - # Separate src.zip call to include sources that were excluded in the build to - # mimic behavior in old build system. - $(eval $(call SetupZipArchive,ARCHIVE_BUILD_CORBA, \ - SRC := $(CORBA_TOPDIR)/src/share/classes $(CORBA_OUTPUTDIR)/gensrc $(CORBA_OUTPUTDIR)/logwrappers, \ - ZIP := $(CORBA_OUTPUTDIR)/dist/lib/src.zip)) - - $(BUILD_CORBA): $(BUILD_IDLS) $(LOGWRAPPER_DEPENDENCIES) - - # Run stripproperties on all sunorb resource files. - STRIP_PROP_SRC_FILES := $(shell $(FIND) $(CORBA_TOPDIR)/src/share/classes -name "sunorb*.properties") - STRIP_PROP_FILES := $(patsubst $(CORBA_TOPDIR)/src/share/classes/%, $(CORBA_OUTPUTDIR)/classes/%, \ - $(STRIP_PROP_SRC_FILES)) - # Simple delivery of zh_HK properties files just copies zh_TW properties files - STRIP_PROP_FILES += $(patsubst $(CORBA_TOPDIR)/src/share/classes/%_zh_TW.properties, \ - $(CORBA_OUTPUTDIR)/classes/%_zh_HK.properties, \ - $(shell $(FIND) $(CORBA_TOPDIR)/src/share/classes -name "sunorb_zh_TW.properties")) - STRIP_PROP_SRC_FILES += $(shell $(FIND) $(CORBA_TOPDIR)/src/share/classes -name "sunorb_zh_TW.properties") - STRIP_PROP_CMDLINE := $(subst _SPACE_, $(SPACE), \ - $(join $(addprefix -clean_SPACE_, $(STRIP_PROP_SRC_FILES)), \ - $(addprefix _SPACE_, $(STRIP_PROP_FILES)))) - - $(CORBA_OUTPUTDIR)/_the.stripped_properties: $(STRIP_PROP_SRC_FILES) \ - $(CORBA_OUTPUTDIR)/btjars/stripproperties.jar - $(MKDIR) -p $(sort $(dir $(STRIP_PROP_FILES))) - $(call ListPathsSafely,STRIP_PROP_CMDLINE,\n, >> $(CORBA_OUTPUTDIR)/_the.strip_prop.cmdline) - $(JAVA) -jar $(CORBA_OUTPUTDIR)/btjars/stripproperties.jar \ - @$(CORBA_OUTPUTDIR)/_the.strip_prop.cmdline - $(TOUCH) $@ - - $(eval $(call SetupArchive,ARCHIVE_CORBA, \ - $(BUILD_CORBA) $(CORBA_OUTPUTDIR)/_the.stripped_properties, \ - SRCS := $(CORBA_OUTPUTDIR)/classes, \ - SUFFIXES := .class .prp .properties, \ - JAR := $(CORBA_OUTPUTDIR)/dist/lib/classes.jar)) - - # The created classes.jar now contains Corba compiled to run on the target JDK - # and is ready for inclusion in jdk rt.jar. - - # The created src.zip now contains .java and .properties files used to create the classes in classes.jar - # and is ready for inclusion into the jdk src.zip - - BIN_FILES := $(CORBA_TOPDIR)/src/share/classes/com/sun/tools/corba/se/idl/orb.idl \ - $(CORBA_TOPDIR)/src/share/classes/com/sun/tools/corba/se/idl/ir.idl - - $(CORBA_OUTPUTDIR)/dist/lib/bin.zip: $(BIN_FILES) $(CORBA_OUTPUTDIR)/dist/lib/classes.jar - $(MKDIR) -p $(CORBA_OUTPUTDIR)/dist/lib - $(MKDIR) -p $(CORBA_OUTPUTDIR)/lib - $(RM) -f $@ - $(ECHO) Creating `basename $@` - $(CP) $(BIN_FILES) $(CORBA_OUTPUTDIR)/lib - $(CHMOD) ug+w $(CORBA_OUTPUTDIR)/lib/* - (cd $(CORBA_OUTPUTDIR); $(ZIP) -q $@ lib/orb.idl lib/ir.idl) - - # The created bin.zip now contains the corba specific binaries: orb.idl, ir.idl - - all: $(CORBA_OUTPUTDIR)/btjars/stripproperties.jar \ - $(CORBA_OUTPUTDIR)/btjars/idlj.jar \ - $(CORBA_OUTPUTDIR)/btjars/logutil.jar \ - $(CORBA_OUTPUTDIR)/btjars/btcorba.jar \ - $(CORBA_OUTPUTDIR)/dist/lib/classes.jar \ - $(CORBA_OUTPUTDIR)/dist/lib/src.zip \ - $(CORBA_OUTPUTDIR)/dist/lib/bin.zip - endif -endif - -clean: - $(RM) -rf $(CORBA_OUTPUTDIR) - -.PHONY: default all clean clobber +.PHONY: default all +.PHONY: gensrc-corba compile-corba diff --git a/corba/make/CommonCorba.gmk b/corba/make/CommonCorba.gmk new file mode 100644 index 00000000000..11b69b6f715 --- /dev/null +++ b/corba/make/CommonCorba.gmk @@ -0,0 +1,53 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +################################################################################ +# The Corba sources are old and generates a LOT of warnings. +# Disable these using Xlint, until someone cares to fix them. +DISABLE_CORBA_WARNINGS := -Xlint:all,-deprecation,-unchecked,-serial,-fallthrough,-cast,-rawtypes,-static,-dep-ann + +# The "generate old bytecode" javac setup uses the new compiler to compile for the +# boot jdk to generate tools that need to be run with the boot jdk. +# Thus we force the target bytecode to the boot jdk bytecode. +$(eval $(call SetupJavaCompiler,GENERATE_OLDBYTECODE, \ + JVM := $(JAVA), \ + JAVAC := $(NEW_JAVAC), \ + FLAGS := $(BOOT_JDK_SOURCETARGET) \ + -bootclasspath "$(BOOT_RTJAR)$(PATH_SEP)$(BOOT_TOOLSJAR)" \ + $(DISABLE_CORBA_WARNINGS), \ + SERVER_DIR := $(SJAVAC_SERVER_DIR), \ + SERVER_JVM := $(SJAVAC_SERVER_JAVA))) + +# The "generate new bytecode" uses the new compiler to generate bytecode +# for the new jdk that is being built. The code compiled by this setup +# cannot necessarily be run with the boot jdk. +$(eval $(call SetupJavaCompiler,GENERATE_NEWBYTECODE, \ + JVM := $(JAVA), \ + JAVAC := $(NEW_JAVAC), \ + FLAGS := -cp $(BOOT_TOOLSJAR) -XDignore.symbol.file=true $(DISABLE_CORBA_WARNINGS), \ + SERVER_DIR := $(SJAVAC_SERVER_DIR), \ + SERVER_JVM := $(SJAVAC_SERVER_JAVA))) + +################################################################################ diff --git a/corba/make/CompileCorba.gmk b/corba/make/CompileCorba.gmk new file mode 100644 index 00000000000..16e0c4e679d --- /dev/null +++ b/corba/make/CompileCorba.gmk @@ -0,0 +1,87 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +# This must be the first rule +default: all + +include $(SPEC) +include MakeBase.gmk +include JavaCompilation.gmk + +include CommonCorba.gmk + +################################################################################ + +$(eval $(call SetupJavaCompilation,BUILD_CORBA, \ + SETUP := GENERATE_NEWBYTECODE, \ + SRC := $(CORBA_TOPDIR)/src/share/classes $(CORBA_OUTPUTDIR)/gensrc, \ + EXCLUDES := com/sun/corba/se/PortableActivationIDL \ + com/sun/tools/corba/se/logutil, \ + EXCLUDE_FILES := com/sun/corba/se/impl/presentation/rmi/JNDIStateFactoryImpl.java \ + com/sun/corba/se/spi/presentation/rmi/StubWrapper.java \ + com/sun/org/omg/CORBA/IDLTypeOperations.java \ + com/sun/org/omg/CORBA/IRObjectOperations.java \ + org/omg/PortableInterceptor/UNKNOWN.java \ + com/sun/tools/corba/se/idl/ResourceBundleUtil.java \ + com/sun/corba/se/impl/presentation/rmi/jndi.properties, \ + COPY := .prp LogStrings.properties, \ + BIN := $(CORBA_OUTPUTDIR)/classes, \ + JAR := $(CORBA_OUTPUTDIR)/dist/lib/classes.jar)) + +$(eval $(call SetupJavaCompilation,BUILD_INTERIM_CORBA, \ + SETUP := GENERATE_OLDBYTECODE, \ + SRC := $(BUILD_CORBA_SRC), \ + EXCLUDES := $(BUILD_CORBA_EXCLUDES), \ + EXCLUDE_FILES := $(BUILD_CORBA_EXCLUDE_FILES), \ + COPY := $(BUILD_CORBA_COPY), \ + BIN := $(CORBA_OUTPUTDIR)/interim_classes, \ + JAR := $(INTERIM_CORBA_JAR))) + +# Separate src.zip call to include sources that were excluded in the build to +# mimic behavior in old build system. +$(eval $(call SetupZipArchive,ARCHIVE_CORBA_SRC, \ + SRC := $(CORBA_TOPDIR)/src/share/classes $(CORBA_OUTPUTDIR)/gensrc, \ + ZIP := $(CORBA_OUTPUTDIR)/dist/lib/src.zip)) + JAR := $(CORBA_OUTPUTDIR)/dist/lib/classes.jar)) + +################################################################################ +# Create bin.zip containing the corba specific binaries: orb.idl, ir.idl +BIN_FILES := $(CORBA_TOPDIR)/src/share/classes/com/sun/tools/corba/se/idl/orb.idl \ + $(CORBA_TOPDIR)/src/share/classes/com/sun/tools/corba/se/idl/ir.idl + +$(CORBA_OUTPUTDIR)/dist/lib/bin.zip: $(BIN_FILES) + $(MKDIR) -p $(CORBA_OUTPUTDIR)/dist/lib + $(MKDIR) -p $(CORBA_OUTPUTDIR)/lib + $(RM) -f $@ + $(ECHO) Creating `basename $@` + $(CP) $(BIN_FILES) $(CORBA_OUTPUTDIR)/lib + $(CHMOD) ug+w $(CORBA_OUTPUTDIR)/lib/* + (cd $(CORBA_OUTPUTDIR); $(ZIP) -q $@ lib/orb.idl lib/ir.idl) + +################################################################################ + + +all: $(BUILD_CORBA) $(BUILD_INTERIM_CORBA) $(ARCHIVE_CORBA_SRC) \ + $(CORBA_OUTPUTDIR)/dist/lib/bin.zip diff --git a/corba/make/GensrcCorba.gmk b/corba/make/GensrcCorba.gmk new file mode 100644 index 00000000000..61030ed5af7 --- /dev/null +++ b/corba/make/GensrcCorba.gmk @@ -0,0 +1,153 @@ +# +# Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. +# DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. +# +# This code is free software; you can redistribute it and/or modify it +# under the terms of the GNU General Public License version 2 only, as +# published by the Free Software Foundation. Oracle designates this +# particular file as subject to the "Classpath" exception as provided +# by Oracle in the LICENSE file that accompanied this code. +# +# This code is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or +# FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License +# version 2 for more details (a copy is included in the LICENSE file that +# accompanied this code). +# +# You should have received a copy of the GNU General Public License version +# 2 along with this work; if not, write to the Free Software Foundation, +# Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. +# +# Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA +# or visit www.oracle.com if you need additional information or have any +# questions. +# + +default: all + +include $(SPEC) +include MakeBase.gmk +include JavaCompilation.gmk +include IdlCompilation.gmk + +include CommonCorba.gmk + +################################################################################ + +$(eval $(call SetupJavaCompilation,BUILD_STRIPPROP, \ + SETUP := GENERATE_OLDBYTECODE, \ + SRC := $(CORBA_TOPDIR)/make/tools/src, \ + BIN := $(CORBA_OUTPUTDIR)/stripprop_classes)) + +TOOL_STRIPPROP_CMD := $(JAVA) -cp $(CORBA_OUTPUTDIR)/stripprop_classes \ + build.tools.stripproperties.StripPropertiesCorba + +$(eval $(call SetupJavaCompilation,BUILD_IDLJ, \ + SETUP := GENERATE_OLDBYTECODE, \ + SRC := $(CORBA_TOPDIR)/src/share/classes, \ + BIN := $(CORBA_OUTPUTDIR)/idlj_classes, \ + COPY := .prp, \ + INCLUDES := com/sun/tools/corba/se/idl, \ + EXCLUDE_FILES := ResourceBundleUtil.java)) + +TOOL_IDLJ_CMD := $(JAVA) -cp $(CORBA_OUTPUTDIR)/idlj_classes \ + com.sun.tools.corba.se.idl.toJavaPortable.Compile + +$(eval $(call SetupJavaCompilation,BUILD_LOGUTIL, \ + SETUP := GENERATE_OLDBYTECODE, \ + SRC := $(CORBA_TOPDIR)/src/share/classes, \ + BIN := $(CORBA_OUTPUTDIR)/logutil_classes, \ + INCLUDES := com/sun/tools/corba/se/logutil)) + +TOOL_LOGUTIL_CMD := $(JAVA) -cp $(CORBA_OUTPUTDIR)/logutil_classes \ + com.sun.tools.corba.se.logutil.MC + +################################################################################ + +# Generate LogWrapper classes +$(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/%SystemException.java: \ + $(CORBA_TOPDIR)/src/share/classes/com/sun/corba/se/spi/logging/data/%.mc \ + $(BUILD_LOGUTIL) + $(MKDIR) -p $(@D) + $(RM) -f $(@D)/_the_wrappers.d + $(ECHO) $(LOG_INFO) Generating class file from $*.mc + $(TOOL_LOGUTIL_CMD) make-class $< $(@D) + +# Generate LogWrapper properties file by concatening resource files +$(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/LogStrings.properties: \ + $(CORBA_OUTPUTDIR)/logwrappers/ActivationSystemException.resource \ + $(CORBA_OUTPUTDIR)/logwrappers/IORSystemException.resource \ + $(CORBA_OUTPUTDIR)/logwrappers/InterceptorsSystemException.resource \ + $(CORBA_OUTPUTDIR)/logwrappers/NamingSystemException.resource \ + $(CORBA_OUTPUTDIR)/logwrappers/OMGSystemException.resource \ + $(CORBA_OUTPUTDIR)/logwrappers/ORBUtilSystemException.resource \ + $(CORBA_OUTPUTDIR)/logwrappers/POASystemException.resource \ + $(CORBA_OUTPUTDIR)/logwrappers/UtilSystemException.resource + $(MKDIR) -p $(@D) + $(ECHO) $(LOG_INFO) Concatenating 8 resource files into $(@F) + $(CAT) $^ > $@ + +# The resources files are generated from lisp-like .mc files. +$(CORBA_OUTPUTDIR)/logwrappers/%SystemException.resource: \ + $(CORBA_TOPDIR)/src/share/classes/com/sun/corba/se/spi/logging/data/%.mc \ + $(BUILD_LOGUTIL) + $(MKDIR) -p $(@D) + $(RM) -f $(@D)/_the_wrappers.d + $(ECHO) $(LOG_INFO) Generating resource file from $*.mc + $(TOOL_LOGUTIL_CMD) make-resource $< $(@D) + + +LOGWRAPPER_TARGETS := \ + $(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/ActivationSystemException.java \ + $(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/IORSystemException.java \ + $(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/InterceptorsSystemException.java \ + $(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/NamingSystemException.java \ + $(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/OMGSystemException.java \ + $(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/ORBUtilSystemException.java \ + $(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/POASystemException.java \ + $(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/UtilSystemException.java \ + $(CORBA_OUTPUTDIR)/gensrc/com/sun/corba/se/impl/logging/LogStrings.properties + +################################################################################ +# Build the IDLs. + +$(eval $(call SetupIdlCompilation,BUILD_IDLS, \ + IDLJ := $(TOOL_IDLJ_CMD), \ + SRC := $(CORBA_TOPDIR)/src/share/classes, \ + BIN := $(CORBA_OUTPUTDIR)/gensrc, \ + EXCLUDES := com/sun/tools/corba/se/idl/% \ + org/omg/CORBA/% \ + com/sun/corba/se/GiopIDL/% \ + org/omg/PortableServer/corba.idl, \ + INCLUDES := %, \ + OLDIMPLBASES := com/sun/corba/se/PortableActivationIDL/activation.idl \ + com/sun/corba/se/spi/activation/activation.idl, \ + DELETES := DYNANYDELETEFILES org/omg/DynamicAny/*POA* org/omg/DynamicAny/*Holder* org/omg/DynamicAny/DynValueBoxHelper.java org/omg/DynamicAny/DynValueCommonHelper.java org/omg/DynamicAny/_DynValueCommonStub.java org/omg/DynamicAny/_DynValueBoxStub.java org/omg/DynamicAny/DynAnyPackage/TypeMismatchHolder.java org/omg/DynamicAny/DynAnyPackage/InvalidValueHolder.java org/omg/DynamicAny/DynAnyFactoryPackage/InconsistentTypeCodeHolder.java IOPDELETEFILES org/omg/IOP/BI_DIR_IIOP.java org/omg/IOP/ChainBypassCheck.java org/omg/IOP/ChainBypassInfo.java org/omg/IOP/FORWARDED_IDENTITY.java org/omg/IOP/INVOCATION_POLICIES.java org/omg/IOP/LogicalThreadId.java org/omg/IOP/SendingContextRunTime.java org/omg/IOP/UnknownExceptionInfo.java org/omg/IOP/TaggedComponentSeqHolder.java POAHELHOLFILES org/omg/PortableServer/CurrentPackage/NoContextHolder.java org/omg/PortableServer/ForwardRequestHolder.java org/omg/PortableServer/IdAssignmentPolicyValueHelper.java org/omg/PortableServer/IdAssignmentPolicyValueHolder.java org/omg/PortableServer/IdUniquenessPolicyValueHelper.java org/omg/PortableServer/IdUniquenessPolicyValueHolder.java org/omg/PortableServer/ImplicitActivationPolicyValueHelper.java org/omg/PortableServer/ImplicitActivationPolicyValueHolder.java org/omg/PortableServer/LifespanPolicyValueHelper.java org/omg/PortableServer/LifespanPolicyValueHolder.java org/omg/PortableServer/ServantRetentionPolicyValueHelper.java org/omg/PortableServer/ServantRetentionPolicyValueHolder.java org/omg/PortableServer/ObjectIdHelper.java org/omg/PortableServer/ObjectIdHolder.java org/omg/PortableServer/POAListHelper.java org/omg/PortableServer/POAListHolder.java org/omg/PortableServer/POAManagerPackage/AdapterInactiveHolder.java org/omg/PortableServer/POAManagerPackage/StateHelper.java org/omg/PortableServer/POAManagerPackage/StateHolder.java org/omg/PortableServer/POAPackage/AdapterAlreadyExistsHolder.java org/omg/PortableServer/POAPackage/AdapterNonExistentHolder.java org/omg/PortableServer/POAPackage/InvalidPolicyHolder.java org/omg/PortableServer/POAPackage/NoServantHolder.java org/omg/PortableServer/POAPackage/ObjectAlreadyActiveHolder.java org/omg/PortableServer/POAPackage/ObjectNotActiveHolder.java org/omg/PortableServer/POAPackage/ServantAlreadyActiveHolder.java org/omg/PortableServer/POAPackage/ServantNotActiveHolder.java org/omg/PortableServer/POAPackage/WrongAdapterHolder.java org/omg/PortableServer/POAPackage/WrongPolicyHolder.java org/omg/PortableServer/RequestProcessingPolicyValueHelper.java org/omg/PortableServer/RequestProcessingPolicyValueHolder.java org/omg/PortableServer/ServantActivatorHolder.java org/omg/PortableServer/ServantLocatorHolder.java org/omg/PortableServer/ThreadPolicyValueHelper.java org/omg/PortableServer/ThreadPolicyValueHolder.java PIHELHOLFILES org/omg/PortableInterceptor/ClientRequestInfoHelper.java org/omg/PortableInterceptor/ClientRequestInterceptorHelper.java org/omg/PortableInterceptor/IORInfoHelper.java org/omg/PortableInterceptor/IORInterceptorHelper.java org/omg/PortableInterceptor/InterceptorHelper.java org/omg/PortableInterceptor/ORBInitInfoHelper.java org/omg/PortableInterceptor/ORBInitializerHelper.java org/omg/PortableInterceptor/PolicyFactoryHelper.java org/omg/PortableInterceptor/ReplyStatusHelper.java org/omg/PortableInterceptor/RequestInfoHelper.java org/omg/PortableInterceptor/ServerRequestInfoHelper.java org/omg/PortableInterceptor/ServerRequestInterceptorHelper.java org/omg/PortableInterceptor/SlotIdHelper.java org/omg/PortableInterceptor/ClientRequestInfoHolder.java org/omg/PortableInterceptor/ClientRequestInterceptorHolder.java org/omg/PortableInterceptor/CurrentHolder.java org/omg/PortableInterceptor/ForwardRequestHolder.java org/omg/PortableInterceptor/IORInfoHolder.java org/omg/PortableInterceptor/IORInterceptorHolder.java org/omg/PortableInterceptor/InterceptorHolder.java org/omg/PortableInterceptor/InvalidSlotHolder.java org/omg/PortableInterceptor/ORBInitInfoHolder.java org/omg/PortableInterceptor/ORBInitializerHolder.java org/omg/PortableInterceptor/PolicyFactoryHolder.java org/omg/PortableInterceptor/RequestInfoHolder.java org/omg/PortableInterceptor/ServerRequestInfoHolder.java org/omg/PortableInterceptor/ServerRequestInterceptorHolder.java org/omg/PortableInterceptor/TaggedComponentSeqHolder.java org/omg/PortableInterceptor/ORBInitInfoPackage/DuplicateNameHolder.java org/omg/PortableInterceptor/ORBInitInfoPackage/InvalidNameHolder.java org/omg/IOP/CodecPackage/FormatMismatchHolder.java org/omg/IOP/CodecPackage/InvalidTypeForEncodingHolder.java org/omg/IOP/CodecPackage/TypeMismatchHolder.java org/omg/IOP/CodecHelper.java org/omg/IOP/EncodingFormatHelper.java org/omg/IOP/EncodingHelper.java org/omg/IOP/CodecFactoryPackage/UnknownEncodingHolder.java org/omg/IOP/CodecFactoryHolder.java org/omg/IOP/CodecHolder.java org/omg/IOP/EncodingHolder.java org/omg/IOP/TaggedComponentSeqHelper.java org/omg/Dynamic/ContextListHelper.java org/omg/Dynamic/ExceptionListHelper.java org/omg/Dynamic/ParameterHolder.java org/omg/Dynamic/ParameterListHolder.java org/omg/Dynamic/ExceptionListHolder.java org/omg/Dynamic/ParameterHelper.java org/omg/Dynamic/ParameterListHelper.java org/omg/Dynamic/RequestContextHelper.java CORBAX org/omg/CORBA/OctetSeqHelper.java org/omg/CORBA/OctetSeqHolder.java org/omg/CORBA/PolicyError.java org/omg/CORBA/RepositoryIdHelper.java)) + +$(BUILD_IDLS): $(BUILD_IDLJ) + +################################################################################ +# Run stripproperties on all sunorb resource files. + +STRIP_PROP_SRC_FILES := $(shell $(FIND) $(CORBA_TOPDIR)/src/share/classes -name "sunorb*.properties") +STRIP_PROP_FILES := $(patsubst $(CORBA_TOPDIR)/src/share/classes/%, $(CORBA_OUTPUTDIR)/classes/%, \ + $(STRIP_PROP_SRC_FILES)) +# Simple delivery of zh_HK properties files just copies zh_TW properties files +STRIP_PROP_SRC_FILE_ZH_TW := $(shell $(FIND) $(CORBA_TOPDIR)/src/share/classes -name "sunorb_zh_TW.properties") +STRIP_PROP_SRC_FILES += $(STRIP_PROP_SRC_FILE_ZH_TW) +STRIP_PROP_FILES += $(patsubst $(CORBA_TOPDIR)/src/share/classes/%_zh_TW.properties, \ + $(CORBA_OUTPUTDIR)/classes/%_zh_HK.properties, $(STRIP_PROP_SRC_FILE_ZH_TW)) +STRIP_PROP_CMDLINE := $(subst _SPACE_, $(SPACE), \ + $(join $(addprefix -clean_SPACE_, $(STRIP_PROP_SRC_FILES)), \ + $(addprefix _SPACE_, $(STRIP_PROP_FILES)))) + +$(CORBA_OUTPUTDIR)/_the.stripped_properties: $(STRIP_PROP_SRC_FILES) \ + $(BUILD_STRIPPROP) + $(MKDIR) -p $(sort $(dir $(STRIP_PROP_FILES))) + $(call ListPathsSafely,STRIP_PROP_CMDLINE,\n, >> $(CORBA_OUTPUTDIR)/_the.strip_prop.cmdline) + $(TOOL_STRIPPROP_CMD) @$(CORBA_OUTPUTDIR)/_the.strip_prop.cmdline + $(TOUCH) $@ + +################################################################################ + +all: $(BUILD_IDLS) $(CORBA_OUTPUTDIR)/_the.stripped_properties $(LOGWRAPPER_TARGETS) From 91a6e1b0926cf0c94ad134f3c86b381e9dc7f07a Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 5 Feb 2014 11:05:24 +0100 Subject: [PATCH 110/159] 8026773: Failing compilation in Corba does not fail the build Reviewed-by: ihse, tbell --- jdk/make/GenerateClasses.gmk | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/make/GenerateClasses.gmk b/jdk/make/GenerateClasses.gmk index f4dafc55087..1503c0b8dd4 100644 --- a/jdk/make/GenerateClasses.gmk +++ b/jdk/make/GenerateClasses.gmk @@ -52,7 +52,7 @@ $(eval $(call SetupJavaCompilation,BUILD_BOOTSTRAP_RMIC, \ ########################################################################################## -BTRMIC_CP := $(CORBA_OUTPUTDIR)/btjars/btcorba.jar$(PATH_SEP)$(JDK_OUTPUTDIR)/btclasses_rmic$(PATH_SEP)$(BOOTSTRAP_JAVAC_JAR) +BTRMIC_CP := $(INTERIM_CORBA_JAR)$(PATH_SEP)$(JDK_OUTPUTDIR)/btclasses_rmic$(PATH_SEP)$(INTERIM_LANGTOOLS_JAR) BTRMIC_ARGS := "-Xbootclasspath/p:$(BTRMIC_CP)" -cp "$(BTRMIC_CP)" RMIC := $(JAVA) $(BTRMIC_ARGS) sun.rmi.rmic.Main From e8f1f33e46647138a5dc8965ce137f2f8cb1163a Mon Sep 17 00:00:00 2001 From: Alan Bateman Date: Wed, 5 Feb 2014 10:20:30 +0000 Subject: [PATCH 111/159] 8031586: Check jdk/src/*/native/com/sun/security/auth/module for pending JNI exceptions Reviewed-by: vinnie, chegar --- .../com/sun/security/auth/module/Solaris.c | 54 ++++----- .../com/sun/security/auth/module/Unix.c | 8 +- .../native/com/sun/security/auth/module/nt.c | 112 ++++++++---------- 3 files changed, 82 insertions(+), 92 deletions(-) diff --git a/jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c b/jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c index 3e31e7ff125..2b8e2d2b11e 100644 --- a/jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c +++ b/jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c @@ -32,6 +32,12 @@ #include #include +static void throwIllegalArgumentException(JNIEnv *env, const char *msg) { + jclass clazz = (*env)->FindClass(env, "java/lang/IllegalArgumentException"); + if (clazz != NULL) + (*env)->ThrowNew(env, clazz, msg); +} + JNIEXPORT void JNICALL Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo (JNIEnv *env, jobject obj) { @@ -51,7 +57,7 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo if (groups == NULL) { jclass cls = (*env)->FindClass(env,"java/lang/OutOfMemoryError"); - if(cls != 0) + if (cls != NULL) (*env)->ThrowNew(env, cls, NULL); return; } @@ -67,15 +73,13 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo */ fid = (*env)->GetFieldID(env, cls, "username", "Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - /* Unable to find the new exception class, give up. */ - return; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: username"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: username"); + return; } jstr = (*env)->NewStringUTF(env, pwd.pw_name); + if (jstr == NULL) + return; (*env)->SetObjectField(env, obj, fid, jstr); /* @@ -83,13 +87,9 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo */ fid = (*env)->GetFieldID(env, cls, "uid", "J"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - /* Unable to find the new exception class, give up. */ - return; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: username"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: uid"); + return; } (*env)->SetLongField(env, obj, fid, pwd.pw_uid); @@ -98,13 +98,9 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo */ fid = (*env)->GetFieldID(env, cls, "gid", "J"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - /* Unable to find the new exception class, give up. */ - return; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: username"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: gid"); + return; } (*env)->SetLongField(env, obj, fid, pwd.pw_gid); @@ -113,17 +109,17 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo */ fid = (*env)->GetFieldID(env, cls, "groups", "[J"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - /* Unable to find the new exception class, give up. */ - return; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: username"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: groups"); + return; } jgroups = (*env)->NewLongArray(env, numSuppGroups); + if (jgroups == NULL) + return; jgroupsAsArray = (*env)->GetLongArrayElements(env, jgroups, 0); + if (jgroupsAsArray == NULL) + return; for (i = 0; i < numSuppGroups; i++) jgroupsAsArray[i] = groups[i]; (*env)->ReleaseLongArrayElements(env, jgroups, jgroupsAsArray, 0); diff --git a/jdk/src/solaris/native/com/sun/security/auth/module/Unix.c b/jdk/src/solaris/native/com/sun/security/auth/module/Unix.c index 620e19bb236..188a389d666 100644 --- a/jdk/src/solaris/native/com/sun/security/auth/module/Unix.c +++ b/jdk/src/solaris/native/com/sun/security/auth/module/Unix.c @@ -60,7 +60,7 @@ Java_com_sun_security_auth_module_UnixSystem_getUnixInfo groups = (gid_t *)calloc(numSuppGroups, sizeof(gid_t)); if (groups == NULL) { jclass cls = (*env)->FindClass(env,"java/lang/OutOfMemoryError"); - if(cls != 0) + if (cls != NULL) (*env)->ThrowNew(env, cls, NULL); return; } @@ -90,6 +90,8 @@ Java_com_sun_security_auth_module_UnixSystem_getUnixInfo goto cleanUpAndReturn; jstr = (*env)->NewStringUTF(env, pwd->pw_name); + if (jstr == NULL) + goto cleanUpAndReturn; (*env)->SetObjectField(env, obj, userNameID, jstr); (*env)->SetLongField(env, obj, userID, pwd->pw_uid); @@ -97,7 +99,11 @@ Java_com_sun_security_auth_module_UnixSystem_getUnixInfo (*env)->SetLongField(env, obj, groupID, pwd->pw_gid); jgroups = (*env)->NewLongArray(env, numSuppGroups); + if (jgroups == NULL) + goto cleanUpAndReturn; jgroupsAsArray = (*env)->GetLongArrayElements(env, jgroups, 0); + if (jgroupsAsArray == NULL) + goto cleanUpAndReturn; for (i = 0; i < numSuppGroups; i++) jgroupsAsArray[i] = groups[i]; (*env)->ReleaseLongArrayElements(env, jgroups, jgroupsAsArray, 0); diff --git a/jdk/src/windows/native/com/sun/security/auth/module/nt.c b/jdk/src/windows/native/com/sun/security/auth/module/nt.c index 64ef356e1dc..038ceb14f95 100644 --- a/jdk/src/windows/native/com/sun/security/auth/module/nt.c +++ b/jdk/src/windows/native/com/sun/security/auth/module/nt.c @@ -43,6 +43,12 @@ BOOL getImpersonationToken(PHANDLE impersonationToken); BOOL getTextualSid(PSID pSid, LPTSTR TextualSid, LPDWORD lpdwBufferLen); void DisplayErrorText(DWORD dwLastError); +static void throwIllegalArgumentException(JNIEnv *env, const char *msg) { + jclass clazz = (*env)->FindClass(env, "java/lang/IllegalArgumentException"); + if (clazz != NULL) + (*env)->ThrowNew(env, clazz, msg); +} + JNIEXPORT jlong JNICALL Java_com_sun_security_auth_module_NTSystem_getImpersonationToken0 (JNIEnv *env, jobject obj) { @@ -62,7 +68,6 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent long i, j = 0; HANDLE tokenHandle = INVALID_HANDLE_VALUE; - BOOL systemError = FALSE; LPTSTR userName = NULL; // user name LPTSTR userSid = NULL; // user sid @@ -116,70 +121,59 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent fid = (*env)->GetFieldID(env, cls, "userName", "Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - // Unable to find exception class - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: userName"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: userName"); + goto cleanup; } jstr = (*env)->NewStringUTF(env, userName); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); fid = (*env)->GetFieldID(env, cls, "userSID", "Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: userSID"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: userSID"); + goto cleanup; } jstr = (*env)->NewStringUTF(env, userSid); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); fid = (*env)->GetFieldID(env, cls, "domain", "Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: domain"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: domain"); + goto cleanup; } jstr = (*env)->NewStringUTF(env, domainName); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); if (domainSid != NULL) { fid = (*env)->GetFieldID(env, cls, "domainSID", "Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: domainSID"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: domainSID"); + goto cleanup; } jstr = (*env)->NewStringUTF(env, domainSid); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); } fid = (*env)->GetFieldID(env, cls, "primaryGroupID", "Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: PrimaryGroupID"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "invalid field: PrimaryGroupID"); + goto cleanup; } jstr = (*env)->NewStringUTF(env, primaryGroup); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); // primary group may or may not be part of supplementary groups @@ -204,19 +198,14 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent fid = (*env)->GetFieldID(env, cls, "groupIDs", "[Ljava/lang/String;"); if (fid == 0) { - jclass newExcCls = - (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (newExcCls == 0) { - systemError = TRUE; - goto out; - } - (*env)->ThrowNew(env, newExcCls, "invalid field: groupIDs"); + (*env)->ExceptionClear(env); + throwIllegalArgumentException(env, "groupIDs"); + goto cleanup; } stringClass = (*env)->FindClass(env, "java/lang/String"); - if (stringClass == 0) { - goto out; - } + if (stringClass == NULL) + goto cleanup; if (pIndex == -1) { // primary group not in groups array @@ -226,6 +215,8 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent // allocate one less array entry and do not add into new array jgroups = (*env)->NewObjectArray(env, numGroups-1, stringClass, 0); } + if (jgroups == NULL) + goto cleanup; for (i = 0, j = 0; i < (long)numGroups; i++) { if (pIndex == i) { @@ -233,12 +224,14 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent continue; } jstr = (*env)->NewStringUTF(env, groups[i]); + if (jstr == NULL) + goto cleanup; (*env)->SetObjectArrayElement(env, jgroups, j++, jstr); } (*env)->SetObjectField(env, obj, fid, jgroups); } -out: +cleanup: if (userName != NULL) { HeapFree(GetProcessHeap(), 0, userName); } @@ -264,11 +257,6 @@ out: } CloseHandle(tokenHandle); - if (systemError && debug) { - printf(" [getCurrent] System Error: "); - printf("unable to find IllegalArgumentException class\n"); - } - return; } @@ -336,7 +324,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, DisplayErrorText(GetLastError()); } error = TRUE; - goto out; + goto cleanup; } if (debug) { @@ -369,7 +357,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, DisplayErrorText(GetLastError()); } error = TRUE; - goto out; + goto cleanup; } if (debug) { @@ -411,7 +399,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, DisplayErrorText(GetLastError()); } // ok not to have a domain SID (no error) - goto out; + goto cleanup; } bufSize = 0; @@ -422,7 +410,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, printf(" [getUser] domainSid: %s\n", *domainSid); } -out: +cleanup: if (tokenUserInfo != NULL) { HeapFree(GetProcessHeap(), 0, tokenUserInfo); } @@ -466,7 +454,7 @@ BOOL getPrimaryGroup(HANDLE tokenHandle, LPTSTR *primaryGroup) { DisplayErrorText(GetLastError()); } error = TRUE; - goto out; + goto cleanup; } if (debug) { @@ -481,7 +469,7 @@ BOOL getPrimaryGroup(HANDLE tokenHandle, LPTSTR *primaryGroup) { printf(" [getPrimaryGroup] primaryGroup: %s\n", *primaryGroup); } -out: +cleanup: if (tokenGroupInfo != NULL) { HeapFree(GetProcessHeap(), 0, tokenGroupInfo); } @@ -519,7 +507,7 @@ BOOL getGroups(HANDLE tokenHandle, PDWORD numGroups, LPTSTR **groups) { DisplayErrorText(GetLastError()); } error = TRUE; - goto out; + goto cleanup; } if (debug) { @@ -528,7 +516,7 @@ BOOL getGroups(HANDLE tokenHandle, PDWORD numGroups, LPTSTR **groups) { if (tokenGroupInfo->GroupCount == 0) { // no groups - goto out; + goto cleanup; } // return group info @@ -545,7 +533,7 @@ BOOL getGroups(HANDLE tokenHandle, PDWORD numGroups, LPTSTR **groups) { } } -out: +cleanup: if (tokenGroupInfo != NULL) { HeapFree(GetProcessHeap(), 0, tokenGroupInfo); } From edcca42faa4f34016cfe1f6864cef5232345cb0f Mon Sep 17 00:00:00 2001 From: Magnus Ihse Bursie Date: Wed, 5 Feb 2014 11:32:27 +0100 Subject: [PATCH 112/159] 8033532: Freetype include statement must come before X11 include Reviewed-by: erikj, drchase --- jdk/make/lib/Awt2dLibraries.gmk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/make/lib/Awt2dLibraries.gmk b/jdk/make/lib/Awt2dLibraries.gmk index f101b87cc79..a1263ba5775 100644 --- a/jdk/make/lib/Awt2dLibraries.gmk +++ b/jdk/make/lib/Awt2dLibraries.gmk @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2013, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. # DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. # # This code is free software; you can redistribute it and/or modify it @@ -792,9 +792,9 @@ else endif BUILD_LIBFONTMANAGER_CFLAGS_COMMON := \ + $(FONT_HEADERS) \ $(X_CFLAGS) \ -DLE_STANDALONE -DHEADLESS \ - $(FONT_HEADERS) \ -I$(JDK_TOPDIR)/src/share/native/sun/font \ -I$(JDK_TOPDIR)/src/share/native/sun/font/layout \ -I$(JDK_TOPDIR)/src/share/native/sun/awt/image/cvutils \ From 329369ddf68c7515ff59ae91179dd3b9970b83fa Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 5 Feb 2014 14:21:10 +0100 Subject: [PATCH 113/159] 8033680: Profiles build broken Reviewed-by: alanb --- jdk/make/Tools.gmk | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/jdk/make/Tools.gmk b/jdk/make/Tools.gmk index 2336ed4ce98..661bf3e3b03 100644 --- a/jdk/make/Tools.gmk +++ b/jdk/make/Tools.gmk @@ -122,12 +122,12 @@ TOOL_OSX_TOBIN = $(JAVA) -Djava.awt.headless=true -cp $(JDK_OUTPUTDIR)/btclasses TOOL_CLDRCONVERTER = $(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \ build.tools.cldrconverter.CLDRConverter -TOOL_CHECKDEPS = $(JAVA) -Xbootclasspath/p:$(LANGTOOLS_OUTPUTDIR)/dist/bootstrap/lib/javac.jar \ +TOOL_CHECKDEPS = $(JAVA) -Xbootclasspath/p:$(INTERIM_LANGTOOLS_JAR) \ -cp $(JDK_OUTPUTDIR)/btclasses:$(JDK_OUTPUTDIR) \ build.tools.deps.CheckDeps TOOL_ADDTORESTRICTEDPKGS=$(JAVA) -cp $(JDK_OUTPUTDIR)/btclasses \ - build.tools.addtorestrictedpkgs.AddToRestrictedPkgs + build.tools.addtorestrictedpkgs.AddToRestrictedPkgs ########################################################################################## From 319dd343be2cd20269ed9de51d519a974991a1dc Mon Sep 17 00:00:00 2001 From: Chris Hegarty Date: Wed, 5 Feb 2014 14:14:46 +0000 Subject: [PATCH 114/159] 8033689: PlainDatagramSocketImpl missing returns after throwing an exception Reviewed-by: michaelm --- jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c index 3df46c85171..ac4a8385e9a 100644 --- a/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c +++ b/jdk/src/solaris/native/java/net/PlainDatagramSocketImpl.c @@ -506,6 +506,7 @@ Java_java_net_PlainDatagramSocketImpl_peek(JNIEnv *env, jobject this, } if (IS_NULL(addressObj)) { JNU_ThrowNullPointerException(env, "Null address in peek()"); + return -1; } if (timeout) { int ret = NET_Timeout(fd, timeout); @@ -1419,7 +1420,7 @@ Java_java_net_PlainDatagramSocketImpl_socketSetOption(JNIEnv *env, default : JNU_ThrowByName(env, JNU_JAVANETPKG "SocketException", "Socket option not supported by PlainDatagramSocketImp"); - break; + return; } @@ -1833,6 +1834,7 @@ Java_java_net_PlainDatagramSocketImpl_setTimeToLive(JNIEnv *env, jobject this, #ifdef AF_INET6 #ifdef __linux__ setTTL(env, fd, ttl); + JNU_CHECK_EXCEPTION(env); if (ipv6_available()) { setHopLimit(env, fd, ttl); } @@ -2120,6 +2122,7 @@ static void mcast_join_leave(JNIEnv *env, jobject this, else NET_ThrowCurrent(env, "setsockopt IP_DROP_MEMBERSHIP failed"); } + return; } } From adeedfee16f5c76a4e68a667d47552de0adede36 Mon Sep 17 00:00:00 2001 From: Vinnie Ryan Date: Wed, 5 Feb 2014 15:58:27 +0000 Subject: [PATCH 115/159] 8011983: [parfait] False positive: unportable format string argument mismatch in jdk/src/windows/native/com/sun/security/auth/module/nt.c Reviewed-by: alanb --- .../native/com/sun/security/auth/module/nt.c | 117 ++++++++++-------- 1 file changed, 65 insertions(+), 52 deletions(-) diff --git a/jdk/src/windows/native/com/sun/security/auth/module/nt.c b/jdk/src/windows/native/com/sun/security/auth/module/nt.c index 038ceb14f95..72c0ef84f33 100644 --- a/jdk/src/windows/native/com/sun/security/auth/module/nt.c +++ b/jdk/src/windows/native/com/sun/security/auth/module/nt.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -43,12 +43,6 @@ BOOL getImpersonationToken(PHANDLE impersonationToken); BOOL getTextualSid(PSID pSid, LPTSTR TextualSid, LPDWORD lpdwBufferLen); void DisplayErrorText(DWORD dwLastError); -static void throwIllegalArgumentException(JNIEnv *env, const char *msg) { - jclass clazz = (*env)->FindClass(env, "java/lang/IllegalArgumentException"); - if (clazz != NULL) - (*env)->ThrowNew(env, clazz, msg); -} - JNIEXPORT jlong JNICALL Java_com_sun_security_auth_module_NTSystem_getImpersonationToken0 (JNIEnv *env, jobject obj) { @@ -68,6 +62,7 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent long i, j = 0; HANDLE tokenHandle = INVALID_HANDLE_VALUE; + BOOL systemError = FALSE; LPTSTR userName = NULL; // user name LPTSTR userSid = NULL; // user sid @@ -121,59 +116,70 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent fid = (*env)->GetFieldID(env, cls, "userName", "Ljava/lang/String;"); if (fid == 0) { - (*env)->ExceptionClear(env); - throwIllegalArgumentException(env, "invalid field: userName"); - goto cleanup; + jclass newExcCls = + (*env)->FindClass(env, "java/lang/IllegalArgumentException"); + if (newExcCls == 0) { + // Unable to find exception class + systemError = TRUE; + goto out; + } + (*env)->ThrowNew(env, newExcCls, "invalid field: userName"); } jstr = (*env)->NewStringUTF(env, userName); - if (jstr == NULL) - goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); fid = (*env)->GetFieldID(env, cls, "userSID", "Ljava/lang/String;"); if (fid == 0) { - (*env)->ExceptionClear(env); - throwIllegalArgumentException(env, "invalid field: userSID"); - goto cleanup; + jclass newExcCls = + (*env)->FindClass(env, "java/lang/IllegalArgumentException"); + if (newExcCls == 0) { + systemError = TRUE; + goto out; + } + (*env)->ThrowNew(env, newExcCls, "invalid field: userSID"); } jstr = (*env)->NewStringUTF(env, userSid); - if (jstr == NULL) - goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); fid = (*env)->GetFieldID(env, cls, "domain", "Ljava/lang/String;"); if (fid == 0) { - (*env)->ExceptionClear(env); - throwIllegalArgumentException(env, "invalid field: domain"); - goto cleanup; + jclass newExcCls = + (*env)->FindClass(env, "java/lang/IllegalArgumentException"); + if (newExcCls == 0) { + systemError = TRUE; + goto out; + } + (*env)->ThrowNew(env, newExcCls, "invalid field: domain"); } jstr = (*env)->NewStringUTF(env, domainName); - if (jstr == NULL) - goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); if (domainSid != NULL) { fid = (*env)->GetFieldID(env, cls, "domainSID", "Ljava/lang/String;"); if (fid == 0) { - (*env)->ExceptionClear(env); - throwIllegalArgumentException(env, "invalid field: domainSID"); - goto cleanup; + jclass newExcCls = + (*env)->FindClass(env, "java/lang/IllegalArgumentException"); + if (newExcCls == 0) { + systemError = TRUE; + goto out; + } + (*env)->ThrowNew(env, newExcCls, "invalid field: domainSID"); } jstr = (*env)->NewStringUTF(env, domainSid); - if (jstr == NULL) - goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); } fid = (*env)->GetFieldID(env, cls, "primaryGroupID", "Ljava/lang/String;"); if (fid == 0) { - (*env)->ExceptionClear(env); - throwIllegalArgumentException(env, "invalid field: PrimaryGroupID"); - goto cleanup; + jclass newExcCls = + (*env)->FindClass(env, "java/lang/IllegalArgumentException"); + if (newExcCls == 0) { + systemError = TRUE; + goto out; + } + (*env)->ThrowNew(env, newExcCls, "invalid field: PrimaryGroupID"); } jstr = (*env)->NewStringUTF(env, primaryGroup); - if (jstr == NULL) - goto cleanup; (*env)->SetObjectField(env, obj, fid, jstr); // primary group may or may not be part of supplementary groups @@ -198,14 +204,19 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent fid = (*env)->GetFieldID(env, cls, "groupIDs", "[Ljava/lang/String;"); if (fid == 0) { - (*env)->ExceptionClear(env); - throwIllegalArgumentException(env, "groupIDs"); - goto cleanup; + jclass newExcCls = + (*env)->FindClass(env, "java/lang/IllegalArgumentException"); + if (newExcCls == 0) { + systemError = TRUE; + goto out; + } + (*env)->ThrowNew(env, newExcCls, "invalid field: groupIDs"); } stringClass = (*env)->FindClass(env, "java/lang/String"); - if (stringClass == NULL) - goto cleanup; + if (stringClass == 0) { + goto out; + } if (pIndex == -1) { // primary group not in groups array @@ -215,8 +226,6 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent // allocate one less array entry and do not add into new array jgroups = (*env)->NewObjectArray(env, numGroups-1, stringClass, 0); } - if (jgroups == NULL) - goto cleanup; for (i = 0, j = 0; i < (long)numGroups; i++) { if (pIndex == i) { @@ -224,14 +233,12 @@ Java_com_sun_security_auth_module_NTSystem_getCurrent continue; } jstr = (*env)->NewStringUTF(env, groups[i]); - if (jstr == NULL) - goto cleanup; (*env)->SetObjectArrayElement(env, jgroups, j++, jstr); } (*env)->SetObjectField(env, obj, fid, jgroups); } -cleanup: +out: if (userName != NULL) { HeapFree(GetProcessHeap(), 0, userName); } @@ -257,6 +264,11 @@ cleanup: } CloseHandle(tokenHandle); + if (systemError && debug) { + printf(" [getCurrent] System Error: "); + printf("unable to find IllegalArgumentException class\n"); + } + return; } @@ -324,7 +336,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, DisplayErrorText(GetLastError()); } error = TRUE; - goto cleanup; + goto out; } if (debug) { @@ -357,7 +369,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, DisplayErrorText(GetLastError()); } error = TRUE; - goto cleanup; + goto out; } if (debug) { @@ -399,7 +411,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, DisplayErrorText(GetLastError()); } // ok not to have a domain SID (no error) - goto cleanup; + goto out; } bufSize = 0; @@ -410,7 +422,7 @@ BOOL getUser(HANDLE tokenHandle, LPTSTR *userName, printf(" [getUser] domainSid: %s\n", *domainSid); } -cleanup: +out: if (tokenUserInfo != NULL) { HeapFree(GetProcessHeap(), 0, tokenUserInfo); } @@ -454,7 +466,7 @@ BOOL getPrimaryGroup(HANDLE tokenHandle, LPTSTR *primaryGroup) { DisplayErrorText(GetLastError()); } error = TRUE; - goto cleanup; + goto out; } if (debug) { @@ -469,7 +481,7 @@ BOOL getPrimaryGroup(HANDLE tokenHandle, LPTSTR *primaryGroup) { printf(" [getPrimaryGroup] primaryGroup: %s\n", *primaryGroup); } -cleanup: +out: if (tokenGroupInfo != NULL) { HeapFree(GetProcessHeap(), 0, tokenGroupInfo); } @@ -507,7 +519,7 @@ BOOL getGroups(HANDLE tokenHandle, PDWORD numGroups, LPTSTR **groups) { DisplayErrorText(GetLastError()); } error = TRUE; - goto cleanup; + goto out; } if (debug) { @@ -516,7 +528,7 @@ BOOL getGroups(HANDLE tokenHandle, PDWORD numGroups, LPTSTR **groups) { if (tokenGroupInfo->GroupCount == 0) { // no groups - goto cleanup; + goto out; } // return group info @@ -533,7 +545,7 @@ BOOL getGroups(HANDLE tokenHandle, PDWORD numGroups, LPTSTR **groups) { } } -cleanup: +out: if (tokenGroupInfo != NULL) { HeapFree(GetProcessHeap(), 0, tokenGroupInfo); } @@ -577,7 +589,8 @@ BOOL getImpersonationToken(PHANDLE impersonationToken) { CloseHandle(dupToken); if (debug) { - printf(" [getImpersonationToken] token = %d\n", *impersonationToken); + printf(" [getImpersonationToken] token = %p\n", + (void *)*impersonationToken); } return TRUE; } From 5804adca86a5038523f22ef2bfbd093d2a4560d9 Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Wed, 5 Feb 2014 10:59:53 -0500 Subject: [PATCH 116/159] 8030993: Check jdk/src/share/native/common/jni_util.c for JNI pending exceptions Check for pending exceptions Reviewed-by: alanb, chegar --- jdk/src/share/native/common/jni_util.c | 51 ++++++++++++++++++++------ 1 file changed, 39 insertions(+), 12 deletions(-) diff --git a/jdk/src/share/native/common/jni_util.c b/jdk/src/share/native/common/jni_util.c index 3ef707f6079..de3509b7a59 100644 --- a/jdk/src/share/native/common/jni_util.c +++ b/jdk/src/share/native/common/jni_util.c @@ -626,10 +626,14 @@ initializeEncoding(JNIEnv *env) { jstring propname = 0; jstring enc = 0; + jclass strClazz = NULL; if ((*env)->EnsureLocalCapacity(env, 3) < 0) return; + strClazz = JNU_ClassString(env); + CHECK_NULL(strClazz); + propname = (*env)->NewStringUTF(env, "sun.jnu.encoding"); if (propname) { jboolean exc; @@ -683,9 +687,10 @@ initializeEncoding(JNIEnv *env) (*env)->DeleteLocalRef(env, enc); /* Initialize method-id cache */ - String_getBytes_ID = (*env)->GetMethodID(env, JNU_ClassString(env), + String_getBytes_ID = (*env)->GetMethodID(env, strClazz, "getBytes", "(Ljava/lang/String;)[B"); - String_init_ID = (*env)->GetMethodID(env, JNU_ClassString(env), + CHECK_NULL(String_getBytes_ID); + String_init_ID = (*env)->GetMethodID(env, strClazz, "", "([BLjava/lang/String;)V"); } @@ -720,8 +725,10 @@ JNU_NewStringPlatform(JNIEnv *env, const char *str) jbyteArray hab = 0; int len; - if (fastEncoding == NO_ENCODING_YET) + if (fastEncoding == NO_ENCODING_YET) { initializeEncoding(env); + JNU_CHECK_EXCEPTION_RETURN(env, NULL); + } if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET)) return newString8859_1(env, str); @@ -736,9 +743,11 @@ JNU_NewStringPlatform(JNIEnv *env, const char *str) len = (int)strlen(str); hab = (*env)->NewByteArray(env, len); if (hab != 0) { + jclass strClazz = JNU_ClassString(env); + CHECK_NULL_RETURN(strClazz, 0); (*env)->SetByteArrayRegion(env, hab, 0, len, (jbyte *)str); if (jnuEncodingSupported(env)) { - result = (*env)->NewObject(env, JNU_ClassString(env), + result = (*env)->NewObject(env, strClazz, String_init_ID, hab, jnuEncoding); } else { /*If the encoding specified in sun.jnu.encoding is not endorsed @@ -747,9 +756,11 @@ JNU_NewStringPlatform(JNIEnv *env, const char *str) StringCoding class will pickup the iso-8859-1 as the fallback converter for us. */ - jmethodID mid = (*env)->GetMethodID(env, JNU_ClassString(env), + jmethodID mid = (*env)->GetMethodID(env, strClazz, "", "([B)V"); - result = (*env)->NewObject(env, JNU_ClassString(env), mid, hab); + if (mid != NULL) { + result = (*env)->NewObject(env, strClazz, mid, hab); + } } (*env)->DeleteLocalRef(env, hab); return result; @@ -775,8 +786,10 @@ JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) if (isCopy) *isCopy = JNI_TRUE; - if (fastEncoding == NO_ENCODING_YET) + if (fastEncoding == NO_ENCODING_YET) { initializeEncoding(env); + JNU_CHECK_EXCEPTION_RETURN(env, 0); + } if ((fastEncoding == FAST_8859_1) || (fastEncoding == NO_ENCODING_YET)) return getString8859_1Chars(env, jstr); @@ -791,9 +804,14 @@ JNU_GetStringPlatformChars(JNIEnv *env, jstring jstr, jboolean *isCopy) if (jnuEncodingSupported(env)) { hab = (*env)->CallObjectMethod(env, jstr, String_getBytes_ID, jnuEncoding); } else { - jmethodID mid = (*env)->GetMethodID(env, JNU_ClassString(env), - "getBytes", "()[B"); - hab = (*env)->CallObjectMethod(env, jstr, mid); + jmethodID mid; + jclass strClazz = JNU_ClassString(env); + CHECK_NULL_RETURN(strClazz, 0); + mid = (*env)->GetMethodID(env, strClazz, + "getBytes", "()[B"); + if (mid != NULL) { + hab = (*env)->CallObjectMethod(env, jstr, mid); + } } if (!(*env)->ExceptionCheck(env)) { @@ -842,6 +860,7 @@ JNU_ClassString(JNIEnv *env) if ((*env)->EnsureLocalCapacity(env, 1) < 0) return 0; c = (*env)->FindClass(env, "java/lang/String"); + CHECK_NULL_RETURN(c, NULL); cls = (*env)->NewGlobalRef(env, c); (*env)->DeleteLocalRef(env, c); } @@ -857,6 +876,7 @@ JNU_ClassClass(JNIEnv *env) if ((*env)->EnsureLocalCapacity(env, 1) < 0) return 0; c = (*env)->FindClass(env, "java/lang/Class"); + CHECK_NULL_RETURN(c, NULL); cls = (*env)->NewGlobalRef(env, c); (*env)->DeleteLocalRef(env, c); } @@ -872,6 +892,7 @@ JNU_ClassObject(JNIEnv *env) if ((*env)->EnsureLocalCapacity(env, 1) < 0) return 0; c = (*env)->FindClass(env, "java/lang/Object"); + CHECK_NULL_RETURN(c, NULL); cls = (*env)->NewGlobalRef(env, c); (*env)->DeleteLocalRef(env, c); } @@ -887,6 +908,7 @@ JNU_ClassThrowable(JNIEnv *env) if ((*env)->EnsureLocalCapacity(env, 1) < 0) return 0; c = (*env)->FindClass(env, "java/lang/Throwable"); + CHECK_NULL_RETURN(c, NULL); cls = (*env)->NewGlobalRef(env, c); (*env)->DeleteLocalRef(env, c); } @@ -936,8 +958,11 @@ JNU_Equals(JNIEnv *env, jobject object1, jobject object2) { static jmethodID mid = NULL; if (mid == NULL) { - mid = (*env)->GetMethodID(env, JNU_ClassObject(env), "equals", + jclass objClazz = JNU_ClassObject(env); + CHECK_NULL_RETURN(objClazz, JNI_FALSE); + mid = (*env)->GetMethodID(env, objClazz, "equals", "(Ljava/lang/Object;)Z"); + CHECK_NULL_RETURN(mid, JNI_FALSE); } return (*env)->CallBooleanMethod(env, object1, mid, object2); } @@ -1039,7 +1064,9 @@ JNU_PrintClass(JNIEnv *env, char* hdr, jobject object) } else { jclass cls = (*env)->GetObjectClass(env, object); jstring clsName = JNU_ToString(env, cls); - JNU_PrintString(env, hdr, clsName); + if (clsName == NULL) { + JNU_PrintString(env, hdr, clsName); + } (*env)->DeleteLocalRef(env, cls); (*env)->DeleteLocalRef(env, clsName); } From 8ca6ca944ba0851d2ea5d843e312eff2be13af9e Mon Sep 17 00:00:00 2001 From: Roger Riggs Date: Wed, 5 Feb 2014 10:59:55 -0500 Subject: [PATCH 117/159] 8032749: Typo in java.time.Clock 8032888: Error message typo in TemporalAccessor 8032558: Instant spec includes incorrect assertion wrt valid range 8032494: DateTimeFormatter spec includes irrelevent detail on parsing pattern Update to fix typos, remove extraneous text Reviewed-by: darcy, lancea, sherman, scolebourne --- jdk/src/share/classes/java/time/Clock.java | 2 +- jdk/src/share/classes/java/time/Instant.java | 5 ----- .../share/classes/java/time/format/DateTimeFormatter.java | 5 +---- .../share/classes/java/time/temporal/TemporalAccessor.java | 2 +- 4 files changed, 3 insertions(+), 11 deletions(-) diff --git a/jdk/src/share/classes/java/time/Clock.java b/jdk/src/share/classes/java/time/Clock.java index cd90822925f..b1127848bed 100644 --- a/jdk/src/share/classes/java/time/Clock.java +++ b/jdk/src/share/classes/java/time/Clock.java @@ -104,7 +104,7 @@ import java.util.TimeZone; * resolution clock if one is available. * * @implSpec - * This abstract class must be implemented with care to ensure other operate correctly. + * This abstract class must be implemented with care to ensure other classes operate correctly. * All implementations that can be instantiated must be final, immutable and thread-safe. *

      * The principal methods are defined to allow the throwing of an exception. diff --git a/jdk/src/share/classes/java/time/Instant.java b/jdk/src/share/classes/java/time/Instant.java index 312e2d4159d..1b944a50c3d 100644 --- a/jdk/src/share/classes/java/time/Instant.java +++ b/jdk/src/share/classes/java/time/Instant.java @@ -100,11 +100,6 @@ import java.util.Objects; * This class models a single instantaneous point on the time-line. * This might be used to record event time-stamps in the application. *

      - * For practicality, the instant is stored with some constraints. - * The measurable time-line is restricted to the number of seconds that can be held - * in a {@code long}. This is greater than the current estimated age of the universe. - * The instant is stored to nanosecond resolution. - *

      * The range of an instant requires the storage of a number larger than a {@code long}. * To achieve this, the class stores a {@code long} representing epoch-seconds and an * {@code int} representing nanosecond-of-second, which will always be between 0 and 999,999,999. diff --git a/jdk/src/share/classes/java/time/format/DateTimeFormatter.java b/jdk/src/share/classes/java/time/format/DateTimeFormatter.java index 4109d20e590..39d91986f86 100644 --- a/jdk/src/share/classes/java/time/format/DateTimeFormatter.java +++ b/jdk/src/share/classes/java/time/format/DateTimeFormatter.java @@ -344,10 +344,7 @@ import java.util.Set; * Fraction: Outputs the nano-of-second field as a fraction-of-second. * The nano-of-second value has nine digits, thus the count of pattern letters * is from 1 to 9. If it is less than 9, then the nano-of-second value is - * truncated, with only the most significant digits being output. When parsing - * in strict mode, the number of parsed digits must match the count of pattern - * letters. When parsing in lenient mode, the number of parsed digits must be at - * least the count of pattern letters, up to 9 digits. + * truncated, with only the most significant digits being output. *

      * Year: The count of letters determines the minimum field width below * which padding is used. If the count of letters is two, then a diff --git a/jdk/src/share/classes/java/time/temporal/TemporalAccessor.java b/jdk/src/share/classes/java/time/temporal/TemporalAccessor.java index 081bbbaec32..a6133e18837 100644 --- a/jdk/src/share/classes/java/time/temporal/TemporalAccessor.java +++ b/jdk/src/share/classes/java/time/temporal/TemporalAccessor.java @@ -217,7 +217,7 @@ public interface TemporalAccessor { default int get(TemporalField field) { ValueRange range = range(field); if (range.isIntValue() == false) { - throw new UnsupportedTemporalTypeException("Invalid field " + field + " + for get() method, use getLong() instead"); + throw new UnsupportedTemporalTypeException("Invalid field " + field + " for get() method, use getLong() instead"); } long value = getLong(field); if (range.isValidValue(value) == false) { From 650470b407f3fdd786597a868beff5bddfbd1fea Mon Sep 17 00:00:00 2001 From: Erik Joelsson Date: Wed, 5 Feb 2014 17:24:03 +0100 Subject: [PATCH 118/159] 8033210: Intermittent build failure: jdk8 fails on win_i586 in jdk/make (p11_convert.c(67) : Cannot open 'sun_security_pkcs11_wrapper_PKCS11.h) Reviewed-by: ihse, tbell --- make/common/JavaCompilation.gmk | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/make/common/JavaCompilation.gmk b/make/common/JavaCompilation.gmk index fe4ff3e5eb1..c2dd54b2be5 100644 --- a/make/common/JavaCompilation.gmk +++ b/make/common/JavaCompilation.gmk @@ -534,16 +534,16 @@ define SetupJavaCompilation # When building in batch, put headers in a temp dir to filter out those that actually # changed before copying them to the real header dir. ifneq (,$$($1_HEADERS)) - $1_HEADERS_ARG := -h $$($1_HEADERS).tmp + $1_HEADERS_ARG := -h $$($1_HEADERS).$1.tmp $$($1_HEADERS)/_the.$1_headers: $$($1_BIN)/_the.$1_batch $(MKDIR) -p $$(@D) - for f in `ls $$($1_HEADERS).tmp`; do \ - if [ ! -f "$$($1_HEADERS)/$$$$f" ] || [ "`$(DIFF) $$($1_HEADERS)/$$$$f $$($1_HEADERS).tmp/$$$$f`" != "" ]; then \ - $(CP) -f $$($1_HEADERS).tmp/$$$$f $$($1_HEADERS)/$$$$f; \ + for f in `ls $$($1_HEADERS).$1.tmp`; do \ + if [ ! -f "$$($1_HEADERS)/$$$$f" ] || [ "`$(DIFF) $$($1_HEADERS)/$$$$f $$($1_HEADERS).$1.tmp/$$$$f`" != "" ]; then \ + $(CP) -f $$($1_HEADERS).$1.tmp/$$$$f $$($1_HEADERS)/$$$$f; \ fi; \ done - $(RM) -r $$($1_HEADERS).tmp + $(RM) -r $$($1_HEADERS).$1.tmp $(TOUCH) $$@ $1 += $$($1_HEADERS)/_the.$1_headers From 11c56780a40438a99ac2f7edf7d4c34e68545823 Mon Sep 17 00:00:00 2001 From: Daniel Fuchs Date: Wed, 5 Feb 2014 17:56:04 +0100 Subject: [PATCH 119/159] 8033542: test/java/util/logging/SimpleLogManager might let Loggers be gc'ed too early Fix another case of potentially premature Logger garbage collection in tests. Reviewed-by: mchung --- jdk/test/java/util/logging/SimpleLogManager.java | 8 +++----- 1 file changed, 3 insertions(+), 5 deletions(-) diff --git a/jdk/test/java/util/logging/SimpleLogManager.java b/jdk/test/java/util/logging/SimpleLogManager.java index f469727654f..1e1da7919a5 100644 --- a/jdk/test/java/util/logging/SimpleLogManager.java +++ b/jdk/test/java/util/logging/SimpleLogManager.java @@ -98,16 +98,14 @@ public class SimpleLogManager extends CustomLogManager { return false; } CustomLogger newLogger = new CustomLogger(logger); - super.addLogger(newLogger); - return true; + return super.addLogger(newLogger); } public class CustomLogger extends Logger { + final Logger keepRef; // keep a strong reference to avoid GC. CustomLogger(Logger logger) { super(logger.getName(), logger.getResourceBundleName()); - } - CustomLogger(String name) { - super(name, null); + keepRef = logger; } } } From 8a6d9792cee6c89c5fea86a0144b48d5a7d7b0d0 Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 5 Feb 2014 10:15:45 -0800 Subject: [PATCH 120/159] 8033526: Fix serial lint warnings in java.awt.* Reviewed-by: briangoetz --- jdk/src/share/classes/java/awt/color/CMMException.java | 1 + .../share/classes/java/awt/color/ProfileDataException.java | 3 ++- jdk/src/share/classes/java/awt/datatransfer/FlavorEvent.java | 4 +++- .../classes/java/awt/geom/IllegalPathStateException.java | 4 +++- .../java/awt/geom/NoninvertibleTransformException.java | 4 +++- jdk/src/share/classes/java/awt/image/ImagingOpException.java | 3 ++- .../share/classes/java/awt/image/RasterFormatException.java | 3 ++- .../classes/java/awt/image/renderable/ParameterBlock.java | 4 +++- .../share/classes/java/awt/print/PrinterAbortException.java | 3 ++- jdk/src/share/classes/java/awt/print/PrinterException.java | 3 ++- 10 files changed, 23 insertions(+), 9 deletions(-) diff --git a/jdk/src/share/classes/java/awt/color/CMMException.java b/jdk/src/share/classes/java/awt/color/CMMException.java index 04497f69cc4..c175bc38ebe 100644 --- a/jdk/src/share/classes/java/awt/color/CMMException.java +++ b/jdk/src/share/classes/java/awt/color/CMMException.java @@ -47,6 +47,7 @@ package java.awt.color; */ public class CMMException extends java.lang.RuntimeException { + private static final long serialVersionUID = 5775558044142994965L; /** * Constructs a CMMException with the specified detail message. diff --git a/jdk/src/share/classes/java/awt/color/ProfileDataException.java b/jdk/src/share/classes/java/awt/color/ProfileDataException.java index 829a92862f8..1a37014b89f 100644 --- a/jdk/src/share/classes/java/awt/color/ProfileDataException.java +++ b/jdk/src/share/classes/java/awt/color/ProfileDataException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ package java.awt.color; */ public class ProfileDataException extends java.lang.RuntimeException { + private static final long serialVersionUID = 7286140888240322498L; /** * Constructs a ProfileDataException with the specified detail message. diff --git a/jdk/src/share/classes/java/awt/datatransfer/FlavorEvent.java b/jdk/src/share/classes/java/awt/datatransfer/FlavorEvent.java index 036ea9aef10..3e627e69603 100644 --- a/jdk/src/share/classes/java/awt/datatransfer/FlavorEvent.java +++ b/jdk/src/share/classes/java/awt/datatransfer/FlavorEvent.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2006, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -38,6 +38,8 @@ import java.util.EventObject; * @since 1.5 */ public class FlavorEvent extends EventObject { + private static final long serialVersionUID = -5842664112252414548L; + /** * Constructs a FlavorEvent object. * diff --git a/jdk/src/share/classes/java/awt/geom/IllegalPathStateException.java b/jdk/src/share/classes/java/awt/geom/IllegalPathStateException.java index 629a46576ac..b07ea6af2aa 100644 --- a/jdk/src/share/classes/java/awt/geom/IllegalPathStateException.java +++ b/jdk/src/share/classes/java/awt/geom/IllegalPathStateException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -35,6 +35,8 @@ package java.awt.geom; */ public class IllegalPathStateException extends RuntimeException { + private static final long serialVersionUID = -5158084205220481094L; + /** * Constructs an IllegalPathStateException with no * detail message. diff --git a/jdk/src/share/classes/java/awt/geom/NoninvertibleTransformException.java b/jdk/src/share/classes/java/awt/geom/NoninvertibleTransformException.java index 72c1417ba77..8184f784b2b 100644 --- a/jdk/src/share/classes/java/awt/geom/NoninvertibleTransformException.java +++ b/jdk/src/share/classes/java/awt/geom/NoninvertibleTransformException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1999, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,8 @@ package java.awt.geom; */ public class NoninvertibleTransformException extends java.lang.Exception { + private static final long serialVersionUID = 6137225240503990466L; + /** * Constructs an instance of * NoninvertibleTransformException diff --git a/jdk/src/share/classes/java/awt/image/ImagingOpException.java b/jdk/src/share/classes/java/awt/image/ImagingOpException.java index c139e47a521..ca12f18f371 100644 --- a/jdk/src/share/classes/java/awt/image/ImagingOpException.java +++ b/jdk/src/share/classes/java/awt/image/ImagingOpException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ package java.awt.image; * process the image. */ public class ImagingOpException extends java.lang.RuntimeException { + private static final long serialVersionUID = 8026288481846276658L; /** * Constructs an ImagingOpException object with the diff --git a/jdk/src/share/classes/java/awt/image/RasterFormatException.java b/jdk/src/share/classes/java/awt/image/RasterFormatException.java index 59dd8959936..976eb782201 100644 --- a/jdk/src/share/classes/java/awt/image/RasterFormatException.java +++ b/jdk/src/share/classes/java/awt/image/RasterFormatException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -31,6 +31,7 @@ package java.awt.image; * invalid layout information in the {@link Raster}. */ public class RasterFormatException extends java.lang.RuntimeException { + private static final long serialVersionUID = 96598996116164315L; /** * Constructs a new RasterFormatException with the diff --git a/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java b/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java index 9726020dd30..ca12bfc4c4b 100644 --- a/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java +++ b/jdk/src/share/classes/java/awt/image/renderable/ParameterBlock.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, 2004, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -93,6 +93,8 @@ import java.util.Vector; * * */ public class ParameterBlock implements Cloneable, Serializable { + private static final long serialVersionUID = -7577115551785240750L; + /** A Vector of sources, stored as arbitrary Objects. */ protected Vector sources = new Vector(); diff --git a/jdk/src/share/classes/java/awt/print/PrinterAbortException.java b/jdk/src/share/classes/java/awt/print/PrinterAbortException.java index d775121dbf1..f421dae9bea 100644 --- a/jdk/src/share/classes/java/awt/print/PrinterAbortException.java +++ b/jdk/src/share/classes/java/awt/print/PrinterAbortException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -33,6 +33,7 @@ package java.awt.print; */ public class PrinterAbortException extends PrinterException { + private static final long serialVersionUID = 4725169026278854136L; /** * Constructs a new PrinterAbortException with no diff --git a/jdk/src/share/classes/java/awt/print/PrinterException.java b/jdk/src/share/classes/java/awt/print/PrinterException.java index 6304b29c481..5ec275ec5f0 100644 --- a/jdk/src/share/classes/java/awt/print/PrinterException.java +++ b/jdk/src/share/classes/java/awt/print/PrinterException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1998, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1998, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -32,6 +32,7 @@ package java.awt.print; */ public class PrinterException extends Exception { + private static final long serialVersionUID = -3757589981158265819L; /** * Constructs a new PrinterException object From 5475110b726b3c11b717dd130a9f16f8ed97c4bb Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Wed, 5 Feb 2014 10:21:18 -0800 Subject: [PATCH 121/159] 8033616: Fix serial lint warnings in javax.imageio.* Reviewed-by: alanb --- jdk/src/share/classes/javax/imageio/IIOException.java | 3 ++- .../javax/imageio/metadata/IIOInvalidTreeException.java | 3 ++- .../share/classes/javax/imageio/metadata/IIOMetadataNode.java | 3 ++- jdk/src/share/classes/javax/imageio/spi/DigraphNode.java | 3 ++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/jdk/src/share/classes/javax/imageio/IIOException.java b/jdk/src/share/classes/javax/imageio/IIOException.java index 6a1c4d9ac5f..1b3cb8e6a96 100644 --- a/jdk/src/share/classes/javax/imageio/IIOException.java +++ b/jdk/src/share/classes/javax/imageio/IIOException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ import java.io.IOException; * */ public class IIOException extends IOException { + private static final long serialVersionUID = -3216210718638985251L; /** * Constructs an IIOException with a given message diff --git a/jdk/src/share/classes/javax/imageio/metadata/IIOInvalidTreeException.java b/jdk/src/share/classes/javax/imageio/metadata/IIOInvalidTreeException.java index 7f50cc80a85..9bec7c90eb4 100644 --- a/jdk/src/share/classes/javax/imageio/metadata/IIOInvalidTreeException.java +++ b/jdk/src/share/classes/javax/imageio/metadata/IIOInvalidTreeException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -44,6 +44,7 @@ import org.w3c.dom.Node; * */ public class IIOInvalidTreeException extends IIOException { + private static final long serialVersionUID = -1314083172544132777L; /** * The Node that led to the parsing error, or diff --git a/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataNode.java b/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataNode.java index bb5833a0a2f..1f3fd25f131 100644 --- a/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataNode.java +++ b/jdk/src/share/classes/javax/imageio/metadata/IIOMetadataNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,6 +41,7 @@ import org.w3c.dom.UserDataHandler; class IIODOMException extends DOMException { + private static final long serialVersionUID = -4369510142067447468L; public IIODOMException(short code, String message) { super(code, message); diff --git a/jdk/src/share/classes/javax/imageio/spi/DigraphNode.java b/jdk/src/share/classes/javax/imageio/spi/DigraphNode.java index 9473ced32fc..b133c29db9a 100644 --- a/jdk/src/share/classes/javax/imageio/spi/DigraphNode.java +++ b/jdk/src/share/classes/javax/imageio/spi/DigraphNode.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -40,6 +40,7 @@ import java.util.Set; * */ class DigraphNode implements Cloneable, Serializable { + private static final long serialVersionUID = 5308261378582246841L; /** The data associated with this node. */ protected Object data; From aef65cc369d3351b93510383f84010d798372399 Mon Sep 17 00:00:00 2001 From: Vinnie Ryan Date: Wed, 5 Feb 2014 18:37:42 +0000 Subject: [PATCH 122/159] 8025669: [parfait] warning from b62 for jdk.src.solaris.native.com.sun.security.auth.module: memory leak Reviewed-by: alanb, chegar --- .../com/sun/security/auth/module/Solaris.c | 26 ++++++++++++------- 1 file changed, 16 insertions(+), 10 deletions(-) diff --git a/jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c b/jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c index 2b8e2d2b11e..dd989f735f7 100644 --- a/jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c +++ b/jdk/src/solaris/native/com/sun/security/auth/module/Solaris.c @@ -75,11 +75,12 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo if (fid == 0) { (*env)->ExceptionClear(env); throwIllegalArgumentException(env, "invalid field: username"); - return; + goto cleanupAndReturn; } jstr = (*env)->NewStringUTF(env, pwd.pw_name); - if (jstr == NULL) - return; + if (jstr == NULL) { + goto cleanupAndReturn; + } (*env)->SetObjectField(env, obj, fid, jstr); /* @@ -89,7 +90,7 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo if (fid == 0) { (*env)->ExceptionClear(env); throwIllegalArgumentException(env, "invalid field: uid"); - return; + goto cleanupAndReturn; } (*env)->SetLongField(env, obj, fid, pwd.pw_uid); @@ -100,7 +101,7 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo if (fid == 0) { (*env)->ExceptionClear(env); throwIllegalArgumentException(env, "invalid field: gid"); - return; + goto cleanupAndReturn; } (*env)->SetLongField(env, obj, fid, pwd.pw_gid); @@ -111,19 +112,24 @@ Java_com_sun_security_auth_module_SolarisSystem_getSolarisInfo if (fid == 0) { (*env)->ExceptionClear(env); throwIllegalArgumentException(env, "invalid field: groups"); - return; + goto cleanupAndReturn; } jgroups = (*env)->NewLongArray(env, numSuppGroups); - if (jgroups == NULL) - return; + if (jgroups == NULL) { + goto cleanupAndReturn; + } jgroupsAsArray = (*env)->GetLongArrayElements(env, jgroups, 0); - if (jgroupsAsArray == NULL) - return; + if (jgroupsAsArray == NULL) { + goto cleanupAndReturn; + } for (i = 0; i < numSuppGroups; i++) jgroupsAsArray[i] = groups[i]; (*env)->ReleaseLongArrayElements(env, jgroups, jgroupsAsArray, 0); (*env)->SetObjectField(env, obj, fid, jgroups); } +cleanupAndReturn: + free(groups); + return; } From 93c628f1577e4a8f3bf2bbb5c0deeeef13338970 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Feb 2014 13:08:35 -0800 Subject: [PATCH 123/159] Added tag jdk9-b02 for changeset 325b5971d828 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 6a7cb46c540..fe1310f80db 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -244,3 +244,4 @@ a4afb0a8d55ef75aef5b0d77b434070468fb89f8 jdk8-b117 cd3825b2983045784d6fc6d1729c799b08215752 jdk8-b120 1e1f86d5d4e22c15a9bf9f1581acddb8c59abae2 jdk9-b00 50669e45cec4491de0d921d3118a3fe2e767020a jdk9-b01 +135f0c7af57ebace31383d8877f47e32172759ff jdk9-b02 From aedfbb387a96b64fe176cbfa743337abc13648d2 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Feb 2014 13:08:37 -0800 Subject: [PATCH 124/159] Added tag jdk9-b02 for changeset 82544a65e6da --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 914430fb54c..03c69ec949f 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -244,3 +244,4 @@ d6820a414f182a011a53a29a52370c696cd58dab jdk8-b118 53fd772d28c8a9f0f43adfc06f75f6b3cfa93cb5 jdk8-b120 a7d3638deb2f4e33217b1ecf889479e90f9e5b50 jdk9-b00 79a8136b18c1c6848f500088f5a4b39f262f082d jdk9-b01 +8394993063135a42b63a94473280399fb2a13aa7 jdk9-b02 From d57ec22d365ec0d1c4063093bc9b08f57a3266e8 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Feb 2014 13:08:44 -0800 Subject: [PATCH 125/159] Added tag jdk9-b02 for changeset e67a27d0c98a --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index 7b9d7597d6e..9b4aa750ec2 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -404,3 +404,4 @@ ce42d815dd2130250acf6132b51b624001638f0d jdk8-b119 fca262db9c4309f99d2f5542ab0780e45c2f1578 jdk8-b120 ce2d7e46f3c7e41241f3b407705a4071323a11ab jdk9-b00 050a626a88951140df874f7b163e304d07b6c296 jdk9-b01 +b188446de75bda5fc52d102cddf242c3ef5ecbdf jdk9-b02 From 5dee3f88bdbc159a01dd4650dfbb6c4745643bad Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Feb 2014 13:08:54 -0800 Subject: [PATCH 126/159] Added tag jdk9-b02 for changeset 851ae056cca1 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index dc38862e746..bca7de34ab8 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -244,3 +244,4 @@ e4e5069250e717defcb556e2f6be291460988c51 jdk8-b118 64d8b228a72cf9082b1a9a881c81188ccffde234 jdk8-b120 4045edd35e8ba73bfdc23ce8961b9640d4145fe5 jdk9-b00 e5256f530a9b5f2d677ca245de44a617ffb58f52 jdk9-b01 +02f60a253e15240087c043bad77a106792e4d56a jdk9-b02 From a3723a4c6599d0f70892ae4eea4ff6f455b6a77e Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Feb 2014 13:08:57 -0800 Subject: [PATCH 127/159] Added tag jdk9-b02 for changeset 01145cf69089 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index a3601127a12..a6c41cf6400 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -247,3 +247,4 @@ bc622ba563f9316f981c11c3a260f4c3fdc5ef07 jdk8-b122 91f5c542ccad330efc0d281362dd6f33f2039746 jdk8-b123 32050ab53c8a8e4cb09f04b88db78258a480fb61 jdk9-b00 9c9fabbcd3d526d7ca29165169155f49a107533a jdk9-b01 +efe2bc258c78af49de9517a4a5699d3a2e630c44 jdk9-b02 From 3bc4831434bf1ee8c1277f3a511a9e307b095240 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Feb 2014 13:09:10 -0800 Subject: [PATCH 128/159] Added tag jdk9-b02 for changeset 22a10c3cb5f3 --- jdk/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/.hgtags b/jdk/.hgtags index 4cde2b895e7..5a7ffba22b9 100644 --- a/jdk/.hgtags +++ b/jdk/.hgtags @@ -244,3 +244,4 @@ e4499a6529e8c3e762ba86f45cdd774c92a8e7bc jdk8-b119 d31cd980e1da31fa496a359caaf1a165aeb5791a jdk8-b120 27b384262cba51dd0fe3e3534820189b46abc8cb jdk9-b00 3b4ac8d1b76fc6bec9815f0ab714f15b552e4c7b jdk9-b01 +8c8275426a3207d91393354f7a7f9bc362ec25cf jdk9-b02 From fa155ae4bdbf55ed58ed0f746e7a0755652cf304 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Feb 2014 13:09:40 -0800 Subject: [PATCH 129/159] Added tag jdk9-b02 for changeset fc0fe10fbee9 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 87ec29040c5..7713b53738e 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -244,3 +244,4 @@ af6244ba81b6b8d1bf4ab06587a2067e021e4570 jdk8-b111 b3d7e86a06474fe5100a7b15a95eaa10d41509a6 jdk8-b120 afe63d41c699e0e2ee910ef20c41b60603c852a1 jdk9-b00 077c12d527fb5531c59666c1f84000fc1245a260 jdk9-b01 +f2c58a337c8aaa1ce84dfa8a8e8c5d4c8c1e12fa jdk9-b02 From b7addf4329493f2b368b4b6a484683776ff5a459 Mon Sep 17 00:00:00 2001 From: David Katleman Date: Thu, 6 Feb 2014 13:09:43 -0800 Subject: [PATCH 130/159] Added tag jdk9-b02 for changeset 81bb5f538220 --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index 3d90b565999..6236fcba08e 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -235,3 +235,4 @@ c3343930c73c58a22c1d58719bb988aeb25a871f jdk8-b119 688f4167f92188482b0d80e315c72f726c6d5ff6 jdk8-b123 32631eed0fad2b31346eb41b29a50227bd29e2ec jdk9-b00 65347535840f045f2cd4341d7466c51009b1b06f jdk9-b01 +b3517e51f40477f10db8bc30a557aa0ea712c274 jdk9-b02 From 2a866afcdbc63751170fca81f8415e3c11a0f5d0 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Thu, 13 Feb 2014 17:44:39 +0100 Subject: [PATCH 131/159] 8034761: Remove the do_code_roots parameter from process_strong_roots Reviewed-by: tschatzl, mgerdin, jmasa --- .../concurrentMarkSweepGeneration.cpp | 12 ---------- .../concurrentMarkSweepGeneration.hpp | 7 ------ .../gc_implementation/g1/g1CollectedHeap.cpp | 22 +++++++------------ .../gc_implementation/g1/g1CollectedHeap.hpp | 5 ----- .../vm/gc_implementation/g1/g1MarkSweep.cpp | 6 ++--- .../parNew/parNewGeneration.cpp | 1 - .../vm/gc_implementation/shared/markSweep.cpp | 1 - .../vm/gc_implementation/shared/markSweep.hpp | 1 - .../src/share/vm/memory/defNewGeneration.cpp | 1 - .../src/share/vm/memory/genCollectedHeap.cpp | 17 ++++---------- .../src/share/vm/memory/genCollectedHeap.hpp | 10 ++++----- hotspot/src/share/vm/memory/genMarkSweep.cpp | 11 ++-------- hotspot/src/share/vm/memory/sharedHeap.cpp | 19 ++++++++-------- hotspot/src/share/vm/memory/sharedHeap.hpp | 13 ++++++----- 14 files changed, 36 insertions(+), 90 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp index 847a8326fa0..5807db38eed 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.cpp @@ -3035,7 +3035,6 @@ void CMSCollector::verify_after_remark_work_1() { true, // activate StrongRootsScope SharedHeap::ScanningOption(roots_scanning_options()), ¬Older, - true, // walk code active on stacks NULL, NULL); // SSS: Provide correct closure @@ -3102,7 +3101,6 @@ void CMSCollector::verify_after_remark_work_2() { true, // activate StrongRootsScope SharedHeap::ScanningOption(roots_scanning_options()), ¬Older, - true, // walk code active on stacks NULL, &klass_closure); @@ -3680,12 +3678,6 @@ void CMSCollector::checkpointRootsInitialWork(bool asynch) { ResourceMark rm; HandleMark hm; - FalseClosure falseClosure; - // In the case of a synchronous collection, we will elide the - // remark step, so it's important to catch all the nmethod oops - // in this step. - // The final 'true' flag to gen_process_strong_roots will ensure this. - // If 'async' is true, we can relax the nmethod tracing. MarkRefsIntoClosure notOlder(_span, &_markBitMap); GenCollectedHeap* gch = GenCollectedHeap::heap(); @@ -3738,7 +3730,6 @@ void CMSCollector::checkpointRootsInitialWork(bool asynch) { true, // activate StrongRootsScope SharedHeap::ScanningOption(roots_scanning_options()), ¬Older, - true, // walk all of code cache if (so & SO_AllCodeCache) NULL, &klass_closure); } @@ -5237,7 +5228,6 @@ void CMSParInitialMarkTask::work(uint worker_id) { false, // this is parallel code SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), &par_mri_cl, - true, // walk all of code cache if (so & SO_AllCodeCache) NULL, &klass_closure); assert(_collector->should_unload_classes() @@ -5373,7 +5363,6 @@ void CMSParRemarkTask::work(uint worker_id) { false, // this is parallel code SharedHeap::ScanningOption(_collector->CMSCollector::roots_scanning_options()), &par_mrias_cl, - true, // walk all of code cache if (so & SO_AllCodeCache) NULL, NULL); // The dirty klasses will be handled below assert(_collector->should_unload_classes() @@ -5963,7 +5952,6 @@ void CMSCollector::do_remark_non_parallel() { false, // use the local StrongRootsScope SharedHeap::ScanningOption(roots_scanning_options()), &mrias_cl, - true, // walk code active on stacks NULL, NULL); // The dirty klasses will be handled below diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp index e98e8b6ce28..3c771ef3946 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/concurrentMarkSweepGeneration.hpp @@ -1383,13 +1383,6 @@ class ASConcurrentMarkSweepGeneration : public ConcurrentMarkSweepGeneration { // Closures of various sorts used by CMS to accomplish its work // -// This closure is used to check that a certain set of oops is empty. -class FalseClosure: public OopClosure { - public: - void do_oop(oop* p) { guarantee(false, "Should be an empty set"); } - void do_oop(narrowOop* p) { guarantee(false, "Should be an empty set"); } -}; - // This closure is used to do concurrent marking from the roots // following the first checkpoint. class MarkFromRootsClosure: public BitMapClosure { diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp index f027f29491c..c9e43171368 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.cpp @@ -3394,13 +3394,12 @@ void G1CollectedHeap::verify(bool silent, VerifyOption vo) { if (!silent) { gclog_or_tty->print("Roots "); } VerifyRootsClosure rootsCl(vo); - G1VerifyCodeRootOopClosure codeRootsCl(this, &rootsCl, vo); - G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl); VerifyKlassClosure klassCl(this, &rootsCl); // We apply the relevant closures to all the oops in the - // system dictionary, the string table and the code cache. - const int so = SO_AllClasses | SO_Strings | SO_AllCodeCache; + // system dictionary, class loader data graph and the string table. + // Don't verify the code cache here, since it's verified below. + const int so = SO_AllClasses | SO_Strings; // Need cleared claim bits for the strong roots processing ClassLoaderDataGraph::clear_claimed_marks(); @@ -3408,10 +3407,14 @@ void G1CollectedHeap::verify(bool silent, VerifyOption vo) { process_strong_roots(true, // activate StrongRootsScope ScanningOption(so), // roots scanning options &rootsCl, - &blobsCl, &klassCl ); + // Verify the nmethods in the code cache. + G1VerifyCodeRootOopClosure codeRootsCl(this, &rootsCl, vo); + G1VerifyCodeRootBlobClosure blobsCl(&codeRootsCl); + CodeCache::blobs_do(&blobsCl); + bool failures = rootsCl.failures() || codeRootsCl.failures(); if (vo != VerifyOption_G1UseMarkWord) { @@ -5115,12 +5118,9 @@ g1_process_strong_roots(bool is_scavenging, BufferingOopClosure buf_scan_non_heap_roots(scan_non_heap_roots); - CodeBlobToOopClosure scan_code_roots(&buf_scan_non_heap_roots, true /* do_marking */); - process_strong_roots(false, // no scoping; this is parallel code so, &buf_scan_non_heap_roots, - &scan_code_roots, scan_klasses ); @@ -5180,12 +5180,6 @@ g1_process_strong_roots(bool is_scavenging, _process_strong_tasks->all_tasks_completed(); } -void -G1CollectedHeap::g1_process_weak_roots(OopClosure* root_closure) { - CodeBlobToOopClosure roots_in_blobs(root_closure, /*do_marking=*/ false); - SharedHeap::process_weak_roots(root_closure, &roots_in_blobs); -} - class G1StringSymbolTableUnlinkTask : public AbstractGangTask { private: BoolObjectClosure* _is_alive; diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp index 07bbe275788..45caab039ea 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1CollectedHeap.hpp @@ -833,11 +833,6 @@ protected: G1KlassScanClosure* scan_klasses, int worker_i); - // Apply "blk" to all the weak roots of the system. These include - // JNI weak roots, the code cache, system dictionary, symbol table, - // string table, and referents of reachable weak refs. - void g1_process_weak_roots(OopClosure* root_closure); - // Frees a non-humongous region by initializing its contents and // adding it to the free list that's passed as a parameter (this is // usually a local list which will be appended to the master free diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp index 2cc0f46a2cc..cee1cfd047a 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp @@ -133,7 +133,6 @@ void G1MarkSweep::mark_sweep_phase1(bool& marked_for_unloading, sh->process_strong_roots(true, // activate StrongRootsScope SharedHeap::SO_SystemClasses, &GenMarkSweep::follow_root_closure, - &GenMarkSweep::follow_code_root_closure, &GenMarkSweep::follow_klass_closure); // Process reference objects found during marking @@ -307,9 +306,8 @@ void G1MarkSweep::mark_sweep_phase3() { ClassLoaderDataGraph::clear_claimed_marks(); sh->process_strong_roots(true, // activate StrongRootsScope - SharedHeap::SO_AllClasses, + SharedHeap::SO_AllClasses | SharedHeap::SO_AllCodeCache, &GenMarkSweep::adjust_pointer_closure, - NULL, // do not touch code cache here &GenMarkSweep::adjust_klass_closure); assert(GenMarkSweep::ref_processor() == g1h->ref_processor_stw(), "Sanity"); @@ -317,7 +315,7 @@ void G1MarkSweep::mark_sweep_phase3() { // Now adjust pointers in remaining weak roots. (All of which should // have been cleared if they pointed to non-surviving objects.) - g1h->g1_process_weak_roots(&GenMarkSweep::adjust_pointer_closure); + sh->process_weak_roots(&GenMarkSweep::adjust_pointer_closure); GenMarkSweep::adjust_marks(); diff --git a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp index d97cc0dceb0..cc926949990 100644 --- a/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp +++ b/hotspot/src/share/vm/gc_implementation/parNew/parNewGeneration.cpp @@ -621,7 +621,6 @@ void ParNewGenTask::work(uint worker_id) { false, // no scope; this is parallel code SharedHeap::ScanningOption(so), &par_scan_state.to_space_root_closure(), - true, // walk *all* scavengable nmethods &par_scan_state.older_gen_closure(), &klass_scan_closure); par_scan_state.end_strong_roots(); diff --git a/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp b/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp index 1bc3ea46a3e..67d8a5ac8ec 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/markSweep.cpp @@ -47,7 +47,6 @@ STWGCTimer* MarkSweep::_gc_timer = NULL; SerialOldTracer* MarkSweep::_gc_tracer = NULL; MarkSweep::FollowRootClosure MarkSweep::follow_root_closure; -CodeBlobToOopClosure MarkSweep::follow_code_root_closure(&MarkSweep::follow_root_closure, /*do_marking=*/ true); void MarkSweep::FollowRootClosure::do_oop(oop* p) { follow_root(p); } void MarkSweep::FollowRootClosure::do_oop(narrowOop* p) { follow_root(p); } diff --git a/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp b/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp index 38fc8e70589..1857c2a3acc 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp +++ b/hotspot/src/share/vm/gc_implementation/shared/markSweep.hpp @@ -143,7 +143,6 @@ class MarkSweep : AllStatic { // Public closures static IsAliveClosure is_alive; static FollowRootClosure follow_root_closure; - static CodeBlobToOopClosure follow_code_root_closure; // => follow_root_closure static MarkAndPushClosure mark_and_push_closure; static FollowKlassClosure follow_klass_closure; static FollowStackClosure follow_stack_closure; diff --git a/hotspot/src/share/vm/memory/defNewGeneration.cpp b/hotspot/src/share/vm/memory/defNewGeneration.cpp index 1e3cb9aaa3c..b4cf451f10e 100644 --- a/hotspot/src/share/vm/memory/defNewGeneration.cpp +++ b/hotspot/src/share/vm/memory/defNewGeneration.cpp @@ -626,7 +626,6 @@ void DefNewGeneration::collect(bool full, true, // activate StrongRootsScope SharedHeap::ScanningOption(so), &fsc_with_no_gc_barrier, - true, // walk *all* scavengable nmethods &fsc_with_gc_barrier, &klass_scan_closure); diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.cpp b/hotspot/src/share/vm/memory/genCollectedHeap.cpp index 5e0572e4ba7..be4ad6945dd 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.cpp @@ -594,20 +594,12 @@ gen_process_strong_roots(int level, bool activate_scope, SharedHeap::ScanningOption so, OopsInGenClosure* not_older_gens, - bool do_code_roots, OopsInGenClosure* older_gens, KlassClosure* klass_closure) { // General strong roots. - if (!do_code_roots) { - SharedHeap::process_strong_roots(activate_scope, so, - not_older_gens, NULL, klass_closure); - } else { - bool do_code_marking = (activate_scope || nmethod::oops_do_marking_is_active()); - CodeBlobToOopClosure code_roots(not_older_gens, /*do_marking=*/ do_code_marking); - SharedHeap::process_strong_roots(activate_scope, so, - not_older_gens, &code_roots, klass_closure); - } + SharedHeap::process_strong_roots(activate_scope, so, + not_older_gens, klass_closure); if (younger_gens_as_roots) { if (!_gen_process_strong_tasks->is_task_claimed(GCH_PS_younger_gens)) { @@ -629,9 +621,8 @@ gen_process_strong_roots(int level, _gen_process_strong_tasks->all_tasks_completed(); } -void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure, - CodeBlobClosure* code_roots) { - SharedHeap::process_weak_roots(root_closure, code_roots); +void GenCollectedHeap::gen_process_weak_roots(OopClosure* root_closure) { + SharedHeap::process_weak_roots(root_closure); // "Local" "weak" refs for (int i = 0; i < _n_gens; i++) { _gens[i]->ref_processor()->weak_oops_do(root_closure); diff --git a/hotspot/src/share/vm/memory/genCollectedHeap.hpp b/hotspot/src/share/vm/memory/genCollectedHeap.hpp index 7bea23d68e4..f687a1c97e6 100644 --- a/hotspot/src/share/vm/memory/genCollectedHeap.hpp +++ b/hotspot/src/share/vm/memory/genCollectedHeap.hpp @@ -414,15 +414,13 @@ public: bool activate_scope, SharedHeap::ScanningOption so, OopsInGenClosure* not_older_gens, - bool do_code_roots, OopsInGenClosure* older_gens, KlassClosure* klass_closure); - // Apply "blk" to all the weak roots of the system. These include - // JNI weak roots, the code cache, system dictionary, symbol table, - // string table, and referents of reachable weak refs. - void gen_process_weak_roots(OopClosure* root_closure, - CodeBlobClosure* code_roots); + // Apply "root_closure" to all the weak roots of the system. + // These include JNI weak roots, string table, + // and referents of reachable weak refs. + void gen_process_weak_roots(OopClosure* root_closure); // Set the saved marks of generations, if that makes sense. // In particular, if any generation might iterate over the oops diff --git a/hotspot/src/share/vm/memory/genMarkSweep.cpp b/hotspot/src/share/vm/memory/genMarkSweep.cpp index 2ae8b3dc6e2..9582ba2480f 100644 --- a/hotspot/src/share/vm/memory/genMarkSweep.cpp +++ b/hotspot/src/share/vm/memory/genMarkSweep.cpp @@ -212,7 +212,6 @@ void GenMarkSweep::mark_sweep_phase1(int level, true, // activate StrongRootsScope SharedHeap::SO_SystemClasses, &follow_root_closure, - true, // walk code active on stacks &follow_root_closure, &follow_klass_closure); @@ -295,18 +294,12 @@ void GenMarkSweep::mark_sweep_phase3(int level) { gch->gen_process_strong_roots(level, false, // Younger gens are not roots. true, // activate StrongRootsScope - SharedHeap::SO_AllClasses, + SharedHeap::SO_AllClasses | SharedHeap::SO_AllCodeCache, &adjust_pointer_closure, - false, // do not walk code &adjust_pointer_closure, &adjust_klass_closure); - // Now adjust pointers in remaining weak roots. (All of which should - // have been cleared if they pointed to non-surviving objects.) - CodeBlobToOopClosure adjust_code_pointer_closure(&adjust_pointer_closure, - /*do_marking=*/ false); - gch->gen_process_weak_roots(&adjust_pointer_closure, - &adjust_code_pointer_closure); + gch->gen_process_weak_roots(&adjust_pointer_closure); adjust_marks(); GenAdjustPointersClosure blk; diff --git a/hotspot/src/share/vm/memory/sharedHeap.cpp b/hotspot/src/share/vm/memory/sharedHeap.cpp index 2dbf43ef156..43c8503f1fc 100644 --- a/hotspot/src/share/vm/memory/sharedHeap.cpp +++ b/hotspot/src/share/vm/memory/sharedHeap.cpp @@ -139,7 +139,6 @@ SharedHeap::StrongRootsScope::~StrongRootsScope() { void SharedHeap::process_strong_roots(bool activate_scope, ScanningOption so, OopClosure* roots, - CodeBlobClosure* code_roots, KlassClosure* klass_closure) { StrongRootsScope srs(this, activate_scope); @@ -156,15 +155,17 @@ void SharedHeap::process_strong_roots(bool activate_scope, if (!_process_strong_tasks->is_task_claimed(SH_PS_JNIHandles_oops_do)) JNIHandles::oops_do(roots); + CodeBlobToOopClosure code_roots(roots, true); + CLDToOopClosure roots_from_clds(roots); // If we limit class scanning to SO_SystemClasses we need to apply a CLD closure to // CLDs which are strongly reachable from the thread stacks. CLDToOopClosure* roots_from_clds_p = ((so & SO_SystemClasses) ? &roots_from_clds : NULL); // All threads execute this; the individual threads are task groups. if (CollectedHeap::use_parallel_gc_threads()) { - Threads::possibly_parallel_oops_do(roots, roots_from_clds_p, code_roots); + Threads::possibly_parallel_oops_do(roots, roots_from_clds_p, &code_roots); } else { - Threads::oops_do(roots, roots_from_clds_p, code_roots); + Threads::oops_do(roots, roots_from_clds_p, &code_roots); } if (!_process_strong_tasks-> is_task_claimed(SH_PS_ObjectSynchronizer_oops_do)) @@ -206,17 +207,17 @@ void SharedHeap::process_strong_roots(bool activate_scope, if (!_process_strong_tasks->is_task_claimed(SH_PS_CodeCache_oops_do)) { if (so & SO_ScavengeCodeCache) { - assert(code_roots != NULL, "must supply closure for code cache"); + assert(&code_roots != NULL, "must supply closure for code cache"); // We only visit parts of the CodeCache when scavenging. - CodeCache::scavenge_root_nmethods_do(code_roots); + CodeCache::scavenge_root_nmethods_do(&code_roots); } if (so & SO_AllCodeCache) { - assert(code_roots != NULL, "must supply closure for code cache"); + assert(&code_roots != NULL, "must supply closure for code cache"); // CMSCollector uses this to do intermediate-strength collections. // We scan the entire code cache, since CodeCache::do_unloading is not called. - CodeCache::blobs_do(code_roots); + CodeCache::blobs_do(&code_roots); } // Verify that the code cache contents are not subject to // movement by a scavenging collection. @@ -233,12 +234,10 @@ public: }; static AlwaysTrueClosure always_true; -void SharedHeap::process_weak_roots(OopClosure* root_closure, - CodeBlobClosure* code_roots) { +void SharedHeap::process_weak_roots(OopClosure* root_closure) { // Global (weak) JNI handles JNIHandles::weak_oops_do(&always_true, root_closure); - CodeCache::blobs_do(code_roots); StringTable::oops_do(root_closure); } diff --git a/hotspot/src/share/vm/memory/sharedHeap.hpp b/hotspot/src/share/vm/memory/sharedHeap.hpp index 398e593cc10..62669cf86e4 100644 --- a/hotspot/src/share/vm/memory/sharedHeap.hpp +++ b/hotspot/src/share/vm/memory/sharedHeap.hpp @@ -238,14 +238,11 @@ public: void process_strong_roots(bool activate_scope, ScanningOption so, OopClosure* roots, - CodeBlobClosure* code_roots, KlassClosure* klass_closure); - // Apply "blk" to all the weak roots of the system. These include - // JNI weak roots, the code cache, system dictionary, symbol table, - // string table. - void process_weak_roots(OopClosure* root_closure, - CodeBlobClosure* code_roots); + // Apply "root_closure" to all the weak roots of the system. + // These include JNI weak roots and string table. + void process_weak_roots(OopClosure* root_closure); // The functions below are helper functions that a subclass of // "SharedHeap" can use in the implementation of its virtual @@ -275,4 +272,8 @@ public: size_t capacity); }; +inline SharedHeap::ScanningOption operator|(SharedHeap::ScanningOption so0, SharedHeap::ScanningOption so1) { + return static_cast(static_cast(so0) | static_cast(so1)); +} + #endif // SHARE_VM_MEMORY_SHAREDHEAP_HPP From 2a5c51998d9dc9703aaad5c5be7e7536b7105865 Mon Sep 17 00:00:00 2001 From: Stefan Karlsson Date: Fri, 14 Feb 2014 09:29:56 +0100 Subject: [PATCH 132/159] 8034764: Use process_strong_roots to adjust the StringTable Reviewed-by: tschatzl, brutisso --- hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp | 2 +- hotspot/src/share/vm/memory/genMarkSweep.cpp | 2 +- hotspot/src/share/vm/memory/sharedHeap.cpp | 2 -- hotspot/src/share/vm/memory/sharedHeap.hpp | 3 +-- 4 files changed, 3 insertions(+), 6 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp index cee1cfd047a..dee7ce0b72e 100644 --- a/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp +++ b/hotspot/src/share/vm/gc_implementation/g1/g1MarkSweep.cpp @@ -306,7 +306,7 @@ void G1MarkSweep::mark_sweep_phase3() { ClassLoaderDataGraph::clear_claimed_marks(); sh->process_strong_roots(true, // activate StrongRootsScope - SharedHeap::SO_AllClasses | SharedHeap::SO_AllCodeCache, + SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_AllCodeCache, &GenMarkSweep::adjust_pointer_closure, &GenMarkSweep::adjust_klass_closure); diff --git a/hotspot/src/share/vm/memory/genMarkSweep.cpp b/hotspot/src/share/vm/memory/genMarkSweep.cpp index 9582ba2480f..80a35d10e2c 100644 --- a/hotspot/src/share/vm/memory/genMarkSweep.cpp +++ b/hotspot/src/share/vm/memory/genMarkSweep.cpp @@ -294,7 +294,7 @@ void GenMarkSweep::mark_sweep_phase3(int level) { gch->gen_process_strong_roots(level, false, // Younger gens are not roots. true, // activate StrongRootsScope - SharedHeap::SO_AllClasses | SharedHeap::SO_AllCodeCache, + SharedHeap::SO_AllClasses | SharedHeap::SO_Strings | SharedHeap::SO_AllCodeCache, &adjust_pointer_closure, &adjust_pointer_closure, &adjust_klass_closure); diff --git a/hotspot/src/share/vm/memory/sharedHeap.cpp b/hotspot/src/share/vm/memory/sharedHeap.cpp index 43c8503f1fc..9de74e25c7c 100644 --- a/hotspot/src/share/vm/memory/sharedHeap.cpp +++ b/hotspot/src/share/vm/memory/sharedHeap.cpp @@ -237,8 +237,6 @@ static AlwaysTrueClosure always_true; void SharedHeap::process_weak_roots(OopClosure* root_closure) { // Global (weak) JNI handles JNIHandles::weak_oops_do(&always_true, root_closure); - - StringTable::oops_do(root_closure); } void SharedHeap::set_barrier_set(BarrierSet* bs) { diff --git a/hotspot/src/share/vm/memory/sharedHeap.hpp b/hotspot/src/share/vm/memory/sharedHeap.hpp index 62669cf86e4..21d6755d9d3 100644 --- a/hotspot/src/share/vm/memory/sharedHeap.hpp +++ b/hotspot/src/share/vm/memory/sharedHeap.hpp @@ -240,8 +240,7 @@ public: OopClosure* roots, KlassClosure* klass_closure); - // Apply "root_closure" to all the weak roots of the system. - // These include JNI weak roots and string table. + // Apply "root_closure" to the JNI weak roots.. void process_weak_roots(OopClosure* root_closure); // The functions below are helper functions that a subclass of From 2b8f41202aec30473a6a1deed52a95b4185aa7ff Mon Sep 17 00:00:00 2001 From: Matthias Baesken Date: Tue, 11 Feb 2014 09:34:50 +0100 Subject: [PATCH 133/159] 8034171: Remove use of template template parameters from binaryTreeDictionary Reviewed-by: mgerdin, jmasa --- .../compactibleFreeListSpace.cpp | 8 +- .../share/vm/memory/binaryTreeDictionary.cpp | 227 +++++++++--------- .../share/vm/memory/binaryTreeDictionary.hpp | 32 +-- hotspot/src/share/vm/memory/metaspace.cpp | 16 +- hotspot/src/share/vm/runtime/vmStructs.cpp | 2 +- 5 files changed, 136 insertions(+), 149 deletions(-) diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp index 58a2d871317..d2aae84697d 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/compactibleFreeListSpace.cpp @@ -1704,8 +1704,8 @@ CompactibleFreeListSpace::returnChunkToDictionary(FreeChunk* chunk) { _dictionary->return_chunk(chunk); #ifndef PRODUCT if (CMSCollector::abstract_state() != CMSCollector::Sweeping) { - TreeChunk* tc = TreeChunk::as_TreeChunk(chunk); - TreeList* tl = tc->list(); + TreeChunk >* tc = TreeChunk >::as_TreeChunk(chunk); + TreeList >* tl = tc->list(); tl->verify_stats(); } #endif // PRODUCT @@ -2515,10 +2515,10 @@ void CompactibleFreeListSpace::verifyIndexedFreeList(size_t size) const { #ifndef PRODUCT void CompactibleFreeListSpace::check_free_list_consistency() const { - assert((TreeChunk::min_size() <= IndexSetSize), + assert((TreeChunk >::min_size() <= IndexSetSize), "Some sizes can't be allocated without recourse to" " linear allocation buffers"); - assert((TreeChunk::min_size()*HeapWordSize == sizeof(TreeChunk)), + assert((TreeChunk >::min_size()*HeapWordSize == sizeof(TreeChunk >)), "else MIN_TREE_CHUNK_SIZE is wrong"); assert(IndexSetStart != 0, "IndexSetStart not initialized"); assert(IndexSetStride != 0, "IndexSetStride not initialized"); diff --git a/hotspot/src/share/vm/memory/binaryTreeDictionary.cpp b/hotspot/src/share/vm/memory/binaryTreeDictionary.cpp index 68b97e9f0d3..8198c2f927c 100644 --- a/hotspot/src/share/vm/memory/binaryTreeDictionary.cpp +++ b/hotspot/src/share/vm/memory/binaryTreeDictionary.cpp @@ -44,16 +44,16 @@ // This is currently used in the Concurrent Mark&Sweep implementation. //////////////////////////////////////////////////////////////////////////////// -template class FreeList_t> +template size_t TreeChunk::_min_tree_chunk_size = sizeof(TreeChunk)/HeapWordSize; -template class FreeList_t> +template TreeChunk* TreeChunk::as_TreeChunk(Chunk_t* fc) { // Do some assertion checking here. return (TreeChunk*) fc; } -template class FreeList_t> +template void TreeChunk::verify_tree_chunk_list() const { TreeChunk* nextTC = (TreeChunk*)next(); if (prev() != NULL) { // interior list node shouldn't have tree fields @@ -67,11 +67,11 @@ void TreeChunk::verify_tree_chunk_list() const { } } -template class FreeList_t> +template TreeList::TreeList() : _parent(NULL), _left(NULL), _right(NULL) {} -template class FreeList_t> +template TreeList* TreeList::as_TreeList(TreeChunk* tc) { // This first free chunk in the list will be the tree list. @@ -88,20 +88,7 @@ TreeList::as_TreeList(TreeChunk* tc) { return tl; } - -template class FreeList_t> -TreeList* -get_chunk(size_t size, enum FreeBlockDictionary::Dither dither) { - FreeBlockDictionary::verify_par_locked(); - Chunk_t* res = get_chunk_from_tree(size, dither); - assert(res == NULL || res->is_free(), - "Should be returning a free chunk"); - assert(dither != FreeBlockDictionary::exactly || - res->size() == size, "Not correct size"); - return res; -} - -template class FreeList_t> +template TreeList* TreeList::as_TreeList(HeapWord* addr, size_t size) { TreeChunk* tc = (TreeChunk*) addr; @@ -125,17 +112,17 @@ TreeList::as_TreeList(HeapWord* addr, size_t size) { // an over populated size. The general get_better_list() just returns // the current list. template <> -TreeList* -TreeList::get_better_list( - BinaryTreeDictionary* dictionary) { +TreeList >* +TreeList >::get_better_list( + BinaryTreeDictionary >* dictionary) { // A candidate chunk has been found. If it is already under // populated, get a chunk associated with the hint for this // chunk. - TreeList* curTL = this; + TreeList >* curTL = this; if (surplus() <= 0) { /* Use the hint to find a size with a surplus, and reset the hint. */ - TreeList* hintTL = this; + TreeList >* hintTL = this; while (hintTL->hint() != 0) { assert(hintTL->hint() > hintTL->size(), "hint points in the wrong direction"); @@ -163,14 +150,14 @@ TreeList::get_better_list( } #endif // INCLUDE_ALL_GCS -template class FreeList_t> +template TreeList* TreeList::get_better_list( BinaryTreeDictionary* dictionary) { return this; } -template class FreeList_t> +template TreeList* TreeList::remove_chunk_replace_if_needed(TreeChunk* tc) { TreeList* retTL = this; @@ -286,7 +273,7 @@ TreeList* TreeList::remove_chunk_repla return retTL; } -template class FreeList_t> +template void TreeList::return_chunk_at_tail(TreeChunk* chunk) { assert(chunk != NULL, "returning NULL chunk"); assert(chunk->list() == this, "list should be set for chunk"); @@ -301,7 +288,7 @@ void TreeList::return_chunk_at_tail(TreeChunklink_tail(chunk); assert(!tail() || size() == tail()->size(), "Wrong sized chunk in list"); - FreeList_t::increment_count(); + FreeList_t::increment_count(); debug_only(this->increment_returned_bytes_by(chunk->size()*sizeof(HeapWord));) assert(head() == NULL || head()->prev() == NULL, "list invariant"); assert(tail() == NULL || tail()->next() == NULL, "list invariant"); @@ -311,7 +298,7 @@ void TreeList::return_chunk_at_tail(TreeChunk is embedded in the first TreeChunk in the // list. See the definition of TreeChunk. -template class FreeList_t> +template void TreeList::return_chunk_at_head(TreeChunk* chunk) { assert(chunk->list() == this, "list should be set for chunk"); assert(head() != NULL, "The tree list is embedded in the first chunk"); @@ -329,13 +316,13 @@ void TreeList::return_chunk_at_head(TreeChunklink_after(chunk); assert(!head() || size() == head()->size(), "Wrong sized chunk in list"); - FreeList_t::increment_count(); + FreeList_t::increment_count(); debug_only(this->increment_returned_bytes_by(chunk->size()*sizeof(HeapWord));) assert(head() == NULL || head()->prev() == NULL, "list invariant"); assert(tail() == NULL || tail()->next() == NULL, "list invariant"); } -template class FreeList_t> +template void TreeChunk::assert_is_mangled() const { assert((ZapUnusedHeapArea && SpaceMangler::is_mangled((HeapWord*) Chunk_t::size_addr()) && @@ -345,14 +332,14 @@ void TreeChunk::assert_is_mangled() const { "Space should be clear or mangled"); } -template class FreeList_t> +template TreeChunk* TreeList::head_as_TreeChunk() { assert(head() == NULL || (TreeChunk::as_TreeChunk(head())->list() == this), "Wrong type of chunk?"); return TreeChunk::as_TreeChunk(head()); } -template class FreeList_t> +template TreeChunk* TreeList::first_available() { assert(head() != NULL, "The head of the list cannot be NULL"); Chunk_t* fc = head()->next(); @@ -369,7 +356,7 @@ TreeChunk* TreeList::first_available() // Returns the block with the largest heap address amongst // those in the list for this size; potentially slow and expensive, // use with caution! -template class FreeList_t> +template TreeChunk* TreeList::largest_address() { assert(head() != NULL, "The head of the list cannot be NULL"); Chunk_t* fc = head()->next(); @@ -392,7 +379,7 @@ TreeChunk* TreeList::largest_address() return retTC; } -template class FreeList_t> +template BinaryTreeDictionary::BinaryTreeDictionary(MemRegion mr) { assert((mr.byte_size() > min_size()), "minimum chunk size"); @@ -405,17 +392,17 @@ BinaryTreeDictionary::BinaryTreeDictionary(MemRegion mr) { assert(total_free_blocks() == 1, "reset check failed"); } -template class FreeList_t> +template void BinaryTreeDictionary::inc_total_size(size_t inc) { _total_size = _total_size + inc; } -template class FreeList_t> +template void BinaryTreeDictionary::dec_total_size(size_t dec) { _total_size = _total_size - dec; } -template class FreeList_t> +template void BinaryTreeDictionary::reset(MemRegion mr) { assert((mr.byte_size() > min_size()), "minimum chunk size"); set_root(TreeList::as_TreeList(mr.start(), mr.word_size())); @@ -423,13 +410,13 @@ void BinaryTreeDictionary::reset(MemRegion mr) { set_total_free_blocks(1); } -template class FreeList_t> +template void BinaryTreeDictionary::reset(HeapWord* addr, size_t byte_size) { MemRegion mr(addr, heap_word_size(byte_size)); reset(mr); } -template class FreeList_t> +template void BinaryTreeDictionary::reset() { set_root(NULL); set_total_size(0); @@ -437,7 +424,7 @@ void BinaryTreeDictionary::reset() { } // Get a free block of size at least size from tree, or NULL. -template class FreeList_t> +template TreeChunk* BinaryTreeDictionary::get_chunk_from_tree( size_t size, @@ -496,7 +483,7 @@ BinaryTreeDictionary::get_chunk_from_tree( return retTC; } -template class FreeList_t> +template TreeList* BinaryTreeDictionary::find_list(size_t size) const { TreeList* curTL; for (curTL = root(); curTL != NULL;) { @@ -515,7 +502,7 @@ TreeList* BinaryTreeDictionary::find_l } -template class FreeList_t> +template bool BinaryTreeDictionary::verify_chunk_in_free_list(Chunk_t* tc) const { size_t size = tc->size(); TreeList* tl = find_list(size); @@ -526,7 +513,7 @@ bool BinaryTreeDictionary::verify_chunk_in_free_list(Chunk_ } } -template class FreeList_t> +template Chunk_t* BinaryTreeDictionary::find_largest_dict() const { TreeList *curTL = root(); if (curTL != NULL) { @@ -541,7 +528,7 @@ Chunk_t* BinaryTreeDictionary::find_largest_dict() const { // chunk in a list on a tree node, just unlink it. // If it is the last chunk in the list (the next link is NULL), // remove the node and repair the tree. -template class FreeList_t> +template TreeChunk* BinaryTreeDictionary::remove_chunk_from_tree(TreeChunk* tc) { assert(tc != NULL, "Should not call with a NULL chunk"); @@ -682,7 +669,7 @@ BinaryTreeDictionary::remove_chunk_from_tree(TreeChunk class FreeList_t> +template TreeList* BinaryTreeDictionary::remove_tree_minimum(TreeList* tl) { assert(tl != NULL && tl->parent() != NULL, "really need a proper sub-tree"); // locate the subtree minimum by walking down left branches @@ -717,7 +704,7 @@ TreeList* BinaryTreeDictionary::remove return curTL; } -template class FreeList_t> +template void BinaryTreeDictionary::insert_chunk_in_tree(Chunk_t* fc) { TreeList *curTL, *prevTL; size_t size = fc->size(); @@ -783,7 +770,7 @@ void BinaryTreeDictionary::insert_chunk_in_tree(Chunk_t* fc } } -template class FreeList_t> +template size_t BinaryTreeDictionary::max_chunk_size() const { FreeBlockDictionary::verify_par_locked(); TreeList* tc = root(); @@ -792,7 +779,7 @@ size_t BinaryTreeDictionary::max_chunk_size() const { return tc->size(); } -template class FreeList_t> +template size_t BinaryTreeDictionary::total_list_length(TreeList* tl) const { size_t res; res = tl->count(); @@ -805,7 +792,7 @@ size_t BinaryTreeDictionary::total_list_length(TreeList class FreeList_t> +template size_t BinaryTreeDictionary::total_size_in_tree(TreeList* tl) const { if (tl == NULL) return 0; @@ -814,7 +801,7 @@ size_t BinaryTreeDictionary::total_size_in_tree(TreeListright()); } -template class FreeList_t> +template double BinaryTreeDictionary::sum_of_squared_block_sizes(TreeList* const tl) const { if (tl == NULL) { return 0.0; @@ -826,7 +813,7 @@ double BinaryTreeDictionary::sum_of_squared_block_sizes(Tre return curr; } -template class FreeList_t> +template size_t BinaryTreeDictionary::total_free_blocks_in_tree(TreeList* tl) const { if (tl == NULL) return 0; @@ -835,14 +822,14 @@ size_t BinaryTreeDictionary::total_free_blocks_in_tree(Tree total_free_blocks_in_tree(tl->right()); } -template class FreeList_t> +template size_t BinaryTreeDictionary::num_free_blocks() const { assert(total_free_blocks_in_tree(root()) == total_free_blocks(), "_total_free_blocks inconsistency"); return total_free_blocks(); } -template class FreeList_t> +template size_t BinaryTreeDictionary::tree_height_helper(TreeList* tl) const { if (tl == NULL) return 0; @@ -850,12 +837,12 @@ size_t BinaryTreeDictionary::tree_height_helper(TreeListright())); } -template class FreeList_t> +template size_t BinaryTreeDictionary::tree_height() const { return tree_height_helper(root()); } -template class FreeList_t> +template size_t BinaryTreeDictionary::total_nodes_helper(TreeList* tl) const { if (tl == NULL) { return 0; @@ -864,18 +851,18 @@ size_t BinaryTreeDictionary::total_nodes_helper(TreeListright()); } -template class FreeList_t> +template size_t BinaryTreeDictionary::total_nodes_in_tree(TreeList* tl) const { return total_nodes_helper(root()); } -template class FreeList_t> +template void BinaryTreeDictionary::dict_census_update(size_t size, bool split, bool birth){} #if INCLUDE_ALL_GCS template <> -void AFLBinaryTreeDictionary::dict_census_update(size_t size, bool split, bool birth){ - TreeList* nd = find_list(size); +void AFLBinaryTreeDictionary::dict_census_update(size_t size, bool split, bool birth) { + TreeList >* nd = find_list(size); if (nd) { if (split) { if (birth) { @@ -903,7 +890,7 @@ void AFLBinaryTreeDictionary::dict_census_update(size_t size, bool split, bool b } #endif // INCLUDE_ALL_GCS -template class FreeList_t> +template bool BinaryTreeDictionary::coal_dict_over_populated(size_t size) { // For the general type of freelists, encourage coalescing by // returning true. @@ -915,7 +902,7 @@ template <> bool AFLBinaryTreeDictionary::coal_dict_over_populated(size_t size) { if (FLSAlwaysCoalesceLarge) return true; - TreeList* list_of_size = find_list(size); + TreeList >* list_of_size = find_list(size); // None of requested size implies overpopulated. return list_of_size == NULL || list_of_size->coal_desired() <= 0 || list_of_size->count() > list_of_size->coal_desired(); @@ -928,15 +915,15 @@ bool AFLBinaryTreeDictionary::coal_dict_over_populated(size_t size) { // do_tree() walks the nodes in the binary tree applying do_list() // to each list at each node. -template class FreeList_t> +template class TreeCensusClosure : public StackObj { protected: - virtual void do_list(FreeList_t* fl) = 0; + virtual void do_list(FreeList_t* fl) = 0; public: virtual void do_tree(TreeList* tl) = 0; }; -template class FreeList_t> +template class AscendTreeCensusClosure : public TreeCensusClosure { public: void do_tree(TreeList* tl) { @@ -948,7 +935,7 @@ class AscendTreeCensusClosure : public TreeCensusClosure { } }; -template class FreeList_t> +template class DescendTreeCensusClosure : public TreeCensusClosure { public: void do_tree(TreeList* tl) { @@ -962,7 +949,7 @@ class DescendTreeCensusClosure : public TreeCensusClosure { // For each list in the tree, calculate the desired, desired // coalesce, count before sweep, and surplus before sweep. -template class FreeList_t> +template class BeginSweepClosure : public AscendTreeCensusClosure { double _percentage; float _inter_sweep_current; @@ -995,16 +982,16 @@ class BeginSweepClosure : public AscendTreeCensusClosure { // Similar to TreeCensusClosure but searches the // tree and returns promptly when found. -template class FreeList_t> +template class TreeSearchClosure : public StackObj { protected: - virtual bool do_list(FreeList_t* fl) = 0; + virtual bool do_list(FreeList_t* fl) = 0; public: virtual bool do_tree(TreeList* tl) = 0; }; #if 0 // Don't need this yet but here for symmetry. -template class FreeList_t> +template class AscendTreeSearchClosure : public TreeSearchClosure { public: bool do_tree(TreeList* tl) { @@ -1018,7 +1005,7 @@ class AscendTreeSearchClosure : public TreeSearchClosure { }; #endif -template class FreeList_t> +template class DescendTreeSearchClosure : public TreeSearchClosure { public: bool do_tree(TreeList* tl) { @@ -1033,14 +1020,14 @@ class DescendTreeSearchClosure : public TreeSearchClosure { // Searches the tree for a chunk that ends at the // specified address. -template class FreeList_t> +template class EndTreeSearchClosure : public DescendTreeSearchClosure { HeapWord* _target; Chunk_t* _found; public: EndTreeSearchClosure(HeapWord* target) : _target(target), _found(NULL) {} - bool do_list(FreeList_t* fl) { + bool do_list(FreeList_t* fl) { Chunk_t* item = fl->head(); while (item != NULL) { if (item->end() == (uintptr_t*) _target) { @@ -1054,7 +1041,7 @@ class EndTreeSearchClosure : public DescendTreeSearchClosure class FreeList_t> +template Chunk_t* BinaryTreeDictionary::find_chunk_ends_at(HeapWord* target) const { EndTreeSearchClosure etsc(target); bool found_target = etsc.do_tree(root()); @@ -1063,7 +1050,7 @@ Chunk_t* BinaryTreeDictionary::find_chunk_ends_at(HeapWord* return etsc.found(); } -template class FreeList_t> +template void BinaryTreeDictionary::begin_sweep_dict_census(double coalSurplusPercent, float inter_sweep_current, float inter_sweep_estimate, float intra_sweep_estimate) { BeginSweepClosure bsc(coalSurplusPercent, inter_sweep_current, @@ -1075,32 +1062,32 @@ void BinaryTreeDictionary::begin_sweep_dict_census(double c // Closures and methods for calculating total bytes returned to the // free lists in the tree. #ifndef PRODUCT -template class FreeList_t> +template class InitializeDictReturnedBytesClosure : public AscendTreeCensusClosure { public: - void do_list(FreeList_t* fl) { + void do_list(FreeList_t* fl) { fl->set_returned_bytes(0); } }; -template class FreeList_t> +template void BinaryTreeDictionary::initialize_dict_returned_bytes() { InitializeDictReturnedBytesClosure idrb; idrb.do_tree(root()); } -template class FreeList_t> +template class ReturnedBytesClosure : public AscendTreeCensusClosure { size_t _dict_returned_bytes; public: ReturnedBytesClosure() { _dict_returned_bytes = 0; } - void do_list(FreeList_t* fl) { + void do_list(FreeList_t* fl) { _dict_returned_bytes += fl->returned_bytes(); } size_t dict_returned_bytes() { return _dict_returned_bytes; } }; -template class FreeList_t> +template size_t BinaryTreeDictionary::sum_dict_returned_bytes() { ReturnedBytesClosure rbc; rbc.do_tree(root()); @@ -1109,17 +1096,17 @@ size_t BinaryTreeDictionary::sum_dict_returned_bytes() { } // Count the number of entries in the tree. -template class FreeList_t> +template class treeCountClosure : public DescendTreeCensusClosure { public: uint count; treeCountClosure(uint c) { count = c; } - void do_list(FreeList_t* fl) { + void do_list(FreeList_t* fl) { count++; } }; -template class FreeList_t> +template size_t BinaryTreeDictionary::total_count() { treeCountClosure ctc(0); ctc.do_tree(root()); @@ -1128,7 +1115,7 @@ size_t BinaryTreeDictionary::total_count() { #endif // PRODUCT // Calculate surpluses for the lists in the tree. -template class FreeList_t> +template class setTreeSurplusClosure : public AscendTreeCensusClosure { double percentage; public: @@ -1144,14 +1131,14 @@ class setTreeSurplusClosure : public AscendTreeCensusClosure class FreeList_t> +template void BinaryTreeDictionary::set_tree_surplus(double splitSurplusPercent) { setTreeSurplusClosure sts(splitSurplusPercent); sts.do_tree(root()); } // Set hints for the lists in the tree. -template class FreeList_t> +template class setTreeHintsClosure : public DescendTreeCensusClosure { size_t hint; public: @@ -1170,14 +1157,14 @@ class setTreeHintsClosure : public DescendTreeCensusClosure #endif // INCLUDE_ALL_GCS }; -template class FreeList_t> +template void BinaryTreeDictionary::set_tree_hints(void) { setTreeHintsClosure sth(0); sth.do_tree(root()); } // Save count before previous sweep and splits and coalesces. -template class FreeList_t> +template class clearTreeCensusClosure : public AscendTreeCensusClosure { void do_list(FreeList* fl) {} @@ -1192,14 +1179,14 @@ class clearTreeCensusClosure : public AscendTreeCensusClosure class FreeList_t> +template void BinaryTreeDictionary::clear_tree_census(void) { clearTreeCensusClosure ctc; ctc.do_tree(root()); } // Do reporting and post sweep clean up. -template class FreeList_t> +template void BinaryTreeDictionary::end_sweep_dict_census(double splitSurplusPercent) { // Does walking the tree 3 times hurt? set_tree_surplus(splitSurplusPercent); @@ -1211,7 +1198,7 @@ void BinaryTreeDictionary::end_sweep_dict_census(double spl } // Print summary statistics -template class FreeList_t> +template void BinaryTreeDictionary::report_statistics() const { FreeBlockDictionary::verify_par_locked(); gclog_or_tty->print("Statistics for BinaryTreeDictionary:\n" @@ -1230,22 +1217,22 @@ void BinaryTreeDictionary::report_statistics() const { // Print census information - counts, births, deaths, etc. // for each list in the tree. Also print some summary // information. -template class FreeList_t> +template class PrintTreeCensusClosure : public AscendTreeCensusClosure { int _print_line; size_t _total_free; - FreeList_t _total; + FreeList_t _total; public: PrintTreeCensusClosure() { _print_line = 0; _total_free = 0; } - FreeList_t* total() { return &_total; } + FreeList_t* total() { return &_total; } size_t total_free() { return _total_free; } void do_list(FreeList* fl) { if (++_print_line >= 40) { - FreeList_t::print_labels_on(gclog_or_tty, "size"); + FreeList_t::print_labels_on(gclog_or_tty, "size"); _print_line = 0; } fl->print_on(gclog_or_tty); @@ -1256,7 +1243,7 @@ class PrintTreeCensusClosure : public AscendTreeCensusClosure* fl) { if (++_print_line >= 40) { - FreeList_t::print_labels_on(gclog_or_tty, "size"); + FreeList_t::print_labels_on(gclog_or_tty, "size"); _print_line = 0; } fl->print_on(gclog_or_tty); @@ -1275,16 +1262,16 @@ class PrintTreeCensusClosure : public AscendTreeCensusClosure class FreeList_t> +template void BinaryTreeDictionary::print_dict_census(void) const { gclog_or_tty->print("\nBinaryTree\n"); - FreeList_t::print_labels_on(gclog_or_tty, "size"); + FreeList_t::print_labels_on(gclog_or_tty, "size"); PrintTreeCensusClosure ptc; ptc.do_tree(root()); - FreeList_t* total = ptc.total(); - FreeList_t::print_labels_on(gclog_or_tty, " "); + FreeList_t* total = ptc.total(); + FreeList_t::print_labels_on(gclog_or_tty, " "); } #if INCLUDE_ALL_GCS @@ -1293,7 +1280,7 @@ void AFLBinaryTreeDictionary::print_dict_census(void) const { gclog_or_tty->print("\nBinaryTree\n"); AdaptiveFreeList::print_labels_on(gclog_or_tty, "size"); - PrintTreeCensusClosure ptc; + PrintTreeCensusClosure > ptc; ptc.do_tree(root()); AdaptiveFreeList* total = ptc.total(); @@ -1311,7 +1298,7 @@ void AFLBinaryTreeDictionary::print_dict_census(void) const { } #endif // INCLUDE_ALL_GCS -template class FreeList_t> +template class PrintFreeListsClosure : public AscendTreeCensusClosure { outputStream* _st; int _print_line; @@ -1321,9 +1308,9 @@ class PrintFreeListsClosure : public AscendTreeCensusClosure* fl) { + void do_list(FreeList_t* fl) { if (++_print_line >= 40) { - FreeList_t::print_labels_on(_st, "size"); + FreeList_t::print_labels_on(_st, "size"); _print_line = 0; } fl->print_on(gclog_or_tty); @@ -1337,10 +1324,10 @@ class PrintFreeListsClosure : public AscendTreeCensusClosure class FreeList_t> +template void BinaryTreeDictionary::print_free_lists(outputStream* st) const { - FreeList_t::print_labels_on(st, "size"); + FreeList_t::print_labels_on(st, "size"); PrintFreeListsClosure pflc(st); pflc.do_tree(root()); } @@ -1349,7 +1336,7 @@ void BinaryTreeDictionary::print_free_lists(outputStream* s // . _root has no parent // . parent and child point to each other // . each node's key correctly related to that of its child(ren) -template class FreeList_t> +template void BinaryTreeDictionary::verify_tree() const { guarantee(root() == NULL || total_free_blocks() == 0 || total_size() != 0, "_total_size shouldn't be 0?"); @@ -1357,7 +1344,7 @@ void BinaryTreeDictionary::verify_tree() const { verify_tree_helper(root()); } -template class FreeList_t> +template size_t BinaryTreeDictionary::verify_prev_free_ptrs(TreeList* tl) { size_t ct = 0; for (Chunk_t* curFC = tl->head(); curFC != NULL; curFC = curFC->next()) { @@ -1371,7 +1358,7 @@ size_t BinaryTreeDictionary::verify_prev_free_ptrs(TreeList // Note: this helper is recursive rather than iterative, so use with // caution on very deep trees; and watch out for stack overflow errors; // In general, to be used only for debugging. -template class FreeList_t> +template void BinaryTreeDictionary::verify_tree_helper(TreeList* tl) const { if (tl == NULL) return; @@ -1400,25 +1387,25 @@ void BinaryTreeDictionary::verify_tree_helper(TreeListright()); } -template class FreeList_t> +template void BinaryTreeDictionary::verify() const { verify_tree(); guarantee(total_size() == total_size_in_tree(root()), "Total Size inconsistency"); } -template class TreeList; -template class BinaryTreeDictionary; -template class TreeChunk; +template class TreeList >; +template class BinaryTreeDictionary >; +template class TreeChunk >; -template class TreeList; -template class BinaryTreeDictionary; -template class TreeChunk; +template class TreeList >; +template class BinaryTreeDictionary >; +template class TreeChunk >; #if INCLUDE_ALL_GCS // Explicitly instantiate these types for FreeChunk. -template class TreeList; -template class BinaryTreeDictionary; -template class TreeChunk; +template class TreeList >; +template class BinaryTreeDictionary >; +template class TreeChunk >; #endif // INCLUDE_ALL_GCS diff --git a/hotspot/src/share/vm/memory/binaryTreeDictionary.hpp b/hotspot/src/share/vm/memory/binaryTreeDictionary.hpp index 1867ed2ae22..8377912f242 100644 --- a/hotspot/src/share/vm/memory/binaryTreeDictionary.hpp +++ b/hotspot/src/share/vm/memory/binaryTreeDictionary.hpp @@ -37,18 +37,18 @@ // A TreeList is a FreeList which can be used to maintain a // binary tree of free lists. -template class FreeList_t> class TreeChunk; -template class FreeList_t> class BinaryTreeDictionary; -template class FreeList_t> class AscendTreeCensusClosure; -template class FreeList_t> class DescendTreeCensusClosure; -template class FreeList_t> class DescendTreeSearchClosure; +template class TreeChunk; +template class BinaryTreeDictionary; +template class AscendTreeCensusClosure; +template class DescendTreeCensusClosure; +template class DescendTreeSearchClosure; class FreeChunk; template class AdaptiveFreeList; -typedef BinaryTreeDictionary AFLBinaryTreeDictionary; +typedef BinaryTreeDictionary > AFLBinaryTreeDictionary; -template class FreeList_t> -class TreeList : public FreeList_t { +template +class TreeList : public FreeList_t { friend class TreeChunk; friend class BinaryTreeDictionary; friend class AscendTreeCensusClosure; @@ -66,12 +66,12 @@ class TreeList : public FreeList_t { TreeList* right() const { return _right; } // Wrapper on call to base class, to get the template to compile. - Chunk_t* head() const { return FreeList_t::head(); } - Chunk_t* tail() const { return FreeList_t::tail(); } - void set_head(Chunk_t* head) { FreeList_t::set_head(head); } - void set_tail(Chunk_t* tail) { FreeList_t::set_tail(tail); } + Chunk_t* head() const { return FreeList_t::head(); } + Chunk_t* tail() const { return FreeList_t::tail(); } + void set_head(Chunk_t* head) { FreeList_t::set_head(head); } + void set_tail(Chunk_t* tail) { FreeList_t::set_tail(tail); } - size_t size() const { return FreeList_t::size(); } + size_t size() const { return FreeList_t::size(); } // Accessors for links in tree. @@ -90,7 +90,7 @@ class TreeList : public FreeList_t { void clear_left() { _left = NULL; } void clear_right() { _right = NULL; } void clear_parent() { _parent = NULL; } - void initialize() { clear_left(); clear_right(), clear_parent(); FreeList_t::initialize(); } + void initialize() { clear_left(); clear_right(), clear_parent(); FreeList_t::initialize(); } // For constructing a TreeList from a Tree chunk or // address and size. @@ -139,7 +139,7 @@ class TreeList : public FreeList_t { // on the free list for a node in the tree and is only removed if // it is the last chunk on the free list. -template class FreeList_t> +template class TreeChunk : public Chunk_t { friend class TreeList; TreeList* _list; @@ -173,7 +173,7 @@ class TreeChunk : public Chunk_t { }; -template class FreeList_t> +template class BinaryTreeDictionary: public FreeBlockDictionary { friend class VMStructs; size_t _total_size; diff --git a/hotspot/src/share/vm/memory/metaspace.cpp b/hotspot/src/share/vm/memory/metaspace.cpp index 6105321c30f..9c3b48dc8f8 100644 --- a/hotspot/src/share/vm/memory/metaspace.cpp +++ b/hotspot/src/share/vm/memory/metaspace.cpp @@ -46,8 +46,8 @@ #include "utilities/copy.hpp" #include "utilities/debug.hpp" -typedef BinaryTreeDictionary BlockTreeDictionary; -typedef BinaryTreeDictionary ChunkTreeDictionary; +typedef BinaryTreeDictionary > BlockTreeDictionary; +typedef BinaryTreeDictionary > ChunkTreeDictionary; // Set this constant to enable slow integrity checking of the free chunk lists const bool metaspace_slow_verify = false; @@ -790,7 +790,7 @@ MetaWord* BlockFreelist::get_block(size_t word_size) { return NULL; } - if (word_size < TreeChunk::min_size()) { + if (word_size < TreeChunk >::min_size()) { // Dark matter. Too small for dictionary. return NULL; } @@ -810,7 +810,7 @@ MetaWord* BlockFreelist::get_block(size_t word_size) { MetaWord* new_block = (MetaWord*)free_block; assert(block_size >= word_size, "Incorrect size of block from freelist"); const size_t unused = block_size - word_size; - if (unused >= TreeChunk::min_size()) { + if (unused >= TreeChunk >::min_size()) { return_block(new_block + word_size, unused); } @@ -2240,7 +2240,7 @@ ChunkIndex ChunkManager::list_index(size_t size) { void SpaceManager::deallocate(MetaWord* p, size_t word_size) { assert_lock_strong(_lock); size_t raw_word_size = get_raw_word_size(word_size); - size_t min_size = TreeChunk::min_size(); + size_t min_size = TreeChunk >::min_size(); assert(raw_word_size >= min_size, err_msg("Should not deallocate dark matter " SIZE_FORMAT "<" SIZE_FORMAT, word_size, min_size)); block_freelists()->return_block(p, raw_word_size); @@ -2296,7 +2296,7 @@ void SpaceManager::add_chunk(Metachunk* new_chunk, bool make_current) { void SpaceManager::retire_current_chunk() { if (current_chunk() != NULL) { size_t remaining_words = current_chunk()->free_word_size(); - if (remaining_words >= TreeChunk::min_size()) { + if (remaining_words >= TreeChunk >::min_size()) { block_freelists()->return_block(current_chunk()->allocate(remaining_words), remaining_words); inc_used_metrics(remaining_words); } @@ -3279,7 +3279,7 @@ void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) { assert(Thread::current()->is_VM_thread(), "should be the VM thread"); // Don't take Heap_lock MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag); - if (word_size < TreeChunk::min_size()) { + if (word_size < TreeChunk >::min_size()) { // Dark matter. Too small for dictionary. #ifdef ASSERT Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5); @@ -3294,7 +3294,7 @@ void Metaspace::deallocate(MetaWord* ptr, size_t word_size, bool is_class) { } else { MutexLockerEx ml(vsm()->lock(), Mutex::_no_safepoint_check_flag); - if (word_size < TreeChunk::min_size()) { + if (word_size < TreeChunk >::min_size()) { // Dark matter. Too small for dictionary. #ifdef ASSERT Copy::fill_to_words((HeapWord*)ptr, word_size, 0xf5f5f5f5); diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 0897c25183b..c1191a0562c 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -242,7 +242,7 @@ typedef TwoOopHashtable KlassTwoOopHashtable; typedef Hashtable KlassHashtable; typedef HashtableEntry KlassHashtableEntry; typedef TwoOopHashtable SymbolTwoOopHashtable; -typedef BinaryTreeDictionary MetablockTreeDictionary; +typedef BinaryTreeDictionary > MetablockTreeDictionary; //-------------------------------------------------------------------------------- // VM_STRUCTS From a752b0b503712b63b3831ddbebc953b2b3c5cc80 Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Tue, 11 Feb 2014 21:32:19 -0800 Subject: [PATCH 134/159] 8033215: clang: node.cpp:284 IDX_INIT macro use uninitialized field _out Reviewed-by: twisti, kvn --- hotspot/src/share/vm/opto/node.cpp | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/hotspot/src/share/vm/opto/node.cpp b/hotspot/src/share/vm/opto/node.cpp index 06e74b6d0f2..344f7f0fb8e 100644 --- a/hotspot/src/share/vm/opto/node.cpp +++ b/hotspot/src/share/vm/opto/node.cpp @@ -285,6 +285,10 @@ void DUIterator_Last::verify_step(uint num_edges) { #ifdef _MSC_VER // the IDX_INIT hack falls foul of warning C4355 #pragma warning( disable:4355 ) // 'this' : used in base member initializer list #endif +#ifdef __clang__ +#pragma clang diagnostic push +#pragma GCC diagnostic ignored "-Wuninitialized" +#endif // Out-of-line code from node constructors. // Executed only when extra debug info. is being passed around. @@ -468,6 +472,10 @@ Node::Node(Node *n0, Node *n1, Node *n2, Node *n3, _in[6] = n6; if (n6 != NULL) n6->add_out((Node *)this); } +#ifdef __clang__ +#pragma clang diagnostic pop +#endif + //------------------------------clone------------------------------------------ // Clone a Node. From b633a889a7e8e8885c4b4f6042d37c89a8b42b83 Mon Sep 17 00:00:00 2001 From: Mike Duigou Date: Wed, 12 Feb 2014 09:37:18 -0800 Subject: [PATCH 135/159] 8030350: Enable additional compiler warnings for GCC Reviewed-by: dholmes, coleenp, erikj, tbell, ihse --- hotspot/make/bsd/makefiles/gcc.make | 4 ++-- hotspot/make/linux/makefiles/gcc.make | 2 +- hotspot/make/solaris/makefiles/gcc.make | 2 +- hotspot/src/os/bsd/vm/os_bsd.cpp | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/hotspot/make/bsd/makefiles/gcc.make b/hotspot/make/bsd/makefiles/gcc.make index 8f708eab3df..b6bca43e5bd 100644 --- a/hotspot/make/bsd/makefiles/gcc.make +++ b/hotspot/make/bsd/makefiles/gcc.make @@ -260,7 +260,7 @@ ifeq ($(USE_CLANG), true) WARNINGS_ARE_ERRORS += -Wno-empty-body endif -WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value +WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wformat=2 -Wno-error=format-nonliteral ifeq ($(USE_CLANG),) # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit @@ -289,7 +289,7 @@ CFLAGS += -fno-strict-aliasing # The flags to use for an Optimized g++ build ifeq ($(OS_VENDOR), Darwin) # use -Os by default, unless -O3 can be proved to be worth the cost, as per policy - # + # OPT_CFLAGS_DEFAULT ?= SIZE else OPT_CFLAGS_DEFAULT ?= SPEED diff --git a/hotspot/make/linux/makefiles/gcc.make b/hotspot/make/linux/makefiles/gcc.make index bc4a24c7787..daf6735ab33 100644 --- a/hotspot/make/linux/makefiles/gcc.make +++ b/hotspot/make/linux/makefiles/gcc.make @@ -214,7 +214,7 @@ ifeq ($(USE_CLANG), true) WARNINGS_ARE_ERRORS += -Wno-return-type -Wno-empty-body endif -WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value +WARNING_FLAGS = -Wpointer-arith -Wsign-compare -Wundef -Wunused-function -Wunused-value -Wformat=2 -Wno-error=format-nonliteral ifeq ($(USE_CLANG),) # Since GCC 4.3, -Wconversion has changed its meanings to warn these implicit diff --git a/hotspot/make/solaris/makefiles/gcc.make b/hotspot/make/solaris/makefiles/gcc.make index fe65ad4f5bf..627691c78f3 100644 --- a/hotspot/make/solaris/makefiles/gcc.make +++ b/hotspot/make/solaris/makefiles/gcc.make @@ -118,7 +118,7 @@ endif # Compiler warnings are treated as errors WARNINGS_ARE_ERRORS = -Werror # Enable these warnings. See 'info gcc' about details on these options -WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef +WARNING_FLAGS = -Wpointer-arith -Wconversion -Wsign-compare -Wundef -Wformat=2 -Wno-error=format-nonliteral CFLAGS_WARN/DEFAULT = $(WARNINGS_ARE_ERRORS) $(WARNING_FLAGS) # Special cases CFLAGS_WARN/BYFILE = $(CFLAGS_WARN/$@)$(CFLAGS_WARN/DEFAULT$(CFLAGS_WARN/$@)) diff --git a/hotspot/src/os/bsd/vm/os_bsd.cpp b/hotspot/src/os/bsd/vm/os_bsd.cpp index cadf960b1ac..5be87da64eb 100644 --- a/hotspot/src/os/bsd/vm/os_bsd.cpp +++ b/hotspot/src/os/bsd/vm/os_bsd.cpp @@ -1834,7 +1834,7 @@ void os::jvm_path(char *buf, jint buflen) { jrelib_p = buf + len; snprintf(jrelib_p, buflen-len, "/%s", COMPILER_VARIANT); if (0 != access(buf, F_OK)) { - snprintf(jrelib_p, buflen-len, ""); + snprintf(jrelib_p, buflen-len, "%s", ""); } // If the path exists within JAVA_HOME, add the JVM library name From a279dee28c0b68422e74e35b58e084781d963340 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Wed, 12 Feb 2014 22:08:43 +0400 Subject: [PATCH 136/159] 8023667: SA: ExceptionBlob and other C2 classes not available in client VM Ignore error of intialization of C2 only variables Reviewed-by: sla, dholmes --- .../classes/sun/jvm/hotspot/utilities/soql/sa.js | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js index a700f1bc6bd..9651e0ad4e2 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js @@ -804,6 +804,16 @@ delete tmp; // VM type to SA class map var vmType2Class = new Object(); +// C2 only classes +try{ + vmType2Class["ExceptionBlob"] = sapkg.code.ExceptionBlob; + vmType2Class["UncommonTrapBlob"] = sapkg.code.UncommonTrapBlob; +} catch(e) { + // Ignore exception. C2 specific objects might be not + // available in client VM +} + + // This is *not* exhaustive. Add more if needed. // code blobs vmType2Class["BufferBlob"] = sapkg.code.BufferBlob; @@ -812,10 +822,8 @@ vmType2Class["RuntimeStub"] = sapkg.code.RuntimeStub; vmType2Class["SafepointBlob"] = sapkg.code.SafepointBlob; vmType2Class["C2IAdapter"] = sapkg.code.C2IAdapter; vmType2Class["DeoptimizationBlob"] = sapkg.code.DeoptimizationBlob; -vmType2Class["ExceptionBlob"] = sapkg.code.ExceptionBlob; vmType2Class["I2CAdapter"] = sapkg.code.I2CAdapter; vmType2Class["OSRAdapter"] = sapkg.code.OSRAdapter; -vmType2Class["UncommonTrapBlob"] = sapkg.code.UncommonTrapBlob; vmType2Class["PCDesc"] = sapkg.code.PCDesc; // interpreter From 656746d828c0b7ee24d109ad81b9f0f53b5589f3 Mon Sep 17 00:00:00 2001 From: Dmitry Samersoff Date: Wed, 12 Feb 2014 23:39:53 +0400 Subject: [PATCH 137/159] 7127191: SA JSDB does not display native symbols correctly for transported Linux cores Better handle SA_ALTROOT Reviewed-by: sla, sspitsyn --- hotspot/agent/src/os/linux/libproc_impl.c | 79 +++++++++---------- .../debugger/linux/LinuxCDebugger.java | 36 +++------ .../sun/jvm/hotspot/utilities/soql/sa.js | 68 +++++++++------- 3 files changed, 91 insertions(+), 92 deletions(-) diff --git a/hotspot/agent/src/os/linux/libproc_impl.c b/hotspot/agent/src/os/linux/libproc_impl.c index 2ea0d0f88f9..a04bc37d1d7 100644 --- a/hotspot/agent/src/os/linux/libproc_impl.c +++ b/hotspot/agent/src/os/linux/libproc_impl.c @@ -29,54 +29,51 @@ #include #include "libproc_impl.h" -static const char* alt_root = NULL; -static int alt_root_len = -1; - #define SA_ALTROOT "SA_ALTROOT" -static void init_alt_root() { - if (alt_root_len == -1) { - alt_root = getenv(SA_ALTROOT); - if (alt_root) { - alt_root_len = strlen(alt_root); - } else { - alt_root_len = 0; - } - } -} - int pathmap_open(const char* name) { - int fd; - char alt_path[PATH_MAX + 1]; + static const char *alt_root = NULL; + static int alt_root_initialized = 0; - init_alt_root(); + int fd; + char alt_path[PATH_MAX + 1], *alt_path_end; + const char *s; - if (alt_root_len > 0) { - strcpy(alt_path, alt_root); - strcat(alt_path, name); - fd = open(alt_path, O_RDONLY); - if (fd >= 0) { - print_debug("path %s substituted for %s\n", alt_path, name); - return fd; - } + if (!alt_root_initialized) { + alt_root_initialized = -1; + alt_root = getenv(SA_ALTROOT); + } - if (strrchr(name, '/')) { - strcpy(alt_path, alt_root); - strcat(alt_path, strrchr(name, '/')); - fd = open(alt_path, O_RDONLY); - if (fd >= 0) { - print_debug("path %s substituted for %s\n", alt_path, name); - return fd; - } - } - } else { - fd = open(name, O_RDONLY); - if (fd >= 0) { - return fd; - } - } + if (alt_root == NULL) { + return open(name, O_RDONLY); + } - return -1; + strcpy(alt_path, alt_root); + alt_path_end = alt_path + strlen(alt_path); + + // Strip path items one by one and try to open file with alt_root prepended + s = name; + while (1) { + strcat(alt_path, s); + s += 1; + + fd = open(alt_path, O_RDONLY); + if (fd >= 0) { + print_debug("path %s substituted for %s\n", alt_path, name); + return fd; + } + + // Linker always put full path to solib to process, so we can rely + // on presence of /. If slash is not present, it means, that SOlib doesn't + // physically exist (e.g. linux-gate.so) and we fail opening it anyway + if ((s = strchr(s, '/')) == NULL) { + break; + } + + *alt_path_end = 0; + } + + return -1; } static bool _libsaproc_debug; diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java index f2d947493ee..91d47c60e3f 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/debugger/linux/LinuxCDebugger.java @@ -55,31 +55,21 @@ class LinuxCDebugger implements CDebugger { if (pc == null) { return null; } - List objs = getLoadObjectList(); - Object[] arr = objs.toArray(); - // load objects are sorted by base address, do binary search - int mid = -1; - int low = 0; - int high = arr.length - 1; - while (low <= high) { - mid = (low + high) >> 1; - LoadObject midVal = (LoadObject) arr[mid]; - long cmp = pc.minus(midVal.getBase()); - if (cmp < 0) { - high = mid - 1; - } else if (cmp > 0) { - long size = midVal.getSize(); - if (cmp >= size) { - low = mid + 1; - } else { - return (LoadObject) arr[mid]; - } - } else { // match found - return (LoadObject) arr[mid]; - } + /* Typically we have about ten loaded objects here. So no reason to do + sort/binary search here. Linear search gives us acceptable performance.*/ + + List objs = getLoadObjectList(); + + for (int i = 0; i < objs.size(); i++) { + LoadObject ob = (LoadObject) objs.get(i); + Address base = ob.getBase(); + long size = ob.getSize(); + if ( pc.greaterThanOrEqual(base) && pc.lessThan(base.addOffsetTo(size))) { + return ob; + } } - // no match found. + return null; } diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js index 9651e0ad4e2..14a8e9aa137 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/utilities/soql/sa.js @@ -371,19 +371,23 @@ function sym2addr(dso, sym) { return sa.dbg.lookup(dso, sym); } -// returns the ClosestSymbol or null -function closestSymbolFor(addr) { - if (sa.cdbg == null) { +function loadObjectContainingPC(addr) { + if (sa.cdbg == null) { // no CDebugger support, return null return null; - } else { - var dso = sa.cdbg.loadObjectContainingPC(addr); - if (dso != null) { - return dso.closestSymbolToPC(addr); - } else { - return null; - } - } + } + + return sa.cdbg.loadObjectContainingPC(addr); +} + +// returns the ClosestSymbol or null +function closestSymbolFor(addr) { + var dso = loadObjectContainingPC(addr); + if (dso != null) { + return dso.closestSymbolToPC(addr); + } + + return null; } // Address-to-symbol @@ -884,21 +888,29 @@ function isOop(addr) { // returns description of given pointer as a String function whatis(addr) { - addr = any2addr(addr); - var ptrLoc = findPtr(addr); - if (ptrLoc.isUnknown()) { - var vmType = vmTypeof(addr); - if (vmType != null) { - return "pointer to " + vmType.name; - } else { - var sym = closestSymbolFor(addr); - if (sym != null) { - return sym.name + '+' + sym.offset; - } else { - return ptrLoc.toString(); - } - } - } else { - return ptrLoc.toString(); - } + addr = any2addr(addr); + var ptrLoc = findPtr(addr); + if (!ptrLoc.isUnknown()) { + return ptrLoc.toString(); + } + + var vmType = vmTypeof(addr); + if (vmType != null) { + return "pointer to " + vmType.name; + } + + var dso = loadObjectContainingPC(addr); + if (dso == null) { + return ptrLoc.toString(); + } + + var sym = dso.closestSymbolToPC(addr); + if (sym != null) { + return sym.name + '+' + sym.offset; + } + + var s = dso.getName(); + var p = s.lastIndexOf("/"); + var base = dso.getBase(); + return s.substring(p+1, s.length) + '+' + addr.minus(base); } From 56c2d62e5e040c692e976dfd9ed9c7c03be98b02 Mon Sep 17 00:00:00 2001 From: Christian Tornqvist Date: Wed, 12 Feb 2014 20:40:02 +0100 Subject: [PATCH 138/159] 8034781: [TESTBUG] runtime/ClassFileUnsupportedClassFileVersion.java unable to find or load main class Passed empty string to ProcessBuilder which caused problems on Linux, fixed by checking string length Reviewed-by: lfoltan, sla, mseledtsov --- .../testlibrary/com/oracle/java/testlibrary/ProcessTools.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java b/hotspot/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java index 4bc11f8bf5d..04293905824 100644 --- a/hotspot/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java +++ b/hotspot/test/testlibrary/com/oracle/java/testlibrary/ProcessTools.java @@ -154,7 +154,7 @@ public final class ProcessTools { if (addTestVmOptions) { String vmopts = System.getProperty("test.vm.opts"); - if (vmopts != null) { + if (vmopts != null && vmopts.length() > 0) { Collections.addAll(args, vmopts.split("\\s")); } } From afe8f1c904ccfd41d10648f04f41d60462b1b650 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Wed, 12 Feb 2014 12:01:45 -0800 Subject: [PATCH 139/159] 8028785: [parfait] warnings from b116 for hotspot.src.share.vm.prims: JNI exception pending Added JNI exception pending check in several files under src/share/vm/prims directory Reviewed-by: coleenp, minqi --- hotspot/src/share/vm/prims/jni.cpp | 15 +++++++++++++++ hotspot/src/share/vm/prims/unsafe.cpp | 5 +++++ hotspot/src/share/vm/prims/whitebox.cpp | 25 ++++++++++++++++++++----- hotspot/src/share/vm/prims/whitebox.hpp | 16 ++++++++++++++++ 4 files changed, 56 insertions(+), 5 deletions(-) diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index 5d3327d1c23..de225f997eb 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -4348,8 +4348,23 @@ static bool initializeDirectBufferSupport(JNIEnv* env, JavaThread* thread) { // Get needed field and method IDs directByteBufferConstructor = env->GetMethodID(directByteBufferClass, "", "(JI)V"); + if (env->ExceptionCheck()) { + env->ExceptionClear(); + directBufferSupportInitializeFailed = 1; + return false; + } directBufferAddressField = env->GetFieldID(bufferClass, "address", "J"); + if (env->ExceptionCheck()) { + env->ExceptionClear(); + directBufferSupportInitializeFailed = 1; + return false; + } bufferCapacityField = env->GetFieldID(bufferClass, "capacity", "I"); + if (env->ExceptionCheck()) { + env->ExceptionClear(); + directBufferSupportInitializeFailed = 1; + return false; + } if ((directByteBufferConstructor == NULL) || (directBufferAddressField == NULL) || diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 2e432264b6e..5a5d7c93c47 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -858,6 +858,11 @@ static inline void throw_new(JNIEnv *env, const char *ename) { strcpy(buf, "java/lang/"); strcat(buf, ename); jclass cls = env->FindClass(buf); + if (env->ExceptionCheck()) { + env->ExceptionClear(); + tty->print_cr("Unsafe: cannot throw %s because FindClass has failed", buf); + return; + } char* msg = NULL; env->ThrowNew(cls, msg); } diff --git a/hotspot/src/share/vm/prims/whitebox.cpp b/hotspot/src/share/vm/prims/whitebox.cpp index 1cb799b3ea9..095ac20c3c9 100644 --- a/hotspot/src/share/vm/prims/whitebox.cpp +++ b/hotspot/src/share/vm/prims/whitebox.cpp @@ -316,9 +316,10 @@ WB_END WB_ENTRY(jint, WB_DeoptimizeMethod(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); + int result = 0; + CHECK_JNI_EXCEPTION_(env, result); MutexLockerEx mu(Compile_lock); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); - int result = 0; nmethod* code; if (is_osr) { int bci = InvocationEntryBci; @@ -344,6 +345,7 @@ WB_END WB_ENTRY(jboolean, WB_IsMethodCompiled(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION_(env, JNI_FALSE); MutexLockerEx mu(Compile_lock); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); @@ -355,6 +357,7 @@ WB_END WB_ENTRY(jboolean, WB_IsMethodCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION_(env, JNI_FALSE); MutexLockerEx mu(Compile_lock); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); if (is_osr) { @@ -366,6 +369,7 @@ WB_END WB_ENTRY(jboolean, WB_IsMethodQueuedForCompilation(JNIEnv* env, jobject o, jobject method)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION_(env, JNI_FALSE); MutexLockerEx mu(Compile_lock); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); return mh->queued_for_compilation(); @@ -373,6 +377,7 @@ WB_END WB_ENTRY(jint, WB_GetMethodCompilationLevel(JNIEnv* env, jobject o, jobject method, jboolean is_osr)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION_(env, CompLevel_none); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); nmethod* code = is_osr ? mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false) : mh->code(); return (code != NULL ? code->comp_level() : CompLevel_none); @@ -380,6 +385,7 @@ WB_END WB_ENTRY(void, WB_MakeMethodNotCompilable(JNIEnv* env, jobject o, jobject method, jint comp_level, jboolean is_osr)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION(env); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); if (is_osr) { mh->set_not_osr_compilable(comp_level, true /* report */, "WhiteBox"); @@ -390,6 +396,7 @@ WB_END WB_ENTRY(jint, WB_GetMethodEntryBci(JNIEnv* env, jobject o, jobject method)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION_(env, InvocationEntryBci); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); nmethod* code = mh->lookup_osr_nmethod_for(InvocationEntryBci, CompLevel_none, false); return (code != NULL && code->is_osr_method() ? code->osr_entry_bci() : InvocationEntryBci); @@ -397,6 +404,7 @@ WB_END WB_ENTRY(jboolean, WB_TestSetDontInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION_(env, JNI_FALSE); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); bool result = mh->dont_inline(); mh->set_dont_inline(value == JNI_TRUE); @@ -414,6 +422,7 @@ WB_END WB_ENTRY(jboolean, WB_TestSetForceInlineMethod(JNIEnv* env, jobject o, jobject method, jboolean value)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION_(env, JNI_FALSE); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); bool result = mh->force_inline(); mh->set_force_inline(value == JNI_TRUE); @@ -422,6 +431,7 @@ WB_END WB_ENTRY(jboolean, WB_EnqueueMethodForCompilation(JNIEnv* env, jobject o, jobject method, jint comp_level, jint bci)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION_(env, JNI_FALSE); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); nmethod* nm = CompileBroker::compile_method(mh, bci, comp_level, mh, mh->invocation_count(), "WhiteBox", THREAD); MutexLockerEx mu(Compile_lock); @@ -430,6 +440,7 @@ WB_END WB_ENTRY(void, WB_ClearMethodState(JNIEnv* env, jobject o, jobject method)) jmethodID jmid = reflected_method_to_jmid(thread, env, method); + CHECK_JNI_EXCEPTION(env); methodHandle mh(THREAD, Method::checked_resolve_jmethod_id(jmid)); MutexLockerEx mu(Compile_lock); MethodData* mdo = mh->method_data(); @@ -616,14 +627,18 @@ JVM_ENTRY(void, JVM_RegisterWhiteBoxMethods(JNIEnv* env, jclass wbclass)) bool result = true; // one by one registration natives for exception catching jclass exceptionKlass = env->FindClass(vmSymbols::java_lang_NoSuchMethodError()->as_C_string()); + CHECK_JNI_EXCEPTION(env); for (int i = 0, n = sizeof(methods) / sizeof(methods[0]); i < n; ++i) { if (env->RegisterNatives(wbclass, methods + i, 1) != 0) { result = false; - if (env->ExceptionCheck() && env->IsInstanceOf(env->ExceptionOccurred(), exceptionKlass)) { - // j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native - // ignoring the exception - tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature); + jthrowable throwable_obj = env->ExceptionOccurred(); + if (throwable_obj != NULL) { env->ExceptionClear(); + if (env->IsInstanceOf(throwable_obj, exceptionKlass)) { + // j.l.NoSuchMethodError is thrown when a method can't be found or a method is not native + // ignoring the exception + tty->print_cr("Warning: 'NoSuchMethodError' on register of sun.hotspot.WhiteBox::%s%s", methods[i].name, methods[i].signature); + } } else { // register is failed w/o exception or w/ unexpected exception tty->print_cr("Warning: unexpected error on register of sun.hotspot.WhiteBox::%s%s. All methods will be unregistered", methods[i].name, methods[i].signature); diff --git a/hotspot/src/share/vm/prims/whitebox.hpp b/hotspot/src/share/vm/prims/whitebox.hpp index f78117414cf..42d00b2fcda 100644 --- a/hotspot/src/share/vm/prims/whitebox.hpp +++ b/hotspot/src/share/vm/prims/whitebox.hpp @@ -36,6 +36,22 @@ #define WB_END JNI_END #define WB_METHOD_DECLARE(result_type) extern "C" result_type JNICALL +#define CHECK_JNI_EXCEPTION_(env, value) \ + do { \ + if (env->ExceptionCheck()) { \ + env->ExceptionClear(); \ + return(value); \ + } \ + } while (0) + +#define CHECK_JNI_EXCEPTION(env) \ + do { \ + if (env->ExceptionCheck()) { \ + env->ExceptionClear(); \ + return; \ + } \ + } while (0) + class WhiteBox : public AllStatic { private: static bool _used; From 297485c528129bb0f132a3909dec1cded6e3b585 Mon Sep 17 00:00:00 2001 From: Calvin Cheung Date: Fri, 14 Feb 2014 09:50:17 -0800 Subject: [PATCH 140/159] 8034860: Fatal error due to incorrect thread state during nightly testing Use the HAS_PENDING_EXCEPTION and CLEAR_PENDING_EXCEPTION macros Reviewed-by: dholmes, coleenp, dcubed --- hotspot/src/share/vm/prims/whitebox.hpp | 26 +++++++++++++------------ 1 file changed, 14 insertions(+), 12 deletions(-) diff --git a/hotspot/src/share/vm/prims/whitebox.hpp b/hotspot/src/share/vm/prims/whitebox.hpp index 42d00b2fcda..a6e27b49055 100644 --- a/hotspot/src/share/vm/prims/whitebox.hpp +++ b/hotspot/src/share/vm/prims/whitebox.hpp @@ -36,20 +36,22 @@ #define WB_END JNI_END #define WB_METHOD_DECLARE(result_type) extern "C" result_type JNICALL -#define CHECK_JNI_EXCEPTION_(env, value) \ - do { \ - if (env->ExceptionCheck()) { \ - env->ExceptionClear(); \ - return(value); \ - } \ +#define CHECK_JNI_EXCEPTION_(env, value) \ + do { \ + JavaThread* THREAD = JavaThread::thread_from_jni_environment(env); \ + if (HAS_PENDING_EXCEPTION) { \ + CLEAR_PENDING_EXCEPTION; \ + return(value); \ + } \ } while (0) -#define CHECK_JNI_EXCEPTION(env) \ - do { \ - if (env->ExceptionCheck()) { \ - env->ExceptionClear(); \ - return; \ - } \ +#define CHECK_JNI_EXCEPTION(env) \ + do { \ + JavaThread* THREAD = JavaThread::thread_from_jni_environment(env); \ + if (HAS_PENDING_EXCEPTION) { \ + CLEAR_PENDING_EXCEPTION; \ + return; \ + } \ } while (0) class WhiteBox : public AllStatic { From c9b3cbbdcca37d679abaab7ece0bccb5c79fa28e Mon Sep 17 00:00:00 2001 From: Shanliang Jiang Date: Fri, 14 Feb 2014 16:17:22 +0100 Subject: [PATCH 141/159] 8007710: runtime/7158988/FieldMonitor.java fails with com.sun.jdi.VMDisconnectedException: Connection closed Reviewed-by: sla, jbachorik, sspitsyn --- .../test/runtime/7158988/FieldMonitor.java | 35 +++++++------------ 1 file changed, 12 insertions(+), 23 deletions(-) diff --git a/hotspot/test/runtime/7158988/FieldMonitor.java b/hotspot/test/runtime/7158988/FieldMonitor.java index 5421f626278..9b16fc3d798 100644 --- a/hotspot/test/runtime/7158988/FieldMonitor.java +++ b/hotspot/test/runtime/7158988/FieldMonitor.java @@ -34,10 +34,6 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; -import java.io.OutputStream; -import java.io.OutputStreamWriter; -import java.io.Reader; -import java.io.Writer; import java.util.Iterator; import java.util.List; import java.util.Map; @@ -56,6 +52,7 @@ import com.sun.jdi.event.EventQueue; import com.sun.jdi.event.EventSet; import com.sun.jdi.event.ModificationWatchpointEvent; import com.sun.jdi.event.VMDeathEvent; +import com.sun.jdi.event.VMStartEvent; import com.sun.jdi.event.VMDisconnectEvent; import com.sun.jdi.request.ClassPrepareRequest; import com.sun.jdi.request.EventRequest; @@ -71,24 +68,10 @@ public class FieldMonitor { public static void main(String[] args) throws IOException, InterruptedException { - StringBuffer sb = new StringBuffer(); - - for (int i=0; i < args.length; i++) { - sb.append(' '); - sb.append(args[i]); - } //VirtualMachine vm = launchTarget(sb.toString()); VirtualMachine vm = launchTarget(CLASS_NAME); System.out.println("Vm launched"); - // set watch field on already loaded classes - List referenceTypes = vm - .classesByName(CLASS_NAME); - for (ReferenceType refType : referenceTypes) { - addFieldWatch(vm, refType); - } - // watch for loaded classes - addClassWatch(vm); // process events EventQueue eventQueue = vm.eventQueue(); @@ -104,13 +87,15 @@ public class FieldMonitor { errThread.start(); outThread.start(); - - vm.resume(); boolean connected = true; + int watched = 0; while (connected) { EventSet eventSet = eventQueue.remove(); for (Event event : eventSet) { - if (event instanceof VMDeathEvent + System.out.println("FieldMonitor-main receives: "+event); + if (event instanceof VMStartEvent) { + addClassWatch(vm); + } else if (event instanceof VMDeathEvent || event instanceof VMDisconnectEvent) { // exit connected = false; @@ -122,17 +107,17 @@ public class FieldMonitor { .referenceType(); addFieldWatch(vm, refType); } else if (event instanceof ModificationWatchpointEvent) { + watched++; System.out.println("sleep for 500 ms"); Thread.sleep(500); - System.out.println("resume..."); ModificationWatchpointEvent modEvent = (ModificationWatchpointEvent) event; System.out.println("old=" + modEvent.valueCurrent()); System.out.println("new=" + modEvent.valueToBe()); - System.out.println(); } } + System.out.println("resume..."); eventSet.resume(); } // Shutdown begins when event thread terminates @@ -142,6 +127,10 @@ public class FieldMonitor { } catch (InterruptedException exc) { // we don't interrupt } + + if (watched != 11) { // init + 10 modifications in TestPostFieldModification class + throw new Error("Expected to receive 11 times ModificationWatchpointEvent, but got "+watched); + } } /** From 4ab0b2732c2bb0113d559b9c7e2cdadb1e308eef Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Sat, 15 Feb 2014 13:03:38 -0500 Subject: [PATCH 142/159] 8027146: Class loading verification failure if GC occurs in Universe::flush_dependents_on Remove search in system dictionary and hacks, replace with verifying in CLD::_klasses list. Reviewed-by: dcubed, acorn --- .../share/vm/classfile/classLoaderData.cpp | 9 ++++++++- .../share/vm/classfile/classLoaderData.hpp | 3 ++- hotspot/src/share/vm/classfile/dictionary.cpp | 4 ++-- .../share/vm/classfile/systemDictionary.cpp | 19 +------------------ .../share/vm/classfile/systemDictionary.hpp | 6 +----- hotspot/src/share/vm/oops/arrayKlass.cpp | 6 +++--- hotspot/src/share/vm/oops/arrayKlass.hpp | 4 ++-- hotspot/src/share/vm/oops/instanceKlass.cpp | 15 ++++++--------- hotspot/src/share/vm/oops/instanceKlass.hpp | 2 +- hotspot/src/share/vm/oops/klass.cpp | 4 ++-- hotspot/src/share/vm/oops/klass.hpp | 6 +++--- hotspot/src/share/vm/oops/objArrayKlass.cpp | 6 +++--- hotspot/src/share/vm/oops/objArrayKlass.hpp | 4 ++-- 13 files changed, 36 insertions(+), 52 deletions(-) diff --git a/hotspot/src/share/vm/classfile/classLoaderData.cpp b/hotspot/src/share/vm/classfile/classLoaderData.cpp index 892ea92fb00..6b34e01506c 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.cpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -520,6 +520,13 @@ void ClassLoaderData::verify() { } } +bool ClassLoaderData::contains_klass(Klass* klass) { + for (Klass* k = _klasses; k != NULL; k = k->next_link()) { + if (k == klass) return true; + } + return false; +} + // GC root of class loader data created. ClassLoaderData* ClassLoaderDataGraph::_head = NULL; diff --git a/hotspot/src/share/vm/classfile/classLoaderData.hpp b/hotspot/src/share/vm/classfile/classLoaderData.hpp index 9e76b50441f..3fcbb6b7d5c 100644 --- a/hotspot/src/share/vm/classfile/classLoaderData.hpp +++ b/hotspot/src/share/vm/classfile/classLoaderData.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -260,6 +260,7 @@ class ClassLoaderData : public CHeapObj { jobject add_handle(Handle h); void add_class(Klass* k); void remove_class(Klass* k); + bool contains_klass(Klass* k); void record_dependency(Klass* to, TRAPS); void init_dependencies(TRAPS); diff --git a/hotspot/src/share/vm/classfile/dictionary.cpp b/hotspot/src/share/vm/classfile/dictionary.cpp index e308791caa7..9a2bb74f821 100644 --- a/hotspot/src/share/vm/classfile/dictionary.cpp +++ b/hotspot/src/share/vm/classfile/dictionary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -707,7 +707,7 @@ void Dictionary::verify() { loader_data->class_loader() == NULL || loader_data->class_loader()->is_instance(), "checking type of class_loader"); - e->verify(/*check_dictionary*/false); + e->verify(); probe->verify_protection_domain_set(); element_count++; } diff --git a/hotspot/src/share/vm/classfile/systemDictionary.cpp b/hotspot/src/share/vm/classfile/systemDictionary.cpp index f5c5c017dcd..703443517fd 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.cpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -2650,23 +2650,6 @@ void SystemDictionary::verify() { constraints()->verify(dictionary(), placeholders()); } - -void SystemDictionary::verify_obj_klass_present(Symbol* class_name, - ClassLoaderData* loader_data) { - GCMutexLocker mu(SystemDictionary_lock); - Symbol* name; - - Klass* probe = find_class(class_name, loader_data); - if (probe == NULL) { - probe = SystemDictionary::find_shared_class(class_name); - if (probe == NULL) { - name = find_placeholder(class_name, loader_data); - } - } - guarantee(probe != NULL || name != NULL, - "Loaded klasses should be in SystemDictionary"); -} - // utility function for class load event void SystemDictionary::post_class_load_event(const Ticks& start_time, instanceKlassHandle k, diff --git a/hotspot/src/share/vm/classfile/systemDictionary.hpp b/hotspot/src/share/vm/classfile/systemDictionary.hpp index b0e914ff9e4..88132f5209f 100644 --- a/hotspot/src/share/vm/classfile/systemDictionary.hpp +++ b/hotspot/src/share/vm/classfile/systemDictionary.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -375,10 +375,6 @@ public: static bool is_internal_format(Symbol* class_name); #endif - // Verify class is in dictionary - static void verify_obj_klass_present(Symbol* class_name, - ClassLoaderData* loader_data); - // Initialization static void initialize(TRAPS); diff --git a/hotspot/src/share/vm/oops/arrayKlass.cpp b/hotspot/src/share/vm/oops/arrayKlass.cpp index 9e40206c253..fcb46b11f02 100644 --- a/hotspot/src/share/vm/oops/arrayKlass.cpp +++ b/hotspot/src/share/vm/oops/arrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -214,8 +214,8 @@ void ArrayKlass::oop_print_on(oop obj, outputStream* st) { // Verification -void ArrayKlass::verify_on(outputStream* st, bool check_dictionary) { - Klass::verify_on(st, check_dictionary); +void ArrayKlass::verify_on(outputStream* st) { + Klass::verify_on(st); if (component_mirror() != NULL) { guarantee(component_mirror()->klass() != NULL, "should have a class"); diff --git a/hotspot/src/share/vm/oops/arrayKlass.hpp b/hotspot/src/share/vm/oops/arrayKlass.hpp index 4b06f1c0ed6..7b4ad2e9a99 100644 --- a/hotspot/src/share/vm/oops/arrayKlass.hpp +++ b/hotspot/src/share/vm/oops/arrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -146,7 +146,7 @@ class ArrayKlass: public Klass { void oop_print_on(oop obj, outputStream* st); // Verification - void verify_on(outputStream* st, bool check_dictionary); + void verify_on(outputStream* st); void oop_verify_on(oop obj, outputStream* st); }; diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index a6ca58c42c1..ac9340a8777 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -3180,7 +3180,7 @@ class VerifyFieldClosure: public OopClosure { virtual void do_oop(narrowOop* p) { VerifyFieldClosure::do_oop_work(p); } }; -void InstanceKlass::verify_on(outputStream* st, bool check_dictionary) { +void InstanceKlass::verify_on(outputStream* st) { #ifndef PRODUCT // Avoid redundant verifies, this really should be in product. if (_verify_count == Universe::verify_count()) return; @@ -3188,14 +3188,11 @@ void InstanceKlass::verify_on(outputStream* st, bool check_dictionary) { #endif // Verify Klass - Klass::verify_on(st, check_dictionary); + Klass::verify_on(st); - // Verify that klass is present in SystemDictionary if not already - // verifying the SystemDictionary. - if (is_loaded() && !is_anonymous() && check_dictionary) { - Symbol* h_name = name(); - SystemDictionary::verify_obj_klass_present(h_name, class_loader_data()); - } + // Verify that klass is present in ClassLoaderData + guarantee(class_loader_data()->contains_klass(this), + "this class isn't found in class loader data"); // Verify vtables if (is_linked()) { diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index f503de6725a..db14be29a14 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -1087,7 +1087,7 @@ public: const char* internal_name() const; // Verification - void verify_on(outputStream* st, bool check_dictionary); + void verify_on(outputStream* st); void oop_verify_on(oop obj, outputStream* st); }; diff --git a/hotspot/src/share/vm/oops/klass.cpp b/hotspot/src/share/vm/oops/klass.cpp index bf5dae0606d..adca246aaa9 100644 --- a/hotspot/src/share/vm/oops/klass.cpp +++ b/hotspot/src/share/vm/oops/klass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -638,7 +638,7 @@ void Klass::collect_statistics(KlassSizeStats *sz) const { // Verification -void Klass::verify_on(outputStream* st, bool check_dictionary) { +void Klass::verify_on(outputStream* st) { // This can be expensive, but it is worth checking that this klass is actually // in the CLD graph but not in production. diff --git a/hotspot/src/share/vm/oops/klass.hpp b/hotspot/src/share/vm/oops/klass.hpp index 9855fdd3233..a31a2357355 100644 --- a/hotspot/src/share/vm/oops/klass.hpp +++ b/hotspot/src/share/vm/oops/klass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -695,8 +695,8 @@ class Klass : public Metadata { virtual const char* internal_name() const = 0; // Verification - virtual void verify_on(outputStream* st, bool check_dictionary); - void verify(bool check_dictionary = true) { verify_on(tty, check_dictionary); } + virtual void verify_on(outputStream* st); + void verify() { verify_on(tty); } #ifndef PRODUCT bool verify_vtable_index(int index); diff --git a/hotspot/src/share/vm/oops/objArrayKlass.cpp b/hotspot/src/share/vm/oops/objArrayKlass.cpp index 7294ebe9adb..3316a8b27e6 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.cpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -674,8 +674,8 @@ const char* ObjArrayKlass::internal_name() const { // Verification -void ObjArrayKlass::verify_on(outputStream* st, bool check_dictionary) { - ArrayKlass::verify_on(st, check_dictionary); +void ObjArrayKlass::verify_on(outputStream* st) { + ArrayKlass::verify_on(st); guarantee(element_klass()->is_klass(), "should be klass"); guarantee(bottom_klass()->is_klass(), "should be klass"); Klass* bk = bottom_klass(); diff --git a/hotspot/src/share/vm/oops/objArrayKlass.hpp b/hotspot/src/share/vm/oops/objArrayKlass.hpp index af06fd42084..cfe31e86e61 100644 --- a/hotspot/src/share/vm/oops/objArrayKlass.hpp +++ b/hotspot/src/share/vm/oops/objArrayKlass.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -151,7 +151,7 @@ class ObjArrayKlass : public ArrayKlass { const char* internal_name() const; // Verification - void verify_on(outputStream* st, bool check_dictionary); + void verify_on(outputStream* st); void oop_verify_on(oop obj, outputStream* st); }; From 10d4420b0815f86c68546b819423657658f19447 Mon Sep 17 00:00:00 2001 From: Stefan Johansson Date: Mon, 17 Feb 2014 09:51:37 +0100 Subject: [PATCH 143/159] 8033440: jmap reports unexpected used/free size of concurrent mark-sweep generation SA used the wrong type for the indexedFreeList in CompactibleFreeListSpace. Reviewed-by: coleenp, dsamersoff --- .../jvm/hotspot/memory/AdaptiveFreeList.java | 77 +++++++++++++++++++ .../memory/CompactibleFreeListSpace.java | 38 +++++---- .../sun/jvm/hotspot/memory/FreeList.java | 72 ----------------- .../concurrentMarkSweep/vmStructs_cms.hpp | 4 +- hotspot/src/share/vm/runtime/vmStructs.cpp | 20 ++--- 5 files changed, 105 insertions(+), 106 deletions(-) create mode 100644 hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/AdaptiveFreeList.java delete mode 100644 hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/FreeList.java diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/AdaptiveFreeList.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/AdaptiveFreeList.java new file mode 100644 index 00000000000..19dca2610ce --- /dev/null +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/AdaptiveFreeList.java @@ -0,0 +1,77 @@ +/* + * @(#)AdaptiveFreeList.java + * + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA + * or visit www.oracle.com if you need additional information or have any + * questions. + * + */ + +package sun.jvm.hotspot.memory; + +import java.util.Observable; +import java.util.Observer; + +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.runtime.VMObject; +import sun.jvm.hotspot.types.CIntegerField; +import sun.jvm.hotspot.types.Type; +import sun.jvm.hotspot.types.TypeDataBase; + +public class AdaptiveFreeList extends VMObject { + static { + VM.registerVMInitializedObserver(new Observer() { + public void update(Observable o, Object data) { + initialize(VM.getVM().getTypeDataBase()); + } + }); + } + + private static synchronized void initialize(TypeDataBase db) { + Type type = db.lookupType("AdaptiveFreeList"); + sizeField = type.getCIntegerField("_size"); + countField = type.getCIntegerField("_count"); + headerSize = type.getSize(); + } + + // Fields + private static CIntegerField sizeField; + private static CIntegerField countField; + private static long headerSize; + + //Constructor + public AdaptiveFreeList(Address address) { + super(address); + } + + // Accessors + public long size() { + return sizeField.getValue(addr); + } + + public long count() { + return countField.getValue(addr); + } + + public static long sizeOf() { + return headerSize; + } +} diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java index 23cb0bcb7fb..ed26af725e0 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/memory/CompactibleFreeListSpace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -24,25 +24,29 @@ package sun.jvm.hotspot.memory; -import java.io.*; -import java.util.*; -import sun.jvm.hotspot.debugger.*; -import sun.jvm.hotspot.oops.*; -import sun.jvm.hotspot.runtime.*; -import sun.jvm.hotspot.types.*; -import sun.jvm.hotspot.utilities.*; +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Iterator; +import java.util.List; +import java.util.Observable; +import java.util.Observer; + +import sun.jvm.hotspot.debugger.Address; +import sun.jvm.hotspot.debugger.Debugger; +import sun.jvm.hotspot.oops.ObjectHeap; +import sun.jvm.hotspot.oops.Oop; +import sun.jvm.hotspot.runtime.VM; +import sun.jvm.hotspot.runtime.VMObjectFactory; +import sun.jvm.hotspot.types.AddressField; +import sun.jvm.hotspot.types.Type; +import sun.jvm.hotspot.types.TypeDataBase; +import sun.jvm.hotspot.utilities.Assert; public class CompactibleFreeListSpace extends CompactibleSpace { private static AddressField collectorField; - - // for free size, three fields - // FreeBlockDictionary* _dictionary; // ptr to dictionary for large size blocks - // FreeList _indexedFreeList[IndexSetSize]; // indexed array for small size blocks - // LinearAllocBlock _smallLinearAllocBlock; // small linear alloc in TLAB private static AddressField indexedFreeListField; private static AddressField dictionaryField; private static long smallLinearAllocBlockFieldOffset; - private static long indexedFreeListSizeOf; private int heapWordSize; // 4 for 32bit, 8 for 64 bits private int IndexSetStart; // for small indexed list @@ -109,11 +113,11 @@ public class CompactibleFreeListSpace extends CompactibleSpace { // small chunks long size = 0; Address cur = addr.addOffsetTo( indexedFreeListField.getOffset() ); - cur = cur.addOffsetTo(IndexSetStart*FreeList.sizeOf()); + cur = cur.addOffsetTo(IndexSetStart*AdaptiveFreeList.sizeOf()); for (int i=IndexSetStart; i"); - sizeField = type.getCIntegerField("_size"); - countField = type.getCIntegerField("_count"); - headerSize = type.getSize(); - } - - // Fields - private static CIntegerField sizeField; - private static CIntegerField countField; - private static long headerSize; - - //Constructor - public FreeList(Address address) { - super(address); - } - - // Accessors - public long size() { - return sizeField.getValue(addr); - } - - public long count() { - return countField.getValue(addr); - } - - public static long sizeOf() { - return headerSize; - } -} diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmStructs_cms.hpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmStructs_cms.hpp index 1a46ed3f52d..2a0a563d5f4 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmStructs_cms.hpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmStructs_cms.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -41,7 +41,7 @@ nonstatic_field(LinearAllocBlock, _word_size, size_t) \ nonstatic_field(AFLBinaryTreeDictionary, _total_size, size_t) \ nonstatic_field(CompactibleFreeListSpace, _dictionary, AFLBinaryTreeDictionary*) \ - nonstatic_field(CompactibleFreeListSpace, _indexedFreeList[0], FreeList) \ + nonstatic_field(CompactibleFreeListSpace, _indexedFreeList[0], AdaptiveFreeList) \ nonstatic_field(CompactibleFreeListSpace, _smallLinearAllocBlock, LinearAllocBlock) diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index c1191a0562c..b5cdb27b26f 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -242,7 +242,6 @@ typedef TwoOopHashtable KlassTwoOopHashtable; typedef Hashtable KlassHashtable; typedef HashtableEntry KlassHashtableEntry; typedef TwoOopHashtable SymbolTwoOopHashtable; -typedef BinaryTreeDictionary > MetablockTreeDictionary; //-------------------------------------------------------------------------------- // VM_STRUCTS @@ -1281,11 +1280,8 @@ typedef BinaryTreeDictionary > MetablockTreeDicti volatile_nonstatic_field(FreeChunk, _size, size_t) \ nonstatic_field(FreeChunk, _next, FreeChunk*) \ nonstatic_field(FreeChunk, _prev, FreeChunk*) \ - nonstatic_field(FreeList, _size, size_t) \ - nonstatic_field(FreeList, _size, size_t) \ - nonstatic_field(FreeList, _count, ssize_t) \ - nonstatic_field(FreeList, _count, ssize_t) \ - nonstatic_field(MetablockTreeDictionary, _total_size, size_t) + nonstatic_field(AdaptiveFreeList, _size, size_t) \ + nonstatic_field(AdaptiveFreeList, _count, ssize_t) //-------------------------------------------------------------------------------- @@ -2155,14 +2151,8 @@ typedef BinaryTreeDictionary > MetablockTreeDicti \ /* freelist */ \ declare_toplevel_type(FreeChunk*) \ - declare_toplevel_type(Metablock*) \ - declare_toplevel_type(FreeBlockDictionary*) \ - declare_toplevel_type(FreeList*) \ - declare_toplevel_type(FreeList) \ - declare_toplevel_type(FreeBlockDictionary*) \ - declare_toplevel_type(FreeList*) \ - declare_toplevel_type(FreeList) \ - declare_type(MetablockTreeDictionary, FreeBlockDictionary) + declare_toplevel_type(AdaptiveFreeList*) \ + declare_toplevel_type(AdaptiveFreeList) //-------------------------------------------------------------------------------- From 43b711ea78c080bcc12eb50b68d212ef70d7a181 Mon Sep 17 00:00:00 2001 From: Staffan Larsen Date: Tue, 18 Feb 2014 09:15:40 +0100 Subject: [PATCH 144/159] 8034080: Remove the USDT1 dtrace code from Hotspot Reviewed-by: dholmes, coleenp --- hotspot/src/share/vm/code/nmethod.cpp | 33 - .../src/share/vm/compiler/compileBroker.cpp | 33 - .../concurrentMarkSweep/vmCMSOperations.cpp | 24 - .../shared/vmGCOperations.cpp | 15 - hotspot/src/share/vm/oops/instanceKlass.cpp | 46 - hotspot/src/share/vm/prims/jni.cpp | 1315 +---------------- hotspot/src/share/vm/prims/jvm.cpp | 33 +- hotspot/src/share/vm/prims/unsafe.cpp | 28 +- hotspot/src/share/vm/runtime/java.cpp | 8 - .../src/share/vm/runtime/objectMonitor.cpp | 34 - .../src/share/vm/runtime/sharedRuntime.cpp | 27 - hotspot/src/share/vm/runtime/synchronizer.cpp | 27 - hotspot/src/share/vm/runtime/thread.cpp | 33 - hotspot/src/share/vm/runtime/vmThread.cpp | 21 - .../share/vm/services/classLoadingService.cpp | 21 - .../src/share/vm/services/memoryManager.cpp | 23 - .../src/share/vm/services/runtimeService.cpp | 13 - hotspot/src/share/vm/utilities/dtrace.hpp | 143 +- ...usdt2_disabled.hpp => dtrace_disabled.hpp} | 10 +- 19 files changed, 86 insertions(+), 1801 deletions(-) rename hotspot/src/share/vm/utilities/{dtrace_usdt2_disabled.hpp => dtrace_disabled.hpp} (99%) diff --git a/hotspot/src/share/vm/code/nmethod.cpp b/hotspot/src/share/vm/code/nmethod.cpp index 50ee61adfab..0dc8ed1f47a 100644 --- a/hotspot/src/share/vm/code/nmethod.cpp +++ b/hotspot/src/share/vm/code/nmethod.cpp @@ -50,27 +50,6 @@ // Only bother with this argument setup if dtrace is available -#ifndef USDT2 -HS_DTRACE_PROBE_DECL8(hotspot, compiled__method__load, - const char*, int, const char*, int, const char*, int, void*, size_t); - -HS_DTRACE_PROBE_DECL6(hotspot, compiled__method__unload, - char*, int, char*, int, char*, int); - -#define DTRACE_METHOD_UNLOAD_PROBE(method) \ - { \ - Method* m = (method); \ - if (m != NULL) { \ - Symbol* klass_name = m->klass_name(); \ - Symbol* name = m->name(); \ - Symbol* signature = m->signature(); \ - HS_DTRACE_PROBE6(hotspot, compiled__method__unload, \ - klass_name->bytes(), klass_name->utf8_length(), \ - name->bytes(), name->utf8_length(), \ - signature->bytes(), signature->utf8_length()); \ - } \ - } -#else /* USDT2 */ #define DTRACE_METHOD_UNLOAD_PROBE(method) \ { \ Method* m = (method); \ @@ -84,7 +63,6 @@ HS_DTRACE_PROBE_DECL6(hotspot, compiled__method__unload, (char *) signature->bytes(), signature->utf8_length()); \ } \ } -#endif /* USDT2 */ #else // ndef DTRACE_ENABLED @@ -1520,16 +1498,6 @@ bool nmethod::can_unload(BoolObjectClosure* is_alive, oop* root, bool unloading_ void nmethod::post_compiled_method_load_event() { Method* moop = method(); -#ifndef USDT2 - HS_DTRACE_PROBE8(hotspot, compiled__method__load, - moop->klass_name()->bytes(), - moop->klass_name()->utf8_length(), - moop->name()->bytes(), - moop->name()->utf8_length(), - moop->signature()->bytes(), - moop->signature()->utf8_length(), - insts_begin(), insts_size()); -#else /* USDT2 */ HOTSPOT_COMPILED_METHOD_LOAD( (char *) moop->klass_name()->bytes(), moop->klass_name()->utf8_length(), @@ -1538,7 +1506,6 @@ void nmethod::post_compiled_method_load_event() { (char *) moop->signature()->bytes(), moop->signature()->utf8_length(), insts_begin(), insts_size()); -#endif /* USDT2 */ if (JvmtiExport::should_post_compiled_method_load() || JvmtiExport::should_post_compiled_method_unload()) { diff --git a/hotspot/src/share/vm/compiler/compileBroker.cpp b/hotspot/src/share/vm/compiler/compileBroker.cpp index 536bca7851a..51fff71d54b 100644 --- a/hotspot/src/share/vm/compiler/compileBroker.cpp +++ b/hotspot/src/share/vm/compiler/compileBroker.cpp @@ -60,38 +60,6 @@ // Only bother with this argument setup if dtrace is available -#ifndef USDT2 -HS_DTRACE_PROBE_DECL8(hotspot, method__compile__begin, - char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t); -HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end, - char*, intptr_t, char*, intptr_t, char*, intptr_t, char*, intptr_t, bool); - -#define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name) \ - { \ - Symbol* klass_name = (method)->klass_name(); \ - Symbol* name = (method)->name(); \ - Symbol* signature = (method)->signature(); \ - HS_DTRACE_PROBE8(hotspot, method__compile__begin, \ - comp_name, strlen(comp_name), \ - klass_name->bytes(), klass_name->utf8_length(), \ - name->bytes(), name->utf8_length(), \ - signature->bytes(), signature->utf8_length()); \ - } - -#define DTRACE_METHOD_COMPILE_END_PROBE(method, comp_name, success) \ - { \ - Symbol* klass_name = (method)->klass_name(); \ - Symbol* name = (method)->name(); \ - Symbol* signature = (method)->signature(); \ - HS_DTRACE_PROBE9(hotspot, method__compile__end, \ - comp_name, strlen(comp_name), \ - klass_name->bytes(), klass_name->utf8_length(), \ - name->bytes(), name->utf8_length(), \ - signature->bytes(), signature->utf8_length(), (success)); \ - } - -#else /* USDT2 */ - #define DTRACE_METHOD_COMPILE_BEGIN_PROBE(method, comp_name) \ { \ Symbol* klass_name = (method)->klass_name(); \ @@ -115,7 +83,6 @@ HS_DTRACE_PROBE_DECL9(hotspot, method__compile__end, (char *) name->bytes(), name->utf8_length(), \ (char *) signature->bytes(), signature->utf8_length(), (success)); \ } -#endif /* USDT2 */ #else // ndef DTRACE_ENABLED diff --git a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp index 8024d298f05..46c0650a772 100644 --- a/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp +++ b/hotspot/src/share/vm/gc_implementation/concurrentMarkSweep/vmCMSOperations.cpp @@ -35,14 +35,6 @@ #include "utilities/dtrace.hpp" -#ifndef USDT2 -HS_DTRACE_PROBE_DECL(hs_private, cms__initmark__begin); -HS_DTRACE_PROBE_DECL(hs_private, cms__initmark__end); - -HS_DTRACE_PROBE_DECL(hs_private, cms__remark__begin); -HS_DTRACE_PROBE_DECL(hs_private, cms__remark__end); -#endif /* !USDT2 */ - ////////////////////////////////////////////////////////// // Methods in abstract class VM_CMS_Operation ////////////////////////////////////////////////////////// @@ -138,11 +130,7 @@ void VM_CMS_Initial_Mark::doit() { // Nothing to do. return; } -#ifndef USDT2 - HS_DTRACE_PROBE(hs_private, cms__initmark__begin); -#else /* USDT2 */ HS_PRIVATE_CMS_INITMARK_BEGIN(); -#endif /* USDT2 */ _collector->_gc_timer_cm->register_gc_pause_start("Initial Mark"); @@ -158,11 +146,7 @@ void VM_CMS_Initial_Mark::doit() { _collector->_gc_timer_cm->register_gc_pause_end(); -#ifndef USDT2 - HS_DTRACE_PROBE(hs_private, cms__initmark__end); -#else /* USDT2 */ HS_PRIVATE_CMS_INITMARK_END(); -#endif /* USDT2 */ } ////////////////////////////////////////////////////////// @@ -173,11 +157,7 @@ void VM_CMS_Final_Remark::doit() { // Nothing to do. return; } -#ifndef USDT2 - HS_DTRACE_PROBE(hs_private, cms__remark__begin); -#else /* USDT2 */ HS_PRIVATE_CMS_REMARK_BEGIN(); -#endif /* USDT2 */ _collector->_gc_timer_cm->register_gc_pause_start("Final Mark"); @@ -194,11 +174,7 @@ void VM_CMS_Final_Remark::doit() { _collector->save_heap_summary(); _collector->_gc_timer_cm->register_gc_pause_end(); -#ifndef USDT2 - HS_DTRACE_PROBE(hs_private, cms__remark__end); -#else /* USDT2 */ HS_PRIVATE_CMS_REMARK_END(); -#endif /* USDT2 */ } // VM operation to invoke a concurrent collection of a diff --git a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp index ca3c0f48310..9027b89c375 100644 --- a/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp +++ b/hotspot/src/share/vm/gc_implementation/shared/vmGCOperations.cpp @@ -41,33 +41,18 @@ #include "gc_implementation/g1/g1CollectedHeap.inline.hpp" #endif // INCLUDE_ALL_GCS -#ifndef USDT2 -HS_DTRACE_PROBE_DECL1(hotspot, gc__begin, bool); -HS_DTRACE_PROBE_DECL(hotspot, gc__end); -#endif /* !USDT2 */ - // The same dtrace probe can't be inserted in two different files, so we // have to call it here, so it's only in one file. Can't create new probes // for the other file anymore. The dtrace probes have to remain stable. void VM_GC_Operation::notify_gc_begin(bool full) { -#ifndef USDT2 - HS_DTRACE_PROBE1(hotspot, gc__begin, full); - HS_DTRACE_WORKAROUND_TAIL_CALL_BUG(); -#else /* USDT2 */ HOTSPOT_GC_BEGIN( full); HS_DTRACE_WORKAROUND_TAIL_CALL_BUG(); -#endif /* USDT2 */ } void VM_GC_Operation::notify_gc_end() { -#ifndef USDT2 - HS_DTRACE_PROBE(hotspot, gc__end); - HS_DTRACE_WORKAROUND_TAIL_CALL_BUG(); -#else /* USDT2 */ HOTSPOT_GC_END(); HS_DTRACE_WORKAROUND_TAIL_CALL_BUG(); -#endif /* USDT2 */ } void VM_GC_Operation::acquire_pending_list_lock() { diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index ac9340a8777..66b46725828 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -77,51 +77,6 @@ #ifdef DTRACE_ENABLED -#ifndef USDT2 - -HS_DTRACE_PROBE_DECL4(hotspot, class__initialization__required, - char*, intptr_t, oop, intptr_t); -HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__recursive, - char*, intptr_t, oop, intptr_t, int); -HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__concurrent, - char*, intptr_t, oop, intptr_t, int); -HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__erroneous, - char*, intptr_t, oop, intptr_t, int); -HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__super__failed, - char*, intptr_t, oop, intptr_t, int); -HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__clinit, - char*, intptr_t, oop, intptr_t, int); -HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__error, - char*, intptr_t, oop, intptr_t, int); -HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__end, - char*, intptr_t, oop, intptr_t, int); - -#define DTRACE_CLASSINIT_PROBE(type, clss, thread_type) \ - { \ - char* data = NULL; \ - int len = 0; \ - Symbol* name = (clss)->name(); \ - if (name != NULL) { \ - data = (char*)name->bytes(); \ - len = name->utf8_length(); \ - } \ - HS_DTRACE_PROBE4(hotspot, class__initialization__##type, \ - data, len, SOLARIS_ONLY((void *))(clss)->class_loader(), thread_type); \ - } - -#define DTRACE_CLASSINIT_PROBE_WAIT(type, clss, thread_type, wait) \ - { \ - char* data = NULL; \ - int len = 0; \ - Symbol* name = (clss)->name(); \ - if (name != NULL) { \ - data = (char*)name->bytes(); \ - len = name->utf8_length(); \ - } \ - HS_DTRACE_PROBE5(hotspot, class__initialization__##type, \ - data, len, SOLARIS_ONLY((void *))(clss)->class_loader(), thread_type, wait); \ - } -#else /* USDT2 */ #define HOTSPOT_CLASS_INITIALIZATION_required HOTSPOT_CLASS_INITIALIZATION_REQUIRED #define HOTSPOT_CLASS_INITIALIZATION_recursive HOTSPOT_CLASS_INITIALIZATION_RECURSIVE @@ -156,7 +111,6 @@ HS_DTRACE_PROBE_DECL5(hotspot, class__initialization__end, HOTSPOT_CLASS_INITIALIZATION_##type( \ data, len, (clss)->class_loader(), thread_type, wait); \ } -#endif /* USDT2 */ #else // ndef DTRACE_ENABLED diff --git a/hotspot/src/share/vm/prims/jni.cpp b/hotspot/src/share/vm/prims/jni.cpp index a24967eaa13..030393cd275 100644 --- a/hotspot/src/share/vm/prims/jni.cpp +++ b/hotspot/src/share/vm/prims/jni.cpp @@ -114,33 +114,6 @@ static jint CurrentVersion = JNI_VERSION_1_8; // return_value = 5; // return return_value; // JNI_END -#ifndef USDT2 -#define DT_RETURN_MARK_DECL(name, type) \ - HS_DTRACE_PROBE_DECL1(hotspot_jni, name##__return, type); \ - DTRACE_ONLY( \ - class DTraceReturnProbeMark_##name { \ - public: \ - const type& _ret_ref; \ - DTraceReturnProbeMark_##name(const type& v) : _ret_ref(v) {} \ - ~DTraceReturnProbeMark_##name() { \ - HS_DTRACE_PROBE1(hotspot_jni, name##__return, _ret_ref); \ - } \ - } \ - ) -// Void functions are simpler since there's no return value -#define DT_VOID_RETURN_MARK_DECL(name) \ - HS_DTRACE_PROBE_DECL0(hotspot_jni, name##__return); \ - DTRACE_ONLY( \ - class DTraceReturnProbeMark_##name { \ - public: \ - ~DTraceReturnProbeMark_##name() { \ - HS_DTRACE_PROBE0(hotspot_jni, name##__return); \ - } \ - } \ - ) - -#else /* USDT2 */ - #define DT_RETURN_MARK_DECL(name, type, probe) \ DTRACE_ONLY( \ class DTraceReturnProbeMark_##name { \ @@ -162,7 +135,6 @@ static jint CurrentVersion = JNI_VERSION_1_8; } \ } \ ) -#endif /* USDT2 */ // Place these macros in the function to mark the return. Non-void // functions need the type and address of the return value. @@ -191,15 +163,9 @@ static jint CurrentVersion = JNI_VERSION_1_8; // Choose DT_RETURN_MARK macros based on the type: float/double -> void // (dtrace doesn't do FP yet) -#ifndef USDT2 -#define DT_RETURN_MARK_DECL_FOR(TypeName, name, type) \ - FP_SELECT(TypeName, \ - DT_RETURN_MARK_DECL(name, type), DT_VOID_RETURN_MARK_DECL(name) ) -#else /* USDT2 */ #define DT_RETURN_MARK_DECL_FOR(TypeName, name, type, probe) \ FP_SELECT(TypeName, \ DT_RETURN_MARK_DECL(name, type, probe), DT_VOID_RETURN_MARK_DECL(name, probe) ) -#endif /* USDT2 */ #define DT_RETURN_MARK_FOR(TypeName, name, type, ref) \ FP_SELECT(TypeName, \ DT_RETURN_MARK(name, type, ref), DT_VOID_RETURN_MARK(name) ) @@ -358,24 +324,16 @@ const int MAX_REASONABLE_LOCAL_CAPACITY = 4*K; // Implementation of JNI entries -#ifndef USDT2 -DT_RETURN_MARK_DECL(DefineClass, jclass); -#else /* USDT2 */ DT_RETURN_MARK_DECL(DefineClass, jclass , HOTSPOT_JNI_DEFINECLASS_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jclass, jni_DefineClass(JNIEnv *env, const char *name, jobject loaderRef, const jbyte *buf, jsize bufLen)) JNIWrapper("DefineClass"); -#ifndef USDT2 - DTRACE_PROBE5(hotspot_jni, DefineClass__entry, - env, name, loaderRef, buf, bufLen); -#else /* USDT2 */ HOTSPOT_JNI_DEFINECLASS_ENTRY( env, (char*) name, loaderRef, (char*) buf, bufLen); -#endif /* USDT2 */ + jclass cls = NULL; DT_RETURN_MARK(DefineClass, jclass, (const jclass&)cls); @@ -421,20 +379,13 @@ JNI_END static bool first_time_FindClass = true; -#ifndef USDT2 -DT_RETURN_MARK_DECL(FindClass, jclass); -#else /* USDT2 */ DT_RETURN_MARK_DECL(FindClass, jclass , HOTSPOT_JNI_FINDCLASS_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name)) JNIWrapper("FindClass"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, FindClass__entry, env, name); -#else /* USDT2 */ + HOTSPOT_JNI_FINDCLASS_ENTRY(env, (char *)name); -#endif /* USDT2 */ jclass result = NULL; DT_RETURN_MARK(FindClass, jclass, (const jclass&)result); @@ -498,20 +449,14 @@ JNI_ENTRY(jclass, jni_FindClass(JNIEnv *env, const char *name)) return result; JNI_END -#ifndef USDT2 -DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID); -#else /* USDT2 */ DT_RETURN_MARK_DECL(FromReflectedMethod, jmethodID , HOTSPOT_JNI_FROMREFLECTEDMETHOD_RETURN((uintptr_t)_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method)) JNIWrapper("FromReflectedMethod"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, FromReflectedMethod__entry, env, method); -#else /* USDT2 */ + HOTSPOT_JNI_FROMREFLECTEDMETHOD_ENTRY(env, method); -#endif /* USDT2 */ + jmethodID ret = NULL; DT_RETURN_MARK(FromReflectedMethod, jmethodID, (const jmethodID&)ret); @@ -538,20 +483,14 @@ JNI_ENTRY(jmethodID, jni_FromReflectedMethod(JNIEnv *env, jobject method)) return ret; JNI_END -#ifndef USDT2 -DT_RETURN_MARK_DECL(FromReflectedField, jfieldID); -#else /* USDT2 */ DT_RETURN_MARK_DECL(FromReflectedField, jfieldID , HOTSPOT_JNI_FROMREFLECTEDFIELD_RETURN((uintptr_t)_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jfieldID, jni_FromReflectedField(JNIEnv *env, jobject field)) JNIWrapper("FromReflectedField"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, FromReflectedField__entry, env, field); -#else /* USDT2 */ + HOTSPOT_JNI_FROMREFLECTEDFIELD_ENTRY(env, field); -#endif /* USDT2 */ + jfieldID ret = NULL; DT_RETURN_MARK(FromReflectedField, jfieldID, (const jfieldID&)ret); @@ -586,20 +525,15 @@ JNI_ENTRY(jfieldID, jni_FromReflectedField(JNIEnv *env, jobject field)) return ret; JNI_END -#ifndef USDT2 -DT_RETURN_MARK_DECL(ToReflectedMethod, jobject); -#else /* USDT2 */ + DT_RETURN_MARK_DECL(ToReflectedMethod, jobject , HOTSPOT_JNI_TOREFLECTEDMETHOD_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jobject, jni_ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID method_id, jboolean isStatic)) JNIWrapper("ToReflectedMethod"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, ToReflectedMethod__entry, env, cls, method_id, isStatic); -#else /* USDT2 */ + HOTSPOT_JNI_TOREFLECTEDMETHOD_ENTRY(env, cls, (uintptr_t) method_id, isStatic); -#endif /* USDT2 */ + jobject ret = NULL; DT_RETURN_MARK(ToReflectedMethod, jobject, (const jobject&)ret); @@ -615,20 +549,14 @@ JNI_ENTRY(jobject, jni_ToReflectedMethod(JNIEnv *env, jclass cls, jmethodID meth return ret; JNI_END -#ifndef USDT2 -DT_RETURN_MARK_DECL(GetSuperclass, jclass); -#else /* USDT2 */ DT_RETURN_MARK_DECL(GetSuperclass, jclass , HOTSPOT_JNI_GETSUPERCLASS_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jclass, jni_GetSuperclass(JNIEnv *env, jclass sub)) JNIWrapper("GetSuperclass"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, GetSuperclass__entry, env, sub); -#else /* USDT2 */ + HOTSPOT_JNI_GETSUPERCLASS_ENTRY(env, sub); -#endif /* USDT2 */ + jclass obj = NULL; DT_RETURN_MARK(GetSuperclass, jclass, (const jclass&)obj); @@ -657,21 +585,16 @@ JNI_END JNI_QUICK_ENTRY(jboolean, jni_IsAssignableFrom(JNIEnv *env, jclass sub, jclass super)) JNIWrapper("IsSubclassOf"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, IsAssignableFrom__entry, env, sub, super); -#else /* USDT2 */ + HOTSPOT_JNI_ISASSIGNABLEFROM_ENTRY(env, sub, super); -#endif /* USDT2 */ + oop sub_mirror = JNIHandles::resolve_non_null(sub); oop super_mirror = JNIHandles::resolve_non_null(super); if (java_lang_Class::is_primitive(sub_mirror) || java_lang_Class::is_primitive(super_mirror)) { jboolean ret = (sub_mirror == super_mirror); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret); -#else /* USDT2 */ + HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN(ret); -#endif /* USDT2 */ return ret; } Klass* sub_klass = java_lang_Class::as_Klass(sub_mirror); @@ -679,28 +602,20 @@ JNI_QUICK_ENTRY(jboolean, jni_IsAssignableFrom(JNIEnv *env, jclass sub, jclass s assert(sub_klass != NULL && super_klass != NULL, "invalid arguments to jni_IsAssignableFrom"); jboolean ret = sub_klass->is_subtype_of(super_klass) ? JNI_TRUE : JNI_FALSE; -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, IsAssignableFrom__return, ret); -#else /* USDT2 */ + HOTSPOT_JNI_ISASSIGNABLEFROM_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END -#ifndef USDT2 -DT_RETURN_MARK_DECL(Throw, jint); -#else /* USDT2 */ + DT_RETURN_MARK_DECL(Throw, jint , HOTSPOT_JNI_THROW_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jint, jni_Throw(JNIEnv *env, jthrowable obj)) JNIWrapper("Throw"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, Throw__entry, env, obj); -#else /* USDT2 */ + HOTSPOT_JNI_THROW_ENTRY(env, obj); -#endif /* USDT2 */ + jint ret = JNI_OK; DT_RETURN_MARK(Throw, jint, (const jint&)ret); @@ -708,20 +623,15 @@ JNI_ENTRY(jint, jni_Throw(JNIEnv *env, jthrowable obj)) ShouldNotReachHere(); JNI_END -#ifndef USDT2 -DT_RETURN_MARK_DECL(ThrowNew, jint); -#else /* USDT2 */ + DT_RETURN_MARK_DECL(ThrowNew, jint , HOTSPOT_JNI_THROWNEW_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jint, jni_ThrowNew(JNIEnv *env, jclass clazz, const char *message)) JNIWrapper("ThrowNew"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, ThrowNew__entry, env, clazz, message); -#else /* USDT2 */ + HOTSPOT_JNI_THROWNEW_ENTRY(env, clazz, (char *) message); -#endif /* USDT2 */ + jint ret = JNI_OK; DT_RETURN_MARK(ThrowNew, jint, (const jint&)ret); @@ -750,30 +660,23 @@ static void jni_check_async_exceptions(JavaThread *thread) { JNI_ENTRY_NO_PRESERVE(jthrowable, jni_ExceptionOccurred(JNIEnv *env)) JNIWrapper("ExceptionOccurred"); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, ExceptionOccurred__entry, env); -#else /* USDT2 */ + HOTSPOT_JNI_EXCEPTIONOCCURRED_ENTRY(env); -#endif /* USDT2 */ + jni_check_async_exceptions(thread); oop exception = thread->pending_exception(); jthrowable ret = (jthrowable) JNIHandles::make_local(env, exception); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, ExceptionOccurred__return, ret); -#else /* USDT2 */ + HOTSPOT_JNI_EXCEPTIONOCCURRED_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionDescribe(JNIEnv *env)) JNIWrapper("ExceptionDescribe"); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, ExceptionDescribe__entry, env); -#else /* USDT2 */ + HOTSPOT_JNI_EXCEPTIONDESCRIBE_ENTRY(env); -#endif /* USDT2 */ + if (thread->has_pending_exception()) { Handle ex(thread, thread->pending_exception()); thread->clear_pending_exception(); @@ -809,21 +712,15 @@ JNI_ENTRY_NO_PRESERVE(void, jni_ExceptionDescribe(JNIEnv *env)) } } } -#ifndef USDT2 - DTRACE_PROBE(hotspot_jni, ExceptionDescribe__return); -#else /* USDT2 */ + HOTSPOT_JNI_EXCEPTIONDESCRIBE_RETURN(); -#endif /* USDT2 */ JNI_END JNI_QUICK_ENTRY(void, jni_ExceptionClear(JNIEnv *env)) JNIWrapper("ExceptionClear"); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, ExceptionClear__entry, env); -#else /* USDT2 */ + HOTSPOT_JNI_EXCEPTIONCLEAR_ENTRY(env); -#endif /* USDT2 */ // The jni code might be using this API to clear java thrown exception. // So just mark jvmti thread exception state as exception caught. @@ -832,21 +729,16 @@ JNI_QUICK_ENTRY(void, jni_ExceptionClear(JNIEnv *env)) state->set_exception_caught(); } thread->clear_pending_exception(); -#ifndef USDT2 - DTRACE_PROBE(hotspot_jni, ExceptionClear__return); -#else /* USDT2 */ + HOTSPOT_JNI_EXCEPTIONCLEAR_RETURN(); -#endif /* USDT2 */ JNI_END JNI_ENTRY(void, jni_FatalError(JNIEnv *env, const char *msg)) JNIWrapper("FatalError"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, FatalError__entry, env, msg); -#else /* USDT2 */ + HOTSPOT_JNI_FATALERROR_ENTRY(env, (char *) msg); -#endif /* USDT2 */ + tty->print_cr("FATAL ERROR in native method: %s", msg); thread->print_stack(); os::abort(); // Dump core and abort @@ -855,18 +747,12 @@ JNI_END JNI_ENTRY(jint, jni_PushLocalFrame(JNIEnv *env, jint capacity)) JNIWrapper("PushLocalFrame"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, PushLocalFrame__entry, env, capacity); -#else /* USDT2 */ + HOTSPOT_JNI_PUSHLOCALFRAME_ENTRY(env, capacity); -#endif /* USDT2 */ + //%note jni_11 if (capacity < 0 || capacity > MAX_REASONABLE_LOCAL_CAPACITY) { -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, JNI_ERR); -#else /* USDT2 */ HOTSPOT_JNI_PUSHLOCALFRAME_RETURN((uint32_t)JNI_ERR); -#endif /* USDT2 */ return JNI_ERR; } JNIHandleBlock* old_handles = thread->active_handles(); @@ -875,22 +761,16 @@ JNI_ENTRY(jint, jni_PushLocalFrame(JNIEnv *env, jint capacity)) new_handles->set_pop_frame_link(old_handles); thread->set_active_handles(new_handles); jint ret = JNI_OK; -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, PushLocalFrame__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_PUSHLOCALFRAME_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY(jobject, jni_PopLocalFrame(JNIEnv *env, jobject result)) JNIWrapper("PopLocalFrame"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, PopLocalFrame__entry, env, result); -#else /* USDT2 */ + HOTSPOT_JNI_POPLOCALFRAME_ENTRY(env, result); -#endif /* USDT2 */ + //%note jni_11 Handle result_handle(thread, JNIHandles::resolve(result)); JNIHandleBlock* old_handles = thread->active_handles(); @@ -905,127 +785,91 @@ JNI_ENTRY(jobject, jni_PopLocalFrame(JNIEnv *env, jobject result)) JNIHandleBlock::release_block(old_handles, thread); // may block result = JNIHandles::make_local(thread, result_handle()); } -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, PopLocalFrame__return, result); -#else /* USDT2 */ HOTSPOT_JNI_POPLOCALFRAME_RETURN(result); -#endif /* USDT2 */ return result; JNI_END JNI_ENTRY(jobject, jni_NewGlobalRef(JNIEnv *env, jobject ref)) JNIWrapper("NewGlobalRef"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, NewGlobalRef__entry, env, ref); -#else /* USDT2 */ + HOTSPOT_JNI_NEWGLOBALREF_ENTRY(env, ref); -#endif /* USDT2 */ + Handle ref_handle(thread, JNIHandles::resolve(ref)); jobject ret = JNIHandles::make_global(ref_handle); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, NewGlobalRef__return, ret); -#else /* USDT2 */ + HOTSPOT_JNI_NEWGLOBALREF_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END // Must be JNI_ENTRY (with HandleMark) JNI_ENTRY_NO_PRESERVE(void, jni_DeleteGlobalRef(JNIEnv *env, jobject ref)) JNIWrapper("DeleteGlobalRef"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, DeleteGlobalRef__entry, env, ref); -#else /* USDT2 */ + HOTSPOT_JNI_DELETEGLOBALREF_ENTRY(env, ref); -#endif /* USDT2 */ + JNIHandles::destroy_global(ref); -#ifndef USDT2 - DTRACE_PROBE(hotspot_jni, DeleteGlobalRef__return); -#else /* USDT2 */ + HOTSPOT_JNI_DELETEGLOBALREF_RETURN(); -#endif /* USDT2 */ JNI_END JNI_QUICK_ENTRY(void, jni_DeleteLocalRef(JNIEnv *env, jobject obj)) JNIWrapper("DeleteLocalRef"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, DeleteLocalRef__entry, env, obj); -#else /* USDT2 */ + HOTSPOT_JNI_DELETELOCALREF_ENTRY(env, obj); -#endif /* USDT2 */ + JNIHandles::destroy_local(obj); -#ifndef USDT2 - DTRACE_PROBE(hotspot_jni, DeleteLocalRef__return); -#else /* USDT2 */ + HOTSPOT_JNI_DELETELOCALREF_RETURN(); -#endif /* USDT2 */ JNI_END JNI_QUICK_ENTRY(jboolean, jni_IsSameObject(JNIEnv *env, jobject r1, jobject r2)) JNIWrapper("IsSameObject"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, IsSameObject__entry, env, r1, r2); -#else /* USDT2 */ + HOTSPOT_JNI_ISSAMEOBJECT_ENTRY(env, r1, r2); -#endif /* USDT2 */ + oop a = JNIHandles::resolve(r1); oop b = JNIHandles::resolve(r2); jboolean ret = (a == b) ? JNI_TRUE : JNI_FALSE; -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, IsSameObject__return, ret); -#else /* USDT2 */ + HOTSPOT_JNI_ISSAMEOBJECT_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY(jobject, jni_NewLocalRef(JNIEnv *env, jobject ref)) JNIWrapper("NewLocalRef"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, NewLocalRef__entry, env, ref); -#else /* USDT2 */ + HOTSPOT_JNI_NEWLOCALREF_ENTRY(env, ref); -#endif /* USDT2 */ + jobject ret = JNIHandles::make_local(env, JNIHandles::resolve(ref)); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, NewLocalRef__return, ret); -#else /* USDT2 */ + HOTSPOT_JNI_NEWLOCALREF_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END JNI_LEAF(jint, jni_EnsureLocalCapacity(JNIEnv *env, jint capacity)) JNIWrapper("EnsureLocalCapacity"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, EnsureLocalCapacity__entry, env, capacity); -#else /* USDT2 */ + HOTSPOT_JNI_ENSURELOCALCAPACITY_ENTRY(env, capacity); -#endif /* USDT2 */ + jint ret; if (capacity >= 0 && capacity <= MAX_REASONABLE_LOCAL_CAPACITY) { ret = JNI_OK; } else { ret = JNI_ERR; } -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, EnsureLocalCapacity__return, ret); -#else /* USDT2 */ + HOTSPOT_JNI_ENSURELOCALCAPACITY_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END // Return the Handle Type JNI_LEAF(jobjectRefType, jni_GetObjectRefType(JNIEnv *env, jobject obj)) JNIWrapper("GetObjectRefType"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, GetObjectRefType__entry, env, obj); -#else /* USDT2 */ + HOTSPOT_JNI_GETOBJECTREFTYPE_ENTRY(env, obj); -#endif /* USDT2 */ + jobjectRefType ret; if (JNIHandles::is_local_handle(thread, obj) || JNIHandles::is_frame_handle(thread, obj)) @@ -1036,11 +880,8 @@ JNI_LEAF(jobjectRefType, jni_GetObjectRefType(JNIEnv *env, jobject obj)) ret = JNIWeakGlobalRefType; else ret = JNIInvalidRefType; -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetObjectRefType__return, ret); -#else /* USDT2 */ + HOTSPOT_JNI_GETOBJECTREFTYPE_RETURN((void *) ret); -#endif /* USDT2 */ return ret; JNI_END @@ -1369,21 +1210,14 @@ static instanceOop alloc_object(jclass clazz, TRAPS) { return ih; } -#ifndef USDT2 -DT_RETURN_MARK_DECL(AllocObject, jobject); -#else /* USDT2 */ DT_RETURN_MARK_DECL(AllocObject, jobject , HOTSPOT_JNI_ALLOCOBJECT_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz)) JNIWrapper("AllocObject"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, AllocObject__entry, env, clazz); -#else /* USDT2 */ HOTSPOT_JNI_ALLOCOBJECT_ENTRY(env, clazz); -#endif /* USDT2 */ + jobject ret = NULL; DT_RETURN_MARK(AllocObject, jobject, (const jobject&)ret); @@ -1392,20 +1226,14 @@ JNI_ENTRY(jobject, jni_AllocObject(JNIEnv *env, jclass clazz)) return ret; JNI_END -#ifndef USDT2 -DT_RETURN_MARK_DECL(NewObjectA, jobject); -#else /* USDT2 */ DT_RETURN_MARK_DECL(NewObjectA, jobject , HOTSPOT_JNI_NEWOBJECTA_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, const jvalue *args)) JNIWrapper("NewObjectA"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, NewObjectA__entry, env, clazz, methodID); -#else /* USDT2 */ + HOTSPOT_JNI_NEWOBJECTA_ENTRY(env, clazz, (uintptr_t) methodID); -#endif /* USDT2 */ + jobject obj = NULL; DT_RETURN_MARK(NewObjectA, jobject, (const jobject)obj); @@ -1417,20 +1245,15 @@ JNI_ENTRY(jobject, jni_NewObjectA(JNIEnv *env, jclass clazz, jmethodID methodID, return obj; JNI_END -#ifndef USDT2 -DT_RETURN_MARK_DECL(NewObjectV, jobject); -#else /* USDT2 */ + DT_RETURN_MARK_DECL(NewObjectV, jobject , HOTSPOT_JNI_NEWOBJECTV_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, va_list args)) JNIWrapper("NewObjectV"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, NewObjectV__entry, env, clazz, methodID); -#else /* USDT2 */ + HOTSPOT_JNI_NEWOBJECTV_ENTRY(env, clazz, (uintptr_t) methodID); -#endif /* USDT2 */ + jobject obj = NULL; DT_RETURN_MARK(NewObjectV, jobject, (const jobject&)obj); @@ -1442,20 +1265,15 @@ JNI_ENTRY(jobject, jni_NewObjectV(JNIEnv *env, jclass clazz, jmethodID methodID, return obj; JNI_END -#ifndef USDT2 -DT_RETURN_MARK_DECL(NewObject, jobject); -#else /* USDT2 */ + DT_RETURN_MARK_DECL(NewObject, jobject , HOTSPOT_JNI_NEWOBJECT_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jobject, jni_NewObject(JNIEnv *env, jclass clazz, jmethodID methodID, ...)) JNIWrapper("NewObject"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, NewObject__entry, env, clazz, methodID); -#else /* USDT2 */ + HOTSPOT_JNI_NEWOBJECT_ENTRY(env, clazz, (uintptr_t) methodID); -#endif /* USDT2 */ + jobject obj = NULL; DT_RETURN_MARK(NewObject, jobject, (const jobject&)obj); @@ -1473,29 +1291,22 @@ JNI_END JNI_ENTRY(jclass, jni_GetObjectClass(JNIEnv *env, jobject obj)) JNIWrapper("GetObjectClass"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, GetObjectClass__entry, env, obj); -#else /* USDT2 */ + HOTSPOT_JNI_GETOBJECTCLASS_ENTRY(env, obj); -#endif /* USDT2 */ + Klass* k = JNIHandles::resolve_non_null(obj)->klass(); jclass ret = (jclass) JNIHandles::make_local(env, k->java_mirror()); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetObjectClass__return, ret); -#else /* USDT2 */ + HOTSPOT_JNI_GETOBJECTCLASS_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END JNI_QUICK_ENTRY(jboolean, jni_IsInstanceOf(JNIEnv *env, jobject obj, jclass clazz)) JNIWrapper("IsInstanceOf"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, IsInstanceOf__entry, env, obj, clazz); -#else /* USDT2 */ + HOTSPOT_JNI_ISINSTANCEOF_ENTRY(env, obj, clazz); -#endif /* USDT2 */ + jboolean ret = JNI_TRUE; if (obj != NULL) { ret = JNI_FALSE; @@ -1505,11 +1316,8 @@ JNI_QUICK_ENTRY(jboolean, jni_IsInstanceOf(JNIEnv *env, jobject obj, jclass claz ret = JNIHandles::resolve_non_null(obj)->is_a(k) ? JNI_TRUE : JNI_FALSE; } } -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, IsInstanceOf__return, ret); -#else /* USDT2 */ + HOTSPOT_JNI_ISINSTANCEOF_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END @@ -1569,17 +1377,9 @@ static jmethodID get_method_id(JNIEnv *env, jclass clazz, const char *name_str, JNI_ENTRY(jmethodID, jni_GetMethodID(JNIEnv *env, jclass clazz, const char *name, const char *sig)) JNIWrapper("GetMethodID"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, GetMethodID__entry, env, clazz, name, sig); -#else /* USDT2 */ HOTSPOT_JNI_GETMETHODID_ENTRY(env, clazz, (char *) name, (char *) sig); -#endif /* USDT2 */ jmethodID ret = get_method_id(env, clazz, name, sig, false, thread); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetMethodID__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_GETMETHODID_RETURN((uintptr_t) ret); -#endif /* USDT2 */ return ret; JNI_END @@ -1587,17 +1387,9 @@ JNI_END JNI_ENTRY(jmethodID, jni_GetStaticMethodID(JNIEnv *env, jclass clazz, const char *name, const char *sig)) JNIWrapper("GetStaticMethodID"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, GetStaticMethodID__entry, env, clazz, name, sig); -#else /* USDT2 */ HOTSPOT_JNI_GETSTATICMETHODID_ENTRY(env, (char *) clazz, (char *) name, (char *)sig); -#endif /* USDT2 */ jmethodID ret = get_method_id(env, clazz, name, sig, true, thread); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetStaticMethodID__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_GETSTATICMETHODID_RETURN((uintptr_t) ret); -#endif /* USDT2 */ return ret; JNI_END @@ -1607,82 +1399,6 @@ JNI_END // Calling Methods // -#ifndef USDT2 -#define DEFINE_CALLMETHOD(ResultType, Result, Tag) \ -\ - DT_RETURN_MARK_DECL_FOR(Result, Call##Result##Method, ResultType);\ - DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodV, ResultType);\ - DT_RETURN_MARK_DECL_FOR(Result, Call##Result##MethodA, ResultType);\ -\ -JNI_ENTRY(ResultType, \ - jni_Call##Result##Method(JNIEnv *env, jobject obj, jmethodID methodID, ...)) \ - JNIWrapper("Call" XSTR(Result) "Method"); \ -\ - DTRACE_PROBE3(hotspot_jni, Call##Result##Method__entry, env, obj, methodID); \ - ResultType ret = 0;\ - DT_RETURN_MARK_FOR(Result, Call##Result##Method, ResultType, \ - (const ResultType&)ret);\ -\ - va_list args; \ - va_start(args, methodID); \ - JavaValue jvalue(Tag); \ - JNI_ArgumentPusherVaArg ap(methodID, args); \ - jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ - va_end(args); \ - ret = jvalue.get_##ResultType(); \ - return ret;\ -JNI_END \ -\ -\ -JNI_ENTRY(ResultType, \ - jni_Call##Result##MethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) \ - JNIWrapper("Call" XSTR(Result) "MethodV"); \ -\ - DTRACE_PROBE3(hotspot_jni, Call##Result##MethodV__entry, env, obj, methodID); \ - ResultType ret = 0;\ - DT_RETURN_MARK_FOR(Result, Call##Result##MethodV, ResultType, \ - (const ResultType&)ret);\ -\ - JavaValue jvalue(Tag); \ - JNI_ArgumentPusherVaArg ap(methodID, args); \ - jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ - ret = jvalue.get_##ResultType(); \ - return ret;\ -JNI_END \ -\ -\ -JNI_ENTRY(ResultType, \ - jni_Call##Result##MethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) \ - JNIWrapper("Call" XSTR(Result) "MethodA"); \ - DTRACE_PROBE3(hotspot_jni, Call##Result##MethodA__entry, env, obj, methodID); \ - ResultType ret = 0;\ - DT_RETURN_MARK_FOR(Result, Call##Result##MethodA, ResultType, \ - (const ResultType&)ret);\ -\ - JavaValue jvalue(Tag); \ - JNI_ArgumentPusherArray ap(methodID, args); \ - jni_invoke_nonstatic(env, &jvalue, obj, JNI_VIRTUAL, methodID, &ap, CHECK_0); \ - ret = jvalue.get_##ResultType(); \ - return ret;\ -JNI_END - -// the runtime type of subword integral basic types is integer -DEFINE_CALLMETHOD(jboolean, Boolean, T_BOOLEAN) -DEFINE_CALLMETHOD(jbyte, Byte, T_BYTE) -DEFINE_CALLMETHOD(jchar, Char, T_CHAR) -DEFINE_CALLMETHOD(jshort, Short, T_SHORT) - -DEFINE_CALLMETHOD(jobject, Object, T_OBJECT) -DEFINE_CALLMETHOD(jint, Int, T_INT) -DEFINE_CALLMETHOD(jlong, Long, T_LONG) -DEFINE_CALLMETHOD(jfloat, Float, T_FLOAT) -DEFINE_CALLMETHOD(jdouble, Double, T_DOUBLE) - -DT_VOID_RETURN_MARK_DECL(CallVoidMethod); -DT_VOID_RETURN_MARK_DECL(CallVoidMethodV); -DT_VOID_RETURN_MARK_DECL(CallVoidMethodA); - -#else /* USDT2 */ #define DEFINE_CALLMETHOD(ResultType, Result, Tag \ , EntryProbe, ReturnProbe) \ @@ -1849,15 +1565,10 @@ DT_VOID_RETURN_MARK_DECL(CallVoidMethod, HOTSPOT_JNI_CALLVOIDMETHOD_RETURN()); DT_VOID_RETURN_MARK_DECL(CallVoidMethodV, HOTSPOT_JNI_CALLVOIDMETHODV_RETURN()); DT_VOID_RETURN_MARK_DECL(CallVoidMethodA, HOTSPOT_JNI_CALLVOIDMETHODA_RETURN()); -#endif /* USDT2 */ JNI_ENTRY(void, jni_CallVoidMethod(JNIEnv *env, jobject obj, jmethodID methodID, ...)) JNIWrapper("CallVoidMethod"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, CallVoidMethod__entry, env, obj, methodID); -#else /* USDT2 */ HOTSPOT_JNI_CALLVOIDMETHOD_ENTRY(env, obj, (uintptr_t) methodID); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallVoidMethod); va_list args; @@ -1871,11 +1582,7 @@ JNI_END JNI_ENTRY(void, jni_CallVoidMethodV(JNIEnv *env, jobject obj, jmethodID methodID, va_list args)) JNIWrapper("CallVoidMethodV"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, CallVoidMethodV__entry, env, obj, methodID); -#else /* USDT2 */ HOTSPOT_JNI_CALLVOIDMETHODV_ENTRY(env, obj, (uintptr_t) methodID); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallVoidMethodV); JavaValue jvalue(T_VOID); @@ -1886,11 +1593,7 @@ JNI_END JNI_ENTRY(void, jni_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID, const jvalue *args)) JNIWrapper("CallVoidMethodA"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, CallVoidMethodA__entry, env, obj, methodID); -#else /* USDT2 */ HOTSPOT_JNI_CALLVOIDMETHODA_ENTRY(env, obj, (uintptr_t) methodID); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallVoidMethodA); JavaValue jvalue(T_VOID); @@ -1899,80 +1602,6 @@ JNI_ENTRY(void, jni_CallVoidMethodA(JNIEnv *env, jobject obj, jmethodID methodID JNI_END -#ifndef USDT2 -#define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag) \ -\ - DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##Method, ResultType);\ - DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodV, ResultType);\ - DT_RETURN_MARK_DECL_FOR(Result, CallNonvirtual##Result##MethodA, ResultType);\ -\ -JNI_ENTRY(ResultType, \ - jni_CallNonvirtual##Result##Method(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) \ - JNIWrapper("CallNonvitual" XSTR(Result) "Method"); \ -\ - DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##Method__entry, env, obj, cls, methodID);\ - ResultType ret;\ - DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##Method, ResultType, \ - (const ResultType&)ret);\ -\ - va_list args; \ - va_start(args, methodID); \ - JavaValue jvalue(Tag); \ - JNI_ArgumentPusherVaArg ap(methodID, args); \ - jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ - va_end(args); \ - ret = jvalue.get_##ResultType(); \ - return ret;\ -JNI_END \ -\ -JNI_ENTRY(ResultType, \ - jni_CallNonvirtual##Result##MethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) \ - JNIWrapper("CallNonvitual" XSTR(Result) "#MethodV"); \ - DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##MethodV__entry, env, obj, cls, methodID);\ - ResultType ret;\ - DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodV, ResultType, \ - (const ResultType&)ret);\ -\ - JavaValue jvalue(Tag); \ - JNI_ArgumentPusherVaArg ap(methodID, args); \ - jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ - ret = jvalue.get_##ResultType(); \ - return ret;\ -JNI_END \ -\ -JNI_ENTRY(ResultType, \ - jni_CallNonvirtual##Result##MethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) \ - JNIWrapper("CallNonvitual" XSTR(Result) "MethodA"); \ - DTRACE_PROBE4(hotspot_jni, CallNonvirtual##Result##MethodA__entry, env, obj, cls, methodID);\ - ResultType ret;\ - DT_RETURN_MARK_FOR(Result, CallNonvirtual##Result##MethodA, ResultType, \ - (const ResultType&)ret);\ -\ - JavaValue jvalue(Tag); \ - JNI_ArgumentPusherArray ap(methodID, args); \ - jni_invoke_nonstatic(env, &jvalue, obj, JNI_NONVIRTUAL, methodID, &ap, CHECK_0); \ - ret = jvalue.get_##ResultType(); \ - return ret;\ -JNI_END - -// the runtime type of subword integral basic types is integer -DEFINE_CALLNONVIRTUALMETHOD(jboolean, Boolean, T_BOOLEAN) -DEFINE_CALLNONVIRTUALMETHOD(jbyte, Byte, T_BYTE) -DEFINE_CALLNONVIRTUALMETHOD(jchar, Char, T_CHAR) -DEFINE_CALLNONVIRTUALMETHOD(jshort, Short, T_SHORT) - -DEFINE_CALLNONVIRTUALMETHOD(jobject, Object, T_OBJECT) -DEFINE_CALLNONVIRTUALMETHOD(jint, Int, T_INT) -DEFINE_CALLNONVIRTUALMETHOD(jlong, Long, T_LONG) -DEFINE_CALLNONVIRTUALMETHOD(jfloat, Float, T_FLOAT) -DEFINE_CALLNONVIRTUALMETHOD(jdouble, Double, T_DOUBLE) - - -DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethod); -DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodV); -DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodA); - -#else /* USDT2 */ #define DEFINE_CALLNONVIRTUALMETHOD(ResultType, Result, Tag \ , EntryProbe, ReturnProbe) \ @@ -2142,17 +1771,11 @@ DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodV , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_RETURN()); DT_VOID_RETURN_MARK_DECL(CallNonvirtualVoidMethodA , HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_RETURN()); -#endif /* USDT2 */ JNI_ENTRY(void, jni_CallNonvirtualVoidMethod(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, ...)) JNIWrapper("CallNonvirtualVoidMethod"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethod__entry, - env, obj, cls, methodID); -#else /* USDT2 */ HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHOD_ENTRY(env, obj, cls, (uintptr_t) methodID); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallNonvirtualVoidMethod); va_list args; @@ -2167,13 +1790,8 @@ JNI_END JNI_ENTRY(void, jni_CallNonvirtualVoidMethodV(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, va_list args)) JNIWrapper("CallNonvirtualVoidMethodV"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodV__entry, - env, obj, cls, methodID); -#else /* USDT2 */ HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODV_ENTRY( env, obj, cls, (uintptr_t) methodID); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodV); JavaValue jvalue(T_VOID); @@ -2184,13 +1802,8 @@ JNI_END JNI_ENTRY(void, jni_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass cls, jmethodID methodID, const jvalue *args)) JNIWrapper("CallNonvirtualVoidMethodA"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, CallNonvirtualVoidMethodA__entry, - env, obj, cls, methodID); -#else /* USDT2 */ HOTSPOT_JNI_CALLNONVIRTUALVOIDMETHODA_ENTRY( env, obj, cls, (uintptr_t) methodID); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallNonvirtualVoidMethodA); JavaValue jvalue(T_VOID); JNI_ArgumentPusherArray ap(methodID, args); @@ -2198,80 +1811,6 @@ JNI_ENTRY(void, jni_CallNonvirtualVoidMethodA(JNIEnv *env, jobject obj, jclass c JNI_END -#ifndef USDT2 -#define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag) \ -\ - DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##Method, ResultType);\ - DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodV, ResultType);\ - DT_RETURN_MARK_DECL_FOR(Result, CallStatic##Result##MethodA, ResultType);\ -\ -JNI_ENTRY(ResultType, \ - jni_CallStatic##Result##Method(JNIEnv *env, jclass cls, jmethodID methodID, ...)) \ - JNIWrapper("CallStatic" XSTR(Result) "Method"); \ -\ - DTRACE_PROBE3(hotspot_jni, CallStatic##Result##Method__entry, env, cls, methodID);\ - ResultType ret = 0;\ - DT_RETURN_MARK_FOR(Result, CallStatic##Result##Method, ResultType, \ - (const ResultType&)ret);\ -\ - va_list args; \ - va_start(args, methodID); \ - JavaValue jvalue(Tag); \ - JNI_ArgumentPusherVaArg ap(methodID, args); \ - jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ - va_end(args); \ - ret = jvalue.get_##ResultType(); \ - return ret;\ -JNI_END \ -\ -JNI_ENTRY(ResultType, \ - jni_CallStatic##Result##MethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) \ - JNIWrapper("CallStatic" XSTR(Result) "MethodV"); \ - DTRACE_PROBE3(hotspot_jni, CallStatic##Result##MethodV__entry, env, cls, methodID);\ - ResultType ret = 0;\ - DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodV, ResultType, \ - (const ResultType&)ret);\ -\ - JavaValue jvalue(Tag); \ - JNI_ArgumentPusherVaArg ap(methodID, args); \ - jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ - ret = jvalue.get_##ResultType(); \ - return ret;\ -JNI_END \ -\ -JNI_ENTRY(ResultType, \ - jni_CallStatic##Result##MethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) \ - JNIWrapper("CallStatic" XSTR(Result) "MethodA"); \ - DTRACE_PROBE3(hotspot_jni, CallStatic##Result##MethodA__entry, env, cls, methodID);\ - ResultType ret = 0;\ - DT_RETURN_MARK_FOR(Result, CallStatic##Result##MethodA, ResultType, \ - (const ResultType&)ret);\ -\ - JavaValue jvalue(Tag); \ - JNI_ArgumentPusherArray ap(methodID, args); \ - jni_invoke_static(env, &jvalue, NULL, JNI_STATIC, methodID, &ap, CHECK_0); \ - ret = jvalue.get_##ResultType(); \ - return ret;\ -JNI_END - -// the runtime type of subword integral basic types is integer -DEFINE_CALLSTATICMETHOD(jboolean, Boolean, T_BOOLEAN) -DEFINE_CALLSTATICMETHOD(jbyte, Byte, T_BYTE) -DEFINE_CALLSTATICMETHOD(jchar, Char, T_CHAR) -DEFINE_CALLSTATICMETHOD(jshort, Short, T_SHORT) - -DEFINE_CALLSTATICMETHOD(jobject, Object, T_OBJECT) -DEFINE_CALLSTATICMETHOD(jint, Int, T_INT) -DEFINE_CALLSTATICMETHOD(jlong, Long, T_LONG) -DEFINE_CALLSTATICMETHOD(jfloat, Float, T_FLOAT) -DEFINE_CALLSTATICMETHOD(jdouble, Double, T_DOUBLE) - - -DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethod); -DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodV); -DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodA); - -#else /* USDT2 */ #define DEFINE_CALLSTATICMETHOD(ResultType, Result, Tag \ , EntryProbe, ResultProbe) \ @@ -2445,15 +1984,10 @@ DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodV , HOTSPOT_JNI_CALLSTATICVOIDMETHODV_RETURN()); DT_VOID_RETURN_MARK_DECL(CallStaticVoidMethodA , HOTSPOT_JNI_CALLSTATICVOIDMETHODA_RETURN()); -#endif /* USDT2 */ JNI_ENTRY(void, jni_CallStaticVoidMethod(JNIEnv *env, jclass cls, jmethodID methodID, ...)) JNIWrapper("CallStaticVoidMethod"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethod__entry, env, cls, methodID); -#else /* USDT2 */ HOTSPOT_JNI_CALLSTATICVOIDMETHOD_ENTRY(env, cls, (uintptr_t) methodID); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallStaticVoidMethod); va_list args; @@ -2467,11 +2001,7 @@ JNI_END JNI_ENTRY(void, jni_CallStaticVoidMethodV(JNIEnv *env, jclass cls, jmethodID methodID, va_list args)) JNIWrapper("CallStaticVoidMethodV"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodV__entry, env, cls, methodID); -#else /* USDT2 */ HOTSPOT_JNI_CALLSTATICVOIDMETHODV_ENTRY(env, cls, (uintptr_t) methodID); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallStaticVoidMethodV); JavaValue jvalue(T_VOID); @@ -2482,11 +2012,7 @@ JNI_END JNI_ENTRY(void, jni_CallStaticVoidMethodA(JNIEnv *env, jclass cls, jmethodID methodID, const jvalue *args)) JNIWrapper("CallStaticVoidMethodA"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, CallStaticVoidMethodA__entry, env, cls, methodID); -#else /* USDT2 */ HOTSPOT_JNI_CALLSTATICVOIDMETHODA_ENTRY(env, cls, (uintptr_t) methodID); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(CallStaticVoidMethodA); JavaValue jvalue(T_VOID); @@ -2500,21 +2026,13 @@ JNI_END // -#ifndef USDT2 -DT_RETURN_MARK_DECL(GetFieldID, jfieldID); -#else /* USDT2 */ DT_RETURN_MARK_DECL(GetFieldID, jfieldID , HOTSPOT_JNI_GETFIELDID_RETURN((uintptr_t)_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jfieldID, jni_GetFieldID(JNIEnv *env, jclass clazz, const char *name, const char *sig)) JNIWrapper("GetFieldID"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, GetFieldID__entry, env, clazz, name, sig); -#else /* USDT2 */ HOTSPOT_JNI_GETFIELDID_ENTRY(env, clazz, (char *) name, (char *) sig); -#endif /* USDT2 */ jfieldID ret = 0; DT_RETURN_MARK(GetFieldID, jfieldID, (const jfieldID&)ret); @@ -2546,11 +2064,7 @@ JNI_END JNI_ENTRY(jobject, jni_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID)) JNIWrapper("GetObjectField"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, GetObjectField__entry, env, obj, fieldID); -#else /* USDT2 */ HOTSPOT_JNI_GETOBJECTFIELD_ENTRY(env, obj, (uintptr_t) fieldID); -#endif /* USDT2 */ oop o = JNIHandles::resolve_non_null(obj); Klass* k = o->klass(); int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); @@ -2580,50 +2094,11 @@ JNI_ENTRY(jobject, jni_GetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID } } #endif // INCLUDE_ALL_GCS -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetObjectField__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_GETOBJECTFIELD_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END -#ifndef USDT2 -#define DEFINE_GETFIELD(Return,Fieldname,Result) \ -\ - DT_RETURN_MARK_DECL_FOR(Result, Get##Result##Field, Return);\ -\ -JNI_QUICK_ENTRY(Return, jni_Get##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID)) \ - JNIWrapper("Get" XSTR(Result) "Field"); \ -\ - DTRACE_PROBE3(hotspot_jni, Get##Result##Field__entry, env, obj, fieldID);\ - Return ret = 0;\ - DT_RETURN_MARK_FOR(Result, Get##Result##Field, Return, (const Return&)ret);\ -\ - oop o = JNIHandles::resolve_non_null(obj); \ - Klass* k = o->klass(); \ - int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ - /* Keep JVMTI addition small and only check enabled flag here. */ \ - /* jni_GetField_probe_nh() assumes that is not okay to create handles */ \ - /* and creates a ResetNoHandleMark. */ \ - if (JvmtiExport::should_post_field_access()) { \ - o = JvmtiExport::jni_GetField_probe_nh(thread, obj, o, k, fieldID, false); \ - } \ - ret = o->Fieldname##_field(offset); \ - return ret; \ -JNI_END - -DEFINE_GETFIELD(jboolean, bool, Boolean) -DEFINE_GETFIELD(jbyte, byte, Byte) -DEFINE_GETFIELD(jchar, char, Char) -DEFINE_GETFIELD(jshort, short, Short) -DEFINE_GETFIELD(jint, int, Int) -DEFINE_GETFIELD(jlong, long, Long) -DEFINE_GETFIELD(jfloat, float, Float) -DEFINE_GETFIELD(jdouble, double, Double) - -#else /* USDT2 */ #define DEFINE_GETFIELD(Return,Fieldname,Result \ , EntryProbe, ReturnProbe) \ @@ -2676,7 +2151,6 @@ DEFINE_GETFIELD(jfloat, float, Float DEFINE_GETFIELD(jdouble, double, Double , HOTSPOT_JNI_GETDOUBLEFIELD_ENTRY(env, obj, (uintptr_t)fieldID), HOTSPOT_JNI_GETDOUBLEFIELD_RETURN()) -#endif /* USDT2 */ address jni_GetBooleanField_addr() { return (address)jni_GetBooleanField; @@ -2705,11 +2179,7 @@ address jni_GetDoubleField_addr() { JNI_QUICK_ENTRY(void, jni_SetObjectField(JNIEnv *env, jobject obj, jfieldID fieldID, jobject value)) JNIWrapper("SetObjectField"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, SetObjectField__entry, env, obj, fieldID, value); -#else /* USDT2 */ HOTSPOT_JNI_SETOBJECTFIELD_ENTRY(env, obj, (uintptr_t) fieldID, value); -#endif /* USDT2 */ oop o = JNIHandles::resolve_non_null(obj); Klass* k = o->klass(); int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); @@ -2722,48 +2192,9 @@ JNI_QUICK_ENTRY(void, jni_SetObjectField(JNIEnv *env, jobject obj, jfieldID fiel o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, 'L', (jvalue *)&field_value); } o->obj_field_put(offset, JNIHandles::resolve(value)); -#ifndef USDT2 - DTRACE_PROBE(hotspot_jni, SetObjectField__return); -#else /* USDT2 */ HOTSPOT_JNI_SETOBJECTFIELD_RETURN(); -#endif /* USDT2 */ JNI_END -#ifndef USDT2 -#define DEFINE_SETFIELD(Argument,Fieldname,Result,SigType,unionType) \ -\ -JNI_QUICK_ENTRY(void, jni_Set##Result##Field(JNIEnv *env, jobject obj, jfieldID fieldID, Argument value)) \ - JNIWrapper("Set" XSTR(Result) "Field"); \ -\ - FP_SELECT_##Result( \ - DTRACE_PROBE4(hotspot_jni, Set##Result##Field__entry, env, obj, fieldID, value), \ - DTRACE_PROBE3(hotspot_jni, Set##Result##Field__entry, env, obj, fieldID)); \ -\ - oop o = JNIHandles::resolve_non_null(obj); \ - Klass* k = o->klass(); \ - int offset = jfieldIDWorkaround::from_instance_jfieldID(k, fieldID); \ - /* Keep JVMTI addition small and only check enabled flag here. */ \ - /* jni_SetField_probe_nh() assumes that is not okay to create handles */ \ - /* and creates a ResetNoHandleMark. */ \ - if (JvmtiExport::should_post_field_modification()) { \ - jvalue field_value; \ - field_value.unionType = value; \ - o = JvmtiExport::jni_SetField_probe_nh(thread, obj, o, k, fieldID, false, SigType, (jvalue *)&field_value); \ - } \ - o->Fieldname##_field_put(offset, value); \ - DTRACE_PROBE(hotspot_jni, Set##Result##Field__return);\ -JNI_END - -DEFINE_SETFIELD(jboolean, bool, Boolean, 'Z', z) -DEFINE_SETFIELD(jbyte, byte, Byte, 'B', b) -DEFINE_SETFIELD(jchar, char, Char, 'C', c) -DEFINE_SETFIELD(jshort, short, Short, 'S', s) -DEFINE_SETFIELD(jint, int, Int, 'I', i) -DEFINE_SETFIELD(jlong, long, Long, 'J', j) -DEFINE_SETFIELD(jfloat, float, Float, 'F', f) -DEFINE_SETFIELD(jdouble, double, Double, 'D', d) - -#else /* USDT2 */ #define DEFINE_SETFIELD(Argument,Fieldname,Result,SigType,unionType \ , EntryProbe, ReturnProbe) \ @@ -2813,23 +2244,13 @@ DEFINE_SETFIELD(jfloat, float, Float, 'F', f DEFINE_SETFIELD(jdouble, double, Double, 'D', d , HOTSPOT_JNI_SETDOUBLEFIELD_ENTRY(env, obj, (uintptr_t)fieldID), HOTSPOT_JNI_SETDOUBLEFIELD_RETURN()) -#endif /* USDT2 */ -#ifndef USDT2 -DT_RETURN_MARK_DECL(ToReflectedField, jobject); -#else /* USDT2 */ DT_RETURN_MARK_DECL(ToReflectedField, jobject , HOTSPOT_JNI_TOREFLECTEDFIELD_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jobject, jni_ToReflectedField(JNIEnv *env, jclass cls, jfieldID fieldID, jboolean isStatic)) JNIWrapper("ToReflectedField"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, ToReflectedField__entry, - env, cls, fieldID, isStatic); -#else /* USDT2 */ HOTSPOT_JNI_TOREFLECTEDFIELD_ENTRY(env, cls, (uintptr_t) fieldID, isStatic); -#endif /* USDT2 */ jobject ret = NULL; DT_RETURN_MARK(ToReflectedField, jobject, (const jobject&)ret); @@ -2859,21 +2280,13 @@ JNI_END // // Accessing Static Fields // -#ifndef USDT2 -DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID); -#else /* USDT2 */ DT_RETURN_MARK_DECL(GetStaticFieldID, jfieldID , HOTSPOT_JNI_GETSTATICFIELDID_RETURN((uintptr_t)_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jfieldID, jni_GetStaticFieldID(JNIEnv *env, jclass clazz, const char *name, const char *sig)) JNIWrapper("GetStaticFieldID"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, GetStaticFieldID__entry, env, clazz, name, sig); -#else /* USDT2 */ HOTSPOT_JNI_GETSTATICFIELDID_ENTRY(env, clazz, (char *) name, (char *) sig); -#endif /* USDT2 */ jfieldID ret = NULL; DT_RETURN_MARK(GetStaticFieldID, jfieldID, (const jfieldID&)ret); @@ -2909,11 +2322,7 @@ JNI_END JNI_ENTRY(jobject, jni_GetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID)) JNIWrapper("GetStaticObjectField"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, GetStaticObjectField__entry, env, clazz, fieldID); -#else /* USDT2 */ HOTSPOT_JNI_GETSTATICOBJECTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID); -#endif /* USDT2 */ #if INCLUDE_JNI_CHECK DEBUG_ONLY(Klass* param_k = jniCheck::validate_class(thread, clazz);) #endif // INCLUDE_JNI_CHECK @@ -2925,46 +2334,10 @@ JNI_ENTRY(jobject, jni_GetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); } jobject ret = JNIHandles::make_local(id->holder()->java_mirror()->obj_field(id->offset())); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetStaticObjectField__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_GETSTATICOBJECTFIELD_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END -#ifndef USDT2 -#define DEFINE_GETSTATICFIELD(Return,Fieldname,Result) \ -\ - DT_RETURN_MARK_DECL_FOR(Result, GetStatic##Result##Field, Return);\ -\ -JNI_ENTRY(Return, jni_GetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID)) \ - JNIWrapper("GetStatic" XSTR(Result) "Field"); \ - DTRACE_PROBE3(hotspot_jni, GetStatic##Result##Field__entry, env, clazz, fieldID);\ - Return ret = 0;\ - DT_RETURN_MARK_FOR(Result, GetStatic##Result##Field, Return, \ - (const Return&)ret);\ - JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ - assert(id->is_static_field_id(), "invalid static field id"); \ - /* Keep JVMTI addition small and only check enabled flag here. */ \ - /* jni_GetField_probe() assumes that is okay to create handles. */ \ - if (JvmtiExport::should_post_field_access()) { \ - JvmtiExport::jni_GetField_probe(thread, NULL, NULL, id->holder(), fieldID, true); \ - } \ - ret = id->holder()->java_mirror()-> Fieldname##_field (id->offset()); \ - return ret;\ -JNI_END - -DEFINE_GETSTATICFIELD(jboolean, bool, Boolean) -DEFINE_GETSTATICFIELD(jbyte, byte, Byte) -DEFINE_GETSTATICFIELD(jchar, char, Char) -DEFINE_GETSTATICFIELD(jshort, short, Short) -DEFINE_GETSTATICFIELD(jint, int, Int) -DEFINE_GETSTATICFIELD(jlong, long, Long) -DEFINE_GETSTATICFIELD(jfloat, float, Float) -DEFINE_GETSTATICFIELD(jdouble, double, Double) - -#else /* USDT2 */ #define DEFINE_GETSTATICFIELD(Return,Fieldname,Result \ , EntryProbe, ReturnProbe) \ @@ -3006,15 +2379,10 @@ DEFINE_GETSTATICFIELD(jfloat, float, Float , HOTSPOT_JNI_GETSTATICFLOATFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICFLOATFIELD_RETURN() ) DEFINE_GETSTATICFIELD(jdouble, double, Double , HOTSPOT_JNI_GETSTATICDOUBLEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_GETSTATICDOUBLEFIELD_RETURN() ) -#endif /* USDT2 */ JNI_ENTRY(void, jni_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fieldID, jobject value)) JNIWrapper("SetStaticObjectField"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, SetStaticObjectField__entry, env, clazz, fieldID, value); -#else /* USDT2 */ HOTSPOT_JNI_SETSTATICOBJECTFIELD_ENTRY(env, clazz, (uintptr_t) fieldID, value); -#endif /* USDT2 */ JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); assert(id->is_static_field_id(), "invalid static field id"); // Keep JVMTI addition small and only check enabled flag here. @@ -3025,46 +2393,10 @@ JNI_ENTRY(void, jni_SetStaticObjectField(JNIEnv *env, jclass clazz, jfieldID fie JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, 'L', (jvalue *)&field_value); } id->holder()->java_mirror()->obj_field_put(id->offset(), JNIHandles::resolve(value)); -#ifndef USDT2 - DTRACE_PROBE(hotspot_jni, SetStaticObjectField__return); -#else /* USDT2 */ HOTSPOT_JNI_SETSTATICOBJECTFIELD_RETURN(); -#endif /* USDT2 */ JNI_END -#ifndef USDT2 -#define DEFINE_SETSTATICFIELD(Argument,Fieldname,Result,SigType,unionType) \ -\ -JNI_ENTRY(void, jni_SetStatic##Result##Field(JNIEnv *env, jclass clazz, jfieldID fieldID, Argument value)) \ - JNIWrapper("SetStatic" XSTR(Result) "Field"); \ - FP_SELECT_##Result( \ - DTRACE_PROBE4(hotspot_jni, SetStatic##Result##Field__entry, env, clazz, fieldID, value), \ - DTRACE_PROBE3(hotspot_jni, SetStatic##Result##Field__entry, env, clazz, fieldID)); \ -\ - JNIid* id = jfieldIDWorkaround::from_static_jfieldID(fieldID); \ - assert(id->is_static_field_id(), "invalid static field id"); \ - /* Keep JVMTI addition small and only check enabled flag here. */ \ - /* jni_SetField_probe() assumes that is okay to create handles. */ \ - if (JvmtiExport::should_post_field_modification()) { \ - jvalue field_value; \ - field_value.unionType = value; \ - JvmtiExport::jni_SetField_probe(thread, NULL, NULL, id->holder(), fieldID, true, SigType, (jvalue *)&field_value); \ - } \ - id->holder()->java_mirror()-> Fieldname##_field_put (id->offset(), value); \ - DTRACE_PROBE(hotspot_jni, SetStatic##Result##Field__return);\ -JNI_END - -DEFINE_SETSTATICFIELD(jboolean, bool, Boolean, 'Z', z) -DEFINE_SETSTATICFIELD(jbyte, byte, Byte, 'B', b) -DEFINE_SETSTATICFIELD(jchar, char, Char, 'C', c) -DEFINE_SETSTATICFIELD(jshort, short, Short, 'S', s) -DEFINE_SETSTATICFIELD(jint, int, Int, 'I', i) -DEFINE_SETSTATICFIELD(jlong, long, Long, 'J', j) -DEFINE_SETSTATICFIELD(jfloat, float, Float, 'F', f) -DEFINE_SETSTATICFIELD(jdouble, double, Double, 'D', d) - -#else /* USDT2 */ #define DEFINE_SETSTATICFIELD(Argument,Fieldname,Result,SigType,unionType \ , EntryProbe, ReturnProbe) \ @@ -3111,7 +2443,6 @@ DEFINE_SETSTATICFIELD(jfloat, float, Float, 'F', f DEFINE_SETSTATICFIELD(jdouble, double, Double, 'D', d , HOTSPOT_JNI_SETSTATICDOUBLEFIELD_ENTRY(env, clazz, (uintptr_t) fieldID), HOTSPOT_JNI_SETSTATICDOUBLEFIELD_RETURN()) -#endif /* USDT2 */ // // String Operations @@ -3119,20 +2450,12 @@ DEFINE_SETSTATICFIELD(jdouble, double, Double, 'D', d // Unicode Interface -#ifndef USDT2 -DT_RETURN_MARK_DECL(NewString, jstring); -#else /* USDT2 */ DT_RETURN_MARK_DECL(NewString, jstring , HOTSPOT_JNI_NEWSTRING_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jstring, jni_NewString(JNIEnv *env, const jchar *unicodeChars, jsize len)) JNIWrapper("NewString"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, NewString__entry, env, unicodeChars, len); -#else /* USDT2 */ HOTSPOT_JNI_NEWSTRING_ENTRY(env, (uint16_t *) unicodeChars, len); -#endif /* USDT2 */ jstring ret = NULL; DT_RETURN_MARK(NewString, jstring, (const jstring&)ret); oop string=java_lang_String::create_oop_from_unicode((jchar*) unicodeChars, len, CHECK_NULL); @@ -3143,21 +2466,13 @@ JNI_END JNI_QUICK_ENTRY(jsize, jni_GetStringLength(JNIEnv *env, jstring string)) JNIWrapper("GetStringLength"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, GetStringLength__entry, env, string); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGLENGTH_ENTRY(env, string); -#endif /* USDT2 */ jsize ret = 0; oop s = JNIHandles::resolve_non_null(string); if (java_lang_String::value(s) != NULL) { ret = java_lang_String::length(s); } -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetStringLength__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGLENGTH_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END @@ -3165,11 +2480,7 @@ JNI_END JNI_QUICK_ENTRY(const jchar*, jni_GetStringChars( JNIEnv *env, jstring string, jboolean *isCopy)) JNIWrapper("GetStringChars"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, GetStringChars__entry, env, string, isCopy); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGCHARS_ENTRY(env, string, (uintptr_t *) isCopy); -#endif /* USDT2 */ jchar* buf = NULL; oop s = JNIHandles::resolve_non_null(string); typeArrayOop s_value = java_lang_String::value(s); @@ -3189,52 +2500,32 @@ JNI_QUICK_ENTRY(const jchar*, jni_GetStringChars( } } } -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetStringChars__return, buf); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGCHARS_RETURN(buf); -#endif /* USDT2 */ return buf; JNI_END JNI_QUICK_ENTRY(void, jni_ReleaseStringChars(JNIEnv *env, jstring str, const jchar *chars)) JNIWrapper("ReleaseStringChars"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, ReleaseStringChars__entry, env, str, chars); -#else /* USDT2 */ HOTSPOT_JNI_RELEASESTRINGCHARS_ENTRY(env, str, (uint16_t *) chars); -#endif /* USDT2 */ //%note jni_6 if (chars != NULL) { // Since String objects are supposed to be immutable, don't copy any // new data back. A bad user will have to go after the char array. FreeHeap((void*) chars); } -#ifndef USDT2 - DTRACE_PROBE(hotspot_jni, ReleaseStringChars__return); -#else /* USDT2 */ HOTSPOT_JNI_RELEASESTRINGCHARS_RETURN(); -#endif /* USDT2 */ JNI_END // UTF Interface -#ifndef USDT2 -DT_RETURN_MARK_DECL(NewStringUTF, jstring); -#else /* USDT2 */ DT_RETURN_MARK_DECL(NewStringUTF, jstring , HOTSPOT_JNI_NEWSTRINGUTF_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jstring, jni_NewStringUTF(JNIEnv *env, const char *bytes)) JNIWrapper("NewStringUTF"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, NewStringUTF__entry, env, bytes); -#else /* USDT2 */ HOTSPOT_JNI_NEWSTRINGUTF_ENTRY(env, (char *) bytes); -#endif /* USDT2 */ jstring ret; DT_RETURN_MARK(NewStringUTF, jstring, (const jstring&)ret); @@ -3246,32 +2537,20 @@ JNI_END JNI_ENTRY(jsize, jni_GetStringUTFLength(JNIEnv *env, jstring string)) JNIWrapper("GetStringUTFLength"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, GetStringUTFLength__entry, env, string); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGUTFLENGTH_ENTRY(env, string); -#endif /* USDT2 */ jsize ret = 0; oop java_string = JNIHandles::resolve_non_null(string); if (java_lang_String::value(java_string) != NULL) { ret = java_lang_String::utf8_length(java_string); } -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetStringUTFLength__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGUTFLENGTH_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY(const char*, jni_GetStringUTFChars(JNIEnv *env, jstring string, jboolean *isCopy)) JNIWrapper("GetStringUTFChars"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, GetStringUTFChars__entry, env, string, isCopy); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGUTFCHARS_ENTRY(env, string, (uintptr_t *) isCopy); -#endif /* USDT2 */ char* result = NULL; oop java_string = JNIHandles::resolve_non_null(string); if (java_lang_String::value(java_string) != NULL) { @@ -3285,48 +2564,28 @@ JNI_ENTRY(const char*, jni_GetStringUTFChars(JNIEnv *env, jstring string, jboole } } } -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetStringUTFChars__return, result); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGUTFCHARS_RETURN(result); -#endif /* USDT2 */ return result; JNI_END JNI_LEAF(void, jni_ReleaseStringUTFChars(JNIEnv *env, jstring str, const char *chars)) JNIWrapper("ReleaseStringUTFChars"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, ReleaseStringUTFChars__entry, env, str, chars); -#else /* USDT2 */ HOTSPOT_JNI_RELEASESTRINGUTFCHARS_ENTRY(env, str, (char *) chars); -#endif /* USDT2 */ if (chars != NULL) { FreeHeap((char*) chars); } -#ifndef USDT2 - DTRACE_PROBE(hotspot_jni, ReleaseStringUTFChars__return); -#else /* USDT2 */ HOTSPOT_JNI_RELEASESTRINGUTFCHARS_RETURN(); -#endif /* USDT2 */ JNI_END JNI_QUICK_ENTRY(jsize, jni_GetArrayLength(JNIEnv *env, jarray array)) JNIWrapper("GetArrayLength"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, GetArrayLength__entry, env, array); -#else /* USDT2 */ HOTSPOT_JNI_GETARRAYLENGTH_ENTRY(env, array); -#endif /* USDT2 */ arrayOop a = arrayOop(JNIHandles::resolve_non_null(array)); assert(a->is_array(), "must be array"); jsize ret = a->length(); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetArrayLength__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_GETARRAYLENGTH_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END @@ -3335,20 +2594,12 @@ JNI_END // Object Array Operations // -#ifndef USDT2 -DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray); -#else /* USDT2 */ DT_RETURN_MARK_DECL(NewObjectArray, jobjectArray , HOTSPOT_JNI_NEWOBJECTARRAY_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jobjectArray, jni_NewObjectArray(JNIEnv *env, jsize length, jclass elementClass, jobject initialElement)) JNIWrapper("NewObjectArray"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, NewObjectArray__entry, env, length, elementClass, initialElement); -#else /* USDT2 */ HOTSPOT_JNI_NEWOBJECTARRAY_ENTRY(env, length, elementClass, initialElement); -#endif /* USDT2 */ jobjectArray ret = NULL; DT_RETURN_MARK(NewObjectArray, jobjectArray, (const jobjectArray&)ret); KlassHandle ek(THREAD, java_lang_Class::as_Klass(JNIHandles::resolve_non_null(elementClass))); @@ -3366,20 +2617,12 @@ JNI_ENTRY(jobjectArray, jni_NewObjectArray(JNIEnv *env, jsize length, jclass ele return ret; JNI_END -#ifndef USDT2 -DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject); -#else /* USDT2 */ DT_RETURN_MARK_DECL(GetObjectArrayElement, jobject , HOTSPOT_JNI_GETOBJECTARRAYELEMENT_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jobject, jni_GetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index)) JNIWrapper("GetObjectArrayElement"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, GetObjectArrayElement__entry, env, array, index); -#else /* USDT2 */ HOTSPOT_JNI_GETOBJECTARRAYELEMENT_ENTRY(env, array, index); -#endif /* USDT2 */ jobject ret = NULL; DT_RETURN_MARK(GetObjectArrayElement, jobject, (const jobject&)ret); objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); @@ -3393,20 +2636,12 @@ JNI_ENTRY(jobject, jni_GetObjectArrayElement(JNIEnv *env, jobjectArray array, js } JNI_END -#ifndef USDT2 -DT_VOID_RETURN_MARK_DECL(SetObjectArrayElement); -#else /* USDT2 */ DT_VOID_RETURN_MARK_DECL(SetObjectArrayElement , HOTSPOT_JNI_SETOBJECTARRAYELEMENT_RETURN()); -#endif /* USDT2 */ JNI_ENTRY(void, jni_SetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize index, jobject value)) JNIWrapper("SetObjectArrayElement"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, SetObjectArrayElement__entry, env, array, index, value); -#else /* USDT2 */ HOTSPOT_JNI_SETOBJECTARRAYELEMENT_ENTRY(env, array, index, value); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(SetObjectArrayElement); objArrayOop a = objArrayOop(JNIHandles::resolve_non_null(array)); @@ -3425,33 +2660,6 @@ JNI_ENTRY(void, jni_SetObjectArrayElement(JNIEnv *env, jobjectArray array, jsize JNI_END -#ifndef USDT2 -#define DEFINE_NEWSCALARARRAY(Return,Allocator,Result) \ -\ - DT_RETURN_MARK_DECL(New##Result##Array, Return); \ -\ -JNI_ENTRY(Return, \ - jni_New##Result##Array(JNIEnv *env, jsize len)) \ - JNIWrapper("New" XSTR(Result) "Array"); \ - DTRACE_PROBE2(hotspot_jni, New##Result##Array__entry, env, len);\ - Return ret = NULL;\ - DT_RETURN_MARK(New##Result##Array, Return, (const Return&)ret);\ -\ - oop obj= oopFactory::Allocator(len, CHECK_0); \ - ret = (Return) JNIHandles::make_local(env, obj); \ - return ret;\ -JNI_END - -DEFINE_NEWSCALARARRAY(jbooleanArray, new_boolArray, Boolean) -DEFINE_NEWSCALARARRAY(jbyteArray, new_byteArray, Byte) -DEFINE_NEWSCALARARRAY(jshortArray, new_shortArray, Short) -DEFINE_NEWSCALARARRAY(jcharArray, new_charArray, Char) -DEFINE_NEWSCALARARRAY(jintArray, new_intArray, Int) -DEFINE_NEWSCALARARRAY(jlongArray, new_longArray, Long) -DEFINE_NEWSCALARARRAY(jfloatArray, new_singleArray, Float) -DEFINE_NEWSCALARARRAY(jdoubleArray, new_doubleArray, Double) - -#else /* USDT2 */ #define DEFINE_NEWSCALARARRAY(Return,Allocator,Result \ ,EntryProbe,ReturnProbe) \ @@ -3495,7 +2703,6 @@ DEFINE_NEWSCALARARRAY(jfloatArray, new_singleArray, Float, DEFINE_NEWSCALARARRAY(jdoubleArray, new_doubleArray, Double, HOTSPOT_JNI_NEWDOUBLEARRAY_ENTRY(env, len), HOTSPOT_JNI_NEWDOUBLEARRAY_RETURN(_ret_ref)) -#endif /* USDT2 */ // Return an address which will fault if the caller writes to it. @@ -3513,47 +2720,6 @@ static char* get_bad_address() { } -#ifndef USDT2 -#define DEFINE_GETSCALARARRAYELEMENTS(ElementTag,ElementType,Result, Tag) \ -\ -JNI_QUICK_ENTRY(ElementType*, \ - jni_Get##Result##ArrayElements(JNIEnv *env, ElementType##Array array, jboolean *isCopy)) \ - JNIWrapper("Get" XSTR(Result) "ArrayElements"); \ - DTRACE_PROBE3(hotspot_jni, Get##Result##ArrayElements__entry, env, array, isCopy);\ - /* allocate an chunk of memory in c land */ \ - typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ - ElementType* result; \ - int len = a->length(); \ - if (len == 0) { \ - /* Empty array: legal but useless, can't return NULL. \ - * Return a pointer to something useless. \ - * Avoid asserts in typeArrayOop. */ \ - result = (ElementType*)get_bad_address(); \ - } else { \ - /* JNI Specification states return NULL on OOM */ \ - result = NEW_C_HEAP_ARRAY_RETURN_NULL(ElementType, len, mtInternal); \ - if (result != NULL) { \ - /* copy the array to the c chunk */ \ - memcpy(result, a->Tag##_at_addr(0), sizeof(ElementType)*len); \ - if (isCopy) { \ - *isCopy = JNI_TRUE; \ - } \ - } \ - } \ - DTRACE_PROBE1(hotspot_jni, Get##Result##ArrayElements__return, result);\ - return result; \ -JNI_END - -DEFINE_GETSCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool) -DEFINE_GETSCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte) -DEFINE_GETSCALARARRAYELEMENTS(T_SHORT, jshort, Short, short) -DEFINE_GETSCALARARRAYELEMENTS(T_CHAR, jchar, Char, char) -DEFINE_GETSCALARARRAYELEMENTS(T_INT, jint, Int, int) -DEFINE_GETSCALARARRAYELEMENTS(T_LONG, jlong, Long, long) -DEFINE_GETSCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float) -DEFINE_GETSCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double) - -#else /* USDT2 */ #define DEFINE_GETSCALARARRAYELEMENTS(ElementTag,ElementType,Result, Tag \ , EntryProbe, ReturnProbe) \ @@ -3611,39 +2777,7 @@ DEFINE_GETSCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float DEFINE_GETSCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double , HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_ENTRY(env, array, (uintptr_t *) isCopy), HOTSPOT_JNI_GETDOUBLEARRAYELEMENTS_RETURN(result)) -#endif /* USDT2 */ -#ifndef USDT2 -#define DEFINE_RELEASESCALARARRAYELEMENTS(ElementTag,ElementType,Result,Tag) \ -\ -JNI_QUICK_ENTRY(void, \ - jni_Release##Result##ArrayElements(JNIEnv *env, ElementType##Array array, \ - ElementType *buf, jint mode)) \ - JNIWrapper("Release" XSTR(Result) "ArrayElements"); \ - DTRACE_PROBE4(hotspot_jni, Release##Result##ArrayElements__entry, env, array, buf, mode);\ - typeArrayOop a = typeArrayOop(JNIHandles::resolve_non_null(array)); \ - int len = a->length(); \ - if (len != 0) { /* Empty array: nothing to free or copy. */ \ - if ((mode == 0) || (mode == JNI_COMMIT)) { \ - memcpy(a->Tag##_at_addr(0), buf, sizeof(ElementType)*len); \ - } \ - if ((mode == 0) || (mode == JNI_ABORT)) { \ - FreeHeap(buf); \ - } \ - } \ - DTRACE_PROBE(hotspot_jni, Release##Result##ArrayElements__return);\ -JNI_END - -DEFINE_RELEASESCALARARRAYELEMENTS(T_BOOLEAN, jboolean, Boolean, bool) -DEFINE_RELEASESCALARARRAYELEMENTS(T_BYTE, jbyte, Byte, byte) -DEFINE_RELEASESCALARARRAYELEMENTS(T_SHORT, jshort, Short, short) -DEFINE_RELEASESCALARARRAYELEMENTS(T_CHAR, jchar, Char, char) -DEFINE_RELEASESCALARARRAYELEMENTS(T_INT, jint, Int, int) -DEFINE_RELEASESCALARARRAYELEMENTS(T_LONG, jlong, Long, long) -DEFINE_RELEASESCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float) -DEFINE_RELEASESCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double) - -#else /* USDT2 */ #define DEFINE_RELEASESCALARARRAYELEMENTS(ElementTag,ElementType,Result,Tag \ , EntryProbe, ReturnProbe);\ @@ -3690,41 +2824,7 @@ DEFINE_RELEASESCALARARRAYELEMENTS(T_FLOAT, jfloat, Float, float DEFINE_RELEASESCALARARRAYELEMENTS(T_DOUBLE, jdouble, Double, double , HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_ENTRY(env, array, (double *) buf, mode), HOTSPOT_JNI_RELEASEDOUBLEARRAYELEMENTS_RETURN()) -#endif /* USDT2 */ -#ifndef USDT2 -#define DEFINE_GETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \ - DT_VOID_RETURN_MARK_DECL(Get##Result##ArrayRegion);\ -\ -JNI_ENTRY(void, \ -jni_Get##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ - jsize len, ElementType *buf)) \ - JNIWrapper("Get" XSTR(Result) "ArrayRegion"); \ - DTRACE_PROBE5(hotspot_jni, Get##Result##ArrayRegion__entry, env, array, start, len, buf);\ - DT_VOID_RETURN_MARK(Get##Result##ArrayRegion); \ - typeArrayOop src = typeArrayOop(JNIHandles::resolve_non_null(array)); \ - if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)src->length())) { \ - THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ - } else { \ - if (len > 0) { \ - int sc = TypeArrayKlass::cast(src->klass())->log2_element_size(); \ - memcpy((u_char*) buf, \ - (u_char*) src->Tag##_at_addr(start), \ - len << sc); \ - } \ - } \ -JNI_END - -DEFINE_GETSCALARARRAYREGION(T_BOOLEAN, jboolean,Boolean, bool) -DEFINE_GETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte) -DEFINE_GETSCALARARRAYREGION(T_SHORT, jshort, Short, short) -DEFINE_GETSCALARARRAYREGION(T_CHAR, jchar, Char, char) -DEFINE_GETSCALARARRAYREGION(T_INT, jint, Int, int) -DEFINE_GETSCALARARRAYREGION(T_LONG, jlong, Long, long) -DEFINE_GETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float) -DEFINE_GETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double) - -#else /* USDT2 */ #define DEFINE_GETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag \ , EntryProbe, ReturnProbe); \ @@ -3774,41 +2874,7 @@ DEFINE_GETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float DEFINE_GETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double , HOTSPOT_JNI_GETDOUBLEARRAYREGION_ENTRY(env, array, start, len, (double *) buf), HOTSPOT_JNI_GETDOUBLEARRAYREGION_RETURN()); -#endif /* USDT2 */ -#ifndef USDT2 -#define DEFINE_SETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag) \ - DT_VOID_RETURN_MARK_DECL(Set##Result##ArrayRegion);\ -\ -JNI_ENTRY(void, \ -jni_Set##Result##ArrayRegion(JNIEnv *env, ElementType##Array array, jsize start, \ - jsize len, const ElementType *buf)) \ - JNIWrapper("Set" XSTR(Result) "ArrayRegion"); \ - DTRACE_PROBE5(hotspot_jni, Set##Result##ArrayRegion__entry, env, array, start, len, buf);\ - DT_VOID_RETURN_MARK(Set##Result##ArrayRegion); \ - typeArrayOop dst = typeArrayOop(JNIHandles::resolve_non_null(array)); \ - if (start < 0 || len < 0 || ((unsigned int)start + (unsigned int)len > (unsigned int)dst->length())) { \ - THROW(vmSymbols::java_lang_ArrayIndexOutOfBoundsException()); \ - } else { \ - if (len > 0) { \ - int sc = TypeArrayKlass::cast(dst->klass())->log2_element_size(); \ - memcpy((u_char*) dst->Tag##_at_addr(start), \ - (u_char*) buf, \ - len << sc); \ - } \ - } \ -JNI_END - -DEFINE_SETSCALARARRAYREGION(T_BOOLEAN, jboolean, Boolean, bool) -DEFINE_SETSCALARARRAYREGION(T_BYTE, jbyte, Byte, byte) -DEFINE_SETSCALARARRAYREGION(T_SHORT, jshort, Short, short) -DEFINE_SETSCALARARRAYREGION(T_CHAR, jchar, Char, char) -DEFINE_SETSCALARARRAYREGION(T_INT, jint, Int, int) -DEFINE_SETSCALARARRAYREGION(T_LONG, jlong, Long, long) -DEFINE_SETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float) -DEFINE_SETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double) - -#else /* USDT2 */ #define DEFINE_SETSCALARARRAYREGION(ElementTag,ElementType,Result, Tag \ , EntryProbe, ReturnProbe); \ @@ -3858,7 +2924,6 @@ DEFINE_SETSCALARARRAYREGION(T_FLOAT, jfloat, Float, float DEFINE_SETSCALARARRAYREGION(T_DOUBLE, jdouble, Double, double , HOTSPOT_JNI_SETDOUBLEARRAYREGION_ENTRY(env, array, start, len, (double *) buf), HOTSPOT_JNI_SETDOUBLEARRAYREGION_RETURN()) -#endif /* USDT2 */ // @@ -3943,22 +3008,14 @@ static bool register_native(KlassHandle k, Symbol* name, Symbol* signature, addr return true; } -#ifndef USDT2 -DT_RETURN_MARK_DECL(RegisterNatives, jint); -#else /* USDT2 */ DT_RETURN_MARK_DECL(RegisterNatives, jint , HOTSPOT_JNI_REGISTERNATIVES_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jint, jni_RegisterNatives(JNIEnv *env, jclass clazz, const JNINativeMethod *methods, jint nMethods)) JNIWrapper("RegisterNatives"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, RegisterNatives__entry, env, clazz, methods, nMethods); -#else /* USDT2 */ HOTSPOT_JNI_REGISTERNATIVES_ENTRY(env, clazz, (void *) methods, nMethods); -#endif /* USDT2 */ jint ret = 0; DT_RETURN_MARK(RegisterNatives, jint, (const jint&)ret); @@ -3996,11 +3053,7 @@ JNI_END JNI_ENTRY(jint, jni_UnregisterNatives(JNIEnv *env, jclass clazz)) JNIWrapper("UnregisterNatives"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, UnregisterNatives__entry, env, clazz); -#else /* USDT2 */ HOTSPOT_JNI_UNREGISTERNATIVES_ENTRY(env, clazz); -#endif /* USDT2 */ Klass* k = java_lang_Class::as_Klass(JNIHandles::resolve_non_null(clazz)); //%note jni_2 if (k->oop_is_instance()) { @@ -4012,11 +3065,7 @@ JNI_ENTRY(jint, jni_UnregisterNatives(JNIEnv *env, jclass clazz)) } } } -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, UnregisterNatives__return, 0); -#else /* USDT2 */ HOTSPOT_JNI_UNREGISTERNATIVES_RETURN(0); -#endif /* USDT2 */ return 0; JNI_END @@ -4024,19 +3073,11 @@ JNI_END // Monitor functions // -#ifndef USDT2 -DT_RETURN_MARK_DECL(MonitorEnter, jint); -#else /* USDT2 */ DT_RETURN_MARK_DECL(MonitorEnter, jint , HOTSPOT_JNI_MONITORENTER_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jint, jni_MonitorEnter(JNIEnv *env, jobject jobj)) -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, MonitorEnter__entry, env, jobj); -#else /* USDT2 */ HOTSPOT_JNI_MONITORENTER_ENTRY(env, jobj); -#endif /* USDT2 */ jint ret = JNI_ERR; DT_RETURN_MARK(MonitorEnter, jint, (const jint&)ret); @@ -4051,19 +3092,11 @@ JNI_ENTRY(jint, jni_MonitorEnter(JNIEnv *env, jobject jobj)) return ret; JNI_END -#ifndef USDT2 -DT_RETURN_MARK_DECL(MonitorExit, jint); -#else /* USDT2 */ DT_RETURN_MARK_DECL(MonitorExit, jint , HOTSPOT_JNI_MONITOREXIT_RETURN(_ret_ref)); -#endif /* USDT2 */ JNI_ENTRY(jint, jni_MonitorExit(JNIEnv *env, jobject jobj)) -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, MonitorExit__entry, env, jobj); -#else /* USDT2 */ HOTSPOT_JNI_MONITOREXIT_ENTRY(env, jobj); -#endif /* USDT2 */ jint ret = JNI_ERR; DT_RETURN_MARK(MonitorExit, jint, (const jint&)ret); @@ -4083,20 +3116,12 @@ JNI_END // Extensions // -#ifndef USDT2 -DT_VOID_RETURN_MARK_DECL(GetStringRegion); -#else /* USDT2 */ DT_VOID_RETURN_MARK_DECL(GetStringRegion , HOTSPOT_JNI_GETSTRINGREGION_RETURN()); -#endif /* USDT2 */ JNI_ENTRY(void, jni_GetStringRegion(JNIEnv *env, jstring string, jsize start, jsize len, jchar *buf)) JNIWrapper("GetStringRegion"); -#ifndef USDT2 - DTRACE_PROBE5(hotspot_jni, GetStringRegion__entry, env, string, start, len, buf); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGREGION_ENTRY(env, string, start, len, buf); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(GetStringRegion); oop s = JNIHandles::resolve_non_null(string); int s_len = java_lang_String::length(s); @@ -4111,20 +3136,12 @@ JNI_ENTRY(void, jni_GetStringRegion(JNIEnv *env, jstring string, jsize start, js } JNI_END -#ifndef USDT2 -DT_VOID_RETURN_MARK_DECL(GetStringUTFRegion); -#else /* USDT2 */ DT_VOID_RETURN_MARK_DECL(GetStringUTFRegion , HOTSPOT_JNI_GETSTRINGUTFREGION_RETURN()); -#endif /* USDT2 */ JNI_ENTRY(void, jni_GetStringUTFRegion(JNIEnv *env, jstring string, jsize start, jsize len, char *buf)) JNIWrapper("GetStringUTFRegion"); -#ifndef USDT2 - DTRACE_PROBE5(hotspot_jni, GetStringUTFRegion__entry, env, string, start, len, buf); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGUTFREGION_ENTRY(env, string, start, len, buf); -#endif /* USDT2 */ DT_VOID_RETURN_MARK(GetStringUTFRegion); oop s = JNIHandles::resolve_non_null(string); int s_len = java_lang_String::length(s); @@ -4150,11 +3167,7 @@ JNI_END JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboolean *isCopy)) JNIWrapper("GetPrimitiveArrayCritical"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, GetPrimitiveArrayCritical__entry, env, array, isCopy); -#else /* USDT2 */ HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_ENTRY(env, array, (uintptr_t *) isCopy); -#endif /* USDT2 */ GC_locker::lock_critical(thread); if (isCopy != NULL) { *isCopy = JNI_FALSE; @@ -4168,39 +3181,23 @@ JNI_ENTRY(void*, jni_GetPrimitiveArrayCritical(JNIEnv *env, jarray array, jboole type = TypeArrayKlass::cast(a->klass())->element_type(); } void* ret = arrayOop(a)->base(type); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetPrimitiveArrayCritical__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_GETPRIMITIVEARRAYCRITICAL_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY(void, jni_ReleasePrimitiveArrayCritical(JNIEnv *env, jarray array, void *carray, jint mode)) JNIWrapper("ReleasePrimitiveArrayCritical"); -#ifndef USDT2 - DTRACE_PROBE4(hotspot_jni, ReleasePrimitiveArrayCritical__entry, env, array, carray, mode); -#else /* USDT2 */ HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_ENTRY(env, array, carray, mode); -#endif /* USDT2 */ // The array, carray and mode arguments are ignored GC_locker::unlock_critical(thread); -#ifndef USDT2 - DTRACE_PROBE(hotspot_jni, ReleasePrimitiveArrayCritical__return); -#else /* USDT2 */ HOTSPOT_JNI_RELEASEPRIMITIVEARRAYCRITICAL_RETURN(); -#endif /* USDT2 */ JNI_END JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jboolean *isCopy)) JNIWrapper("GetStringCritical"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, GetStringCritical__entry, env, string, isCopy); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGCRITICAL_ENTRY(env, string, (uintptr_t *) isCopy); -#endif /* USDT2 */ GC_locker::lock_critical(thread); if (isCopy != NULL) { *isCopy = JNI_FALSE; @@ -4215,80 +3212,44 @@ JNI_ENTRY(const jchar*, jni_GetStringCritical(JNIEnv *env, jstring string, jbool } else { ret = (jchar*) s_value->base(T_CHAR); } -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetStringCritical__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_GETSTRINGCRITICAL_RETURN((uint16_t *) ret); -#endif /* USDT2 */ return ret; JNI_END JNI_ENTRY(void, jni_ReleaseStringCritical(JNIEnv *env, jstring str, const jchar *chars)) JNIWrapper("ReleaseStringCritical"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, ReleaseStringCritical__entry, env, str, chars); -#else /* USDT2 */ HOTSPOT_JNI_RELEASESTRINGCRITICAL_ENTRY(env, str, (uint16_t *) chars); -#endif /* USDT2 */ // The str and chars arguments are ignored GC_locker::unlock_critical(thread); -#ifndef USDT2 - DTRACE_PROBE(hotspot_jni, ReleaseStringCritical__return); -#else /* USDT2 */ HOTSPOT_JNI_RELEASESTRINGCRITICAL_RETURN(); -#endif /* USDT2 */ JNI_END JNI_ENTRY(jweak, jni_NewWeakGlobalRef(JNIEnv *env, jobject ref)) JNIWrapper("jni_NewWeakGlobalRef"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, NewWeakGlobalRef__entry, env, ref); -#else /* USDT2 */ HOTSPOT_JNI_NEWWEAKGLOBALREF_ENTRY(env, ref); -#endif /* USDT2 */ Handle ref_handle(thread, JNIHandles::resolve(ref)); jweak ret = JNIHandles::make_weak_global(ref_handle); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, NewWeakGlobalRef__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_NEWWEAKGLOBALREF_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END // Must be JNI_ENTRY (with HandleMark) JNI_ENTRY(void, jni_DeleteWeakGlobalRef(JNIEnv *env, jweak ref)) JNIWrapper("jni_DeleteWeakGlobalRef"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, DeleteWeakGlobalRef__entry, env, ref); -#else /* USDT2 */ HOTSPOT_JNI_DELETEWEAKGLOBALREF_ENTRY(env, ref); -#endif /* USDT2 */ JNIHandles::destroy_weak_global(ref); -#ifndef USDT2 - DTRACE_PROBE(hotspot_jni, DeleteWeakGlobalRef__return); -#else /* USDT2 */ HOTSPOT_JNI_DELETEWEAKGLOBALREF_RETURN(); -#endif /* USDT2 */ JNI_END JNI_QUICK_ENTRY(jboolean, jni_ExceptionCheck(JNIEnv *env)) JNIWrapper("jni_ExceptionCheck"); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, ExceptionCheck__entry, env); -#else /* USDT2 */ HOTSPOT_JNI_EXCEPTIONCHECK_ENTRY(env); -#endif /* USDT2 */ jni_check_async_exceptions(thread); jboolean ret = (thread->has_pending_exception()) ? JNI_TRUE : JNI_FALSE; -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, ExceptionCheck__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_EXCEPTIONCHECK_RETURN(ret); -#endif /* USDT2 */ return ret; JNI_END @@ -4395,19 +3356,11 @@ extern "C" jobject JNICALL jni_NewDirectByteBuffer(JNIEnv *env, void* address, j JavaThread* thread = JavaThread::thread_from_jni_environment(env); JNIWrapper("jni_NewDirectByteBuffer"); -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, NewDirectByteBuffer__entry, env, address, capacity); -#else /* USDT2 */ HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_ENTRY(env, address, capacity); -#endif /* USDT2 */ if (!directBufferSupportInitializeEnded) { if (!initializeDirectBufferSupport(env, thread)) { -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, NULL); -#else /* USDT2 */ HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN(NULL); -#endif /* USDT2 */ return NULL; } } @@ -4418,20 +3371,12 @@ extern "C" jobject JNICALL jni_NewDirectByteBuffer(JNIEnv *env, void* address, j // takes int capacity jint cap = (jint) capacity; jobject ret = env->NewObject(directByteBufferClass, directByteBufferConstructor, addr, cap); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, NewDirectByteBuffer__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_NEWDIRECTBYTEBUFFER_RETURN(ret); -#endif /* USDT2 */ return ret; } -#ifndef USDT2 -DT_RETURN_MARK_DECL(GetDirectBufferAddress, void*); -#else /* USDT2 */ DT_RETURN_MARK_DECL(GetDirectBufferAddress, void* , HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_RETURN((void*) _ret_ref)); -#endif /* USDT2 */ extern "C" void* JNICALL jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) { @@ -4439,11 +3384,7 @@ extern "C" void* JNICALL jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) JavaThread* thread = JavaThread::thread_from_jni_environment(env); JNIWrapper("jni_GetDirectBufferAddress"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, GetDirectBufferAddress__entry, env, buf); -#else /* USDT2 */ HOTSPOT_JNI_GETDIRECTBUFFERADDRESS_ENTRY(env, buf); -#endif /* USDT2 */ void* ret = NULL; DT_RETURN_MARK(GetDirectBufferAddress, void*, (const void*&)ret); @@ -4461,12 +3402,8 @@ extern "C" void* JNICALL jni_GetDirectBufferAddress(JNIEnv *env, jobject buf) return ret; } -#ifndef USDT2 -DT_RETURN_MARK_DECL(GetDirectBufferCapacity, jlong); -#else /* USDT2 */ DT_RETURN_MARK_DECL(GetDirectBufferCapacity, jlong , HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_RETURN(_ret_ref)); -#endif /* USDT2 */ extern "C" jlong JNICALL jni_GetDirectBufferCapacity(JNIEnv *env, jobject buf) { @@ -4474,11 +3411,7 @@ extern "C" jlong JNICALL jni_GetDirectBufferCapacity(JNIEnv *env, jobject buf) JavaThread* thread = JavaThread::thread_from_jni_environment(env); JNIWrapper("jni_GetDirectBufferCapacity"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, GetDirectBufferCapacity__entry, env, buf); -#else /* USDT2 */ HOTSPOT_JNI_GETDIRECTBUFFERCAPACITY_ENTRY(env, buf); -#endif /* USDT2 */ jlong ret = -1; DT_RETURN_MARK(GetDirectBufferCapacity, jlong, (const jlong&)ret); @@ -4505,16 +3438,8 @@ extern "C" jlong JNICALL jni_GetDirectBufferCapacity(JNIEnv *env, jobject buf) JNI_LEAF(jint, jni_GetVersion(JNIEnv *env)) JNIWrapper("GetVersion"); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetVersion__entry, env); -#else /* USDT2 */ HOTSPOT_JNI_GETVERSION_ENTRY(env); -#endif /* USDT2 */ -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetVersion__return, CurrentVersion); -#else /* USDT2 */ HOTSPOT_JNI_GETVERSION_RETURN(CurrentVersion); -#endif /* USDT2 */ return CurrentVersion; JNI_END @@ -4522,17 +3447,9 @@ extern struct JavaVM_ main_vm; JNI_LEAF(jint, jni_GetJavaVM(JNIEnv *env, JavaVM **vm)) JNIWrapper("jni_GetJavaVM"); -#ifndef USDT2 - DTRACE_PROBE2(hotspot_jni, GetJavaVM__entry, env, vm); -#else /* USDT2 */ HOTSPOT_JNI_GETJAVAVM_ENTRY(env, (void **) vm); -#endif /* USDT2 */ *vm = (JavaVM *)(&main_vm); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, GetJavaVM__return, JNI_OK); -#else /* USDT2 */ HOTSPOT_JNI_GETJAVAVM_RETURN(JNI_OK); -#endif /* USDT2 */ return JNI_OK; JNI_END @@ -4910,20 +3827,11 @@ struct JavaVM_ main_vm = {&jni_InvokeInterface}; #define JAVASTACKSIZE (400 * 1024) /* Default size of a thread java stack */ enum { VERIFY_NONE, VERIFY_REMOTE, VERIFY_ALL }; -#ifndef USDT2 -HS_DTRACE_PROBE_DECL1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, void*); -DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint); -#else /* USDT2 */ DT_RETURN_MARK_DECL(GetDefaultJavaVMInitArgs, jint , HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_RETURN(_ret_ref)); -#endif /* USDT2 */ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetDefaultJavaVMInitArgs(void *args_) { -#ifndef USDT2 - HS_DTRACE_PROBE1(hotspot_jni, GetDefaultJavaVMInitArgs__entry, args_); -#else /* USDT2 */ HOTSPOT_JNI_GETDEFAULTJAVAVMINITARGS_ENTRY(args_); -#endif /* USDT2 */ JDK1_1InitArgs *args = (JDK1_1InitArgs *)args_; jint ret = JNI_ERR; DT_RETURN_MARK(GetDefaultJavaVMInitArgs, jint, (const jint&)ret); @@ -5009,20 +3917,11 @@ void execute_internal_vm_tests() { #endif -#ifndef USDT2 -HS_DTRACE_PROBE_DECL3(hotspot_jni, CreateJavaVM__entry, vm, penv, args); -DT_RETURN_MARK_DECL(CreateJavaVM, jint); -#else /* USDT2 */ DT_RETURN_MARK_DECL(CreateJavaVM, jint , HOTSPOT_JNI_CREATEJAVAVM_RETURN(_ret_ref)); -#endif /* USDT2 */ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, void *args) { -#ifndef USDT2 - HS_DTRACE_PROBE3(hotspot_jni, CreateJavaVM__entry, vm, penv, args); -#else /* USDT2 */ HOTSPOT_JNI_CREATEJAVAVM_ENTRY((void **) vm, penv, args); -#endif /* USDT2 */ jint result = JNI_ERR; DT_RETURN_MARK(CreateJavaVM, jint, (const jint&)result); @@ -5144,50 +4043,30 @@ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_CreateJavaVM(JavaVM **vm, void **penv, v return result; } -#ifndef USDT2 -HS_DTRACE_PROBE_DECL3(hotspot_jni, GetCreatedJavaVMs__entry, \ - JavaVM**, jsize, jsize*); -HS_DTRACE_PROBE_DECL1(hotspot_jni, GetCreatedJavaVMs__return, jint); -#endif /* !USDT2 */ _JNI_IMPORT_OR_EXPORT_ jint JNICALL JNI_GetCreatedJavaVMs(JavaVM **vm_buf, jsize bufLen, jsize *numVMs) { // See bug 4367188, the wrapper can sometimes cause VM crashes // JNIWrapper("GetCreatedJavaVMs"); -#ifndef USDT2 - HS_DTRACE_PROBE3(hotspot_jni, GetCreatedJavaVMs__entry, \ - vm_buf, bufLen, numVMs); -#else /* USDT2 */ + HOTSPOT_JNI_GETCREATEDJAVAVMS_ENTRY((void **) vm_buf, bufLen, (uintptr_t *) numVMs); -#endif /* USDT2 */ + if (vm_created) { if (numVMs != NULL) *numVMs = 1; if (bufLen > 0) *vm_buf = (JavaVM *)(&main_vm); } else { if (numVMs != NULL) *numVMs = 0; } -#ifndef USDT2 - HS_DTRACE_PROBE1(hotspot_jni, GetCreatedJavaVMs__return, JNI_OK); -#else /* USDT2 */ HOTSPOT_JNI_GETCREATEDJAVAVMS_RETURN(JNI_OK); -#endif /* USDT2 */ return JNI_OK; } extern "C" { -#ifndef USDT2 -DT_RETURN_MARK_DECL(DestroyJavaVM, jint); -#else /* USDT2 */ DT_RETURN_MARK_DECL(DestroyJavaVM, jint , HOTSPOT_JNI_DESTROYJAVAVM_RETURN(_ret_ref)); -#endif /* USDT2 */ jint JNICALL jni_DestroyJavaVM(JavaVM *vm) { -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, DestroyJavaVM__entry, vm); -#else /* USDT2 */ HOTSPOT_JNI_DESTROYJAVAVM_ENTRY(vm); -#endif /* USDT2 */ jint res = JNI_ERR; DT_RETURN_MARK(DestroyJavaVM, jint, (const jint&)res); @@ -5339,58 +4218,34 @@ static jint attach_current_thread(JavaVM *vm, void **penv, void *_args, bool dae jint JNICALL jni_AttachCurrentThread(JavaVM *vm, void **penv, void *_args) { -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, AttachCurrentThread__entry, vm, penv, _args); -#else /* USDT2 */ HOTSPOT_JNI_ATTACHCURRENTTHREAD_ENTRY(vm, penv, _args); -#endif /* USDT2 */ if (!vm_created) { -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, JNI_ERR); -#else /* USDT2 */ HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN((uint32_t) JNI_ERR); -#endif /* USDT2 */ return JNI_ERR; } JNIWrapper("AttachCurrentThread"); jint ret = attach_current_thread(vm, penv, _args, false); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, AttachCurrentThread__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_ATTACHCURRENTTHREAD_RETURN(ret); -#endif /* USDT2 */ return ret; } jint JNICALL jni_DetachCurrentThread(JavaVM *vm) { -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__entry, vm); -#else /* USDT2 */ HOTSPOT_JNI_DETACHCURRENTTHREAD_ENTRY(vm); -#endif /* USDT2 */ VM_Exit::block_if_vm_exited(); JNIWrapper("DetachCurrentThread"); // If the thread has been deattacted the operations is a no-op if (ThreadLocalStorage::thread() == NULL) { -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK); -#else /* USDT2 */ HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(JNI_OK); -#endif /* USDT2 */ return JNI_OK; } JavaThread* thread = JavaThread::current(); if (thread->has_last_Java_frame()) { -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_ERR); -#else /* USDT2 */ HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN((uint32_t) JNI_ERR); -#endif /* USDT2 */ // Can't detach a thread that's running java, that can't work. return JNI_ERR; } @@ -5411,27 +4266,15 @@ jint JNICALL jni_DetachCurrentThread(JavaVM *vm) { thread->exit(false, JavaThread::jni_detach); delete thread; -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, DetachCurrentThread__return, JNI_OK); -#else /* USDT2 */ HOTSPOT_JNI_DETACHCURRENTTHREAD_RETURN(JNI_OK); -#endif /* USDT2 */ return JNI_OK; } -#ifndef USDT2 -DT_RETURN_MARK_DECL(GetEnv, jint); -#else /* USDT2 */ DT_RETURN_MARK_DECL(GetEnv, jint , HOTSPOT_JNI_GETENV_RETURN(_ret_ref)); -#endif /* USDT2 */ jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) { -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, GetEnv__entry, vm, penv, version); -#else /* USDT2 */ HOTSPOT_JNI_GETENV_ENTRY(vm, penv, version); -#endif /* USDT2 */ jint ret = JNI_ERR; DT_RETURN_MARK(GetEnv, jint, (const jint&)ret); @@ -5485,27 +4328,15 @@ jint JNICALL jni_GetEnv(JavaVM *vm, void **penv, jint version) { jint JNICALL jni_AttachCurrentThreadAsDaemon(JavaVM *vm, void **penv, void *_args) { -#ifndef USDT2 - DTRACE_PROBE3(hotspot_jni, AttachCurrentThreadAsDaemon__entry, vm, penv, _args); -#else /* USDT2 */ HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_ENTRY(vm, penv, _args); -#endif /* USDT2 */ if (!vm_created) { -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, JNI_ERR); -#else /* USDT2 */ HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN((uint32_t) JNI_ERR); -#endif /* USDT2 */ return JNI_ERR; } JNIWrapper("AttachCurrentThreadAsDaemon"); jint ret = attach_current_thread(vm, penv, _args, true); -#ifndef USDT2 - DTRACE_PROBE1(hotspot_jni, AttachCurrentThreadAsDaemon__return, ret); -#else /* USDT2 */ HOTSPOT_JNI_ATTACHCURRENTTHREADASDAEMON_RETURN(ret); -#endif /* USDT2 */ return ret; } diff --git a/hotspot/src/share/vm/prims/jvm.cpp b/hotspot/src/share/vm/prims/jvm.cpp index 2b4048ec0de..152f1d807ec 100644 --- a/hotspot/src/share/vm/prims/jvm.cpp +++ b/hotspot/src/share/vm/prims/jvm.cpp @@ -82,12 +82,6 @@ #include -#ifndef USDT2 -HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__begin, long long); -HS_DTRACE_PROBE_DECL1(hotspot, thread__sleep__end, int); -HS_DTRACE_PROBE_DECL0(hotspot, thread__yield); -#endif /* !USDT2 */ - /* NOTE about use of any ctor or function call that can trigger a safepoint/GC: such ctors and calls MUST NOT come between an oop declaration/init and its @@ -3008,11 +3002,8 @@ JVM_END JVM_ENTRY(void, JVM_Yield(JNIEnv *env, jclass threadClass)) JVMWrapper("JVM_Yield"); if (os::dont_yield()) return; -#ifndef USDT2 - HS_DTRACE_PROBE0(hotspot, thread__yield); -#else /* USDT2 */ HOTSPOT_THREAD_YIELD(); -#endif /* USDT2 */ + // When ConvertYieldToSleep is off (default), this matches the classic VM use of yield. // Critical for similar threading behaviour if (ConvertYieldToSleep) { @@ -3038,12 +3029,7 @@ JVM_ENTRY(void, JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)) // And set new thread state to SLEEPING. JavaThreadSleepState jtss(thread); -#ifndef USDT2 - HS_DTRACE_PROBE1(hotspot, thread__sleep__begin, millis); -#else /* USDT2 */ - HOTSPOT_THREAD_SLEEP_BEGIN( - millis); -#endif /* USDT2 */ + HOTSPOT_THREAD_SLEEP_BEGIN(millis); EventThreadSleep event; @@ -3071,12 +3057,8 @@ JVM_ENTRY(void, JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)) event.set_time(millis); event.commit(); } -#ifndef USDT2 - HS_DTRACE_PROBE1(hotspot, thread__sleep__end,1); -#else /* USDT2 */ - HOTSPOT_THREAD_SLEEP_END( - 1); -#endif /* USDT2 */ + HOTSPOT_THREAD_SLEEP_END(1); + // TODO-FIXME: THROW_MSG returns which means we will not call set_state() // to properly restore the thread state. That's likely wrong. THROW_MSG(vmSymbols::java_lang_InterruptedException(), "sleep interrupted"); @@ -3088,12 +3070,7 @@ JVM_ENTRY(void, JVM_Sleep(JNIEnv* env, jclass threadClass, jlong millis)) event.set_time(millis); event.commit(); } -#ifndef USDT2 - HS_DTRACE_PROBE1(hotspot, thread__sleep__end,0); -#else /* USDT2 */ - HOTSPOT_THREAD_SLEEP_END( - 0); -#endif /* USDT2 */ + HOTSPOT_THREAD_SLEEP_END(0); JVM_END JVM_ENTRY(jobject, JVM_CurrentThread(JNIEnv* env, jclass threadClass)) diff --git a/hotspot/src/share/vm/prims/unsafe.cpp b/hotspot/src/share/vm/prims/unsafe.cpp index 5a5d7c93c47..ec99c80f2af 100644 --- a/hotspot/src/share/vm/prims/unsafe.cpp +++ b/hotspot/src/share/vm/prims/unsafe.cpp @@ -44,11 +44,6 @@ * Implementation of class sun.misc.Unsafe */ -#ifndef USDT2 -HS_DTRACE_PROBE_DECL3(hotspot, thread__park__begin, uintptr_t, int, long long); -HS_DTRACE_PROBE_DECL1(hotspot, thread__park__end, uintptr_t); -HS_DTRACE_PROBE_DECL1(hotspot, thread__unpark, uintptr_t); -#endif /* !USDT2 */ #define MAX_OBJECT_SIZE \ ( arrayOopDesc::header_size(T_DOUBLE) * HeapWordSize \ @@ -1211,20 +1206,12 @@ UNSAFE_END UNSAFE_ENTRY(void, Unsafe_Park(JNIEnv *env, jobject unsafe, jboolean isAbsolute, jlong time)) UnsafeWrapper("Unsafe_Park"); EventThreadPark event; -#ifndef USDT2 - HS_DTRACE_PROBE3(hotspot, thread__park__begin, thread->parker(), (int) isAbsolute, time); -#else /* USDT2 */ - HOTSPOT_THREAD_PARK_BEGIN( - (uintptr_t) thread->parker(), (int) isAbsolute, time); -#endif /* USDT2 */ + HOTSPOT_THREAD_PARK_BEGIN((uintptr_t) thread->parker(), (int) isAbsolute, time); + JavaThreadParkedState jtps(thread, time != 0); thread->parker()->park(isAbsolute != 0, time); -#ifndef USDT2 - HS_DTRACE_PROBE1(hotspot, thread__park__end, thread->parker()); -#else /* USDT2 */ - HOTSPOT_THREAD_PARK_END( - (uintptr_t) thread->parker()); -#endif /* USDT2 */ + + HOTSPOT_THREAD_PARK_END((uintptr_t) thread->parker()); if (event.should_commit()) { oop obj = thread->current_park_blocker(); event.set_klass((obj != NULL) ? obj->klass() : NULL); @@ -1263,12 +1250,7 @@ UNSAFE_ENTRY(void, Unsafe_Unpark(JNIEnv *env, jobject unsafe, jobject jthread)) } } if (p != NULL) { -#ifndef USDT2 - HS_DTRACE_PROBE1(hotspot, thread__unpark, p); -#else /* USDT2 */ - HOTSPOT_THREAD_UNPARK( - (uintptr_t) p); -#endif /* USDT2 */ + HOTSPOT_THREAD_UNPARK((uintptr_t) p); p->unpark(); } UNSAFE_END diff --git a/hotspot/src/share/vm/runtime/java.cpp b/hotspot/src/share/vm/runtime/java.cpp index 1c4087412cb..6c2d90daeaa 100644 --- a/hotspot/src/share/vm/runtime/java.cpp +++ b/hotspot/src/share/vm/runtime/java.cpp @@ -97,9 +97,6 @@ #include "opto/runtime.hpp" #endif -#ifndef USDT2 -HS_DTRACE_PROBE_DECL(hotspot, vm__shutdown); -#endif /* !USDT2 */ #ifndef PRODUCT @@ -603,13 +600,8 @@ void vm_exit(int code) { void notify_vm_shutdown() { // For now, just a dtrace probe. -#ifndef USDT2 - HS_DTRACE_PROBE(hotspot, vm__shutdown); - HS_DTRACE_WORKAROUND_TAIL_CALL_BUG(); -#else /* USDT2 */ HOTSPOT_VM_SHUTDOWN(); HS_DTRACE_WORKAROUND_TAIL_CALL_BUG(); -#endif /* USDT2 */ } void vm_direct_exit(int code) { diff --git a/hotspot/src/share/vm/runtime/objectMonitor.cpp b/hotspot/src/share/vm/runtime/objectMonitor.cpp index 9b86b43b636..dc9ef877fed 100644 --- a/hotspot/src/share/vm/runtime/objectMonitor.cpp +++ b/hotspot/src/share/vm/runtime/objectMonitor.cpp @@ -78,39 +78,6 @@ len = klassname->utf8_length(); \ } -#ifndef USDT2 - -HS_DTRACE_PROBE_DECL4(hotspot, monitor__notify, - jlong, uintptr_t, char*, int); -HS_DTRACE_PROBE_DECL4(hotspot, monitor__notifyAll, - jlong, uintptr_t, char*, int); -HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__enter, - jlong, uintptr_t, char*, int); -HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__entered, - jlong, uintptr_t, char*, int); -HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__exit, - jlong, uintptr_t, char*, int); - -#define DTRACE_MONITOR_WAIT_PROBE(monitor, obj, thread, millis) \ - { \ - if (DTraceMonitorProbes) { \ - DTRACE_MONITOR_PROBE_COMMON(obj, thread); \ - HS_DTRACE_PROBE5(hotspot, monitor__wait, jtid, \ - (monitor), bytes, len, (millis)); \ - } \ - } - -#define DTRACE_MONITOR_PROBE(probe, monitor, obj, thread) \ - { \ - if (DTraceMonitorProbes) { \ - DTRACE_MONITOR_PROBE_COMMON(obj, thread); \ - HS_DTRACE_PROBE4(hotspot, monitor__##probe, jtid, \ - (uintptr_t)(monitor), bytes, len); \ - } \ - } - -#else /* USDT2 */ - #define DTRACE_MONITOR_WAIT_PROBE(monitor, obj, thread, millis) \ { \ if (DTraceMonitorProbes) { \ @@ -135,7 +102,6 @@ HS_DTRACE_PROBE_DECL4(hotspot, monitor__contended__exit, } \ } -#endif /* USDT2 */ #else // ndef DTRACE_ENABLED #define DTRACE_MONITOR_WAIT_PROBE(obj, thread, millis, mon) {;} diff --git a/hotspot/src/share/vm/runtime/sharedRuntime.cpp b/hotspot/src/share/vm/runtime/sharedRuntime.cpp index 698c8d2336a..0d36d9cf7c5 100644 --- a/hotspot/src/share/vm/runtime/sharedRuntime.cpp +++ b/hotspot/src/share/vm/runtime/sharedRuntime.cpp @@ -127,14 +127,6 @@ void SharedRuntime::generate_stubs() { #include -#ifndef USDT2 -HS_DTRACE_PROBE_DECL4(hotspot, object__alloc, Thread*, char*, int, size_t); -HS_DTRACE_PROBE_DECL7(hotspot, method__entry, int, - char*, int, char*, int, char*, int); -HS_DTRACE_PROBE_DECL7(hotspot, method__return, int, - char*, int, char*, int, char*, int); -#endif /* !USDT2 */ - // Implementation of SharedRuntime #ifndef PRODUCT @@ -969,14 +961,9 @@ int SharedRuntime::dtrace_object_alloc_base(Thread* thread, oopDesc* o) { Klass* klass = o->klass(); int size = o->size(); Symbol* name = klass->name(); -#ifndef USDT2 - HS_DTRACE_PROBE4(hotspot, object__alloc, get_java_tid(thread), - name->bytes(), name->utf8_length(), size * HeapWordSize); -#else /* USDT2 */ HOTSPOT_OBJECT_ALLOC( get_java_tid(thread), (char *) name->bytes(), name->utf8_length(), size * HeapWordSize); -#endif /* USDT2 */ return 0; } @@ -986,18 +973,11 @@ JRT_LEAF(int, SharedRuntime::dtrace_method_entry( Symbol* kname = method->klass_name(); Symbol* name = method->name(); Symbol* sig = method->signature(); -#ifndef USDT2 - HS_DTRACE_PROBE7(hotspot, method__entry, get_java_tid(thread), - kname->bytes(), kname->utf8_length(), - name->bytes(), name->utf8_length(), - sig->bytes(), sig->utf8_length()); -#else /* USDT2 */ HOTSPOT_METHOD_ENTRY( get_java_tid(thread), (char *) kname->bytes(), kname->utf8_length(), (char *) name->bytes(), name->utf8_length(), (char *) sig->bytes(), sig->utf8_length()); -#endif /* USDT2 */ return 0; JRT_END @@ -1007,18 +987,11 @@ JRT_LEAF(int, SharedRuntime::dtrace_method_exit( Symbol* kname = method->klass_name(); Symbol* name = method->name(); Symbol* sig = method->signature(); -#ifndef USDT2 - HS_DTRACE_PROBE7(hotspot, method__return, get_java_tid(thread), - kname->bytes(), kname->utf8_length(), - name->bytes(), name->utf8_length(), - sig->bytes(), sig->utf8_length()); -#else /* USDT2 */ HOTSPOT_METHOD_RETURN( get_java_tid(thread), (char *) kname->bytes(), kname->utf8_length(), (char *) name->bytes(), name->utf8_length(), (char *) sig->bytes(), sig->utf8_length()); -#endif /* USDT2 */ return 0; JRT_END diff --git a/hotspot/src/share/vm/runtime/synchronizer.cpp b/hotspot/src/share/vm/runtime/synchronizer.cpp index 39a44775edc..d51427a588d 100644 --- a/hotspot/src/share/vm/runtime/synchronizer.cpp +++ b/hotspot/src/share/vm/runtime/synchronizer.cpp @@ -84,32 +84,6 @@ len = klassname->utf8_length(); \ } -#ifndef USDT2 -HS_DTRACE_PROBE_DECL5(hotspot, monitor__wait, - jlong, uintptr_t, char*, int, long); -HS_DTRACE_PROBE_DECL4(hotspot, monitor__waited, - jlong, uintptr_t, char*, int); - -#define DTRACE_MONITOR_WAIT_PROBE(monitor, obj, thread, millis) \ - { \ - if (DTraceMonitorProbes) { \ - DTRACE_MONITOR_PROBE_COMMON(obj, thread); \ - HS_DTRACE_PROBE5(hotspot, monitor__wait, jtid, \ - (monitor), bytes, len, (millis)); \ - } \ - } - -#define DTRACE_MONITOR_PROBE(probe, monitor, obj, thread) \ - { \ - if (DTraceMonitorProbes) { \ - DTRACE_MONITOR_PROBE_COMMON(obj, thread); \ - HS_DTRACE_PROBE4(hotspot, monitor__##probe, jtid, \ - (uintptr_t)(monitor), bytes, len); \ - } \ - } - -#else /* USDT2 */ - #define DTRACE_MONITOR_WAIT_PROBE(monitor, obj, thread, millis) \ { \ if (DTraceMonitorProbes) { \ @@ -130,7 +104,6 @@ HS_DTRACE_PROBE_DECL4(hotspot, monitor__waited, } \ } -#endif /* USDT2 */ #else // ndef DTRACE_ENABLED #define DTRACE_MONITOR_WAIT_PROBE(obj, thread, millis, mon) {;} diff --git a/hotspot/src/share/vm/runtime/thread.cpp b/hotspot/src/share/vm/runtime/thread.cpp index e93b808ebba..ed2dfa67551 100644 --- a/hotspot/src/share/vm/runtime/thread.cpp +++ b/hotspot/src/share/vm/runtime/thread.cpp @@ -112,29 +112,6 @@ // Only bother with this argument setup if dtrace is available -#ifndef USDT2 -HS_DTRACE_PROBE_DECL(hotspot, vm__init__begin); -HS_DTRACE_PROBE_DECL(hotspot, vm__init__end); -HS_DTRACE_PROBE_DECL5(hotspot, thread__start, char*, intptr_t, - intptr_t, intptr_t, bool); -HS_DTRACE_PROBE_DECL5(hotspot, thread__stop, char*, intptr_t, - intptr_t, intptr_t, bool); - -#define DTRACE_THREAD_PROBE(probe, javathread) \ - { \ - ResourceMark rm(this); \ - int len = 0; \ - const char* name = (javathread)->get_thread_name(); \ - len = strlen(name); \ - HS_DTRACE_PROBE5(hotspot, thread__##probe, \ - name, len, \ - java_lang_Thread::thread_id((javathread)->threadObj()), \ - (javathread)->osthread()->thread_id(), \ - java_lang_Thread::is_daemon((javathread)->threadObj())); \ - } - -#else /* USDT2 */ - #define HOTSPOT_THREAD_PROBE_start HOTSPOT_THREAD_START #define HOTSPOT_THREAD_PROBE_stop HOTSPOT_THREAD_STOP @@ -151,8 +128,6 @@ HS_DTRACE_PROBE_DECL5(hotspot, thread__stop, char*, intptr_t, java_lang_Thread::is_daemon((javathread)->threadObj())); \ } -#endif /* USDT2 */ - #else // ndef DTRACE_ENABLED #define DTRACE_THREAD_PROBE(probe, javathread) @@ -3391,11 +3366,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { os::pause(); } -#ifndef USDT2 - HS_DTRACE_PROBE(hotspot, vm__init__begin); -#else /* USDT2 */ HOTSPOT_VM_INIT_BEGIN(); -#endif /* USDT2 */ // Record VM creation timing statistics TraceVmCreationTime create_vm_timer; @@ -3557,11 +3528,7 @@ jint Threads::create_vm(JavaVMInitArgs* args, bool* canTryAgain) { // debug stuff, that does not work until all basic classes have been initialized. set_init_completed(); -#ifndef USDT2 - HS_DTRACE_PROBE(hotspot, vm__init__end); -#else /* USDT2 */ HOTSPOT_VM_INIT_END(); -#endif /* USDT2 */ // record VM initialization completion time #if INCLUDE_MANAGEMENT diff --git a/hotspot/src/share/vm/runtime/vmThread.cpp b/hotspot/src/share/vm/runtime/vmThread.cpp index bdb508208d4..98fb207c887 100644 --- a/hotspot/src/share/vm/runtime/vmThread.cpp +++ b/hotspot/src/share/vm/runtime/vmThread.cpp @@ -40,12 +40,6 @@ #include "utilities/events.hpp" #include "utilities/xmlstream.hpp" -#ifndef USDT2 -HS_DTRACE_PROBE_DECL3(hotspot, vmops__request, char *, uintptr_t, int); -HS_DTRACE_PROBE_DECL3(hotspot, vmops__begin, char *, uintptr_t, int); -HS_DTRACE_PROBE_DECL3(hotspot, vmops__end, char *, uintptr_t, int); -#endif /* !USDT2 */ - // Dummy VM operation to act as first element in our circular double-linked list class VM_Dummy: public VM_Operation { VMOp_Type type() const { return VMOp_Dummy; } @@ -154,14 +148,9 @@ void VMOperationQueue::drain_list_oops_do(OopClosure* f) { // High-level interface bool VMOperationQueue::add(VM_Operation *op) { -#ifndef USDT2 - HS_DTRACE_PROBE3(hotspot, vmops__request, op->name(), strlen(op->name()), - op->evaluation_mode()); -#else /* USDT2 */ HOTSPOT_VMOPS_REQUEST( (char *) op->name(), strlen(op->name()), op->evaluation_mode()); -#endif /* USDT2 */ // Encapsulates VM queue policy. Currently, that // only involves putting them on the right list @@ -358,14 +347,9 @@ void VMThread::evaluate_operation(VM_Operation* op) { { PerfTraceTime vm_op_timer(perf_accumulated_vm_operation_time()); -#ifndef USDT2 - HS_DTRACE_PROBE3(hotspot, vmops__begin, op->name(), strlen(op->name()), - op->evaluation_mode()); -#else /* USDT2 */ HOTSPOT_VMOPS_BEGIN( (char *) op->name(), strlen(op->name()), op->evaluation_mode()); -#endif /* USDT2 */ EventExecuteVMOperation event; @@ -383,14 +367,9 @@ void VMThread::evaluate_operation(VM_Operation* op) { event.commit(); } -#ifndef USDT2 - HS_DTRACE_PROBE3(hotspot, vmops__end, op->name(), strlen(op->name()), - op->evaluation_mode()); -#else /* USDT2 */ HOTSPOT_VMOPS_END( (char *) op->name(), strlen(op->name()), op->evaluation_mode()); -#endif /* USDT2 */ } // Last access of info in _cur_vm_operation! diff --git a/hotspot/src/share/vm/services/classLoadingService.cpp b/hotspot/src/share/vm/services/classLoadingService.cpp index aa2299fca6d..bdc33fdd2bb 100644 --- a/hotspot/src/share/vm/services/classLoadingService.cpp +++ b/hotspot/src/share/vm/services/classLoadingService.cpp @@ -37,26 +37,6 @@ // Only bother with this argument setup if dtrace is available -#ifndef USDT2 - -HS_DTRACE_PROBE_DECL4(hotspot, class__loaded, char*, int, oop, bool); -HS_DTRACE_PROBE_DECL4(hotspot, class__unloaded, char*, int, oop, bool); - -#define DTRACE_CLASSLOAD_PROBE(type, clss, shared) \ - { \ - char* data = NULL; \ - int len = 0; \ - Symbol* name = (clss)->name(); \ - if (name != NULL) { \ - data = (char*)name->bytes(); \ - len = name->utf8_length(); \ - } \ - HS_DTRACE_PROBE4(hotspot, class__##type, \ - data, len, SOLARIS_ONLY((void *))(clss)->class_loader(), (shared)); \ - } - -#else /* USDT2 */ - #define HOTSPOT_CLASS_unloaded HOTSPOT_CLASS_UNLOADED #define HOTSPOT_CLASS_loaded HOTSPOT_CLASS_LOADED #define DTRACE_CLASSLOAD_PROBE(type, clss, shared) \ @@ -72,7 +52,6 @@ HS_DTRACE_PROBE_DECL4(hotspot, class__unloaded, char*, int, oop, bool); data, len, (clss)->class_loader(), (shared)); \ } -#endif /* USDT2 */ #else // ndef DTRACE_ENABLED #define DTRACE_CLASSLOAD_PROBE(type, clss, shared) diff --git a/hotspot/src/share/vm/services/memoryManager.cpp b/hotspot/src/share/vm/services/memoryManager.cpp index 0cfd05b78f5..f6ada6a8244 100644 --- a/hotspot/src/share/vm/services/memoryManager.cpp +++ b/hotspot/src/share/vm/services/memoryManager.cpp @@ -36,13 +36,6 @@ #include "services/gcNotifier.hpp" #include "utilities/dtrace.hpp" -#ifndef USDT2 -HS_DTRACE_PROBE_DECL8(hotspot, mem__pool__gc__begin, char*, int, char*, int, - size_t, size_t, size_t, size_t); -HS_DTRACE_PROBE_DECL8(hotspot, mem__pool__gc__end, char*, int, char*, int, - size_t, size_t, size_t, size_t); -#endif /* !USDT2 */ - MemoryManager::MemoryManager() { _num_pools = 0; (void)const_cast(_memory_mgr_obj = NULL); @@ -242,19 +235,11 @@ void GCMemoryManager::gc_begin(bool recordGCBeginTime, bool recordPreGCUsage, MemoryPool* pool = MemoryService::get_memory_pool(i); MemoryUsage usage = pool->get_memory_usage(); _current_gc_stat->set_before_gc_usage(i, usage); -#ifndef USDT2 - HS_DTRACE_PROBE8(hotspot, mem__pool__gc__begin, - name(), strlen(name()), - pool->name(), strlen(pool->name()), - usage.init_size(), usage.used(), - usage.committed(), usage.max_size()); -#else /* USDT2 */ HOTSPOT_MEM_POOL_GC_BEGIN( (char *) name(), strlen(name()), (char *) pool->name(), strlen(pool->name()), usage.init_size(), usage.used(), usage.committed(), usage.max_size()); -#endif /* USDT2 */ } } } @@ -280,19 +265,11 @@ void GCMemoryManager::gc_end(bool recordPostGCUsage, MemoryPool* pool = MemoryService::get_memory_pool(i); MemoryUsage usage = pool->get_memory_usage(); -#ifndef USDT2 - HS_DTRACE_PROBE8(hotspot, mem__pool__gc__end, - name(), strlen(name()), - pool->name(), strlen(pool->name()), - usage.init_size(), usage.used(), - usage.committed(), usage.max_size()); -#else /* USDT2 */ HOTSPOT_MEM_POOL_GC_END( (char *) name(), strlen(name()), (char *) pool->name(), strlen(pool->name()), usage.init_size(), usage.used(), usage.committed(), usage.max_size()); -#endif /* USDT2 */ _current_gc_stat->set_after_gc_usage(i, usage); } diff --git a/hotspot/src/share/vm/services/runtimeService.cpp b/hotspot/src/share/vm/services/runtimeService.cpp index 379b8f3ff9e..5fdb9705a4d 100644 --- a/hotspot/src/share/vm/services/runtimeService.cpp +++ b/hotspot/src/share/vm/services/runtimeService.cpp @@ -31,11 +31,6 @@ #include "utilities/exceptions.hpp" #include "utilities/macros.hpp" -#ifndef USDT2 -HS_DTRACE_PROBE_DECL(hs_private, safepoint__begin); -HS_DTRACE_PROBE_DECL(hs_private, safepoint__end); -#endif /* !USDT2 */ - #if INCLUDE_MANAGEMENT TimeStamp RuntimeService::_app_timer; TimeStamp RuntimeService::_safepoint_timer; @@ -112,11 +107,7 @@ void RuntimeService::init() { } void RuntimeService::record_safepoint_begin() { -#ifndef USDT2 - HS_DTRACE_PROBE(hs_private, safepoint__begin); -#else /* USDT2 */ HS_PRIVATE_SAFEPOINT_BEGIN(); -#endif /* USDT2 */ // Print the time interval in which the app was executing if (PrintGCApplicationConcurrentTime && _app_timer.is_updated()) { @@ -143,11 +134,7 @@ void RuntimeService::record_safepoint_synchronized() { } void RuntimeService::record_safepoint_end() { -#ifndef USDT2 - HS_DTRACE_PROBE(hs_private, safepoint__end); -#else /* USDT2 */ HS_PRIVATE_SAFEPOINT_END(); -#endif /* USDT2 */ // Print the time interval for which the app was stopped // during the current safepoint operation. diff --git a/hotspot/src/share/vm/utilities/dtrace.hpp b/hotspot/src/share/vm/utilities/dtrace.hpp index 92d99de204a..e3612070354 100644 --- a/hotspot/src/share/vm/utilities/dtrace.hpp +++ b/hotspot/src/share/vm/utilities/dtrace.hpp @@ -37,7 +37,6 @@ // Work around dtrace tail call bug 6672627 until it is fixed in solaris 10. #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() \ do { volatile size_t dtrace_workaround_tail_call_bug = 1; } while (0) - #elif defined(LINUX) #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() #elif defined(__APPLE__) @@ -47,7 +46,6 @@ #error "dtrace enabled for unknown os" #endif /* defined(SOLARIS) */ -#define USDT2 1 #include "dtracefiles/hotspot.h" #include "dtracefiles/hotspot_jni.h" #include "dtracefiles/hs_private.h" @@ -59,147 +57,8 @@ #define HS_DTRACE_WORKAROUND_TAIL_CALL_BUG() -#ifndef USDT2 - -#define DTRACE_PROBE(a,b) {;} -#define DTRACE_PROBE1(a,b,c) {;} -#define DTRACE_PROBE2(a,b,c,d) {;} -#define DTRACE_PROBE3(a,b,c,d,e) {;} -#define DTRACE_PROBE4(a,b,c,d,e,f) {;} -#define DTRACE_PROBE5(a,b,c,d,e,f,g) {;} -#define DTRACE_PROBE6(a,b,c,d,e,f,g,h) {;} -#define DTRACE_PROBE7(a,b,c,d,e,f,g,h,i) {;} -#define DTRACE_PROBE8(a,b,c,d,e,f,g,h,i,j) {;} -#define DTRACE_PROBE9(a,b,c,d,e,f,g,h,i,j,k) {;} -#define DTRACE_PROBE10(a,b,c,d,e,f,g,h,i,j,k,l) {;} - -#else /* USDT2 */ - -#include "dtrace_usdt2_disabled.hpp" -#endif /* USDT2 */ +#include "dtrace_disabled.hpp" #endif /* defined(DTRACE_ENABLED) */ -#ifndef USDT2 - -#define HS_DTRACE_PROBE_FN(provider,name)\ - __dtrace_##provider##___##name - -#ifdef SOLARIS -// Solaris dtrace needs actual extern function decls. -#define HS_DTRACE_PROBE_DECL_N(provider,name,args) \ - DTRACE_ONLY(extern "C" void HS_DTRACE_PROBE_FN(provider,name) args) -#define HS_DTRACE_PROBE_CDECL_N(provider,name,args) \ - DTRACE_ONLY(extern void HS_DTRACE_PROBE_FN(provider,name) args) -#else -// Systemtap dtrace compatible probes on GNU/Linux don't. -// If dtrace is disabled this macro becomes NULL -#define HS_DTRACE_PROBE_DECL_N(provider,name,args) -#define HS_DTRACE_PROBE_CDECL_N(provider,name,args) -#endif - -/* Dtrace probe declarations */ -#define HS_DTRACE_PROBE_DECL(provider,name) \ - HS_DTRACE_PROBE_DECL0(provider,name) -#define HS_DTRACE_PROBE_DECL0(provider,name)\ - HS_DTRACE_PROBE_DECL_N(provider,name,(void)) -#define HS_DTRACE_PROBE_DECL1(provider,name,t0)\ - HS_DTRACE_PROBE_DECL_N(provider,name,(uintptr_t)) -#define HS_DTRACE_PROBE_DECL2(provider,name,t0,t1)\ - HS_DTRACE_PROBE_DECL_N(provider,name,(uintptr_t,uintptr_t)) -#define HS_DTRACE_PROBE_DECL3(provider,name,t0,t1,t2)\ - HS_DTRACE_PROBE_DECL_N(provider,name,(uintptr_t,uintptr_t,uintptr_t)) -#define HS_DTRACE_PROBE_DECL4(provider,name,t0,t1,t2,t3)\ - HS_DTRACE_PROBE_DECL_N(provider,name,(uintptr_t,uintptr_t,uintptr_t,\ - uintptr_t)) -#define HS_DTRACE_PROBE_DECL5(provider,name,t0,t1,t2,t3,t4)\ - HS_DTRACE_PROBE_DECL_N(provider,name,(\ - uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t)) -#define HS_DTRACE_PROBE_DECL6(provider,name,t0,t1,t2,t3,t4,t5)\ - HS_DTRACE_PROBE_DECL_N(provider,name,(\ - uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t)) -#define HS_DTRACE_PROBE_DECL7(provider,name,t0,t1,t2,t3,t4,t5,t6)\ - HS_DTRACE_PROBE_DECL_N(provider,name,(\ - uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t)) -#define HS_DTRACE_PROBE_DECL8(provider,name,t0,t1,t2,t3,t4,t5,t6,t7)\ - HS_DTRACE_PROBE_DECL_N(provider,name,(\ - uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,\ - uintptr_t)) -#define HS_DTRACE_PROBE_DECL9(provider,name,t0,t1,t2,t3,t4,t5,t6,t7,t8)\ - HS_DTRACE_PROBE_DECL_N(provider,name,(\ - uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,\ - uintptr_t,uintptr_t)) -#define HS_DTRACE_PROBE_DECL10(provider,name,t0,t1,t2,t3,t4,t5,t6,t7,t8,t9)\ - HS_DTRACE_PROBE_DECL_N(provider,name,(\ - uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,uintptr_t,\ - uintptr_t,uintptr_t,uintptr_t)) - -/* Dtrace probe definitions */ -#if defined(SOLARIS) -// Solaris dtrace uses actual function calls. -#define HS_DTRACE_PROBE_N(provider,name, args) \ - DTRACE_ONLY(HS_DTRACE_PROBE_FN(provider,name) args) - -#define HS_DTRACE_PROBE(provider,name) HS_DTRACE_PROBE0(provider,name) -#define HS_DTRACE_PROBE0(provider,name)\ - HS_DTRACE_PROBE_N(provider,name,()) -#define HS_DTRACE_PROBE1(provider,name,a0)\ - HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0)) -#define HS_DTRACE_PROBE2(provider,name,a0,a1)\ - HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1)) -#define HS_DTRACE_PROBE3(provider,name,a0,a1,a2)\ - HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2)) -#define HS_DTRACE_PROBE4(provider,name,a0,a1,a2,a3)\ - HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ - (uintptr_t)a3)) -#define HS_DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4)\ - HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ - (uintptr_t)a3,(uintptr_t)a4)) -#define HS_DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5)\ - HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ - (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5)) -#define HS_DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6)\ - HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ - (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6)) -#define HS_DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7)\ - HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ - (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7)) -#define HS_DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8)\ - HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ - (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7,\ - (uintptr_t)a8)) -#define HS_DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)\ - HS_DTRACE_PROBE_N(provider,name,((uintptr_t)a0,(uintptr_t)a1,(uintptr_t)a2,\ - (uintptr_t)a3,(uintptr_t)a4,(uintptr_t)a5,(uintptr_t)a6,(uintptr_t)a7,\ - (uintptr_t)a8,(uintptr_t)a9)) -#else -// Systemtap dtrace compatible probes on GNU/Linux use direct macros. -// If dtrace is disabled this macro becomes NULL -#define HS_DTRACE_PROBE(provider,name) HS_DTRACE_PROBE0(provider,name) -#define HS_DTRACE_PROBE0(provider,name)\ - DTRACE_PROBE(provider,name) -#define HS_DTRACE_PROBE1(provider,name,a0)\ - DTRACE_PROBE1(provider,name,a0) -#define HS_DTRACE_PROBE2(provider,name,a0,a1)\ - DTRACE_PROBE2(provider,name,a0,a1) -#define HS_DTRACE_PROBE3(provider,name,a0,a1,a2)\ - DTRACE_PROBE3(provider,name,a0,a1,a2) -#define HS_DTRACE_PROBE4(provider,name,a0,a1,a2,a3)\ - DTRACE_PROBE4(provider,name,a0,a1,a2,a3) -#define HS_DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4)\ - DTRACE_PROBE5(provider,name,a0,a1,a2,a3,a4) -#define HS_DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5)\ - DTRACE_PROBE6(provider,name,a0,a1,a2,a3,a4,a5) -#define HS_DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6)\ - DTRACE_PROBE7(provider,name,a0,a1,a2,a3,a4,a5,a6) -#define HS_DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7)\ - DTRACE_PROBE8(provider,name,a0,a1,a2,a3,a4,a5,a6,a7) -#define HS_DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8)\ - DTRACE_PROBE9(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8) -#define HS_DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9)\ - DTRACE_PROBE10(provider,name,a0,a1,a2,a3,a4,a5,a6,a7,a8,a9) -#endif - -#endif /* !USDT2 */ - #endif // SHARE_VM_UTILITIES_DTRACE_HPP diff --git a/hotspot/src/share/vm/utilities/dtrace_usdt2_disabled.hpp b/hotspot/src/share/vm/utilities/dtrace_disabled.hpp similarity index 99% rename from hotspot/src/share/vm/utilities/dtrace_usdt2_disabled.hpp rename to hotspot/src/share/vm/utilities/dtrace_disabled.hpp index 5606bf62926..2906fe22e93 100644 --- a/hotspot/src/share/vm/utilities/dtrace_usdt2_disabled.hpp +++ b/hotspot/src/share/vm/utilities/dtrace_disabled.hpp @@ -32,8 +32,6 @@ */ #if !defined(DTRACE_ENABLED) -#ifdef USDT2 - /* hotspot provider probes */ #define HOTSPOT_CLASS_LOADED(arg0, arg1, arg2, arg3) #define HOTSPOT_CLASS_LOADED_ENABLED() 0 @@ -107,7 +105,7 @@ #define HOTSPOT_THREAD_PARK_BEGIN_ENABLED() 0 #define HOTSPOT_THREAD_PARK_END(arg0) #define HOTSPOT_THREAD_PARK_END_ENABLED() 0 -#define HOTSPOT_THREAD_UNPARK() +#define HOTSPOT_THREAD_UNPARK(arg0) #define HOTSPOT_THREAD_UNPARK_ENABLED() 0 #define HOTSPOT_VM_INIT_BEGIN() #define HOTSPOT_VM_INIT_BEGIN_ENABLED() 0 @@ -1086,12 +1084,8 @@ #define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN(arg0) #define HOTSPOT_JNI_UNREGISTERNATIVES_RETURN_ENABLED() 0 -#else /* USDT2 */ -#error This file should only be included for USDT2 -#endif /* USDT2 */ - #else /* !defined(DTRACE_ENABLED) */ #error This file should only be included when dtrace is not enabled -#end /* !defined(DTRACE_ENABLED) */ +#endif /* !defined(DTRACE_ENABLED) */ #endif // SHARE_VM_UTILITIES_DTRACE_USDT2_DISABLED_HPP From 95cdf53e755db37fc098edf31bbc81449a2de15f Mon Sep 17 00:00:00 2001 From: Serguei Spitsyn Date: Tue, 18 Feb 2014 06:19:49 -0800 Subject: [PATCH 145/159] 8034249: need more workarounds for suspend equivalent condition issue Collect data at safepoint, do not rely on thread suspension Reviewed-by: dcubed, dholmes --- hotspot/src/share/vm/prims/jvmtiEnv.cpp | 24 +++++++++++++-------- hotspot/src/share/vm/prims/jvmtiEnvBase.hpp | 20 +++++++++++------ 2 files changed, 29 insertions(+), 15 deletions(-) diff --git a/hotspot/src/share/vm/prims/jvmtiEnv.cpp b/hotspot/src/share/vm/prims/jvmtiEnv.cpp index 6a197a84996..5aba54b6ca9 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnv.cpp +++ b/hotspot/src/share/vm/prims/jvmtiEnv.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -999,8 +999,9 @@ JvmtiEnv::GetOwnedMonitorInfo(JavaThread* java_thread, jint* owned_monitor_count GrowableArray *owned_monitors_list = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(1, true); - uint32_t debug_bits = 0; - if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { + // It is only safe to perform the direct operation on the current + // thread. All other usage needs to use a vm-safepoint-op for safety. + if (java_thread == calling_thread) { err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list); } else { // JVMTI get monitors info at safepoint. Do not require target thread to @@ -1044,8 +1045,9 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i GrowableArray *owned_monitors_list = new (ResourceObj::C_HEAP, mtInternal) GrowableArray(1, true); - uint32_t debug_bits = 0; - if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { + // It is only safe to perform the direct operation on the current + // thread. All other usage needs to use a vm-safepoint-op for safety. + if (java_thread == calling_thread) { err = get_owned_monitors(calling_thread, java_thread, owned_monitors_list); } else { // JVMTI get owned monitors info at safepoint. Do not require target thread to @@ -1086,9 +1088,11 @@ JvmtiEnv::GetOwnedMonitorStackDepthInfo(JavaThread* java_thread, jint* monitor_i jvmtiError JvmtiEnv::GetCurrentContendedMonitor(JavaThread* java_thread, jobject* monitor_ptr) { jvmtiError err = JVMTI_ERROR_NONE; - uint32_t debug_bits = 0; JavaThread* calling_thread = JavaThread::current(); - if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { + + // It is only safe to perform the direct operation on the current + // thread. All other usage needs to use a vm-safepoint-op for safety. + if (java_thread == calling_thread) { err = get_current_contended_monitor(calling_thread, java_thread, monitor_ptr); } else { // get contended monitor information at safepoint. @@ -1297,8 +1301,10 @@ JvmtiEnv::GetThreadGroupChildren(jthreadGroup group, jint* thread_count_ptr, jth jvmtiError JvmtiEnv::GetStackTrace(JavaThread* java_thread, jint start_depth, jint max_frame_count, jvmtiFrameInfo* frame_buffer, jint* count_ptr) { jvmtiError err = JVMTI_ERROR_NONE; - uint32_t debug_bits = 0; - if (is_thread_fully_suspended(java_thread, true, &debug_bits)) { + + // It is only safe to perform the direct operation on the current + // thread. All other usage needs to use a vm-safepoint-op for safety. + if (java_thread == JavaThread::current()) { err = get_stack_trace(java_thread, start_depth, max_frame_count, frame_buffer, count_ptr); } else { // JVMTI get stack trace at safepoint. Do not require target thread to diff --git a/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp b/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp index 0682118c88a..0f9495945ec 100644 --- a/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp +++ b/hotspot/src/share/vm/prims/jvmtiEnvBase.hpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it @@ -356,8 +356,12 @@ public: } VMOp_Type type() const { return VMOp_GetOwnedMonitorInfo; } void doit() { - ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, _java_thread, - _owned_monitors_list); + _result = JVMTI_ERROR_THREAD_NOT_ALIVE; + if (Threads::includes(_java_thread) && !_java_thread->is_exiting() + && _java_thread->threadObj() != NULL) { + _result = ((JvmtiEnvBase *)_env)->get_owned_monitors(_calling_thread, _java_thread, + _owned_monitors_list); + } } jvmtiError result() { return _result; } }; @@ -439,9 +443,13 @@ public: jvmtiError result() { return _result; } VMOp_Type type() const { return VMOp_GetStackTrace; } void doit() { - _result = ((JvmtiEnvBase *)_env)->get_stack_trace(_java_thread, - _start_depth, _max_count, - _frame_buffer, _count_ptr); + _result = JVMTI_ERROR_THREAD_NOT_ALIVE; + if (Threads::includes(_java_thread) && !_java_thread->is_exiting() + && _java_thread->threadObj() != NULL) { + _result = ((JvmtiEnvBase *)_env)->get_stack_trace(_java_thread, + _start_depth, _max_count, + _frame_buffer, _count_ptr); + } } }; From db6974faf72e655af00af23efa763dd113d19c6b Mon Sep 17 00:00:00 2001 From: Coleen Phillimore Date: Tue, 18 Feb 2014 09:54:24 -0500 Subject: [PATCH 146/159] 8035132: [TESTBUG] test/runtime/lambda-features/InvokespecialInterface.java test has unrecognized option Add IgnoreUnrecognizedVMOptions for product mode run Reviewed-by: ctornqvi, dholmes --- .../test/runtime/lambda-features/InvokespecialInterface.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/hotspot/test/runtime/lambda-features/InvokespecialInterface.java b/hotspot/test/runtime/lambda-features/InvokespecialInterface.java index 80c26186da2..c33dd56ef64 100644 --- a/hotspot/test/runtime/lambda-features/InvokespecialInterface.java +++ b/hotspot/test/runtime/lambda-features/InvokespecialInterface.java @@ -28,7 +28,7 @@ * @bug 8025937 * @bug 8033528 * @summary [JDK 8] Test invokespecial and invokeinterface with the same JVM_CONSTANT_InterfaceMethodref - * @run main/othervm -XX:+StressRewriter InvokespecialInterface + * @run main/othervm -XX:+IgnoreUnrecognizedVMOptions -XX:+StressRewriter InvokespecialInterface */ import java.util.function.*; import java.util.*; From b0422f5f5052bd3e266a2ead748cae32cb5cd8f4 Mon Sep 17 00:00:00 2001 From: Axel Siebenborn Date: Thu, 20 Feb 2014 10:48:57 +0100 Subject: [PATCH 147/159] 8035392: cppInterpreter: fix message of NPE Reviewed-by: kvn --- hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp index 7389d3afbf0..06261c804de 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp +++ b/hotspot/src/share/vm/interpreter/bytecodeInterpreter.cpp @@ -415,10 +415,10 @@ * On some architectures/platforms it should be possible to do this implicitly */ #undef CHECK_NULL -#define CHECK_NULL(obj_) \ - if ((obj_) == NULL) { \ - VM_JAVA_ERROR(vmSymbols::java_lang_NullPointerException(), "", note_nullCheck_trap); \ - } \ +#define CHECK_NULL(obj_) \ + if ((obj_) == NULL) { \ + VM_JAVA_ERROR(vmSymbols::java_lang_NullPointerException(), NULL, note_nullCheck_trap); \ + } \ VERIFY_OOP(obj_) #define VMdoubleConstZero() 0.0 From a5520f1c94d83d37da0ecd81976dd5a104a66917 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Thu, 20 Feb 2014 11:05:12 +0100 Subject: [PATCH 148/159] 8035394: PPC64: Make usage of intrinsic dsqrt depend on processor recognition Reviewed-by: kvn --- hotspot/src/cpu/ppc/vm/ppc.ad | 4 +++- hotspot/src/share/vm/opto/library_call.cpp | 2 +- 2 files changed, 4 insertions(+), 2 deletions(-) diff --git a/hotspot/src/cpu/ppc/vm/ppc.ad b/hotspot/src/cpu/ppc/vm/ppc.ad index cb1d75dc08b..01d5ffb8314 100644 --- a/hotspot/src/cpu/ppc/vm/ppc.ad +++ b/hotspot/src/cpu/ppc/vm/ppc.ad @@ -2076,6 +2076,8 @@ const bool Matcher::match_rule_supported(int opcode) { return false; switch (opcode) { + case Op_SqrtD: + return VM_Version::has_fsqrt(); case Op_CountLeadingZerosI: case Op_CountLeadingZerosL: case Op_CountTrailingZerosI: @@ -8740,7 +8742,7 @@ instruct negD_absD_reg(regD dst, regD src) %{ ins_pipe(pipe_class_default); %} -// VM_Version::has_sqrt() decides if this node will be used. +// VM_Version::has_fsqrt() decides if this node will be used. // Sqrt float double precision instruct sqrtD_reg(regD dst, regD src) %{ match(Set dst (SqrtD src)); diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 3a2279ee568..465de355b67 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -1937,7 +1937,7 @@ bool LibraryCallKit::inline_math_native(vmIntrinsics::ID id) { runtime_math(OptoRuntime::Math_D_D_Type(), FN_PTR(SharedRuntime::dlog10), "LOG10"); // These intrinsics are supported on all hardware - case vmIntrinsics::_dsqrt: return Matcher::has_match_rule(Op_SqrtD) ? inline_math(id) : false; + case vmIntrinsics::_dsqrt: return Matcher::match_rule_supported(Op_SqrtD) ? inline_math(id) : false; case vmIntrinsics::_dabs: return Matcher::has_match_rule(Op_AbsD) ? inline_math(id) : false; case vmIntrinsics::_dexp: return Matcher::has_match_rule(Op_ExpD) ? inline_exp() : From 05eda55e3cba1680a0f2707d665987beb0f087c6 Mon Sep 17 00:00:00 2001 From: Volker Simonis Date: Thu, 20 Feb 2014 14:44:33 +0100 Subject: [PATCH 149/159] 8035423: AIX: Fix os::get_default_process_handle() in os_aix.cpp after 8031968 Reviewed-by: kvn --- hotspot/src/os/aix/vm/os_aix.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hotspot/src/os/aix/vm/os_aix.cpp b/hotspot/src/os/aix/vm/os_aix.cpp index ded1fe218f0..ba6b8d494c6 100644 --- a/hotspot/src/os/aix/vm/os_aix.cpp +++ b/hotspot/src/os/aix/vm/os_aix.cpp @@ -1496,6 +1496,10 @@ void* os::dll_lookup(void* handle, const char* name) { return res; } +void* os::get_default_process_handle() { + return (void*)::dlopen(NULL, RTLD_LAZY); +} + void os::print_dll_info(outputStream *st) { st->print_cr("Dynamic libraries:"); LoadedLibraries::print(st); From be10ffa640889abe06d46922f361e48db63c0795 Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 19:28:22 +0200 Subject: [PATCH 150/159] Added tag jdk9-b02 for changeset b32e2219736e --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index 1bd0c05f284..15669b3da62 100644 --- a/.hgtags +++ b/.hgtags @@ -244,3 +244,4 @@ f5b521ade7a35cea18df78ee86322207729f5611 jdk8-b118 a1ee9743f4ee165eae59389a020f2552f895dac8 jdk8-b120 13b877757b0b1c0d5813298df85364f41d7ba6fe jdk9-b00 f130ca87de6637acae7d99fcd7a8573eea1cbaed jdk9-b01 +b32e2219736e42baaf45daf0ad67ed34f6033799 jdk9-b02 From e2fecea88e5d388df81cae186caf3439f95eb1d0 Mon Sep 17 00:00:00 2001 From: Vladimir Kozlov Date: Mon, 24 Feb 2014 15:12:26 -0800 Subject: [PATCH 151/159] 8033805: Move Fast_Lock/Fast_Unlock code from .ad files to macroassembler Consolidated C2 x86 locking code in one place in macroAssembler_x86.cpp. Reviewed-by: roland --- hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp | 1225 ++++++++++++----- hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp | 7 +- hotspot/src/cpu/x86/vm/x86_32.ad | 561 +------- hotspot/src/cpu/x86/vm/x86_64.ad | 243 +--- 4 files changed, 880 insertions(+), 1156 deletions(-) diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp index b4797bf3a39..74fa1b298ac 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.cpp @@ -98,217 +98,6 @@ Address MacroAssembler::as_Address(ArrayAddress adr) { return Address::make_array(adr); } -int MacroAssembler::biased_locking_enter(Register lock_reg, - Register obj_reg, - Register swap_reg, - Register tmp_reg, - bool swap_reg_contains_mark, - Label& done, - Label* slow_case, - BiasedLockingCounters* counters) { - assert(UseBiasedLocking, "why call this otherwise?"); - assert(swap_reg == rax, "swap_reg must be rax, for cmpxchg"); - assert_different_registers(lock_reg, obj_reg, swap_reg); - - if (PrintBiasedLockingStatistics && counters == NULL) - counters = BiasedLocking::counters(); - - bool need_tmp_reg = false; - if (tmp_reg == noreg) { - need_tmp_reg = true; - tmp_reg = lock_reg; - } else { - assert_different_registers(lock_reg, obj_reg, swap_reg, tmp_reg); - } - assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, "biased locking makes assumptions about bit layout"); - Address mark_addr (obj_reg, oopDesc::mark_offset_in_bytes()); - Address klass_addr (obj_reg, oopDesc::klass_offset_in_bytes()); - Address saved_mark_addr(lock_reg, 0); - - // Biased locking - // See whether the lock is currently biased toward our thread and - // whether the epoch is still valid - // Note that the runtime guarantees sufficient alignment of JavaThread - // pointers to allow age to be placed into low bits - // First check to see whether biasing is even enabled for this object - Label cas_label; - int null_check_offset = -1; - if (!swap_reg_contains_mark) { - null_check_offset = offset(); - movl(swap_reg, mark_addr); - } - if (need_tmp_reg) { - push(tmp_reg); - } - movl(tmp_reg, swap_reg); - andl(tmp_reg, markOopDesc::biased_lock_mask_in_place); - cmpl(tmp_reg, markOopDesc::biased_lock_pattern); - if (need_tmp_reg) { - pop(tmp_reg); - } - jcc(Assembler::notEqual, cas_label); - // The bias pattern is present in the object's header. Need to check - // whether the bias owner and the epoch are both still current. - // Note that because there is no current thread register on x86 we - // need to store off the mark word we read out of the object to - // avoid reloading it and needing to recheck invariants below. This - // store is unfortunate but it makes the overall code shorter and - // simpler. - movl(saved_mark_addr, swap_reg); - if (need_tmp_reg) { - push(tmp_reg); - } - get_thread(tmp_reg); - xorl(swap_reg, tmp_reg); - if (swap_reg_contains_mark) { - null_check_offset = offset(); - } - movl(tmp_reg, klass_addr); - xorl(swap_reg, Address(tmp_reg, Klass::prototype_header_offset())); - andl(swap_reg, ~((int) markOopDesc::age_mask_in_place)); - if (need_tmp_reg) { - pop(tmp_reg); - } - if (counters != NULL) { - cond_inc32(Assembler::zero, - ExternalAddress((address)counters->biased_lock_entry_count_addr())); - } - jcc(Assembler::equal, done); - - Label try_revoke_bias; - Label try_rebias; - - // At this point we know that the header has the bias pattern and - // that we are not the bias owner in the current epoch. We need to - // figure out more details about the state of the header in order to - // know what operations can be legally performed on the object's - // header. - - // If the low three bits in the xor result aren't clear, that means - // the prototype header is no longer biased and we have to revoke - // the bias on this object. - testl(swap_reg, markOopDesc::biased_lock_mask_in_place); - jcc(Assembler::notZero, try_revoke_bias); - - // Biasing is still enabled for this data type. See whether the - // epoch of the current bias is still valid, meaning that the epoch - // bits of the mark word are equal to the epoch bits of the - // prototype header. (Note that the prototype header's epoch bits - // only change at a safepoint.) If not, attempt to rebias the object - // toward the current thread. Note that we must be absolutely sure - // that the current epoch is invalid in order to do this because - // otherwise the manipulations it performs on the mark word are - // illegal. - testl(swap_reg, markOopDesc::epoch_mask_in_place); - jcc(Assembler::notZero, try_rebias); - - // The epoch of the current bias is still valid but we know nothing - // about the owner; it might be set or it might be clear. Try to - // acquire the bias of the object using an atomic operation. If this - // fails we will go in to the runtime to revoke the object's bias. - // Note that we first construct the presumed unbiased header so we - // don't accidentally blow away another thread's valid bias. - movl(swap_reg, saved_mark_addr); - andl(swap_reg, - markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place); - if (need_tmp_reg) { - push(tmp_reg); - } - get_thread(tmp_reg); - orl(tmp_reg, swap_reg); - if (os::is_MP()) { - lock(); - } - cmpxchgptr(tmp_reg, Address(obj_reg, 0)); - if (need_tmp_reg) { - pop(tmp_reg); - } - // If the biasing toward our thread failed, this means that - // another thread succeeded in biasing it toward itself and we - // need to revoke that bias. The revocation will occur in the - // interpreter runtime in the slow case. - if (counters != NULL) { - cond_inc32(Assembler::zero, - ExternalAddress((address)counters->anonymously_biased_lock_entry_count_addr())); - } - if (slow_case != NULL) { - jcc(Assembler::notZero, *slow_case); - } - jmp(done); - - bind(try_rebias); - // At this point we know the epoch has expired, meaning that the - // current "bias owner", if any, is actually invalid. Under these - // circumstances _only_, we are allowed to use the current header's - // value as the comparison value when doing the cas to acquire the - // bias in the current epoch. In other words, we allow transfer of - // the bias from one thread to another directly in this situation. - // - // FIXME: due to a lack of registers we currently blow away the age - // bits in this situation. Should attempt to preserve them. - if (need_tmp_reg) { - push(tmp_reg); - } - get_thread(tmp_reg); - movl(swap_reg, klass_addr); - orl(tmp_reg, Address(swap_reg, Klass::prototype_header_offset())); - movl(swap_reg, saved_mark_addr); - if (os::is_MP()) { - lock(); - } - cmpxchgptr(tmp_reg, Address(obj_reg, 0)); - if (need_tmp_reg) { - pop(tmp_reg); - } - // If the biasing toward our thread failed, then another thread - // succeeded in biasing it toward itself and we need to revoke that - // bias. The revocation will occur in the runtime in the slow case. - if (counters != NULL) { - cond_inc32(Assembler::zero, - ExternalAddress((address)counters->rebiased_lock_entry_count_addr())); - } - if (slow_case != NULL) { - jcc(Assembler::notZero, *slow_case); - } - jmp(done); - - bind(try_revoke_bias); - // The prototype mark in the klass doesn't have the bias bit set any - // more, indicating that objects of this data type are not supposed - // to be biased any more. We are going to try to reset the mark of - // this object to the prototype value and fall through to the - // CAS-based locking scheme. Note that if our CAS fails, it means - // that another thread raced us for the privilege of revoking the - // bias of this particular object, so it's okay to continue in the - // normal locking code. - // - // FIXME: due to a lack of registers we currently blow away the age - // bits in this situation. Should attempt to preserve them. - movl(swap_reg, saved_mark_addr); - if (need_tmp_reg) { - push(tmp_reg); - } - movl(tmp_reg, klass_addr); - movl(tmp_reg, Address(tmp_reg, Klass::prototype_header_offset())); - if (os::is_MP()) { - lock(); - } - cmpxchgptr(tmp_reg, Address(obj_reg, 0)); - if (need_tmp_reg) { - pop(tmp_reg); - } - // Fall through to the normal CAS-based lock, because no matter what - // the result of the above CAS, some thread must have succeeded in - // removing the bias bit from the object's header. - if (counters != NULL) { - cond_inc32(Assembler::zero, - ExternalAddress((address)counters->revoked_lock_entry_count_addr())); - } - - bind(cas_label); - - return null_check_offset; -} void MacroAssembler::call_VM_leaf_base(address entry_point, int number_of_arguments) { call(RuntimeAddress(entry_point)); @@ -726,165 +515,6 @@ Address MacroAssembler::as_Address(ArrayAddress adr) { return array; } -int MacroAssembler::biased_locking_enter(Register lock_reg, - Register obj_reg, - Register swap_reg, - Register tmp_reg, - bool swap_reg_contains_mark, - Label& done, - Label* slow_case, - BiasedLockingCounters* counters) { - assert(UseBiasedLocking, "why call this otherwise?"); - assert(swap_reg == rax, "swap_reg must be rax for cmpxchgq"); - assert(tmp_reg != noreg, "tmp_reg must be supplied"); - assert_different_registers(lock_reg, obj_reg, swap_reg, tmp_reg); - assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, "biased locking makes assumptions about bit layout"); - Address mark_addr (obj_reg, oopDesc::mark_offset_in_bytes()); - Address saved_mark_addr(lock_reg, 0); - - if (PrintBiasedLockingStatistics && counters == NULL) - counters = BiasedLocking::counters(); - - // Biased locking - // See whether the lock is currently biased toward our thread and - // whether the epoch is still valid - // Note that the runtime guarantees sufficient alignment of JavaThread - // pointers to allow age to be placed into low bits - // First check to see whether biasing is even enabled for this object - Label cas_label; - int null_check_offset = -1; - if (!swap_reg_contains_mark) { - null_check_offset = offset(); - movq(swap_reg, mark_addr); - } - movq(tmp_reg, swap_reg); - andq(tmp_reg, markOopDesc::biased_lock_mask_in_place); - cmpq(tmp_reg, markOopDesc::biased_lock_pattern); - jcc(Assembler::notEqual, cas_label); - // The bias pattern is present in the object's header. Need to check - // whether the bias owner and the epoch are both still current. - load_prototype_header(tmp_reg, obj_reg); - orq(tmp_reg, r15_thread); - xorq(tmp_reg, swap_reg); - andq(tmp_reg, ~((int) markOopDesc::age_mask_in_place)); - if (counters != NULL) { - cond_inc32(Assembler::zero, - ExternalAddress((address) counters->anonymously_biased_lock_entry_count_addr())); - } - jcc(Assembler::equal, done); - - Label try_revoke_bias; - Label try_rebias; - - // At this point we know that the header has the bias pattern and - // that we are not the bias owner in the current epoch. We need to - // figure out more details about the state of the header in order to - // know what operations can be legally performed on the object's - // header. - - // If the low three bits in the xor result aren't clear, that means - // the prototype header is no longer biased and we have to revoke - // the bias on this object. - testq(tmp_reg, markOopDesc::biased_lock_mask_in_place); - jcc(Assembler::notZero, try_revoke_bias); - - // Biasing is still enabled for this data type. See whether the - // epoch of the current bias is still valid, meaning that the epoch - // bits of the mark word are equal to the epoch bits of the - // prototype header. (Note that the prototype header's epoch bits - // only change at a safepoint.) If not, attempt to rebias the object - // toward the current thread. Note that we must be absolutely sure - // that the current epoch is invalid in order to do this because - // otherwise the manipulations it performs on the mark word are - // illegal. - testq(tmp_reg, markOopDesc::epoch_mask_in_place); - jcc(Assembler::notZero, try_rebias); - - // The epoch of the current bias is still valid but we know nothing - // about the owner; it might be set or it might be clear. Try to - // acquire the bias of the object using an atomic operation. If this - // fails we will go in to the runtime to revoke the object's bias. - // Note that we first construct the presumed unbiased header so we - // don't accidentally blow away another thread's valid bias. - andq(swap_reg, - markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place); - movq(tmp_reg, swap_reg); - orq(tmp_reg, r15_thread); - if (os::is_MP()) { - lock(); - } - cmpxchgq(tmp_reg, Address(obj_reg, 0)); - // If the biasing toward our thread failed, this means that - // another thread succeeded in biasing it toward itself and we - // need to revoke that bias. The revocation will occur in the - // interpreter runtime in the slow case. - if (counters != NULL) { - cond_inc32(Assembler::zero, - ExternalAddress((address) counters->anonymously_biased_lock_entry_count_addr())); - } - if (slow_case != NULL) { - jcc(Assembler::notZero, *slow_case); - } - jmp(done); - - bind(try_rebias); - // At this point we know the epoch has expired, meaning that the - // current "bias owner", if any, is actually invalid. Under these - // circumstances _only_, we are allowed to use the current header's - // value as the comparison value when doing the cas to acquire the - // bias in the current epoch. In other words, we allow transfer of - // the bias from one thread to another directly in this situation. - // - // FIXME: due to a lack of registers we currently blow away the age - // bits in this situation. Should attempt to preserve them. - load_prototype_header(tmp_reg, obj_reg); - orq(tmp_reg, r15_thread); - if (os::is_MP()) { - lock(); - } - cmpxchgq(tmp_reg, Address(obj_reg, 0)); - // If the biasing toward our thread failed, then another thread - // succeeded in biasing it toward itself and we need to revoke that - // bias. The revocation will occur in the runtime in the slow case. - if (counters != NULL) { - cond_inc32(Assembler::zero, - ExternalAddress((address) counters->rebiased_lock_entry_count_addr())); - } - if (slow_case != NULL) { - jcc(Assembler::notZero, *slow_case); - } - jmp(done); - - bind(try_revoke_bias); - // The prototype mark in the klass doesn't have the bias bit set any - // more, indicating that objects of this data type are not supposed - // to be biased any more. We are going to try to reset the mark of - // this object to the prototype value and fall through to the - // CAS-based locking scheme. Note that if our CAS fails, it means - // that another thread raced us for the privilege of revoking the - // bias of this particular object, so it's okay to continue in the - // normal locking code. - // - // FIXME: due to a lack of registers we currently blow away the age - // bits in this situation. Should attempt to preserve them. - load_prototype_header(tmp_reg, obj_reg); - if (os::is_MP()) { - lock(); - } - cmpxchgq(tmp_reg, Address(obj_reg, 0)); - // Fall through to the normal CAS-based lock, because no matter what - // the result of the above CAS, some thread must have succeeded in - // removing the bias bit from the object's header. - if (counters != NULL) { - cond_inc32(Assembler::zero, - ExternalAddress((address) counters->revoked_lock_entry_count_addr())); - } - - bind(cas_label); - - return null_check_offset; -} - void MacroAssembler::call_VM_leaf_base(address entry_point, int num_args) { Label L, E; @@ -1360,9 +990,16 @@ void MacroAssembler::andptr(Register dst, int32_t imm32) { void MacroAssembler::atomic_incl(AddressLiteral counter_addr) { pushf(); - if (os::is_MP()) - lock(); - incrementl(counter_addr); + if (reachable(counter_addr)) { + if (os::is_MP()) + lock(); + incrementl(as_Address(counter_addr)); + } else { + lea(rscratch1, counter_addr); + if (os::is_MP()) + lock(); + incrementl(Address(rscratch1, 0)); + } popf(); } @@ -1393,6 +1030,234 @@ void MacroAssembler::bang_stack_size(Register size, Register tmp) { } } +int MacroAssembler::biased_locking_enter(Register lock_reg, + Register obj_reg, + Register swap_reg, + Register tmp_reg, + bool swap_reg_contains_mark, + Label& done, + Label* slow_case, + BiasedLockingCounters* counters) { + assert(UseBiasedLocking, "why call this otherwise?"); + assert(swap_reg == rax, "swap_reg must be rax for cmpxchgq"); + LP64_ONLY( assert(tmp_reg != noreg, "tmp_reg must be supplied"); ) + bool need_tmp_reg = false; + if (tmp_reg == noreg) { + need_tmp_reg = true; + tmp_reg = lock_reg; + assert_different_registers(lock_reg, obj_reg, swap_reg); + } else { + assert_different_registers(lock_reg, obj_reg, swap_reg, tmp_reg); + } + assert(markOopDesc::age_shift == markOopDesc::lock_bits + markOopDesc::biased_lock_bits, "biased locking makes assumptions about bit layout"); + Address mark_addr (obj_reg, oopDesc::mark_offset_in_bytes()); + Address saved_mark_addr(lock_reg, 0); + + if (PrintBiasedLockingStatistics && counters == NULL) { + counters = BiasedLocking::counters(); + } + // Biased locking + // See whether the lock is currently biased toward our thread and + // whether the epoch is still valid + // Note that the runtime guarantees sufficient alignment of JavaThread + // pointers to allow age to be placed into low bits + // First check to see whether biasing is even enabled for this object + Label cas_label; + int null_check_offset = -1; + if (!swap_reg_contains_mark) { + null_check_offset = offset(); + movptr(swap_reg, mark_addr); + } + if (need_tmp_reg) { + push(tmp_reg); + } + movptr(tmp_reg, swap_reg); + andptr(tmp_reg, markOopDesc::biased_lock_mask_in_place); + cmpptr(tmp_reg, markOopDesc::biased_lock_pattern); + if (need_tmp_reg) { + pop(tmp_reg); + } + jcc(Assembler::notEqual, cas_label); + // The bias pattern is present in the object's header. Need to check + // whether the bias owner and the epoch are both still current. +#ifndef _LP64 + // Note that because there is no current thread register on x86_32 we + // need to store off the mark word we read out of the object to + // avoid reloading it and needing to recheck invariants below. This + // store is unfortunate but it makes the overall code shorter and + // simpler. + movptr(saved_mark_addr, swap_reg); +#endif + if (need_tmp_reg) { + push(tmp_reg); + } + if (swap_reg_contains_mark) { + null_check_offset = offset(); + } + load_prototype_header(tmp_reg, obj_reg); +#ifdef _LP64 + orptr(tmp_reg, r15_thread); + xorptr(tmp_reg, swap_reg); + Register header_reg = tmp_reg; +#else + xorptr(tmp_reg, swap_reg); + get_thread(swap_reg); + xorptr(swap_reg, tmp_reg); + Register header_reg = swap_reg; +#endif + andptr(header_reg, ~((int) markOopDesc::age_mask_in_place)); + if (need_tmp_reg) { + pop(tmp_reg); + } + if (counters != NULL) { + cond_inc32(Assembler::zero, + ExternalAddress((address) counters->biased_lock_entry_count_addr())); + } + jcc(Assembler::equal, done); + + Label try_revoke_bias; + Label try_rebias; + + // At this point we know that the header has the bias pattern and + // that we are not the bias owner in the current epoch. We need to + // figure out more details about the state of the header in order to + // know what operations can be legally performed on the object's + // header. + + // If the low three bits in the xor result aren't clear, that means + // the prototype header is no longer biased and we have to revoke + // the bias on this object. + testptr(header_reg, markOopDesc::biased_lock_mask_in_place); + jccb(Assembler::notZero, try_revoke_bias); + + // Biasing is still enabled for this data type. See whether the + // epoch of the current bias is still valid, meaning that the epoch + // bits of the mark word are equal to the epoch bits of the + // prototype header. (Note that the prototype header's epoch bits + // only change at a safepoint.) If not, attempt to rebias the object + // toward the current thread. Note that we must be absolutely sure + // that the current epoch is invalid in order to do this because + // otherwise the manipulations it performs on the mark word are + // illegal. + testptr(header_reg, markOopDesc::epoch_mask_in_place); + jccb(Assembler::notZero, try_rebias); + + // The epoch of the current bias is still valid but we know nothing + // about the owner; it might be set or it might be clear. Try to + // acquire the bias of the object using an atomic operation. If this + // fails we will go in to the runtime to revoke the object's bias. + // Note that we first construct the presumed unbiased header so we + // don't accidentally blow away another thread's valid bias. + NOT_LP64( movptr(swap_reg, saved_mark_addr); ) + andptr(swap_reg, + markOopDesc::biased_lock_mask_in_place | markOopDesc::age_mask_in_place | markOopDesc::epoch_mask_in_place); + if (need_tmp_reg) { + push(tmp_reg); + } +#ifdef _LP64 + movptr(tmp_reg, swap_reg); + orptr(tmp_reg, r15_thread); +#else + get_thread(tmp_reg); + orptr(tmp_reg, swap_reg); +#endif + if (os::is_MP()) { + lock(); + } + cmpxchgptr(tmp_reg, mark_addr); // compare tmp_reg and swap_reg + if (need_tmp_reg) { + pop(tmp_reg); + } + // If the biasing toward our thread failed, this means that + // another thread succeeded in biasing it toward itself and we + // need to revoke that bias. The revocation will occur in the + // interpreter runtime in the slow case. + if (counters != NULL) { + cond_inc32(Assembler::zero, + ExternalAddress((address) counters->anonymously_biased_lock_entry_count_addr())); + } + if (slow_case != NULL) { + jcc(Assembler::notZero, *slow_case); + } + jmp(done); + + bind(try_rebias); + // At this point we know the epoch has expired, meaning that the + // current "bias owner", if any, is actually invalid. Under these + // circumstances _only_, we are allowed to use the current header's + // value as the comparison value when doing the cas to acquire the + // bias in the current epoch. In other words, we allow transfer of + // the bias from one thread to another directly in this situation. + // + // FIXME: due to a lack of registers we currently blow away the age + // bits in this situation. Should attempt to preserve them. + if (need_tmp_reg) { + push(tmp_reg); + } + load_prototype_header(tmp_reg, obj_reg); +#ifdef _LP64 + orptr(tmp_reg, r15_thread); +#else + get_thread(swap_reg); + orptr(tmp_reg, swap_reg); + movptr(swap_reg, saved_mark_addr); +#endif + if (os::is_MP()) { + lock(); + } + cmpxchgptr(tmp_reg, mark_addr); // compare tmp_reg and swap_reg + if (need_tmp_reg) { + pop(tmp_reg); + } + // If the biasing toward our thread failed, then another thread + // succeeded in biasing it toward itself and we need to revoke that + // bias. The revocation will occur in the runtime in the slow case. + if (counters != NULL) { + cond_inc32(Assembler::zero, + ExternalAddress((address) counters->rebiased_lock_entry_count_addr())); + } + if (slow_case != NULL) { + jcc(Assembler::notZero, *slow_case); + } + jmp(done); + + bind(try_revoke_bias); + // The prototype mark in the klass doesn't have the bias bit set any + // more, indicating that objects of this data type are not supposed + // to be biased any more. We are going to try to reset the mark of + // this object to the prototype value and fall through to the + // CAS-based locking scheme. Note that if our CAS fails, it means + // that another thread raced us for the privilege of revoking the + // bias of this particular object, so it's okay to continue in the + // normal locking code. + // + // FIXME: due to a lack of registers we currently blow away the age + // bits in this situation. Should attempt to preserve them. + NOT_LP64( movptr(swap_reg, saved_mark_addr); ) + if (need_tmp_reg) { + push(tmp_reg); + } + load_prototype_header(tmp_reg, obj_reg); + if (os::is_MP()) { + lock(); + } + cmpxchgptr(tmp_reg, mark_addr); // compare tmp_reg and swap_reg + if (need_tmp_reg) { + pop(tmp_reg); + } + // Fall through to the normal CAS-based lock, because no matter what + // the result of the above CAS, some thread must have succeeded in + // removing the bias bit from the object's header. + if (counters != NULL) { + cond_inc32(Assembler::zero, + ExternalAddress((address) counters->revoked_lock_entry_count_addr())); + } + + bind(cas_label); + + return null_check_offset; +} + void MacroAssembler::biased_locking_exit(Register obj_reg, Register temp_reg, Label& done) { assert(UseBiasedLocking, "why call this otherwise?"); @@ -1408,6 +1273,620 @@ void MacroAssembler::biased_locking_exit(Register obj_reg, Register temp_reg, La jcc(Assembler::equal, done); } +#ifdef COMPILER2 +// Fast_Lock and Fast_Unlock used by C2 + +// Because the transitions from emitted code to the runtime +// monitorenter/exit helper stubs are so slow it's critical that +// we inline both the stack-locking fast-path and the inflated fast path. +// +// See also: cmpFastLock and cmpFastUnlock. +// +// What follows is a specialized inline transliteration of the code +// in slow_enter() and slow_exit(). If we're concerned about I$ bloat +// another option would be to emit TrySlowEnter and TrySlowExit methods +// at startup-time. These methods would accept arguments as +// (rax,=Obj, rbx=Self, rcx=box, rdx=Scratch) and return success-failure +// indications in the icc.ZFlag. Fast_Lock and Fast_Unlock would simply +// marshal the arguments and emit calls to TrySlowEnter and TrySlowExit. +// In practice, however, the # of lock sites is bounded and is usually small. +// Besides the call overhead, TrySlowEnter and TrySlowExit might suffer +// if the processor uses simple bimodal branch predictors keyed by EIP +// Since the helper routines would be called from multiple synchronization +// sites. +// +// An even better approach would be write "MonitorEnter()" and "MonitorExit()" +// in java - using j.u.c and unsafe - and just bind the lock and unlock sites +// to those specialized methods. That'd give us a mostly platform-independent +// implementation that the JITs could optimize and inline at their pleasure. +// Done correctly, the only time we'd need to cross to native could would be +// to park() or unpark() threads. We'd also need a few more unsafe operators +// to (a) prevent compiler-JIT reordering of non-volatile accesses, and +// (b) explicit barriers or fence operations. +// +// TODO: +// +// * Arrange for C2 to pass "Self" into Fast_Lock and Fast_Unlock in one of the registers (scr). +// This avoids manifesting the Self pointer in the Fast_Lock and Fast_Unlock terminals. +// Given TLAB allocation, Self is usually manifested in a register, so passing it into +// the lock operators would typically be faster than reifying Self. +// +// * Ideally I'd define the primitives as: +// fast_lock (nax Obj, nax box, EAX tmp, nax scr) where box, tmp and scr are KILLED. +// fast_unlock (nax Obj, EAX box, nax tmp) where box and tmp are KILLED +// Unfortunately ADLC bugs prevent us from expressing the ideal form. +// Instead, we're stuck with a rather awkward and brittle register assignments below. +// Furthermore the register assignments are overconstrained, possibly resulting in +// sub-optimal code near the synchronization site. +// +// * Eliminate the sp-proximity tests and just use "== Self" tests instead. +// Alternately, use a better sp-proximity test. +// +// * Currently ObjectMonitor._Owner can hold either an sp value or a (THREAD *) value. +// Either one is sufficient to uniquely identify a thread. +// TODO: eliminate use of sp in _owner and use get_thread(tr) instead. +// +// * Intrinsify notify() and notifyAll() for the common cases where the +// object is locked by the calling thread but the waitlist is empty. +// avoid the expensive JNI call to JVM_Notify() and JVM_NotifyAll(). +// +// * use jccb and jmpb instead of jcc and jmp to improve code density. +// But beware of excessive branch density on AMD Opterons. +// +// * Both Fast_Lock and Fast_Unlock set the ICC.ZF to indicate success +// or failure of the fast-path. If the fast-path fails then we pass +// control to the slow-path, typically in C. In Fast_Lock and +// Fast_Unlock we often branch to DONE_LABEL, just to find that C2 +// will emit a conditional branch immediately after the node. +// So we have branches to branches and lots of ICC.ZF games. +// Instead, it might be better to have C2 pass a "FailureLabel" +// into Fast_Lock and Fast_Unlock. In the case of success, control +// will drop through the node. ICC.ZF is undefined at exit. +// In the case of failure, the node will branch directly to the +// FailureLabel + + +// obj: object to lock +// box: on-stack box address (displaced header location) - KILLED +// rax,: tmp -- KILLED +// scr: tmp -- KILLED +void MacroAssembler::fast_lock(Register objReg, Register boxReg, Register tmpReg, Register scrReg, BiasedLockingCounters* counters) { + // Ensure the register assignents are disjoint + guarantee (objReg != boxReg, ""); + guarantee (objReg != tmpReg, ""); + guarantee (objReg != scrReg, ""); + guarantee (boxReg != tmpReg, ""); + guarantee (boxReg != scrReg, ""); + guarantee (tmpReg == rax, ""); + + if (counters != NULL) { + atomic_incl(ExternalAddress((address)counters->total_entry_count_addr())); + } + if (EmitSync & 1) { + // set box->dhw = unused_mark (3) + // Force all sync thru slow-path: slow_enter() and slow_exit() + movptr (Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark())); + cmpptr (rsp, (int32_t)NULL_WORD); + } else + if (EmitSync & 2) { + Label DONE_LABEL ; + if (UseBiasedLocking) { + // Note: tmpReg maps to the swap_reg argument and scrReg to the tmp_reg argument. + biased_locking_enter(boxReg, objReg, tmpReg, scrReg, false, DONE_LABEL, NULL, counters); + } + + movptr(tmpReg, Address(objReg, 0)); // fetch markword + orptr (tmpReg, 0x1); + movptr(Address(boxReg, 0), tmpReg); // Anticipate successful CAS + if (os::is_MP()) { + lock(); + } + cmpxchgptr(boxReg, Address(objReg, 0)); // Updates tmpReg + jccb(Assembler::equal, DONE_LABEL); + // Recursive locking + subptr(tmpReg, rsp); + andptr(tmpReg, (int32_t) (NOT_LP64(0xFFFFF003) LP64_ONLY(7 - os::vm_page_size())) ); + movptr(Address(boxReg, 0), tmpReg); + bind(DONE_LABEL); + } else { + // Possible cases that we'll encounter in fast_lock + // ------------------------------------------------ + // * Inflated + // -- unlocked + // -- Locked + // = by self + // = by other + // * biased + // -- by Self + // -- by other + // * neutral + // * stack-locked + // -- by self + // = sp-proximity test hits + // = sp-proximity test generates false-negative + // -- by other + // + + Label IsInflated, DONE_LABEL; + + // it's stack-locked, biased or neutral + // TODO: optimize away redundant LDs of obj->mark and improve the markword triage + // order to reduce the number of conditional branches in the most common cases. + // Beware -- there's a subtle invariant that fetch of the markword + // at [FETCH], below, will never observe a biased encoding (*101b). + // If this invariant is not held we risk exclusion (safety) failure. + if (UseBiasedLocking && !UseOptoBiasInlining) { + biased_locking_enter(boxReg, objReg, tmpReg, scrReg, true, DONE_LABEL, NULL, counters); + } + + movptr(tmpReg, Address(objReg, 0)); // [FETCH] + testl (tmpReg, markOopDesc::monitor_value); // inflated vs stack-locked|neutral|biased + jccb (Assembler::notZero, IsInflated); + + // Attempt stack-locking ... + orptr (tmpReg, 0x1); + movptr(Address(boxReg, 0), tmpReg); // Anticipate successful CAS + if (os::is_MP()) { + lock(); + } + cmpxchgptr(boxReg, Address(objReg, 0)); // Updates tmpReg + if (counters != NULL) { + cond_inc32(Assembler::equal, + ExternalAddress((address)counters->fast_path_entry_count_addr())); + } + jccb(Assembler::equal, DONE_LABEL); + + // Recursive locking + subptr(tmpReg, rsp); + andptr(tmpReg, (int32_t) (NOT_LP64(0xFFFFF003) LP64_ONLY(7 - os::vm_page_size())) ); + movptr(Address(boxReg, 0), tmpReg); + if (counters != NULL) { + cond_inc32(Assembler::equal, + ExternalAddress((address)counters->fast_path_entry_count_addr())); + } + jmpb(DONE_LABEL); + + bind(IsInflated); +#ifndef _LP64 + // The object is inflated. + // + // TODO-FIXME: eliminate the ugly use of manifest constants: + // Use markOopDesc::monitor_value instead of "2". + // use markOop::unused_mark() instead of "3". + // The tmpReg value is an objectMonitor reference ORed with + // markOopDesc::monitor_value (2). We can either convert tmpReg to an + // objectmonitor pointer by masking off the "2" bit or we can just + // use tmpReg as an objectmonitor pointer but bias the objectmonitor + // field offsets with "-2" to compensate for and annul the low-order tag bit. + // + // I use the latter as it avoids AGI stalls. + // As such, we write "mov r, [tmpReg+OFFSETOF(Owner)-2]" + // instead of "mov r, [tmpReg+OFFSETOF(Owner)]". + // + #define OFFSET_SKEWED(f) ((ObjectMonitor::f ## _offset_in_bytes())-2) + + // boxReg refers to the on-stack BasicLock in the current frame. + // We'd like to write: + // set box->_displaced_header = markOop::unused_mark(). Any non-0 value suffices. + // This is convenient but results a ST-before-CAS penalty. The following CAS suffers + // additional latency as we have another ST in the store buffer that must drain. + + if (EmitSync & 8192) { + movptr(Address(boxReg, 0), 3); // results in ST-before-CAS penalty + get_thread (scrReg); + movptr(boxReg, tmpReg); // consider: LEA box, [tmp-2] + movptr(tmpReg, NULL_WORD); // consider: xor vs mov + if (os::is_MP()) { + lock(); + } + cmpxchgptr(scrReg, Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2)); + } else + if ((EmitSync & 128) == 0) { // avoid ST-before-CAS + movptr(scrReg, boxReg); + movptr(boxReg, tmpReg); // consider: LEA box, [tmp-2] + + // Using a prefetchw helps avoid later RTS->RTO upgrades and cache probes + if ((EmitSync & 2048) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) { + // prefetchw [eax + Offset(_owner)-2] + prefetchw(Address(tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); + } + + if ((EmitSync & 64) == 0) { + // Optimistic form: consider XORL tmpReg,tmpReg + movptr(tmpReg, NULL_WORD); + } else { + // Can suffer RTS->RTO upgrades on shared or cold $ lines + // Test-And-CAS instead of CAS + movptr(tmpReg, Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); // rax, = m->_owner + testptr(tmpReg, tmpReg); // Locked ? + jccb (Assembler::notZero, DONE_LABEL); + } + + // Appears unlocked - try to swing _owner from null to non-null. + // Ideally, I'd manifest "Self" with get_thread and then attempt + // to CAS the register containing Self into m->Owner. + // But we don't have enough registers, so instead we can either try to CAS + // rsp or the address of the box (in scr) into &m->owner. If the CAS succeeds + // we later store "Self" into m->Owner. Transiently storing a stack address + // (rsp or the address of the box) into m->owner is harmless. + // Invariant: tmpReg == 0. tmpReg is EAX which is the implicit cmpxchg comparand. + if (os::is_MP()) { + lock(); + } + cmpxchgptr(scrReg, Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2)); + movptr(Address(scrReg, 0), 3); // box->_displaced_header = 3 + jccb (Assembler::notZero, DONE_LABEL); + get_thread (scrReg); // beware: clobbers ICCs + movptr(Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2), scrReg); + xorptr(boxReg, boxReg); // set icc.ZFlag = 1 to indicate success + + // If the CAS fails we can either retry or pass control to the slow-path. + // We use the latter tactic. + // Pass the CAS result in the icc.ZFlag into DONE_LABEL + // If the CAS was successful ... + // Self has acquired the lock + // Invariant: m->_recursions should already be 0, so we don't need to explicitly set it. + // Intentional fall-through into DONE_LABEL ... + } else { + movptr(Address(boxReg, 0), intptr_t(markOopDesc::unused_mark())); // results in ST-before-CAS penalty + movptr(boxReg, tmpReg); + + // Using a prefetchw helps avoid later RTS->RTO upgrades and cache probes + if ((EmitSync & 2048) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) { + // prefetchw [eax + Offset(_owner)-2] + prefetchw(Address(tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); + } + + if ((EmitSync & 64) == 0) { + // Optimistic form + xorptr (tmpReg, tmpReg); + } else { + // Can suffer RTS->RTO upgrades on shared or cold $ lines + movptr(tmpReg, Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); // rax, = m->_owner + testptr(tmpReg, tmpReg); // Locked ? + jccb (Assembler::notZero, DONE_LABEL); + } + + // Appears unlocked - try to swing _owner from null to non-null. + // Use either "Self" (in scr) or rsp as thread identity in _owner. + // Invariant: tmpReg == 0. tmpReg is EAX which is the implicit cmpxchg comparand. + get_thread (scrReg); + if (os::is_MP()) { + lock(); + } + cmpxchgptr(scrReg, Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2)); + + // If the CAS fails we can either retry or pass control to the slow-path. + // We use the latter tactic. + // Pass the CAS result in the icc.ZFlag into DONE_LABEL + // If the CAS was successful ... + // Self has acquired the lock + // Invariant: m->_recursions should already be 0, so we don't need to explicitly set it. + // Intentional fall-through into DONE_LABEL ... + } +#else // _LP64 + // It's inflated + + // TODO: someday avoid the ST-before-CAS penalty by + // relocating (deferring) the following ST. + // We should also think about trying a CAS without having + // fetched _owner. If the CAS is successful we may + // avoid an RTO->RTS upgrade on the $line. + + // Without cast to int32_t a movptr will destroy r10 which is typically obj + movptr(Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark())); + + mov (boxReg, tmpReg); + movptr (tmpReg, Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2)); + testptr(tmpReg, tmpReg); + jccb (Assembler::notZero, DONE_LABEL); + + // It's inflated and appears unlocked + if (os::is_MP()) { + lock(); + } + cmpxchgptr(r15_thread, Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2)); + // Intentional fall-through into DONE_LABEL ... + +#endif + + // DONE_LABEL is a hot target - we'd really like to place it at the + // start of cache line by padding with NOPs. + // See the AMD and Intel software optimization manuals for the + // most efficient "long" NOP encodings. + // Unfortunately none of our alignment mechanisms suffice. + bind(DONE_LABEL); + + // At DONE_LABEL the icc ZFlag is set as follows ... + // Fast_Unlock uses the same protocol. + // ZFlag == 1 -> Success + // ZFlag == 0 -> Failure - force control through the slow-path + } +} + +// obj: object to unlock +// box: box address (displaced header location), killed. Must be EAX. +// tmp: killed, cannot be obj nor box. +// +// Some commentary on balanced locking: +// +// Fast_Lock and Fast_Unlock are emitted only for provably balanced lock sites. +// Methods that don't have provably balanced locking are forced to run in the +// interpreter - such methods won't be compiled to use fast_lock and fast_unlock. +// The interpreter provides two properties: +// I1: At return-time the interpreter automatically and quietly unlocks any +// objects acquired the current activation (frame). Recall that the +// interpreter maintains an on-stack list of locks currently held by +// a frame. +// I2: If a method attempts to unlock an object that is not held by the +// the frame the interpreter throws IMSX. +// +// Lets say A(), which has provably balanced locking, acquires O and then calls B(). +// B() doesn't have provably balanced locking so it runs in the interpreter. +// Control returns to A() and A() unlocks O. By I1 and I2, above, we know that O +// is still locked by A(). +// +// The only other source of unbalanced locking would be JNI. The "Java Native Interface: +// Programmer's Guide and Specification" claims that an object locked by jni_monitorenter +// should not be unlocked by "normal" java-level locking and vice-versa. The specification +// doesn't specify what will occur if a program engages in such mixed-mode locking, however. + +void MacroAssembler::fast_unlock(Register objReg, Register boxReg, Register tmpReg) { + guarantee (objReg != boxReg, ""); + guarantee (objReg != tmpReg, ""); + guarantee (boxReg != tmpReg, ""); + guarantee (boxReg == rax, ""); + + if (EmitSync & 4) { + // Disable - inhibit all inlining. Force control through the slow-path + cmpptr (rsp, 0); + } else + if (EmitSync & 8) { + Label DONE_LABEL; + if (UseBiasedLocking) { + biased_locking_exit(objReg, tmpReg, DONE_LABEL); + } + // Classic stack-locking code ... + // Check whether the displaced header is 0 + //(=> recursive unlock) + movptr(tmpReg, Address(boxReg, 0)); + testptr(tmpReg, tmpReg); + jccb(Assembler::zero, DONE_LABEL); + // If not recursive lock, reset the header to displaced header + if (os::is_MP()) { + lock(); + } + cmpxchgptr(tmpReg, Address(objReg, 0)); // Uses RAX which is box + bind(DONE_LABEL); + } else { + Label DONE_LABEL, Stacked, CheckSucc; + + // Critically, the biased locking test must have precedence over + // and appear before the (box->dhw == 0) recursive stack-lock test. + if (UseBiasedLocking && !UseOptoBiasInlining) { + biased_locking_exit(objReg, tmpReg, DONE_LABEL); + } + + cmpptr(Address(boxReg, 0), (int32_t)NULL_WORD); // Examine the displaced header + movptr(tmpReg, Address(objReg, 0)); // Examine the object's markword + jccb (Assembler::zero, DONE_LABEL); // 0 indicates recursive stack-lock + + testptr(tmpReg, 0x02); // Inflated? + jccb (Assembler::zero, Stacked); + + // It's inflated. + // Despite our balanced locking property we still check that m->_owner == Self + // as java routines or native JNI code called by this thread might + // have released the lock. + // Refer to the comments in synchronizer.cpp for how we might encode extra + // state in _succ so we can avoid fetching EntryList|cxq. + // + // I'd like to add more cases in fast_lock() and fast_unlock() -- + // such as recursive enter and exit -- but we have to be wary of + // I$ bloat, T$ effects and BP$ effects. + // + // If there's no contention try a 1-0 exit. That is, exit without + // a costly MEMBAR or CAS. See synchronizer.cpp for details on how + // we detect and recover from the race that the 1-0 exit admits. + // + // Conceptually Fast_Unlock() must execute a STST|LDST "release" barrier + // before it STs null into _owner, releasing the lock. Updates + // to data protected by the critical section must be visible before + // we drop the lock (and thus before any other thread could acquire + // the lock and observe the fields protected by the lock). + // IA32's memory-model is SPO, so STs are ordered with respect to + // each other and there's no need for an explicit barrier (fence). + // See also http://gee.cs.oswego.edu/dl/jmm/cookbook.html. +#ifndef _LP64 + get_thread (boxReg); + if ((EmitSync & 4096) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) { + // prefetchw [ebx + Offset(_owner)-2] + prefetchw(Address(tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); + } + + // Note that we could employ various encoding schemes to reduce + // the number of loads below (currently 4) to just 2 or 3. + // Refer to the comments in synchronizer.cpp. + // In practice the chain of fetches doesn't seem to impact performance, however. + if ((EmitSync & 65536) == 0 && (EmitSync & 256)) { + // Attempt to reduce branch density - AMD's branch predictor. + xorptr(boxReg, Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); + orptr(boxReg, Address (tmpReg, ObjectMonitor::recursions_offset_in_bytes()-2)); + orptr(boxReg, Address (tmpReg, ObjectMonitor::EntryList_offset_in_bytes()-2)); + orptr(boxReg, Address (tmpReg, ObjectMonitor::cxq_offset_in_bytes()-2)); + jccb (Assembler::notZero, DONE_LABEL); + movptr(Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), NULL_WORD); + jmpb (DONE_LABEL); + } else { + xorptr(boxReg, Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); + orptr(boxReg, Address (tmpReg, ObjectMonitor::recursions_offset_in_bytes()-2)); + jccb (Assembler::notZero, DONE_LABEL); + movptr(boxReg, Address (tmpReg, ObjectMonitor::EntryList_offset_in_bytes()-2)); + orptr(boxReg, Address (tmpReg, ObjectMonitor::cxq_offset_in_bytes()-2)); + jccb (Assembler::notZero, CheckSucc); + movptr(Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), NULL_WORD); + jmpb (DONE_LABEL); + } + + // The Following code fragment (EmitSync & 65536) improves the performance of + // contended applications and contended synchronization microbenchmarks. + // Unfortunately the emission of the code - even though not executed - causes regressions + // in scimark and jetstream, evidently because of $ effects. Replacing the code + // with an equal number of never-executed NOPs results in the same regression. + // We leave it off by default. + + if ((EmitSync & 65536) != 0) { + Label LSuccess, LGoSlowPath ; + + bind (CheckSucc); + + // Optional pre-test ... it's safe to elide this + if ((EmitSync & 16) == 0) { + cmpptr(Address (tmpReg, ObjectMonitor::succ_offset_in_bytes()-2), (int32_t)NULL_WORD); + jccb (Assembler::zero, LGoSlowPath); + } + + // We have a classic Dekker-style idiom: + // ST m->_owner = 0 ; MEMBAR; LD m->_succ + // There are a number of ways to implement the barrier: + // (1) lock:andl &m->_owner, 0 + // is fast, but mask doesn't currently support the "ANDL M,IMM32" form. + // LOCK: ANDL [ebx+Offset(_Owner)-2], 0 + // Encodes as 81 31 OFF32 IMM32 or 83 63 OFF8 IMM8 + // (2) If supported, an explicit MFENCE is appealing. + // In older IA32 processors MFENCE is slower than lock:add or xchg + // particularly if the write-buffer is full as might be the case if + // if stores closely precede the fence or fence-equivalent instruction. + // In more modern implementations MFENCE appears faster, however. + // (3) In lieu of an explicit fence, use lock:addl to the top-of-stack + // The $lines underlying the top-of-stack should be in M-state. + // The locked add instruction is serializing, of course. + // (4) Use xchg, which is serializing + // mov boxReg, 0; xchgl boxReg, [tmpReg + Offset(_owner)-2] also works + // (5) ST m->_owner = 0 and then execute lock:orl &m->_succ, 0. + // The integer condition codes will tell us if succ was 0. + // Since _succ and _owner should reside in the same $line and + // we just stored into _owner, it's likely that the $line + // remains in M-state for the lock:orl. + // + // We currently use (3), although it's likely that switching to (2) + // is correct for the future. + + movptr(Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), NULL_WORD); + if (os::is_MP()) { + if (VM_Version::supports_sse2() && 1 == FenceInstruction) { + mfence(); + } else { + lock (); addptr(Address(rsp, 0), 0); + } + } + // Ratify _succ remains non-null + cmpptr(Address (tmpReg, ObjectMonitor::succ_offset_in_bytes()-2), 0); + jccb (Assembler::notZero, LSuccess); + + xorptr(boxReg, boxReg); // box is really EAX + if (os::is_MP()) { lock(); } + cmpxchgptr(rsp, Address(tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); + jccb (Assembler::notEqual, LSuccess); + // Since we're low on registers we installed rsp as a placeholding in _owner. + // Now install Self over rsp. This is safe as we're transitioning from + // non-null to non=null + get_thread (boxReg); + movptr(Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), boxReg); + // Intentional fall-through into LGoSlowPath ... + + bind (LGoSlowPath); + orptr(boxReg, 1); // set ICC.ZF=0 to indicate failure + jmpb (DONE_LABEL); + + bind (LSuccess); + xorptr(boxReg, boxReg); // set ICC.ZF=1 to indicate success + jmpb (DONE_LABEL); + } + + bind (Stacked); + // It's not inflated and it's not recursively stack-locked and it's not biased. + // It must be stack-locked. + // Try to reset the header to displaced header. + // The "box" value on the stack is stable, so we can reload + // and be assured we observe the same value as above. + movptr(tmpReg, Address(boxReg, 0)); + if (os::is_MP()) { + lock(); + } + cmpxchgptr(tmpReg, Address(objReg, 0)); // Uses RAX which is box + // Intention fall-thru into DONE_LABEL + + // DONE_LABEL is a hot target - we'd really like to place it at the + // start of cache line by padding with NOPs. + // See the AMD and Intel software optimization manuals for the + // most efficient "long" NOP encodings. + // Unfortunately none of our alignment mechanisms suffice. + if ((EmitSync & 65536) == 0) { + bind (CheckSucc); + } +#else // _LP64 + // It's inflated + movptr(boxReg, Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); + xorptr(boxReg, r15_thread); + orptr (boxReg, Address (tmpReg, ObjectMonitor::recursions_offset_in_bytes()-2)); + jccb (Assembler::notZero, DONE_LABEL); + movptr(boxReg, Address (tmpReg, ObjectMonitor::cxq_offset_in_bytes()-2)); + orptr (boxReg, Address (tmpReg, ObjectMonitor::EntryList_offset_in_bytes()-2)); + jccb (Assembler::notZero, CheckSucc); + movptr(Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), (int32_t)NULL_WORD); + jmpb (DONE_LABEL); + + if ((EmitSync & 65536) == 0) { + Label LSuccess, LGoSlowPath ; + bind (CheckSucc); + cmpptr(Address (tmpReg, ObjectMonitor::succ_offset_in_bytes()-2), (int32_t)NULL_WORD); + jccb (Assembler::zero, LGoSlowPath); + + // I'd much rather use lock:andl m->_owner, 0 as it's faster than the + // the explicit ST;MEMBAR combination, but masm doesn't currently support + // "ANDQ M,IMM". Don't use MFENCE here. lock:add to TOS, xchg, etc + // are all faster when the write buffer is populated. + movptr (Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), (int32_t)NULL_WORD); + if (os::is_MP()) { + lock (); addl (Address(rsp, 0), 0); + } + cmpptr(Address (tmpReg, ObjectMonitor::succ_offset_in_bytes()-2), (int32_t)NULL_WORD); + jccb (Assembler::notZero, LSuccess); + + movptr (boxReg, (int32_t)NULL_WORD); // box is really EAX + if (os::is_MP()) { lock(); } + cmpxchgptr(r15_thread, Address(tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); + jccb (Assembler::notEqual, LSuccess); + // Intentional fall-through into slow-path + + bind (LGoSlowPath); + orl (boxReg, 1); // set ICC.ZF=0 to indicate failure + jmpb (DONE_LABEL); + + bind (LSuccess); + testl (boxReg, 0); // set ICC.ZF=1 to indicate success + jmpb (DONE_LABEL); + } + + bind (Stacked); + movptr(tmpReg, Address (boxReg, 0)); // re-fetch + if (os::is_MP()) { lock(); } + cmpxchgptr(tmpReg, Address(objReg, 0)); // Uses RAX which is box + + if (EmitSync & 65536) { + bind (CheckSucc); + } +#endif + bind(DONE_LABEL); + // Avoid branch to branch on AMD processors + if (EmitSync & 32768) { + nop(); + } + } +} +#endif // COMPILER2 + void MacroAssembler::c2bool(Register x) { // implements x == 0 ? 0 : 1 // note: must only look at least-significant byte of x diff --git a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp index 198fc98e86a..6ac95774ba9 100644 --- a/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp +++ b/hotspot/src/cpu/x86/vm/macroAssembler_x86.hpp @@ -651,7 +651,12 @@ class MacroAssembler: public Assembler { Label& done, Label* slow_case = NULL, BiasedLockingCounters* counters = NULL); void biased_locking_exit (Register obj_reg, Register temp_reg, Label& done); - +#ifdef COMPILER2 + // Code used by cmpFastLock and cmpFastUnlock mach instructions in .ad file. + // See full desription in macroAssembler_x86.cpp. + void fast_lock(Register obj, Register box, Register tmp, Register scr, BiasedLockingCounters* counters); + void fast_unlock(Register obj, Register box, Register tmp); +#endif Condition negate_condition(Condition cond); diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad index cc0dfaa110f..f13e5c17859 100644 --- a/hotspot/src/cpu/x86/vm/x86_32.ad +++ b/hotspot/src/cpu/x86/vm/x86_32.ad @@ -2918,542 +2918,6 @@ encode %{ emit_d8 (cbuf,0 ); %} - - // Because the transitions from emitted code to the runtime - // monitorenter/exit helper stubs are so slow it's critical that - // we inline both the stack-locking fast-path and the inflated fast path. - // - // See also: cmpFastLock and cmpFastUnlock. - // - // What follows is a specialized inline transliteration of the code - // in slow_enter() and slow_exit(). If we're concerned about I$ bloat - // another option would be to emit TrySlowEnter and TrySlowExit methods - // at startup-time. These methods would accept arguments as - // (rax,=Obj, rbx=Self, rcx=box, rdx=Scratch) and return success-failure - // indications in the icc.ZFlag. Fast_Lock and Fast_Unlock would simply - // marshal the arguments and emit calls to TrySlowEnter and TrySlowExit. - // In practice, however, the # of lock sites is bounded and is usually small. - // Besides the call overhead, TrySlowEnter and TrySlowExit might suffer - // if the processor uses simple bimodal branch predictors keyed by EIP - // Since the helper routines would be called from multiple synchronization - // sites. - // - // An even better approach would be write "MonitorEnter()" and "MonitorExit()" - // in java - using j.u.c and unsafe - and just bind the lock and unlock sites - // to those specialized methods. That'd give us a mostly platform-independent - // implementation that the JITs could optimize and inline at their pleasure. - // Done correctly, the only time we'd need to cross to native could would be - // to park() or unpark() threads. We'd also need a few more unsafe operators - // to (a) prevent compiler-JIT reordering of non-volatile accesses, and - // (b) explicit barriers or fence operations. - // - // TODO: - // - // * Arrange for C2 to pass "Self" into Fast_Lock and Fast_Unlock in one of the registers (scr). - // This avoids manifesting the Self pointer in the Fast_Lock and Fast_Unlock terminals. - // Given TLAB allocation, Self is usually manifested in a register, so passing it into - // the lock operators would typically be faster than reifying Self. - // - // * Ideally I'd define the primitives as: - // fast_lock (nax Obj, nax box, EAX tmp, nax scr) where box, tmp and scr are KILLED. - // fast_unlock (nax Obj, EAX box, nax tmp) where box and tmp are KILLED - // Unfortunately ADLC bugs prevent us from expressing the ideal form. - // Instead, we're stuck with a rather awkward and brittle register assignments below. - // Furthermore the register assignments are overconstrained, possibly resulting in - // sub-optimal code near the synchronization site. - // - // * Eliminate the sp-proximity tests and just use "== Self" tests instead. - // Alternately, use a better sp-proximity test. - // - // * Currently ObjectMonitor._Owner can hold either an sp value or a (THREAD *) value. - // Either one is sufficient to uniquely identify a thread. - // TODO: eliminate use of sp in _owner and use get_thread(tr) instead. - // - // * Intrinsify notify() and notifyAll() for the common cases where the - // object is locked by the calling thread but the waitlist is empty. - // avoid the expensive JNI call to JVM_Notify() and JVM_NotifyAll(). - // - // * use jccb and jmpb instead of jcc and jmp to improve code density. - // But beware of excessive branch density on AMD Opterons. - // - // * Both Fast_Lock and Fast_Unlock set the ICC.ZF to indicate success - // or failure of the fast-path. If the fast-path fails then we pass - // control to the slow-path, typically in C. In Fast_Lock and - // Fast_Unlock we often branch to DONE_LABEL, just to find that C2 - // will emit a conditional branch immediately after the node. - // So we have branches to branches and lots of ICC.ZF games. - // Instead, it might be better to have C2 pass a "FailureLabel" - // into Fast_Lock and Fast_Unlock. In the case of success, control - // will drop through the node. ICC.ZF is undefined at exit. - // In the case of failure, the node will branch directly to the - // FailureLabel - - - // obj: object to lock - // box: on-stack box address (displaced header location) - KILLED - // rax,: tmp -- KILLED - // scr: tmp -- KILLED - enc_class Fast_Lock( eRegP obj, eRegP box, eAXRegI tmp, eRegP scr ) %{ - - Register objReg = as_Register($obj$$reg); - Register boxReg = as_Register($box$$reg); - Register tmpReg = as_Register($tmp$$reg); - Register scrReg = as_Register($scr$$reg); - - // Ensure the register assignents are disjoint - guarantee (objReg != boxReg, "") ; - guarantee (objReg != tmpReg, "") ; - guarantee (objReg != scrReg, "") ; - guarantee (boxReg != tmpReg, "") ; - guarantee (boxReg != scrReg, "") ; - guarantee (tmpReg == as_Register(EAX_enc), "") ; - - MacroAssembler masm(&cbuf); - - if (_counters != NULL) { - masm.atomic_incl(ExternalAddress((address) _counters->total_entry_count_addr())); - } - if (EmitSync & 1) { - // set box->dhw = unused_mark (3) - // Force all sync thru slow-path: slow_enter() and slow_exit() - masm.movptr (Address(boxReg, 0), int32_t(markOopDesc::unused_mark())) ; - masm.cmpptr (rsp, (int32_t)0) ; - } else - if (EmitSync & 2) { - Label DONE_LABEL ; - if (UseBiasedLocking) { - // Note: tmpReg maps to the swap_reg argument and scrReg to the tmp_reg argument. - masm.biased_locking_enter(boxReg, objReg, tmpReg, scrReg, false, DONE_LABEL, NULL, _counters); - } - - masm.movptr(tmpReg, Address(objReg, 0)) ; // fetch markword - masm.orptr (tmpReg, 0x1); - masm.movptr(Address(boxReg, 0), tmpReg); // Anticipate successful CAS - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(boxReg, Address(objReg, 0)); // Updates tmpReg - masm.jcc(Assembler::equal, DONE_LABEL); - // Recursive locking - masm.subptr(tmpReg, rsp); - masm.andptr(tmpReg, (int32_t) 0xFFFFF003 ); - masm.movptr(Address(boxReg, 0), tmpReg); - masm.bind(DONE_LABEL) ; - } else { - // Possible cases that we'll encounter in fast_lock - // ------------------------------------------------ - // * Inflated - // -- unlocked - // -- Locked - // = by self - // = by other - // * biased - // -- by Self - // -- by other - // * neutral - // * stack-locked - // -- by self - // = sp-proximity test hits - // = sp-proximity test generates false-negative - // -- by other - // - - Label IsInflated, DONE_LABEL, PopDone ; - - // TODO: optimize away redundant LDs of obj->mark and improve the markword triage - // order to reduce the number of conditional branches in the most common cases. - // Beware -- there's a subtle invariant that fetch of the markword - // at [FETCH], below, will never observe a biased encoding (*101b). - // If this invariant is not held we risk exclusion (safety) failure. - if (UseBiasedLocking && !UseOptoBiasInlining) { - masm.biased_locking_enter(boxReg, objReg, tmpReg, scrReg, false, DONE_LABEL, NULL, _counters); - } - - masm.movptr(tmpReg, Address(objReg, 0)) ; // [FETCH] - masm.testptr(tmpReg, 0x02) ; // Inflated v (Stack-locked or neutral) - masm.jccb (Assembler::notZero, IsInflated) ; - - // Attempt stack-locking ... - masm.orptr (tmpReg, 0x1); - masm.movptr(Address(boxReg, 0), tmpReg); // Anticipate successful CAS - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(boxReg, Address(objReg, 0)); // Updates tmpReg - if (_counters != NULL) { - masm.cond_inc32(Assembler::equal, - ExternalAddress((address)_counters->fast_path_entry_count_addr())); - } - masm.jccb (Assembler::equal, DONE_LABEL); - - // Recursive locking - masm.subptr(tmpReg, rsp); - masm.andptr(tmpReg, 0xFFFFF003 ); - masm.movptr(Address(boxReg, 0), tmpReg); - if (_counters != NULL) { - masm.cond_inc32(Assembler::equal, - ExternalAddress((address)_counters->fast_path_entry_count_addr())); - } - masm.jmp (DONE_LABEL) ; - - masm.bind (IsInflated) ; - - // The object is inflated. - // - // TODO-FIXME: eliminate the ugly use of manifest constants: - // Use markOopDesc::monitor_value instead of "2". - // use markOop::unused_mark() instead of "3". - // The tmpReg value is an objectMonitor reference ORed with - // markOopDesc::monitor_value (2). We can either convert tmpReg to an - // objectmonitor pointer by masking off the "2" bit or we can just - // use tmpReg as an objectmonitor pointer but bias the objectmonitor - // field offsets with "-2" to compensate for and annul the low-order tag bit. - // - // I use the latter as it avoids AGI stalls. - // As such, we write "mov r, [tmpReg+OFFSETOF(Owner)-2]" - // instead of "mov r, [tmpReg+OFFSETOF(Owner)]". - // - #define OFFSET_SKEWED(f) ((ObjectMonitor::f ## _offset_in_bytes())-2) - - // boxReg refers to the on-stack BasicLock in the current frame. - // We'd like to write: - // set box->_displaced_header = markOop::unused_mark(). Any non-0 value suffices. - // This is convenient but results a ST-before-CAS penalty. The following CAS suffers - // additional latency as we have another ST in the store buffer that must drain. - - if (EmitSync & 8192) { - masm.movptr(Address(boxReg, 0), 3) ; // results in ST-before-CAS penalty - masm.get_thread (scrReg) ; - masm.movptr(boxReg, tmpReg); // consider: LEA box, [tmp-2] - masm.movptr(tmpReg, NULL_WORD); // consider: xor vs mov - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(scrReg, Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2)) ; - } else - if ((EmitSync & 128) == 0) { // avoid ST-before-CAS - masm.movptr(scrReg, boxReg) ; - masm.movptr(boxReg, tmpReg); // consider: LEA box, [tmp-2] - - // Using a prefetchw helps avoid later RTS->RTO upgrades and cache probes - if ((EmitSync & 2048) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) { - // prefetchw [eax + Offset(_owner)-2] - masm.prefetchw(Address(rax, ObjectMonitor::owner_offset_in_bytes()-2)); - } - - if ((EmitSync & 64) == 0) { - // Optimistic form: consider XORL tmpReg,tmpReg - masm.movptr(tmpReg, NULL_WORD) ; - } else { - // Can suffer RTS->RTO upgrades on shared or cold $ lines - // Test-And-CAS instead of CAS - masm.movptr(tmpReg, Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)) ; // rax, = m->_owner - masm.testptr(tmpReg, tmpReg) ; // Locked ? - masm.jccb (Assembler::notZero, DONE_LABEL) ; - } - - // Appears unlocked - try to swing _owner from null to non-null. - // Ideally, I'd manifest "Self" with get_thread and then attempt - // to CAS the register containing Self into m->Owner. - // But we don't have enough registers, so instead we can either try to CAS - // rsp or the address of the box (in scr) into &m->owner. If the CAS succeeds - // we later store "Self" into m->Owner. Transiently storing a stack address - // (rsp or the address of the box) into m->owner is harmless. - // Invariant: tmpReg == 0. tmpReg is EAX which is the implicit cmpxchg comparand. - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(scrReg, Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2)) ; - masm.movptr(Address(scrReg, 0), 3) ; // box->_displaced_header = 3 - masm.jccb (Assembler::notZero, DONE_LABEL) ; - masm.get_thread (scrReg) ; // beware: clobbers ICCs - masm.movptr(Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2), scrReg) ; - masm.xorptr(boxReg, boxReg) ; // set icc.ZFlag = 1 to indicate success - - // If the CAS fails we can either retry or pass control to the slow-path. - // We use the latter tactic. - // Pass the CAS result in the icc.ZFlag into DONE_LABEL - // If the CAS was successful ... - // Self has acquired the lock - // Invariant: m->_recursions should already be 0, so we don't need to explicitly set it. - // Intentional fall-through into DONE_LABEL ... - } else { - masm.movptr(Address(boxReg, 0), 3) ; // results in ST-before-CAS penalty - masm.movptr(boxReg, tmpReg) ; - - // Using a prefetchw helps avoid later RTS->RTO upgrades and cache probes - if ((EmitSync & 2048) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) { - // prefetchw [eax + Offset(_owner)-2] - masm.prefetchw(Address(rax, ObjectMonitor::owner_offset_in_bytes()-2)); - } - - if ((EmitSync & 64) == 0) { - // Optimistic form - masm.xorptr (tmpReg, tmpReg) ; - } else { - // Can suffer RTS->RTO upgrades on shared or cold $ lines - masm.movptr(tmpReg, Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)) ; // rax, = m->_owner - masm.testptr(tmpReg, tmpReg) ; // Locked ? - masm.jccb (Assembler::notZero, DONE_LABEL) ; - } - - // Appears unlocked - try to swing _owner from null to non-null. - // Use either "Self" (in scr) or rsp as thread identity in _owner. - // Invariant: tmpReg == 0. tmpReg is EAX which is the implicit cmpxchg comparand. - masm.get_thread (scrReg) ; - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(scrReg, Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2)) ; - - // If the CAS fails we can either retry or pass control to the slow-path. - // We use the latter tactic. - // Pass the CAS result in the icc.ZFlag into DONE_LABEL - // If the CAS was successful ... - // Self has acquired the lock - // Invariant: m->_recursions should already be 0, so we don't need to explicitly set it. - // Intentional fall-through into DONE_LABEL ... - } - - // DONE_LABEL is a hot target - we'd really like to place it at the - // start of cache line by padding with NOPs. - // See the AMD and Intel software optimization manuals for the - // most efficient "long" NOP encodings. - // Unfortunately none of our alignment mechanisms suffice. - masm.bind(DONE_LABEL); - - // Avoid branch-to-branch on AMD processors - // This appears to be superstition. - if (EmitSync & 32) masm.nop() ; - - - // At DONE_LABEL the icc ZFlag is set as follows ... - // Fast_Unlock uses the same protocol. - // ZFlag == 1 -> Success - // ZFlag == 0 -> Failure - force control through the slow-path - } - %} - - // obj: object to unlock - // box: box address (displaced header location), killed. Must be EAX. - // rbx,: killed tmp; cannot be obj nor box. - // - // Some commentary on balanced locking: - // - // Fast_Lock and Fast_Unlock are emitted only for provably balanced lock sites. - // Methods that don't have provably balanced locking are forced to run in the - // interpreter - such methods won't be compiled to use fast_lock and fast_unlock. - // The interpreter provides two properties: - // I1: At return-time the interpreter automatically and quietly unlocks any - // objects acquired the current activation (frame). Recall that the - // interpreter maintains an on-stack list of locks currently held by - // a frame. - // I2: If a method attempts to unlock an object that is not held by the - // the frame the interpreter throws IMSX. - // - // Lets say A(), which has provably balanced locking, acquires O and then calls B(). - // B() doesn't have provably balanced locking so it runs in the interpreter. - // Control returns to A() and A() unlocks O. By I1 and I2, above, we know that O - // is still locked by A(). - // - // The only other source of unbalanced locking would be JNI. The "Java Native Interface: - // Programmer's Guide and Specification" claims that an object locked by jni_monitorenter - // should not be unlocked by "normal" java-level locking and vice-versa. The specification - // doesn't specify what will occur if a program engages in such mixed-mode locking, however. - - enc_class Fast_Unlock( nabxRegP obj, eAXRegP box, eRegP tmp) %{ - - Register objReg = as_Register($obj$$reg); - Register boxReg = as_Register($box$$reg); - Register tmpReg = as_Register($tmp$$reg); - - guarantee (objReg != boxReg, "") ; - guarantee (objReg != tmpReg, "") ; - guarantee (boxReg != tmpReg, "") ; - guarantee (boxReg == as_Register(EAX_enc), "") ; - MacroAssembler masm(&cbuf); - - if (EmitSync & 4) { - // Disable - inhibit all inlining. Force control through the slow-path - masm.cmpptr (rsp, 0) ; - } else - if (EmitSync & 8) { - Label DONE_LABEL ; - if (UseBiasedLocking) { - masm.biased_locking_exit(objReg, tmpReg, DONE_LABEL); - } - // classic stack-locking code ... - masm.movptr(tmpReg, Address(boxReg, 0)) ; - masm.testptr(tmpReg, tmpReg) ; - masm.jcc (Assembler::zero, DONE_LABEL) ; - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(tmpReg, Address(objReg, 0)); // Uses EAX which is box - masm.bind(DONE_LABEL); - } else { - Label DONE_LABEL, Stacked, CheckSucc, Inflated ; - - // Critically, the biased locking test must have precedence over - // and appear before the (box->dhw == 0) recursive stack-lock test. - if (UseBiasedLocking && !UseOptoBiasInlining) { - masm.biased_locking_exit(objReg, tmpReg, DONE_LABEL); - } - - masm.cmpptr(Address(boxReg, 0), 0) ; // Examine the displaced header - masm.movptr(tmpReg, Address(objReg, 0)) ; // Examine the object's markword - masm.jccb (Assembler::zero, DONE_LABEL) ; // 0 indicates recursive stack-lock - - masm.testptr(tmpReg, 0x02) ; // Inflated? - masm.jccb (Assembler::zero, Stacked) ; - - masm.bind (Inflated) ; - // It's inflated. - // Despite our balanced locking property we still check that m->_owner == Self - // as java routines or native JNI code called by this thread might - // have released the lock. - // Refer to the comments in synchronizer.cpp for how we might encode extra - // state in _succ so we can avoid fetching EntryList|cxq. - // - // I'd like to add more cases in fast_lock() and fast_unlock() -- - // such as recursive enter and exit -- but we have to be wary of - // I$ bloat, T$ effects and BP$ effects. - // - // If there's no contention try a 1-0 exit. That is, exit without - // a costly MEMBAR or CAS. See synchronizer.cpp for details on how - // we detect and recover from the race that the 1-0 exit admits. - // - // Conceptually Fast_Unlock() must execute a STST|LDST "release" barrier - // before it STs null into _owner, releasing the lock. Updates - // to data protected by the critical section must be visible before - // we drop the lock (and thus before any other thread could acquire - // the lock and observe the fields protected by the lock). - // IA32's memory-model is SPO, so STs are ordered with respect to - // each other and there's no need for an explicit barrier (fence). - // See also http://gee.cs.oswego.edu/dl/jmm/cookbook.html. - - masm.get_thread (boxReg) ; - if ((EmitSync & 4096) && VM_Version::supports_3dnow_prefetch() && os::is_MP()) { - // prefetchw [ebx + Offset(_owner)-2] - masm.prefetchw(Address(rbx, ObjectMonitor::owner_offset_in_bytes()-2)); - } - - // Note that we could employ various encoding schemes to reduce - // the number of loads below (currently 4) to just 2 or 3. - // Refer to the comments in synchronizer.cpp. - // In practice the chain of fetches doesn't seem to impact performance, however. - if ((EmitSync & 65536) == 0 && (EmitSync & 256)) { - // Attempt to reduce branch density - AMD's branch predictor. - masm.xorptr(boxReg, Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)) ; - masm.orptr(boxReg, Address (tmpReg, ObjectMonitor::recursions_offset_in_bytes()-2)) ; - masm.orptr(boxReg, Address (tmpReg, ObjectMonitor::EntryList_offset_in_bytes()-2)) ; - masm.orptr(boxReg, Address (tmpReg, ObjectMonitor::cxq_offset_in_bytes()-2)) ; - masm.jccb (Assembler::notZero, DONE_LABEL) ; - masm.movptr(Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), NULL_WORD) ; - masm.jmpb (DONE_LABEL) ; - } else { - masm.xorptr(boxReg, Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)) ; - masm.orptr(boxReg, Address (tmpReg, ObjectMonitor::recursions_offset_in_bytes()-2)) ; - masm.jccb (Assembler::notZero, DONE_LABEL) ; - masm.movptr(boxReg, Address (tmpReg, ObjectMonitor::EntryList_offset_in_bytes()-2)) ; - masm.orptr(boxReg, Address (tmpReg, ObjectMonitor::cxq_offset_in_bytes()-2)) ; - masm.jccb (Assembler::notZero, CheckSucc) ; - masm.movptr(Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), NULL_WORD) ; - masm.jmpb (DONE_LABEL) ; - } - - // The Following code fragment (EmitSync & 65536) improves the performance of - // contended applications and contended synchronization microbenchmarks. - // Unfortunately the emission of the code - even though not executed - causes regressions - // in scimark and jetstream, evidently because of $ effects. Replacing the code - // with an equal number of never-executed NOPs results in the same regression. - // We leave it off by default. - - if ((EmitSync & 65536) != 0) { - Label LSuccess, LGoSlowPath ; - - masm.bind (CheckSucc) ; - - // Optional pre-test ... it's safe to elide this - if ((EmitSync & 16) == 0) { - masm.cmpptr(Address (tmpReg, ObjectMonitor::succ_offset_in_bytes()-2), 0) ; - masm.jccb (Assembler::zero, LGoSlowPath) ; - } - - // We have a classic Dekker-style idiom: - // ST m->_owner = 0 ; MEMBAR; LD m->_succ - // There are a number of ways to implement the barrier: - // (1) lock:andl &m->_owner, 0 - // is fast, but mask doesn't currently support the "ANDL M,IMM32" form. - // LOCK: ANDL [ebx+Offset(_Owner)-2], 0 - // Encodes as 81 31 OFF32 IMM32 or 83 63 OFF8 IMM8 - // (2) If supported, an explicit MFENCE is appealing. - // In older IA32 processors MFENCE is slower than lock:add or xchg - // particularly if the write-buffer is full as might be the case if - // if stores closely precede the fence or fence-equivalent instruction. - // In more modern implementations MFENCE appears faster, however. - // (3) In lieu of an explicit fence, use lock:addl to the top-of-stack - // The $lines underlying the top-of-stack should be in M-state. - // The locked add instruction is serializing, of course. - // (4) Use xchg, which is serializing - // mov boxReg, 0; xchgl boxReg, [tmpReg + Offset(_owner)-2] also works - // (5) ST m->_owner = 0 and then execute lock:orl &m->_succ, 0. - // The integer condition codes will tell us if succ was 0. - // Since _succ and _owner should reside in the same $line and - // we just stored into _owner, it's likely that the $line - // remains in M-state for the lock:orl. - // - // We currently use (3), although it's likely that switching to (2) - // is correct for the future. - - masm.movptr(Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), NULL_WORD) ; - if (os::is_MP()) { - if (VM_Version::supports_sse2() && 1 == FenceInstruction) { - masm.mfence(); - } else { - masm.lock () ; masm.addptr(Address(rsp, 0), 0) ; - } - } - // Ratify _succ remains non-null - masm.cmpptr(Address (tmpReg, ObjectMonitor::succ_offset_in_bytes()-2), 0) ; - masm.jccb (Assembler::notZero, LSuccess) ; - - masm.xorptr(boxReg, boxReg) ; // box is really EAX - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(rsp, Address(tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); - masm.jccb (Assembler::notEqual, LSuccess) ; - // Since we're low on registers we installed rsp as a placeholding in _owner. - // Now install Self over rsp. This is safe as we're transitioning from - // non-null to non=null - masm.get_thread (boxReg) ; - masm.movptr(Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), boxReg) ; - // Intentional fall-through into LGoSlowPath ... - - masm.bind (LGoSlowPath) ; - masm.orptr(boxReg, 1) ; // set ICC.ZF=0 to indicate failure - masm.jmpb (DONE_LABEL) ; - - masm.bind (LSuccess) ; - masm.xorptr(boxReg, boxReg) ; // set ICC.ZF=1 to indicate success - masm.jmpb (DONE_LABEL) ; - } - - masm.bind (Stacked) ; - // It's not inflated and it's not recursively stack-locked and it's not biased. - // It must be stack-locked. - // Try to reset the header to displaced header. - // The "box" value on the stack is stable, so we can reload - // and be assured we observe the same value as above. - masm.movptr(tmpReg, Address(boxReg, 0)) ; - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(tmpReg, Address(objReg, 0)); // Uses EAX which is box - // Intention fall-thru into DONE_LABEL - - - // DONE_LABEL is a hot target - we'd really like to place it at the - // start of cache line by padding with NOPs. - // See the AMD and Intel software optimization manuals for the - // most efficient "long" NOP encodings. - // Unfortunately none of our alignment mechanisms suffice. - if ((EmitSync & 65536) == 0) { - masm.bind (CheckSucc) ; - } - masm.bind(DONE_LABEL); - - // Avoid branch to branch on AMD processors - if (EmitSync & 32768) { masm.nop() ; } - } - %} - - enc_class enc_pop_rdx() %{ emit_opcode(cbuf,0x5A); %} @@ -13157,23 +12621,26 @@ instruct RethrowException() // inlined locking and unlocking - -instruct cmpFastLock( eFlagsReg cr, eRegP object, eBXRegP box, eAXRegI tmp, eRegP scr) %{ - match( Set cr (FastLock object box) ); - effect( TEMP tmp, TEMP scr, USE_KILL box ); +instruct cmpFastLock(eFlagsReg cr, eRegP object, eBXRegP box, eAXRegI tmp, eRegP scr) %{ + match(Set cr (FastLock object box)); + effect(TEMP tmp, TEMP scr, USE_KILL box); ins_cost(300); format %{ "FASTLOCK $object,$box\t! kills $box,$tmp,$scr" %} - ins_encode( Fast_Lock(object,box,tmp,scr) ); - ins_pipe( pipe_slow ); + ins_encode %{ + __ fast_lock($object$$Register, $box$$Register, $tmp$$Register, $scr$$Register, _counters); + %} + ins_pipe(pipe_slow); %} -instruct cmpFastUnlock( eFlagsReg cr, eRegP object, eAXRegP box, eRegP tmp ) %{ - match( Set cr (FastUnlock object box) ); - effect( TEMP tmp, USE_KILL box ); +instruct cmpFastUnlock(eFlagsReg cr, eRegP object, eAXRegP box, eRegP tmp ) %{ + match(Set cr (FastUnlock object box)); + effect(TEMP tmp, USE_KILL box); ins_cost(300); format %{ "FASTUNLOCK $object,$box\t! kills $box,$tmp" %} - ins_encode( Fast_Unlock(object,box,tmp) ); - ins_pipe( pipe_slow ); + ins_encode %{ + __ fast_unlock($object$$Register, $box$$Register, $tmp$$Register); + %} + ins_pipe(pipe_slow); %} diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad index 21f9aca7619..2778320fdec 100644 --- a/hotspot/src/cpu/x86/vm/x86_64.ad +++ b/hotspot/src/cpu/x86/vm/x86_64.ad @@ -2599,231 +2599,6 @@ encode %{ %} - // obj: object to lock - // box: box address (header location) -- killed - // tmp: rax -- killed - // scr: rbx -- killed - // - // What follows is a direct transliteration of fast_lock() and fast_unlock() - // from i486.ad. See that file for comments. - // TODO: where possible switch from movq (r, 0) to movl(r,0) and - // use the shorter encoding. (Movl clears the high-order 32-bits). - - - enc_class Fast_Lock(rRegP obj, rRegP box, rax_RegI tmp, rRegP scr) - %{ - Register objReg = as_Register((int)$obj$$reg); - Register boxReg = as_Register((int)$box$$reg); - Register tmpReg = as_Register($tmp$$reg); - Register scrReg = as_Register($scr$$reg); - MacroAssembler masm(&cbuf); - - // Verify uniqueness of register assignments -- necessary but not sufficient - assert (objReg != boxReg && objReg != tmpReg && - objReg != scrReg && tmpReg != scrReg, "invariant") ; - - if (_counters != NULL) { - masm.atomic_incl(ExternalAddress((address) _counters->total_entry_count_addr())); - } - if (EmitSync & 1) { - // Without cast to int32_t a movptr will destroy r10 which is typically obj - masm.movptr (Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark())) ; - masm.cmpptr(rsp, (int32_t)NULL_WORD) ; - } else - if (EmitSync & 2) { - Label DONE_LABEL; - if (UseBiasedLocking) { - // Note: tmpReg maps to the swap_reg argument and scrReg to the tmp_reg argument. - masm.biased_locking_enter(boxReg, objReg, tmpReg, scrReg, false, DONE_LABEL, NULL, _counters); - } - // QQQ was movl... - masm.movptr(tmpReg, 0x1); - masm.orptr(tmpReg, Address(objReg, 0)); - masm.movptr(Address(boxReg, 0), tmpReg); - if (os::is_MP()) { - masm.lock(); - } - masm.cmpxchgptr(boxReg, Address(objReg, 0)); // Updates tmpReg - masm.jcc(Assembler::equal, DONE_LABEL); - - // Recursive locking - masm.subptr(tmpReg, rsp); - masm.andptr(tmpReg, 7 - os::vm_page_size()); - masm.movptr(Address(boxReg, 0), tmpReg); - - masm.bind(DONE_LABEL); - masm.nop(); // avoid branch to branch - } else { - Label DONE_LABEL, IsInflated, Egress; - - masm.movptr(tmpReg, Address(objReg, 0)) ; - masm.testl (tmpReg, 0x02) ; // inflated vs stack-locked|neutral|biased - masm.jcc (Assembler::notZero, IsInflated) ; - - // it's stack-locked, biased or neutral - // TODO: optimize markword triage order to reduce the number of - // conditional branches in the most common cases. - // Beware -- there's a subtle invariant that fetch of the markword - // at [FETCH], below, will never observe a biased encoding (*101b). - // If this invariant is not held we'll suffer exclusion (safety) failure. - - if (UseBiasedLocking && !UseOptoBiasInlining) { - masm.biased_locking_enter(boxReg, objReg, tmpReg, scrReg, true, DONE_LABEL, NULL, _counters); - masm.movptr(tmpReg, Address(objReg, 0)) ; // [FETCH] - } - - // was q will it destroy high? - masm.orl (tmpReg, 1) ; - masm.movptr(Address(boxReg, 0), tmpReg) ; - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(boxReg, Address(objReg, 0)); // Updates tmpReg - if (_counters != NULL) { - masm.cond_inc32(Assembler::equal, - ExternalAddress((address) _counters->fast_path_entry_count_addr())); - } - masm.jcc (Assembler::equal, DONE_LABEL); - - // Recursive locking - masm.subptr(tmpReg, rsp); - masm.andptr(tmpReg, 7 - os::vm_page_size()); - masm.movptr(Address(boxReg, 0), tmpReg); - if (_counters != NULL) { - masm.cond_inc32(Assembler::equal, - ExternalAddress((address) _counters->fast_path_entry_count_addr())); - } - masm.jmp (DONE_LABEL) ; - - masm.bind (IsInflated) ; - // It's inflated - - // TODO: someday avoid the ST-before-CAS penalty by - // relocating (deferring) the following ST. - // We should also think about trying a CAS without having - // fetched _owner. If the CAS is successful we may - // avoid an RTO->RTS upgrade on the $line. - // Without cast to int32_t a movptr will destroy r10 which is typically obj - masm.movptr(Address(boxReg, 0), (int32_t)intptr_t(markOopDesc::unused_mark())) ; - - masm.mov (boxReg, tmpReg) ; - masm.movptr (tmpReg, Address(tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)) ; - masm.testptr(tmpReg, tmpReg) ; - masm.jcc (Assembler::notZero, DONE_LABEL) ; - - // It's inflated and appears unlocked - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(r15_thread, Address(boxReg, ObjectMonitor::owner_offset_in_bytes()-2)) ; - // Intentional fall-through into DONE_LABEL ... - - masm.bind (DONE_LABEL) ; - masm.nop () ; // avoid jmp to jmp - } - %} - - // obj: object to unlock - // box: box address (displaced header location), killed - // RBX: killed tmp; cannot be obj nor box - enc_class Fast_Unlock(rRegP obj, rax_RegP box, rRegP tmp) - %{ - - Register objReg = as_Register($obj$$reg); - Register boxReg = as_Register($box$$reg); - Register tmpReg = as_Register($tmp$$reg); - MacroAssembler masm(&cbuf); - - if (EmitSync & 4) { - masm.cmpptr(rsp, 0) ; - } else - if (EmitSync & 8) { - Label DONE_LABEL; - if (UseBiasedLocking) { - masm.biased_locking_exit(objReg, tmpReg, DONE_LABEL); - } - - // Check whether the displaced header is 0 - //(=> recursive unlock) - masm.movptr(tmpReg, Address(boxReg, 0)); - masm.testptr(tmpReg, tmpReg); - masm.jcc(Assembler::zero, DONE_LABEL); - - // If not recursive lock, reset the header to displaced header - if (os::is_MP()) { - masm.lock(); - } - masm.cmpxchgptr(tmpReg, Address(objReg, 0)); // Uses RAX which is box - masm.bind(DONE_LABEL); - masm.nop(); // avoid branch to branch - } else { - Label DONE_LABEL, Stacked, CheckSucc ; - - if (UseBiasedLocking && !UseOptoBiasInlining) { - masm.biased_locking_exit(objReg, tmpReg, DONE_LABEL); - } - - masm.movptr(tmpReg, Address(objReg, 0)) ; - masm.cmpptr(Address(boxReg, 0), (int32_t)NULL_WORD) ; - masm.jcc (Assembler::zero, DONE_LABEL) ; - masm.testl (tmpReg, 0x02) ; - masm.jcc (Assembler::zero, Stacked) ; - - // It's inflated - masm.movptr(boxReg, Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)) ; - masm.xorptr(boxReg, r15_thread) ; - masm.orptr (boxReg, Address (tmpReg, ObjectMonitor::recursions_offset_in_bytes()-2)) ; - masm.jcc (Assembler::notZero, DONE_LABEL) ; - masm.movptr(boxReg, Address (tmpReg, ObjectMonitor::cxq_offset_in_bytes()-2)) ; - masm.orptr (boxReg, Address (tmpReg, ObjectMonitor::EntryList_offset_in_bytes()-2)) ; - masm.jcc (Assembler::notZero, CheckSucc) ; - masm.movptr(Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), (int32_t)NULL_WORD) ; - masm.jmp (DONE_LABEL) ; - - if ((EmitSync & 65536) == 0) { - Label LSuccess, LGoSlowPath ; - masm.bind (CheckSucc) ; - masm.cmpptr(Address (tmpReg, ObjectMonitor::succ_offset_in_bytes()-2), (int32_t)NULL_WORD) ; - masm.jcc (Assembler::zero, LGoSlowPath) ; - - // I'd much rather use lock:andl m->_owner, 0 as it's faster than the - // the explicit ST;MEMBAR combination, but masm doesn't currently support - // "ANDQ M,IMM". Don't use MFENCE here. lock:add to TOS, xchg, etc - // are all faster when the write buffer is populated. - masm.movptr (Address (tmpReg, ObjectMonitor::owner_offset_in_bytes()-2), (int32_t)NULL_WORD) ; - if (os::is_MP()) { - masm.lock () ; masm.addl (Address(rsp, 0), 0) ; - } - masm.cmpptr(Address (tmpReg, ObjectMonitor::succ_offset_in_bytes()-2), (int32_t)NULL_WORD) ; - masm.jcc (Assembler::notZero, LSuccess) ; - - masm.movptr (boxReg, (int32_t)NULL_WORD) ; // box is really EAX - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(r15_thread, Address(tmpReg, ObjectMonitor::owner_offset_in_bytes()-2)); - masm.jcc (Assembler::notEqual, LSuccess) ; - // Intentional fall-through into slow-path - - masm.bind (LGoSlowPath) ; - masm.orl (boxReg, 1) ; // set ICC.ZF=0 to indicate failure - masm.jmp (DONE_LABEL) ; - - masm.bind (LSuccess) ; - masm.testl (boxReg, 0) ; // set ICC.ZF=1 to indicate success - masm.jmp (DONE_LABEL) ; - } - - masm.bind (Stacked) ; - masm.movptr(tmpReg, Address (boxReg, 0)) ; // re-fetch - if (os::is_MP()) { masm.lock(); } - masm.cmpxchgptr(tmpReg, Address(objReg, 0)); // Uses RAX which is box - - if (EmitSync & 65536) { - masm.bind (CheckSucc) ; - } - masm.bind(DONE_LABEL); - if (EmitSync & 32768) { - masm.nop(); // avoid branch to branch - } - } - %} - - enc_class enc_rethrow() %{ cbuf.set_insts_mark(); @@ -11453,27 +11228,25 @@ instruct jmpConUCF2_short(cmpOpUCF2 cop, rFlagsRegUCF cmp, label labl) %{ // ============================================================================ // inlined locking and unlocking -instruct cmpFastLock(rFlagsReg cr, - rRegP object, rbx_RegP box, rax_RegI tmp, rRegP scr) -%{ +instruct cmpFastLock(rFlagsReg cr, rRegP object, rbx_RegP box, rax_RegI tmp, rRegP scr) %{ match(Set cr (FastLock object box)); effect(TEMP tmp, TEMP scr, USE_KILL box); - ins_cost(300); format %{ "fastlock $object,$box\t! kills $box,$tmp,$scr" %} - ins_encode(Fast_Lock(object, box, tmp, scr)); + ins_encode %{ + __ fast_lock($object$$Register, $box$$Register, $tmp$$Register, $scr$$Register, _counters); + %} ins_pipe(pipe_slow); %} -instruct cmpFastUnlock(rFlagsReg cr, - rRegP object, rax_RegP box, rRegP tmp) -%{ +instruct cmpFastUnlock(rFlagsReg cr, rRegP object, rax_RegP box, rRegP tmp) %{ match(Set cr (FastUnlock object box)); effect(TEMP tmp, USE_KILL box); - ins_cost(300); format %{ "fastunlock $object,$box\t! kills $box,$tmp" %} - ins_encode(Fast_Unlock(object, box, tmp)); + ins_encode %{ + __ fast_unlock($object$$Register, $box$$Register, $tmp$$Register); + %} ins_pipe(pipe_slow); %} From 0b85ee832e4f48ecd5c05679780c36ad4f67bf5b Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Rickard=20B=C3=A4ckman?= Date: Thu, 23 Jan 2014 12:08:28 +0100 Subject: [PATCH 152/159] 8027754: Enable loop optimizations for loops with MathExact inside Reviewed-by: kvn, iveresov --- hotspot/src/cpu/sparc/vm/sparc.ad | 13 - hotspot/src/cpu/x86/vm/x86_32.ad | 224 +++----- hotspot/src/cpu/x86/vm/x86_64.ad | 435 ++++++-------- hotspot/src/share/vm/adlc/archDesc.cpp | 15 +- hotspot/src/share/vm/opto/c2_globals.hpp | 2 +- hotspot/src/share/vm/opto/classes.hpp | 18 +- hotspot/src/share/vm/opto/compile.cpp | 36 -- hotspot/src/share/vm/opto/ifnode.cpp | 1 - hotspot/src/share/vm/opto/lcm.cpp | 7 - hotspot/src/share/vm/opto/library_call.cpp | 132 ++--- hotspot/src/share/vm/opto/loopTransform.cpp | 8 - hotspot/src/share/vm/opto/loopopts.cpp | 9 +- hotspot/src/share/vm/opto/matcher.cpp | 1 - hotspot/src/share/vm/opto/matcher.hpp | 4 - hotspot/src/share/vm/opto/mathexactnode.cpp | 537 ++++++------------ hotspot/src/share/vm/opto/mathexactnode.hpp | 205 +++---- hotspot/src/share/vm/opto/multnode.cpp | 5 - hotspot/src/share/vm/opto/node.hpp | 6 - hotspot/src/share/vm/opto/subnode.cpp | 6 +- hotspot/src/share/vm/opto/type.cpp | 4 + hotspot/src/share/vm/opto/type.hpp | 11 + hotspot/src/share/vm/runtime/vmStructs.cpp | 18 +- .../mathexact/AddExactICondTest.java | 2 +- .../mathexact/AddExactIConstantTest.java | 2 +- .../mathexact/AddExactILoadTest.java | 2 +- .../mathexact/AddExactILoopDependentTest.java | 2 +- .../mathexact/AddExactINonConstantTest.java | 2 +- .../mathexact/AddExactIRepeatTest.java | 2 +- .../mathexact/AddExactLConstantTest.java | 2 +- .../mathexact/AddExactLNonConstantTest.java | 2 +- .../intrinsics/mathexact/CompareTest.java | 2 +- .../intrinsics/mathexact/DecExactITest.java | 2 +- .../intrinsics/mathexact/DecExactLTest.java | 2 +- .../intrinsics/mathexact/GVNTest.java | 2 +- .../intrinsics/mathexact/IncExactITest.java | 2 +- .../intrinsics/mathexact/IncExactLTest.java | 2 +- .../mathexact/MulExactICondTest.java | 2 +- .../mathexact/MulExactIConstantTest.java | 2 +- .../mathexact/MulExactILoadTest.java | 2 +- .../mathexact/MulExactILoopDependentTest.java | 2 +- .../mathexact/MulExactINonConstantTest.java | 2 +- .../mathexact/MulExactIRepeatTest.java | 2 +- .../mathexact/MulExactLConstantTest.java | 2 +- .../mathexact/MulExactLNonConstantTest.java | 2 +- .../mathexact/NegExactIConstantTest.java | 2 +- .../mathexact/NegExactILoadTest.java | 6 +- .../mathexact/NegExactILoopDependentTest.java | 2 +- .../mathexact/NegExactINonConstantTest.java | 2 +- .../mathexact/NegExactLConstantTest.java | 2 +- .../mathexact/NegExactLNonConstantTest.java | 2 +- .../mathexact/NestedMathExactTest.java | 2 +- .../mathexact/SplitThruPhiTest.java | 2 +- .../mathexact/SubExactICondTest.java | 2 +- .../mathexact/SubExactIConstantTest.java | 2 +- .../mathexact/SubExactILoadTest.java | 2 +- .../mathexact/SubExactILoopDependentTest.java | 2 +- .../mathexact/SubExactINonConstantTest.java | 2 +- .../mathexact/SubExactIRepeatTest.java | 2 +- .../mathexact/SubExactLConstantTest.java | 2 +- .../mathexact/SubExactLNonConstantTest.java | 2 +- .../compiler/intrinsics/mathexact/Verify.java | 5 + .../mathexact/sanity/AddExactIntTest.java | 4 +- .../mathexact/sanity/AddExactLongTest.java | 4 +- .../sanity/DecrementExactIntTest.java | 4 +- .../sanity/DecrementExactLongTest.java | 6 +- .../sanity/IncrementExactIntTest.java | 4 +- .../sanity/IncrementExactLongTest.java | 4 +- .../sanity/MultiplyExactIntTest.java | 4 +- .../sanity/MultiplyExactLongTest.java | 4 +- .../mathexact/sanity/NegateExactIntTest.java | 4 +- .../mathexact/sanity/NegateExactLongTest.java | 4 +- .../sanity/SubtractExactIntTest.java | 4 +- .../sanity/SubtractExactLongTest.java | 4 +- 73 files changed, 675 insertions(+), 1157 deletions(-) diff --git a/hotspot/src/cpu/sparc/vm/sparc.ad b/hotspot/src/cpu/sparc/vm/sparc.ad index 3a470b0f851..15b5c7b524f 100644 --- a/hotspot/src/cpu/sparc/vm/sparc.ad +++ b/hotspot/src/cpu/sparc/vm/sparc.ad @@ -2037,19 +2037,6 @@ const RegMask Matcher::method_handle_invoke_SP_save_mask() { return L7_REGP_mask(); } -const RegMask Matcher::mathExactI_result_proj_mask() { - return G1_REGI_mask(); -} - -const RegMask Matcher::mathExactL_result_proj_mask() { - return G1_REGL_mask(); -} - -const RegMask Matcher::mathExactI_flags_proj_mask() { - return INT_FLAGS_mask(); -} - - %} diff --git a/hotspot/src/cpu/x86/vm/x86_32.ad b/hotspot/src/cpu/x86/vm/x86_32.ad index f13e5c17859..8948682a99f 100644 --- a/hotspot/src/cpu/x86/vm/x86_32.ad +++ b/hotspot/src/cpu/x86/vm/x86_32.ad @@ -1542,19 +1542,6 @@ const RegMask Matcher::method_handle_invoke_SP_save_mask() { return EBP_REG_mask(); } -const RegMask Matcher::mathExactI_result_proj_mask() { - return EAX_REG_mask(); -} - -const RegMask Matcher::mathExactL_result_proj_mask() { - ShouldNotReachHere(); - return RegMask(); -} - -const RegMask Matcher::mathExactI_flags_proj_mask() { - return INT_FLAGS_mask(); -} - // Returns true if the high 32 bits of the value is known to be zero. bool is_operand_hi32_zero(Node* n) { int opc = n->Opcode(); @@ -7009,44 +6996,6 @@ instruct cmovL_regUCF(cmpOpUCF cop, eFlagsRegUCF cr, eRegL dst, eRegL src) %{ //----------Arithmetic Instructions-------------------------------------------- //----------Addition Instructions---------------------------------------------- -instruct addExactI_eReg(eAXRegI dst, rRegI src, eFlagsReg cr) -%{ - match(AddExactI dst src); - effect(DEF cr); - - format %{ "ADD $dst, $src\t# addExact int" %} - ins_encode %{ - __ addl($dst$$Register, $src$$Register); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct addExactI_eReg_imm(eAXRegI dst, immI src, eFlagsReg cr) -%{ - match(AddExactI dst src); - effect(DEF cr); - - format %{ "ADD $dst, $src\t# addExact int" %} - ins_encode %{ - __ addl($dst$$Register, $src$$constant); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct addExactI_eReg_mem(eAXRegI dst, memory src, eFlagsReg cr) -%{ - match(AddExactI dst (LoadI src)); - effect(DEF cr); - - ins_cost(125); - format %{ "ADD $dst,$src\t# addExact int" %} - ins_encode %{ - __ addl($dst$$Register, $src$$Address); - %} - ins_pipe( ialu_reg_mem ); -%} - - // Integer Addition Instructions instruct addI_eReg(rRegI dst, rRegI src, eFlagsReg cr) %{ match(Set dst (AddI dst src)); @@ -7356,43 +7305,6 @@ instruct xchgP( memory mem, pRegP newval) %{ //----------Subtraction Instructions------------------------------------------- -instruct subExactI_eReg(eAXRegI dst, rRegI src, eFlagsReg cr) -%{ - match(SubExactI dst src); - effect(DEF cr); - - format %{ "SUB $dst, $src\t# subExact int" %} - ins_encode %{ - __ subl($dst$$Register, $src$$Register); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct subExactI_eReg_imm(eAXRegI dst, immI src, eFlagsReg cr) -%{ - match(SubExactI dst src); - effect(DEF cr); - - format %{ "SUB $dst, $src\t# subExact int" %} - ins_encode %{ - __ subl($dst$$Register, $src$$constant); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct subExactI_eReg_mem(eAXRegI dst, memory src, eFlagsReg cr) -%{ - match(SubExactI dst (LoadI src)); - effect(DEF cr); - - ins_cost(125); - format %{ "SUB $dst,$src\t# subExact int" %} - ins_encode %{ - __ subl($dst$$Register, $src$$Address); - %} - ins_pipe( ialu_reg_mem ); -%} - // Integer Subtraction Instructions instruct subI_eReg(rRegI dst, rRegI src, eFlagsReg cr) %{ match(Set dst (SubI dst src)); @@ -7461,17 +7373,6 @@ instruct negI_eReg(rRegI dst, immI0 zero, eFlagsReg cr) %{ ins_pipe( ialu_reg ); %} -instruct negExactI_eReg(eAXRegI dst, eFlagsReg cr) %{ - match(NegExactI dst); - effect(DEF cr); - - format %{ "NEG $dst\t# negExact int"%} - ins_encode %{ - __ negl($dst$$Register); - %} - ins_pipe(ialu_reg); -%} - //----------Multiplication/Division Instructions------------------------------- // Integer Multiplication Instructions // Multiply Register @@ -7683,46 +7584,6 @@ instruct mulL_eReg_con(eADXRegL dst, immL_127 src, rRegI tmp, eFlagsReg cr) %{ ins_pipe( pipe_slow ); %} -instruct mulExactI_eReg(eAXRegI dst, rRegI src, eFlagsReg cr) -%{ - match(MulExactI dst src); - effect(DEF cr); - - ins_cost(300); - format %{ "IMUL $dst, $src\t# mulExact int" %} - ins_encode %{ - __ imull($dst$$Register, $src$$Register); - %} - ins_pipe(ialu_reg_reg_alu0); -%} - -instruct mulExactI_eReg_imm(eAXRegI dst, rRegI src, immI imm, eFlagsReg cr) -%{ - match(MulExactI src imm); - effect(DEF cr); - - ins_cost(300); - format %{ "IMUL $dst, $src, $imm\t# mulExact int" %} - ins_encode %{ - __ imull($dst$$Register, $src$$Register, $imm$$constant); - %} - ins_pipe(ialu_reg_reg_alu0); -%} - -instruct mulExactI_eReg_mem(eAXRegI dst, memory src, eFlagsReg cr) -%{ - match(MulExactI dst (LoadI src)); - effect(DEF cr); - - ins_cost(350); - format %{ "IMUL $dst, $src\t# mulExact int" %} - ins_encode %{ - __ imull($dst$$Register, $src$$Address); - %} - ins_pipe(ialu_reg_mem_alu0); -%} - - // Integer DIV with Register instruct divI_eReg(eAXRegI rax, eDXRegI rdx, eCXRegI div, eFlagsReg cr) %{ match(Set rax (DivI rax div)); @@ -8588,6 +8449,91 @@ instruct and_cmpLTMask(rRegI p, rRegI q, rRegI y, eFlagsReg cr) %{ instruct cadd_cmpLTMask_mem(ncxRegI p, ncxRegI q, memory y, eCXRegI tmp, eFlagsReg cr) %{ match(Set p (AddI (AndI (CmpLTMask p q) (LoadI y)) (SubI p q))); */ +//----------Overflow Math Instructions----------------------------------------- + +instruct overflowAddI_eReg(eFlagsReg cr, eAXRegI op1, rRegI op2) +%{ + match(Set cr (OverflowAddI op1 op2)); + effect(DEF cr, USE_KILL op1, USE op2); + + format %{ "ADD $op1, $op2\t# overflow check int" %} + + ins_encode %{ + __ addl($op1$$Register, $op2$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowAddI_rReg_imm(eFlagsReg cr, eAXRegI op1, immI op2) +%{ + match(Set cr (OverflowAddI op1 op2)); + effect(DEF cr, USE_KILL op1, USE op2); + + format %{ "ADD $op1, $op2\t# overflow check int" %} + + ins_encode %{ + __ addl($op1$$Register, $op2$$constant); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowSubI_rReg(eFlagsReg cr, rRegI op1, rRegI op2) +%{ + match(Set cr (OverflowSubI op1 op2)); + + format %{ "CMP $op1, $op2\t# overflow check int" %} + ins_encode %{ + __ cmpl($op1$$Register, $op2$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowSubI_rReg_imm(eFlagsReg cr, rRegI op1, immI op2) +%{ + match(Set cr (OverflowSubI op1 op2)); + + format %{ "CMP $op1, $op2\t# overflow check int" %} + ins_encode %{ + __ cmpl($op1$$Register, $op2$$constant); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowNegI_rReg(eFlagsReg cr, immI0 zero, eAXRegI op2) +%{ + match(Set cr (OverflowSubI zero op2)); + effect(DEF cr, USE_KILL op2); + + format %{ "NEG $op2\t# overflow check int" %} + ins_encode %{ + __ negl($op2$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowMulI_rReg(eFlagsReg cr, eAXRegI op1, rRegI op2) +%{ + match(Set cr (OverflowMulI op1 op2)); + effect(DEF cr, USE_KILL op1, USE op2); + + format %{ "IMUL $op1, $op2\t# overflow check int" %} + ins_encode %{ + __ imull($op1$$Register, $op2$$Register); + %} + ins_pipe(ialu_reg_reg_alu0); +%} + +instruct overflowMulI_rReg_imm(eFlagsReg cr, rRegI op1, immI op2, rRegI tmp) +%{ + match(Set cr (OverflowMulI op1 op2)); + effect(DEF cr, TEMP tmp, USE op1, USE op2); + + format %{ "IMUL $tmp, $op1, $op2\t# overflow check int" %} + ins_encode %{ + __ imull($tmp$$Register, $op1$$Register, $op2$$constant); + %} + ins_pipe(ialu_reg_reg_alu0); +%} //----------Long Instructions------------------------------------------------ // Add Long Register with Register diff --git a/hotspot/src/cpu/x86/vm/x86_64.ad b/hotspot/src/cpu/x86/vm/x86_64.ad index 2778320fdec..b10f920793e 100644 --- a/hotspot/src/cpu/x86/vm/x86_64.ad +++ b/hotspot/src/cpu/x86/vm/x86_64.ad @@ -1657,18 +1657,6 @@ const RegMask Matcher::method_handle_invoke_SP_save_mask() { return PTR_RBP_REG_mask(); } -const RegMask Matcher::mathExactI_result_proj_mask() { - return INT_RAX_REG_mask(); -} - -const RegMask Matcher::mathExactL_result_proj_mask() { - return LONG_RAX_REG_mask(); -} - -const RegMask Matcher::mathExactI_flags_proj_mask() { - return INT_FLAGS_mask(); -} - %} //----------ENCODING BLOCK----------------------------------------------------- @@ -6738,82 +6726,6 @@ instruct cmovD_regUCF(cmpOpUCF cop, rFlagsRegUCF cr, regD dst, regD src) %{ //----------Arithmetic Instructions-------------------------------------------- //----------Addition Instructions---------------------------------------------- -instruct addExactI_rReg(rax_RegI dst, rRegI src, rFlagsReg cr) -%{ - match(AddExactI dst src); - effect(DEF cr); - - format %{ "addl $dst, $src\t# addExact int" %} - ins_encode %{ - __ addl($dst$$Register, $src$$Register); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct addExactI_rReg_imm(rax_RegI dst, immI src, rFlagsReg cr) -%{ - match(AddExactI dst src); - effect(DEF cr); - - format %{ "addl $dst, $src\t# addExact int" %} - ins_encode %{ - __ addl($dst$$Register, $src$$constant); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct addExactI_rReg_mem(rax_RegI dst, memory src, rFlagsReg cr) -%{ - match(AddExactI dst (LoadI src)); - effect(DEF cr); - - ins_cost(125); // XXX - format %{ "addl $dst, $src\t# addExact int" %} - ins_encode %{ - __ addl($dst$$Register, $src$$Address); - %} - - ins_pipe(ialu_reg_mem); -%} - -instruct addExactL_rReg(rax_RegL dst, rRegL src, rFlagsReg cr) -%{ - match(AddExactL dst src); - effect(DEF cr); - - format %{ "addq $dst, $src\t# addExact long" %} - ins_encode %{ - __ addq($dst$$Register, $src$$Register); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct addExactL_rReg_imm(rax_RegL dst, immL32 src, rFlagsReg cr) -%{ - match(AddExactL dst src); - effect(DEF cr); - - format %{ "addq $dst, $src\t# addExact long" %} - ins_encode %{ - __ addq($dst$$Register, $src$$constant); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct addExactL_rReg_mem(rax_RegL dst, memory src, rFlagsReg cr) -%{ - match(AddExactL dst (LoadL src)); - effect(DEF cr); - - ins_cost(125); // XXX - format %{ "addq $dst, $src\t# addExact long" %} - ins_encode %{ - __ addq($dst$$Register, $src$$Address); - %} - - ins_pipe(ialu_reg_mem); -%} - instruct addI_rReg(rRegI dst, rRegI src, rFlagsReg cr) %{ match(Set dst (AddI dst src)); @@ -7426,80 +7338,6 @@ instruct subI_mem_imm(memory dst, immI src, rFlagsReg cr) ins_pipe(ialu_mem_imm); %} -instruct subExactI_rReg(rax_RegI dst, rRegI src, rFlagsReg cr) -%{ - match(SubExactI dst src); - effect(DEF cr); - - format %{ "subl $dst, $src\t# subExact int" %} - ins_encode %{ - __ subl($dst$$Register, $src$$Register); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct subExactI_rReg_imm(rax_RegI dst, immI src, rFlagsReg cr) -%{ - match(SubExactI dst src); - effect(DEF cr); - - format %{ "subl $dst, $src\t# subExact int" %} - ins_encode %{ - __ subl($dst$$Register, $src$$constant); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct subExactI_rReg_mem(rax_RegI dst, memory src, rFlagsReg cr) -%{ - match(SubExactI dst (LoadI src)); - effect(DEF cr); - - ins_cost(125); - format %{ "subl $dst, $src\t# subExact int" %} - ins_encode %{ - __ subl($dst$$Register, $src$$Address); - %} - ins_pipe(ialu_reg_mem); -%} - -instruct subExactL_rReg(rax_RegL dst, rRegL src, rFlagsReg cr) -%{ - match(SubExactL dst src); - effect(DEF cr); - - format %{ "subq $dst, $src\t# subExact long" %} - ins_encode %{ - __ subq($dst$$Register, $src$$Register); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct subExactL_rReg_imm(rax_RegL dst, immL32 src, rFlagsReg cr) -%{ - match(SubExactL dst (LoadL src)); - effect(DEF cr); - - format %{ "subq $dst, $src\t# subExact long" %} - ins_encode %{ - __ subq($dst$$Register, $src$$constant); - %} - ins_pipe(ialu_reg_reg); -%} - -instruct subExactL_rReg_mem(rax_RegI dst, memory src, rFlagsReg cr) -%{ - match(SubExactI dst src); - effect(DEF cr); - - ins_cost(125); - format %{ "subq $dst, $src\t# subExact long" %} - ins_encode %{ - __ subq($dst$$Register, $src$$Address); - %} - ins_pipe(ialu_reg_mem); -%} - instruct subL_rReg(rRegL dst, rRegL src, rFlagsReg cr) %{ match(Set dst (SubL dst src)); @@ -7616,31 +7454,6 @@ instruct negL_mem(memory dst, immL0 zero, rFlagsReg cr) ins_pipe(ialu_reg); %} -instruct negExactI_rReg(rax_RegI dst, rFlagsReg cr) -%{ - match(NegExactI dst); - effect(KILL cr); - - format %{ "negl $dst\t# negExact int" %} - ins_encode %{ - __ negl($dst$$Register); - %} - ins_pipe(ialu_reg); -%} - -instruct negExactL_rReg(rax_RegL dst, rFlagsReg cr) -%{ - match(NegExactL dst); - effect(KILL cr); - - format %{ "negq $dst\t# negExact long" %} - ins_encode %{ - __ negq($dst$$Register); - %} - ins_pipe(ialu_reg); -%} - - //----------Multiplication/Division Instructions------------------------------- // Integer Multiplication Instructions // Multiply Register @@ -7757,86 +7570,6 @@ instruct mulHiL_rReg(rdx_RegL dst, no_rax_RegL src, rax_RegL rax, rFlagsReg cr) ins_pipe(ialu_reg_reg_alu0); %} - -instruct mulExactI_rReg(rax_RegI dst, rRegI src, rFlagsReg cr) -%{ - match(MulExactI dst src); - effect(DEF cr); - - ins_cost(300); - format %{ "imull $dst, $src\t# mulExact int" %} - ins_encode %{ - __ imull($dst$$Register, $src$$Register); - %} - ins_pipe(ialu_reg_reg_alu0); -%} - - -instruct mulExactI_rReg_imm(rax_RegI dst, rRegI src, immI imm, rFlagsReg cr) -%{ - match(MulExactI src imm); - effect(DEF cr); - - ins_cost(300); - format %{ "imull $dst, $src, $imm\t# mulExact int" %} - ins_encode %{ - __ imull($dst$$Register, $src$$Register, $imm$$constant); - %} - ins_pipe(ialu_reg_reg_alu0); -%} - -instruct mulExactI_rReg_mem(rax_RegI dst, memory src, rFlagsReg cr) -%{ - match(MulExactI dst (LoadI src)); - effect(DEF cr); - - ins_cost(350); - format %{ "imull $dst, $src\t# mulExact int" %} - ins_encode %{ - __ imull($dst$$Register, $src$$Address); - %} - ins_pipe(ialu_reg_mem_alu0); -%} - -instruct mulExactL_rReg(rax_RegL dst, rRegL src, rFlagsReg cr) -%{ - match(MulExactL dst src); - effect(DEF cr); - - ins_cost(300); - format %{ "imulq $dst, $src\t# mulExact long" %} - ins_encode %{ - __ imulq($dst$$Register, $src$$Register); - %} - ins_pipe(ialu_reg_reg_alu0); -%} - -instruct mulExactL_rReg_imm(rax_RegL dst, rRegL src, immL32 imm, rFlagsReg cr) -%{ - match(MulExactL src imm); - effect(DEF cr); - - ins_cost(300); - format %{ "imulq $dst, $src, $imm\t# mulExact long" %} - ins_encode %{ - __ imulq($dst$$Register, $src$$Register, $imm$$constant); - %} - ins_pipe(ialu_reg_reg_alu0); -%} - -instruct mulExactL_rReg_mem(rax_RegL dst, memory src, rFlagsReg cr) -%{ - match(MulExactL dst (LoadL src)); - effect(DEF cr); - - ins_cost(350); - format %{ "imulq $dst, $src\t# mulExact long" %} - ins_encode %{ - __ imulq($dst$$Register, $src$$Address); - %} - ins_pipe(ialu_reg_mem_alu0); -%} - instruct divI_rReg(rax_RegI rax, rdx_RegI rdx, no_rax_rdx_RegI div, rFlagsReg cr) %{ @@ -10445,6 +10178,174 @@ instruct encode_iso_array(rsi_RegP src, rdi_RegP dst, rdx_RegI len, ins_pipe( pipe_slow ); %} +//----------Overflow Math Instructions----------------------------------------- + +instruct overflowAddI_rReg(rFlagsReg cr, rax_RegI op1, rRegI op2) +%{ + match(Set cr (OverflowAddI op1 op2)); + effect(DEF cr, USE_KILL op1, USE op2); + + format %{ "addl $op1, $op2\t# overflow check int" %} + + ins_encode %{ + __ addl($op1$$Register, $op2$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowAddI_rReg_imm(rFlagsReg cr, rax_RegI op1, immI op2) +%{ + match(Set cr (OverflowAddI op1 op2)); + effect(DEF cr, USE_KILL op1, USE op2); + + format %{ "addl $op1, $op2\t# overflow check int" %} + + ins_encode %{ + __ addl($op1$$Register, $op2$$constant); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowAddL_rReg(rFlagsReg cr, rax_RegL op1, rRegL op2) +%{ + match(Set cr (OverflowAddL op1 op2)); + effect(DEF cr, USE_KILL op1, USE op2); + + format %{ "addq $op1, $op2\t# overflow check long" %} + ins_encode %{ + __ addq($op1$$Register, $op2$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowAddL_rReg_imm(rFlagsReg cr, rax_RegL op1, immL32 op2) +%{ + match(Set cr (OverflowAddL op1 op2)); + effect(DEF cr, USE_KILL op1, USE op2); + + format %{ "addq $op1, $op2\t# overflow check long" %} + ins_encode %{ + __ addq($op1$$Register, $op2$$constant); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowSubI_rReg(rFlagsReg cr, rRegI op1, rRegI op2) +%{ + match(Set cr (OverflowSubI op1 op2)); + + format %{ "cmpl $op1, $op2\t# overflow check int" %} + ins_encode %{ + __ cmpl($op1$$Register, $op2$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowSubI_rReg_imm(rFlagsReg cr, rRegI op1, immI op2) +%{ + match(Set cr (OverflowSubI op1 op2)); + + format %{ "cmpl $op1, $op2\t# overflow check int" %} + ins_encode %{ + __ cmpl($op1$$Register, $op2$$constant); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowSubL_rReg(rFlagsReg cr, rRegL op1, rRegL op2) +%{ + match(Set cr (OverflowSubL op1 op2)); + + format %{ "cmpq $op1, $op2\t# overflow check long" %} + ins_encode %{ + __ cmpq($op1$$Register, $op2$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowSubL_rReg_imm(rFlagsReg cr, rRegL op1, immL32 op2) +%{ + match(Set cr (OverflowSubL op1 op2)); + + format %{ "cmpq $op1, $op2\t# overflow check long" %} + ins_encode %{ + __ cmpq($op1$$Register, $op2$$constant); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowNegI_rReg(rFlagsReg cr, immI0 zero, rax_RegI op2) +%{ + match(Set cr (OverflowSubI zero op2)); + effect(DEF cr, USE_KILL op2); + + format %{ "negl $op2\t# overflow check int" %} + ins_encode %{ + __ negl($op2$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowNegL_rReg(rFlagsReg cr, immL0 zero, rax_RegL op2) +%{ + match(Set cr (OverflowSubL zero op2)); + effect(DEF cr, USE_KILL op2); + + format %{ "negq $op2\t# overflow check long" %} + ins_encode %{ + __ negq($op2$$Register); + %} + ins_pipe(ialu_reg_reg); +%} + +instruct overflowMulI_rReg(rFlagsReg cr, rax_RegI op1, rRegI op2) +%{ + match(Set cr (OverflowMulI op1 op2)); + effect(DEF cr, USE_KILL op1, USE op2); + + format %{ "imull $op1, $op2\t# overflow check int" %} + ins_encode %{ + __ imull($op1$$Register, $op2$$Register); + %} + ins_pipe(ialu_reg_reg_alu0); +%} + +instruct overflowMulI_rReg_imm(rFlagsReg cr, rRegI op1, immI op2, rRegI tmp) +%{ + match(Set cr (OverflowMulI op1 op2)); + effect(DEF cr, TEMP tmp, USE op1, USE op2); + + format %{ "imull $tmp, $op1, $op2\t# overflow check int" %} + ins_encode %{ + __ imull($tmp$$Register, $op1$$Register, $op2$$constant); + %} + ins_pipe(ialu_reg_reg_alu0); +%} + +instruct overflowMulL_rReg(rFlagsReg cr, rax_RegL op1, rRegL op2) +%{ + match(Set cr (OverflowMulL op1 op2)); + effect(DEF cr, USE_KILL op1, USE op2); + + format %{ "imulq $op1, $op2\t# overflow check long" %} + ins_encode %{ + __ imulq($op1$$Register, $op2$$Register); + %} + ins_pipe(ialu_reg_reg_alu0); +%} + +instruct overflowMulL_rReg_imm(rFlagsReg cr, rRegL op1, immL32 op2, rRegL tmp) +%{ + match(Set cr (OverflowMulL op1 op2)); + effect(DEF cr, TEMP tmp, USE op1, USE op2); + + format %{ "imulq $tmp, $op1, $op2\t# overflow check long" %} + ins_encode %{ + __ imulq($tmp$$Register, $op1$$Register, $op2$$constant); + %} + ins_pipe(ialu_reg_reg_alu0); +%} + //----------Control Flow Instructions------------------------------------------ // Signed compare Instructions diff --git a/hotspot/src/share/vm/adlc/archDesc.cpp b/hotspot/src/share/vm/adlc/archDesc.cpp index 937f175117a..e577c0eead0 100644 --- a/hotspot/src/share/vm/adlc/archDesc.cpp +++ b/hotspot/src/share/vm/adlc/archDesc.cpp @@ -1167,15 +1167,12 @@ void ArchDesc::buildMustCloneMap(FILE *fp_hpp, FILE *fp_cpp) { || strcmp(idealName,"CmpF") == 0 || strcmp(idealName,"FastLock") == 0 || strcmp(idealName,"FastUnlock") == 0 - || strcmp(idealName,"AddExactI") == 0 - || strcmp(idealName,"AddExactL") == 0 - || strcmp(idealName,"SubExactI") == 0 - || strcmp(idealName,"SubExactL") == 0 - || strcmp(idealName,"MulExactI") == 0 - || strcmp(idealName,"MulExactL") == 0 - || strcmp(idealName,"NegExactI") == 0 - || strcmp(idealName,"NegExactL") == 0 - || strcmp(idealName,"FlagsProj") == 0 + || strcmp(idealName,"OverflowAddI") == 0 + || strcmp(idealName,"OverflowAddL") == 0 + || strcmp(idealName,"OverflowSubI") == 0 + || strcmp(idealName,"OverflowSubL") == 0 + || strcmp(idealName,"OverflowMulI") == 0 + || strcmp(idealName,"OverflowMulL") == 0 || strcmp(idealName,"Bool") == 0 || strcmp(idealName,"Binary") == 0 ) { // Removed ConI from the must_clone list. CPUs that cannot use diff --git a/hotspot/src/share/vm/opto/c2_globals.hpp b/hotspot/src/share/vm/opto/c2_globals.hpp index 2ccfb25517a..a22d6871ad6 100644 --- a/hotspot/src/share/vm/opto/c2_globals.hpp +++ b/hotspot/src/share/vm/opto/c2_globals.hpp @@ -644,7 +644,7 @@ diagnostic(bool, OptimizeExpensiveOps, true, \ "Find best control for expensive operations") \ \ - experimental(bool, UseMathExactIntrinsics, false, \ + product(bool, UseMathExactIntrinsics, true, \ "Enables intrinsification of various java.lang.Math functions") \ \ experimental(bool, ReplaceInParentMaps, false, \ diff --git a/hotspot/src/share/vm/opto/classes.hpp b/hotspot/src/share/vm/opto/classes.hpp index bbfd980dd76..3cdc2c58525 100644 --- a/hotspot/src/share/vm/opto/classes.hpp +++ b/hotspot/src/share/vm/opto/classes.hpp @@ -29,8 +29,6 @@ macro(AbsD) macro(AbsF) macro(AbsI) macro(AddD) -macro(AddExactI) -macro(AddExactL) macro(AddF) macro(AddI) macro(AddL) @@ -135,7 +133,6 @@ macro(EncodePKlass) macro(ExpD) macro(FastLock) macro(FastUnlock) -macro(FlagsProj) macro(Goto) macro(Halt) macro(If) @@ -170,9 +167,6 @@ macro(Loop) macro(LoopLimit) macro(Mach) macro(MachProj) -macro(MathExact) -macro(MathExactI) -macro(MathExactL) macro(MaxI) macro(MemBarAcquire) macro(LoadFence) @@ -194,22 +188,24 @@ macro(MoveF2I) macro(MoveL2D) macro(MoveD2L) macro(MulD) -macro(MulExactI) -macro(MulExactL) macro(MulF) macro(MulHiL) macro(MulI) macro(MulL) macro(Multi) macro(NegD) -macro(NegExactI) -macro(NegExactL) macro(NegF) macro(NeverBranch) macro(Opaque1) macro(Opaque2) macro(OrI) macro(OrL) +macro(OverflowAddI) +macro(OverflowSubI) +macro(OverflowMulI) +macro(OverflowAddL) +macro(OverflowSubL) +macro(OverflowMulL) macro(PCTable) macro(Parm) macro(PartialSubtypeCheck) @@ -253,8 +249,6 @@ macro(StrComp) macro(StrEquals) macro(StrIndexOf) macro(SubD) -macro(SubExactI) -macro(SubExactL) macro(SubF) macro(SubI) macro(SubL) diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index d838a5b6a8c..f3b798296f4 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -3028,42 +3028,6 @@ void Compile::final_graph_reshaping_impl( Node *n, Final_Reshape_Counts &frc) { n->set_req(MemBarNode::Precedent, top()); } break; - // Must set a control edge on all nodes that produce a FlagsProj - // so they can't escape the block that consumes the flags. - // Must also set the non throwing branch as the control - // for all nodes that depends on the result. Unless the node - // already have a control that isn't the control of the - // flag producer - case Op_FlagsProj: - { - MathExactNode* math = (MathExactNode*) n->in(0); - Node* ctrl = math->control_node(); - Node* non_throwing = math->non_throwing_branch(); - math->set_req(0, ctrl); - - Node* result = math->result_node(); - if (result != NULL) { - for (DUIterator_Fast jmax, j = result->fast_outs(jmax); j < jmax; j++) { - Node* out = result->fast_out(j); - // Phi nodes shouldn't be moved. They would only match below if they - // had the same control as the MathExactNode. The only time that - // would happen is if the Phi is also an input to the MathExact - // - // Cmp nodes shouldn't have control set at all. - if (out->is_Phi() || - out->is_Cmp()) { - continue; - } - - if (out->in(0) == NULL) { - out->set_req(0, non_throwing); - } else if (out->in(0) == ctrl) { - out->set_req(0, non_throwing); - } - } - } - } - break; default: assert( !n->is_Call(), "" ); assert( !n->is_Mem(), "" ); diff --git a/hotspot/src/share/vm/opto/ifnode.cpp b/hotspot/src/share/vm/opto/ifnode.cpp index 6e61a1f98bc..1c9dbb70839 100644 --- a/hotspot/src/share/vm/opto/ifnode.cpp +++ b/hotspot/src/share/vm/opto/ifnode.cpp @@ -76,7 +76,6 @@ static Node* split_if(IfNode *iff, PhaseIterGVN *igvn) { if( !i1->is_Bool() ) return NULL; BoolNode *b = i1->as_Bool(); Node *cmp = b->in(1); - if( cmp->is_FlagsProj() ) return NULL; if( !cmp->is_Cmp() ) return NULL; i1 = cmp->in(1); if( i1 == NULL || !i1->is_Phi() ) return NULL; diff --git a/hotspot/src/share/vm/opto/lcm.cpp b/hotspot/src/share/vm/opto/lcm.cpp index 869928a54d9..8398bb3d254 100644 --- a/hotspot/src/share/vm/opto/lcm.cpp +++ b/hotspot/src/share/vm/opto/lcm.cpp @@ -520,13 +520,6 @@ Node* PhaseCFG::select(Block* block, Node_List &worklist, GrowableArray &re break; } - // For nodes that produce a FlagsProj, make the node adjacent to the - // use of the FlagsProj - if (use->is_FlagsProj() && get_block_for_node(use) == block) { - found_machif = true; - break; - } - // More than this instruction pending for successor to be ready, // don't choose this if other opportunities are ready if (ready_cnt.at(use->_idx) > 1) diff --git a/hotspot/src/share/vm/opto/library_call.cpp b/hotspot/src/share/vm/opto/library_call.cpp index 465de355b67..73c6e9090f9 100644 --- a/hotspot/src/share/vm/opto/library_call.cpp +++ b/hotspot/src/share/vm/opto/library_call.cpp @@ -203,7 +203,9 @@ class LibraryCallKit : public GraphKit { bool inline_math_native(vmIntrinsics::ID id); bool inline_trig(vmIntrinsics::ID id); bool inline_math(vmIntrinsics::ID id); - void inline_math_mathExact(Node* math); + template + bool inline_math_overflow(Node* arg1, Node* arg2); + void inline_math_mathExact(Node* math, Node* test); bool inline_math_addExactI(bool is_increment); bool inline_math_addExactL(bool is_increment); bool inline_math_multiplyExactI(); @@ -517,31 +519,31 @@ CallGenerator* Compile::make_vm_intrinsic(ciMethod* m, bool is_virtual) { case vmIntrinsics::_incrementExactI: case vmIntrinsics::_addExactI: - if (!Matcher::match_rule_supported(Op_AddExactI) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowAddI) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_incrementExactL: case vmIntrinsics::_addExactL: - if (!Matcher::match_rule_supported(Op_AddExactL) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowAddL) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_decrementExactI: case vmIntrinsics::_subtractExactI: - if (!Matcher::match_rule_supported(Op_SubExactI) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_decrementExactL: case vmIntrinsics::_subtractExactL: - if (!Matcher::match_rule_supported(Op_SubExactL) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowSubL) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_negateExactI: - if (!Matcher::match_rule_supported(Op_NegExactI) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowSubI) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_negateExactL: - if (!Matcher::match_rule_supported(Op_NegExactL) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowSubL) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_multiplyExactI: - if (!Matcher::match_rule_supported(Op_MulExactI) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowMulI) || !UseMathExactIntrinsics) return NULL; break; case vmIntrinsics::_multiplyExactL: - if (!Matcher::match_rule_supported(Op_MulExactL) || !UseMathExactIntrinsics) return NULL; + if (!Matcher::match_rule_supported(Op_OverflowMulL) || !UseMathExactIntrinsics) return NULL; break; default: @@ -1970,18 +1972,8 @@ bool LibraryCallKit::inline_min_max(vmIntrinsics::ID id) { return true; } -void LibraryCallKit::inline_math_mathExact(Node* math) { - // If we didn't get the expected opcode it means we have optimized - // the node to something else and don't need the exception edge. - if (!math->is_MathExact()) { - set_result(math); - return; - } - - Node* result = _gvn.transform( new(C) ProjNode(math, MathExactNode::result_proj_node)); - Node* flags = _gvn.transform( new(C) FlagsProjNode(math, MathExactNode::flags_proj_node)); - - Node* bol = _gvn.transform( new (C) BoolNode(flags, BoolTest::overflow) ); +void LibraryCallKit::inline_math_mathExact(Node* math, Node *test) { + Node* bol = _gvn.transform( new (C) BoolNode(test, BoolTest::overflow) ); IfNode* check = create_and_map_if(control(), bol, PROB_UNLIKELY_MAG(3), COUNT_UNKNOWN); Node* fast_path = _gvn.transform( new (C) IfFalseNode(check)); Node* slow_path = _gvn.transform( new (C) IfTrueNode(check) ); @@ -1999,108 +1991,50 @@ void LibraryCallKit::inline_math_mathExact(Node* math) { } set_control(fast_path); - set_result(result); + set_result(math); +} + +template +bool LibraryCallKit::inline_math_overflow(Node* arg1, Node* arg2) { + typedef typename OverflowOp::MathOp MathOp; + + MathOp* mathOp = new(C) MathOp(arg1, arg2); + Node* operation = _gvn.transform( mathOp ); + Node* ofcheck = _gvn.transform( new(C) OverflowOp(arg1, arg2) ); + inline_math_mathExact(operation, ofcheck); + return true; } bool LibraryCallKit::inline_math_addExactI(bool is_increment) { - Node* arg1 = argument(0); - Node* arg2 = NULL; - - if (is_increment) { - arg2 = intcon(1); - } else { - arg2 = argument(1); - } - - Node* add = _gvn.transform( new(C) AddExactINode(NULL, arg1, arg2) ); - inline_math_mathExact(add); - return true; + return inline_math_overflow(argument(0), is_increment ? intcon(1) : argument(1)); } bool LibraryCallKit::inline_math_addExactL(bool is_increment) { - Node* arg1 = argument(0); // type long - // argument(1) == TOP - Node* arg2 = NULL; - - if (is_increment) { - arg2 = longcon(1); - } else { - arg2 = argument(2); // type long - // argument(3) == TOP - } - - Node* add = _gvn.transform(new(C) AddExactLNode(NULL, arg1, arg2)); - inline_math_mathExact(add); - return true; + return inline_math_overflow(argument(0), is_increment ? longcon(1) : argument(2)); } bool LibraryCallKit::inline_math_subtractExactI(bool is_decrement) { - Node* arg1 = argument(0); - Node* arg2 = NULL; - - if (is_decrement) { - arg2 = intcon(1); - } else { - arg2 = argument(1); - } - - Node* sub = _gvn.transform(new(C) SubExactINode(NULL, arg1, arg2)); - inline_math_mathExact(sub); - return true; + return inline_math_overflow(argument(0), is_decrement ? intcon(1) : argument(1)); } bool LibraryCallKit::inline_math_subtractExactL(bool is_decrement) { - Node* arg1 = argument(0); // type long - // argument(1) == TOP - Node* arg2 = NULL; - - if (is_decrement) { - arg2 = longcon(1); - } else { - arg2 = argument(2); // type long - // argument(3) == TOP - } - - Node* sub = _gvn.transform(new(C) SubExactLNode(NULL, arg1, arg2)); - inline_math_mathExact(sub); - return true; + return inline_math_overflow(argument(0), is_decrement ? longcon(1) : argument(2)); } bool LibraryCallKit::inline_math_negateExactI() { - Node* arg1 = argument(0); - - Node* neg = _gvn.transform(new(C) NegExactINode(NULL, arg1)); - inline_math_mathExact(neg); - return true; + return inline_math_overflow(intcon(0), argument(0)); } bool LibraryCallKit::inline_math_negateExactL() { - Node* arg1 = argument(0); - // argument(1) == TOP - - Node* neg = _gvn.transform(new(C) NegExactLNode(NULL, arg1)); - inline_math_mathExact(neg); - return true; + return inline_math_overflow(longcon(0), argument(0)); } bool LibraryCallKit::inline_math_multiplyExactI() { - Node* arg1 = argument(0); - Node* arg2 = argument(1); - - Node* mul = _gvn.transform(new(C) MulExactINode(NULL, arg1, arg2)); - inline_math_mathExact(mul); - return true; + return inline_math_overflow(argument(0), argument(1)); } bool LibraryCallKit::inline_math_multiplyExactL() { - Node* arg1 = argument(0); - // argument(1) == TOP - Node* arg2 = argument(2); - // argument(3) == TOP - - Node* mul = _gvn.transform(new(C) MulExactLNode(NULL, arg1, arg2)); - inline_math_mathExact(mul); - return true; + return inline_math_overflow(argument(0), argument(2)); } Node* diff --git a/hotspot/src/share/vm/opto/loopTransform.cpp b/hotspot/src/share/vm/opto/loopTransform.cpp index 4cc7a537558..7fa685b03eb 100644 --- a/hotspot/src/share/vm/opto/loopTransform.cpp +++ b/hotspot/src/share/vm/opto/loopTransform.cpp @@ -713,10 +713,6 @@ bool IdealLoopTree::policy_unroll( PhaseIdealLoop *phase ) const { case Op_ModL: body_size += 30; break; case Op_DivL: body_size += 30; break; case Op_MulL: body_size += 10; break; - case Op_FlagsProj: - // Can't handle unrolling of loops containing - // nodes that generate a FlagsProj at the moment - return false; case Op_StrComp: case Op_StrEquals: case Op_StrIndexOf: @@ -780,10 +776,6 @@ bool IdealLoopTree::policy_range_check( PhaseIdealLoop *phase ) const { continue; // not RC Node *cmp = bol->in(1); - if (cmp->is_FlagsProj()) { - continue; - } - Node *rc_exp = cmp->in(1); Node *limit = cmp->in(2); diff --git a/hotspot/src/share/vm/opto/loopopts.cpp b/hotspot/src/share/vm/opto/loopopts.cpp index ac97d3edec5..f9a87bbac57 100644 --- a/hotspot/src/share/vm/opto/loopopts.cpp +++ b/hotspot/src/share/vm/opto/loopopts.cpp @@ -43,12 +43,6 @@ Node *PhaseIdealLoop::split_thru_phi( Node *n, Node *region, int policy ) { return NULL; } - if (n->is_MathExact()) { - // MathExact has projections that are not correctly handled in the code - // below. - return NULL; - } - int wins = 0; assert(!n->is_CFG(), ""); assert(region->is_Region(), ""); @@ -2362,8 +2356,7 @@ bool PhaseIdealLoop::partial_peel( IdealLoopTree *loop, Node_List &old_new ) { opc == Op_Catch || opc == Op_CatchProj || opc == Op_Jump || - opc == Op_JumpProj || - opc == Op_FlagsProj) { + opc == Op_JumpProj) { #if !defined(PRODUCT) if (TracePartialPeeling) { tty->print_cr("\nExit control too complex: lp: %d", head->_idx); diff --git a/hotspot/src/share/vm/opto/matcher.cpp b/hotspot/src/share/vm/opto/matcher.cpp index 6d35afde069..03ee1dc8086 100644 --- a/hotspot/src/share/vm/opto/matcher.cpp +++ b/hotspot/src/share/vm/opto/matcher.cpp @@ -1998,7 +1998,6 @@ void Matcher::find_shared( Node *n ) { case Op_Catch: case Op_CatchProj: case Op_CProj: - case Op_FlagsProj: case Op_JumpProj: case Op_JProj: case Op_NeverBranch: diff --git a/hotspot/src/share/vm/opto/matcher.hpp b/hotspot/src/share/vm/opto/matcher.hpp index 6d0c8e3b050..38eeca40290 100644 --- a/hotspot/src/share/vm/opto/matcher.hpp +++ b/hotspot/src/share/vm/opto/matcher.hpp @@ -340,10 +340,6 @@ public: // Register for MODL projection of divmodL static RegMask modL_proj_mask(); - static const RegMask mathExactI_result_proj_mask(); - static const RegMask mathExactL_result_proj_mask(); - static const RegMask mathExactI_flags_proj_mask(); - // Use hardware DIV instruction when it is faster than // a code which use multiply for division by constant. static bool use_asm_for_ldiv_by_con( jlong divisor ); diff --git a/hotspot/src/share/vm/opto/mathexactnode.cpp b/hotspot/src/share/vm/opto/mathexactnode.cpp index bb930b37d52..00466ad3d50 100644 --- a/hotspot/src/share/vm/opto/mathexactnode.cpp +++ b/hotspot/src/share/vm/opto/mathexactnode.cpp @@ -31,358 +31,93 @@ #include "opto/mathexactnode.hpp" #include "opto/subnode.hpp" -MathExactNode::MathExactNode(Node* ctrl, Node* in1) : MultiNode(2) { - init_class_id(Class_MathExact); - init_req(0, ctrl); - init_req(1, in1); -} +template +class AddHelper { +public: + typedef typename OverflowOp::TypeClass TypeClass; + typedef typename TypeClass::NativeType NativeType; -MathExactNode::MathExactNode(Node* ctrl, Node* in1, Node* in2) : MultiNode(3) { - init_class_id(Class_MathExact); - init_req(0, ctrl); - init_req(1, in1); - init_req(2, in2); -} - -BoolNode* MathExactNode::bool_node() const { - Node* flags = flags_node(); - BoolNode* boolnode = flags->unique_out()->as_Bool(); - assert(boolnode != NULL, "must have BoolNode"); - return boolnode; -} - -IfNode* MathExactNode::if_node() const { - BoolNode* boolnode = bool_node(); - IfNode* ifnode = boolnode->unique_out()->as_If(); - assert(ifnode != NULL, "must have IfNode"); - return ifnode; -} - -Node* MathExactNode::control_node() const { - IfNode* ifnode = if_node(); - return ifnode->in(0); -} - -Node* MathExactNode::non_throwing_branch() const { - IfNode* ifnode = if_node(); - if (bool_node()->_test._test == BoolTest::overflow) { - return ifnode->proj_out(0); - } - return ifnode->proj_out(1); -} - -// If the MathExactNode won't overflow we have to replace the -// FlagsProjNode and ProjNode that is generated by the MathExactNode -Node* MathExactNode::no_overflow(PhaseGVN* phase, Node* new_result) { - PhaseIterGVN* igvn = phase->is_IterGVN(); - if (igvn) { - ProjNode* result = result_node(); - ProjNode* flags = flags_node(); - - if (result != NULL) { - igvn->replace_node(result, new_result); - } - - if (flags != NULL) { - BoolNode* boolnode = bool_node(); - switch (boolnode->_test._test) { - case BoolTest::overflow: - // if the check is for overflow - never taken - igvn->replace_node(boolnode, phase->intcon(0)); - break; - case BoolTest::no_overflow: - // if the check is for no overflow - always taken - igvn->replace_node(boolnode, phase->intcon(1)); - break; - default: - fatal("Unexpected value of BoolTest"); - break; - } - flags->del_req(0); - } - } - return new_result; -} - -Node* MathExactINode::match(const ProjNode* proj, const Matcher* m) { - uint ideal_reg = proj->ideal_reg(); - RegMask rm; - if (proj->_con == result_proj_node) { - rm = m->mathExactI_result_proj_mask(); - } else { - assert(proj->_con == flags_proj_node, "must be result or flags"); - assert(ideal_reg == Op_RegFlags, "sanity"); - rm = m->mathExactI_flags_proj_mask(); - } - return new (m->C) MachProjNode(this, proj->_con, rm, ideal_reg); -} - -Node* MathExactLNode::match(const ProjNode* proj, const Matcher* m) { - uint ideal_reg = proj->ideal_reg(); - RegMask rm; - if (proj->_con == result_proj_node) { - rm = m->mathExactL_result_proj_mask(); - } else { - assert(proj->_con == flags_proj_node, "must be result or flags"); - assert(ideal_reg == Op_RegFlags, "sanity"); - rm = m->mathExactI_flags_proj_mask(); - } - return new (m->C) MachProjNode(this, proj->_con, rm, ideal_reg); -} - -Node* AddExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { - Node* arg1 = in(1); - Node* arg2 = in(2); - - const Type* type1 = phase->type(arg1); - const Type* type2 = phase->type(arg2); - - if (type1 != Type::TOP && type1->singleton() && - type2 != Type::TOP && type2->singleton()) { - jint val1 = arg1->get_int(); - jint val2 = arg2->get_int(); - jint result = val1 + val2; + static bool will_overflow(NativeType value1, NativeType value2) { + NativeType result = value1 + value2; // Hacker's Delight 2-12 Overflow if both arguments have the opposite sign of the result - if ( (((val1 ^ result) & (val2 ^ result)) >= 0)) { - Node* con_result = ConINode::make(phase->C, result); - return no_overflow(phase, con_result); + if (((value1 ^ result) & (value2 ^ result)) >= 0) { + return false; } - return NULL; + return true; } - if (type1 == TypeInt::ZERO || type2 == TypeInt::ZERO) { // (Add 0 x) == x - Node* add_result = new (phase->C) AddINode(arg1, arg2); - return no_overflow(phase, add_result); - } - - if (type2->singleton()) { - return NULL; // no change - keep constant on the right - } - - if (type1->singleton()) { - // Make it x + Constant - move constant to the right - swap_edges(1, 2); - return this; - } - - if (arg2->is_Load()) { - return NULL; // no change - keep load on the right - } - - if (arg1->is_Load()) { - // Make it x + Load - move load to the right - swap_edges(1, 2); - return this; - } - - if (arg1->_idx > arg2->_idx) { - // Sort the edges - swap_edges(1, 2); - return this; - } - - return NULL; -} - -Node* AddExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { - Node* arg1 = in(1); - Node* arg2 = in(2); - - const Type* type1 = phase->type(arg1); - const Type* type2 = phase->type(arg2); - - if (type1 != Type::TOP && type1->singleton() && - type2 != Type::TOP && type2->singleton()) { - jlong val1 = arg1->get_long(); - jlong val2 = arg2->get_long(); - jlong result = val1 + val2; - // Hacker's Delight 2-12 Overflow if both arguments have the opposite sign of the result - if ( (((val1 ^ result) & (val2 ^ result)) >= 0)) { - Node* con_result = ConLNode::make(phase->C, result); - return no_overflow(phase, con_result); + static bool can_overflow(const Type* type1, const Type* type2) { + if (type1 == TypeClass::ZERO || type2 == TypeClass::ZERO) { + return false; } - return NULL; + return true; } +}; - if (type1 == TypeLong::ZERO || type2 == TypeLong::ZERO) { // (Add 0 x) == x - Node* add_result = new (phase->C) AddLNode(arg1, arg2); - return no_overflow(phase, add_result); - } +template +class SubHelper { +public: + typedef typename OverflowOp::TypeClass TypeClass; + typedef typename TypeClass::NativeType NativeType; - if (type2->singleton()) { - return NULL; // no change - keep constant on the right - } - - if (type1->singleton()) { - // Make it x + Constant - move constant to the right - swap_edges(1, 2); - return this; - } - - if (arg2->is_Load()) { - return NULL; // no change - keep load on the right - } - - if (arg1->is_Load()) { - // Make it x + Load - move load to the right - swap_edges(1, 2); - return this; - } - - if (arg1->_idx > arg2->_idx) { - // Sort the edges - swap_edges(1, 2); - return this; - } - - return NULL; -} - -Node* SubExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { - Node* arg1 = in(1); - Node* arg2 = in(2); - - const Type* type1 = phase->type(arg1); - const Type* type2 = phase->type(arg2); - - if (type1 != Type::TOP && type1->singleton() && - type2 != Type::TOP && type2->singleton()) { - jint val1 = arg1->get_int(); - jint val2 = arg2->get_int(); - jint result = val1 - val2; - - // Hacker's Delight 2-12 Overflow iff the arguments have different signs and + static bool will_overflow(NativeType value1, NativeType value2) { + NativeType result = value1 - value2; + // hacker's delight 2-12 overflow iff the arguments have different signs and // the sign of the result is different than the sign of arg1 - if (((val1 ^ val2) & (val1 ^ result)) >= 0) { - Node* con_result = ConINode::make(phase->C, result); - return no_overflow(phase, con_result); + if (((value1 ^ value2) & (value1 ^ result)) >= 0) { + return false; } - return NULL; + return true; } - if (type1 == TypeInt::ZERO || type2 == TypeInt::ZERO) { - // Sub with zero is the same as add with zero - Node* add_result = new (phase->C) AddINode(arg1, arg2); - return no_overflow(phase, add_result); + static bool can_overflow(const Type* type1, const Type* type2) { + if (type2 == TypeClass::ZERO) { + return false; + } + return true; } +}; - return NULL; +template +class MulHelper { +public: + typedef typename OverflowOp::TypeClass TypeClass; + + static bool can_overflow(const Type* type1, const Type* type2) { + if (type1 == TypeClass::ZERO || type2 == TypeClass::ZERO) { + return false; + } else if (type1 == TypeClass::ONE || type2 == TypeClass::ONE) { + return false; + } + return true; + } +}; + +bool OverflowAddINode::will_overflow(jint v1, jint v2) const { + return AddHelper::will_overflow(v1, v2); } -Node* SubExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { - Node* arg1 = in(1); - Node* arg2 = in(2); - - const Type* type1 = phase->type(arg1); - const Type* type2 = phase->type(arg2); - - if (type1 != Type::TOP && type1->singleton() && - type2 != Type::TOP && type2->singleton()) { - jlong val1 = arg1->get_long(); - jlong val2 = arg2->get_long(); - jlong result = val1 - val2; - - // Hacker's Delight 2-12 Overflow iff the arguments have different signs and - // the sign of the result is different than the sign of arg1 - if (((val1 ^ val2) & (val1 ^ result)) >= 0) { - Node* con_result = ConLNode::make(phase->C, result); - return no_overflow(phase, con_result); - } - return NULL; - } - - if (type1 == TypeLong::ZERO || type2 == TypeLong::ZERO) { - // Sub with zero is the same as add with zero - Node* add_result = new (phase->C) AddLNode(arg1, arg2); - return no_overflow(phase, add_result); - } - - return NULL; +bool OverflowSubINode::will_overflow(jint v1, jint v2) const { + return SubHelper::will_overflow(v1, v2); } -Node* NegExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { - Node *arg = in(1); - - const Type* type = phase->type(arg); - if (type != Type::TOP && type->singleton()) { - jint value = arg->get_int(); - if (value != min_jint) { - Node* neg_result = ConINode::make(phase->C, -value); - return no_overflow(phase, neg_result); - } - } - return NULL; -} - -Node* NegExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { - Node *arg = in(1); - - const Type* type = phase->type(arg); - if (type != Type::TOP && type->singleton()) { - jlong value = arg->get_long(); - if (value != min_jlong) { - Node* neg_result = ConLNode::make(phase->C, -value); - return no_overflow(phase, neg_result); - } - } - return NULL; -} - -Node* MulExactINode::Ideal(PhaseGVN* phase, bool can_reshape) { - Node* arg1 = in(1); - Node* arg2 = in(2); - - const Type* type1 = phase->type(arg1); - const Type* type2 = phase->type(arg2); - - if (type1 != Type::TOP && type1->singleton() && - type2 != Type::TOP && type2->singleton()) { - jint val1 = arg1->get_int(); - jint val2 = arg2->get_int(); - jlong result = (jlong) val1 * (jlong) val2; +bool OverflowMulINode::will_overflow(jint v1, jint v2) const { + jlong result = (jlong) v1 * (jlong) v2; if ((jint) result == result) { - // no overflow - Node* mul_result = ConINode::make(phase->C, result); - return no_overflow(phase, mul_result); + return false; } - } - - if (type1 == TypeInt::ZERO || type2 == TypeInt::ZERO) { - return no_overflow(phase, ConINode::make(phase->C, 0)); - } - - if (type1 == TypeInt::ONE) { - Node* mul_result = new (phase->C) AddINode(arg2, phase->intcon(0)); - return no_overflow(phase, mul_result); - } - if (type2 == TypeInt::ONE) { - Node* mul_result = new (phase->C) AddINode(arg1, phase->intcon(0)); - return no_overflow(phase, mul_result); - } - - if (type1 == TypeInt::MINUS_1) { - return new (phase->C) NegExactINode(NULL, arg2); - } - - if (type2 == TypeInt::MINUS_1) { - return new (phase->C) NegExactINode(NULL, arg1); - } - - return NULL; + return true; } -Node* MulExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { - Node* arg1 = in(1); - Node* arg2 = in(2); +bool OverflowAddLNode::will_overflow(jlong v1, jlong v2) const { + return AddHelper::will_overflow(v1, v2); +} - const Type* type1 = phase->type(arg1); - const Type* type2 = phase->type(arg2); - - if (type1 != Type::TOP && type1->singleton() && - type2 != Type::TOP && type2->singleton()) { - jlong val1 = arg1->get_long(); - jlong val2 = arg2->get_long(); +bool OverflowSubLNode::will_overflow(jlong v1, jlong v2) const { + return SubHelper::will_overflow(v1, v2); +} +bool OverflowMulLNode::will_overflow(jlong val1, jlong val2) const { jlong result = val1 * val2; jlong ax = (val1 < 0 ? -val1 : val1); jlong ay = (val2 < 0 ? -val2 : val2); @@ -398,33 +133,125 @@ Node* MulExactLNode::Ideal(PhaseGVN* phase, bool can_reshape) { } } - if (!overflow) { - Node* mul_result = ConLNode::make(phase->C, result); - return no_overflow(phase, mul_result); - } - } - - if (type1 == TypeLong::ZERO || type2 == TypeLong::ZERO) { - return no_overflow(phase, ConLNode::make(phase->C, 0)); - } - - if (type1 == TypeLong::ONE) { - Node* mul_result = new (phase->C) AddLNode(arg2, phase->longcon(0)); - return no_overflow(phase, mul_result); - } - if (type2 == TypeLong::ONE) { - Node* mul_result = new (phase->C) AddLNode(arg1, phase->longcon(0)); - return no_overflow(phase, mul_result); - } - - if (type1 == TypeLong::MINUS_1) { - return new (phase->C) NegExactLNode(NULL, arg2); - } - - if (type2 == TypeLong::MINUS_1) { - return new (phase->C) NegExactLNode(NULL, arg1); - } - - return NULL; + return overflow; +} + +bool OverflowAddINode::can_overflow(const Type* t1, const Type* t2) const { + return AddHelper::can_overflow(t1, t2); +} + +bool OverflowSubINode::can_overflow(const Type* t1, const Type* t2) const { + if (in(1) == in(2)) { + return false; + } + return SubHelper::can_overflow(t1, t2); +} + +bool OverflowMulINode::can_overflow(const Type* t1, const Type* t2) const { + return MulHelper::can_overflow(t1, t2); +} + +bool OverflowAddLNode::can_overflow(const Type* t1, const Type* t2) const { + return AddHelper::can_overflow(t1, t2); +} + +bool OverflowSubLNode::can_overflow(const Type* t1, const Type* t2) const { + if (in(1) == in(2)) { + return false; + } + return SubHelper::can_overflow(t1, t2); +} + +bool OverflowMulLNode::can_overflow(const Type* t1, const Type* t2) const { + return MulHelper::can_overflow(t1, t2); +} + +const Type* OverflowNode::sub(const Type* t1, const Type* t2) const { + fatal(err_msg_res("sub() should not be called for '%s'", NodeClassNames[this->Opcode()])); + return TypeInt::CC; +} + +template +struct IdealHelper { + typedef typename OverflowOp::TypeClass TypeClass; // TypeInt, TypeLong + typedef typename TypeClass::NativeType NativeType; + + static Node* Ideal(const OverflowOp* node, PhaseGVN* phase, bool can_reshape) { + Node* arg1 = node->in(1); + Node* arg2 = node->in(2); + const Type* type1 = phase->type(arg1); + const Type* type2 = phase->type(arg2); + + if (type1 == NULL || type2 == NULL) { + return NULL; + } + + if (type1 != Type::TOP && type1->singleton() && + type2 != Type::TOP && type2->singleton()) { + NativeType val1 = TypeClass::as_self(type1)->get_con(); + NativeType val2 = TypeClass::as_self(type2)->get_con(); + if (node->will_overflow(val1, val2) == false) { + Node* con_result = ConINode::make(phase->C, 0); + return con_result; + } + return NULL; + } + return NULL; + } + + static const Type* Value(const OverflowOp* node, PhaseTransform* phase) { + const Type *t1 = phase->type( node->in(1) ); + const Type *t2 = phase->type( node->in(2) ); + if( t1 == Type::TOP ) return Type::TOP; + if( t2 == Type::TOP ) return Type::TOP; + + const TypeClass* i1 = TypeClass::as_self(t1); + const TypeClass* i2 = TypeClass::as_self(t2); + + if (i1 == NULL || i2 == NULL) { + return TypeInt::CC; + } + + if (t1->singleton() && t2->singleton()) { + NativeType val1 = i1->get_con(); + NativeType val2 = i2->get_con(); + if (node->will_overflow(val1, val2)) { + return TypeInt::CC; + } + return TypeInt::ZERO; + } else if (i1 != TypeClass::TYPE_DOMAIN && i2 != TypeClass::TYPE_DOMAIN) { + if (node->will_overflow(i1->_lo, i2->_lo)) { + return TypeInt::CC; + } else if (node->will_overflow(i1->_lo, i2->_hi)) { + return TypeInt::CC; + } else if (node->will_overflow(i1->_hi, i2->_lo)) { + return TypeInt::CC; + } else if (node->will_overflow(i1->_hi, i2->_hi)) { + return TypeInt::CC; + } + return TypeInt::ZERO; + } + + if (!node->can_overflow(t1, t2)) { + return TypeInt::ZERO; + } + return TypeInt::CC; + } +}; + +Node* OverflowINode::Ideal(PhaseGVN* phase, bool can_reshape) { + return IdealHelper::Ideal(this, phase, can_reshape); +} + +Node* OverflowLNode::Ideal(PhaseGVN* phase, bool can_reshape) { + return IdealHelper::Ideal(this, phase, can_reshape); +} + +const Type* OverflowINode::Value(PhaseTransform* phase) const { + return IdealHelper::Value(this, phase); +} + +const Type* OverflowLNode::Value(PhaseTransform* phase) const { + return IdealHelper::Value(this, phase); } diff --git a/hotspot/src/share/vm/opto/mathexactnode.hpp b/hotspot/src/share/vm/opto/mathexactnode.hpp index a30304ba93a..3e037cf568b 100644 --- a/hotspot/src/share/vm/opto/mathexactnode.hpp +++ b/hotspot/src/share/vm/opto/mathexactnode.hpp @@ -27,128 +27,111 @@ #include "opto/multnode.hpp" #include "opto/node.hpp" +#include "opto/addnode.hpp" #include "opto/subnode.hpp" #include "opto/type.hpp" -class BoolNode; -class IfNode; -class Node; - class PhaseGVN; class PhaseTransform; -class MathExactNode : public MultiNode { +class OverflowNode : public CmpNode { public: - MathExactNode(Node* ctrl, Node* in1); - MathExactNode(Node* ctrl, Node* in1, Node* in2); - enum { - result_proj_node = 0, - flags_proj_node = 1 - }; - virtual int Opcode() const; - virtual Node* Identity(PhaseTransform* phase) { return this; } - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape) { return NULL; } - virtual const Type* Value(PhaseTransform* phase) const { return bottom_type(); } - virtual uint hash() const { return NO_HASH; } - virtual bool is_CFG() const { return false; } - virtual uint ideal_reg() const { return NotAMachineReg; } + OverflowNode(Node* in1, Node* in2) : CmpNode(in1, in2) {} - ProjNode* result_node() const { return proj_out(result_proj_node); } - ProjNode* flags_node() const { return proj_out(flags_proj_node); } - Node* control_node() const; - Node* non_throwing_branch() const; -protected: - IfNode* if_node() const; - BoolNode* bool_node() const; - Node* no_overflow(PhaseGVN *phase, Node* new_result); -}; - -class MathExactINode : public MathExactNode { - public: - MathExactINode(Node* ctrl, Node* in1) : MathExactNode(ctrl, in1) {} - MathExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactNode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node* match(const ProjNode* proj, const Matcher* m); - virtual const Type* bottom_type() const { return TypeTuple::INT_CC_PAIR; } -}; - -class MathExactLNode : public MathExactNode { -public: - MathExactLNode(Node* ctrl, Node* in1) : MathExactNode(ctrl, in1) {} - MathExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactNode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node* match(const ProjNode* proj, const Matcher* m); - virtual const Type* bottom_type() const { return TypeTuple::LONG_CC_PAIR; } -}; - -class AddExactINode : public MathExactINode { -public: - AddExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node *Ideal(PhaseGVN *phase, bool can_reshape); -}; - -class AddExactLNode : public MathExactLNode { -public: - AddExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); -}; - -class SubExactINode : public MathExactINode { -public: - SubExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); -}; - -class SubExactLNode : public MathExactLNode { -public: - SubExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); -}; - -class NegExactINode : public MathExactINode { -public: - NegExactINode(Node* ctrl, Node* in1) : MathExactINode(ctrl, in1) {} - virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); -}; - -class NegExactLNode : public MathExactLNode { -public: - NegExactLNode(Node* ctrl, Node* in1) : MathExactLNode(ctrl, in1) {} - virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); -}; - -class MulExactINode : public MathExactINode { -public: - MulExactINode(Node* ctrl, Node* in1, Node* in2) : MathExactINode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); -}; - -class MulExactLNode : public MathExactLNode { -public: - MulExactLNode(Node* ctrl, Node* in1, Node* in2) : MathExactLNode(ctrl, in1, in2) {} - virtual int Opcode() const; - virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); -}; - -class FlagsProjNode : public ProjNode { -public: - FlagsProjNode(Node* src, uint con) : ProjNode(src, con) { - init_class_id(Class_FlagsProj); - } - - virtual int Opcode() const; - virtual bool is_CFG() const { return false; } - virtual const Type* bottom_type() const { return TypeInt::CC; } virtual uint ideal_reg() const { return Op_RegFlags; } + virtual const Type* sub(const Type* t1, const Type* t2) const; }; +class OverflowINode : public OverflowNode { +public: + typedef TypeInt TypeClass; + + OverflowINode(Node* in1, Node* in2) : OverflowNode(in1, in2) {} + virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); + virtual const Type* Value(PhaseTransform* phase) const; + + virtual bool will_overflow(jint v1, jint v2) const = 0; + virtual bool can_overflow(const Type* t1, const Type* t2) const = 0; +}; + + +class OverflowLNode : public OverflowNode { +public: + typedef TypeLong TypeClass; + + OverflowLNode(Node* in1, Node* in2) : OverflowNode(in1, in2) {} + virtual Node* Ideal(PhaseGVN* phase, bool can_reshape); + virtual const Type* Value(PhaseTransform* phase) const; + + virtual bool will_overflow(jlong v1, jlong v2) const = 0; + virtual bool can_overflow(const Type* t1, const Type* t2) const = 0; +}; + +class OverflowAddINode : public OverflowINode { +public: + typedef AddINode MathOp; + + OverflowAddINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {} + virtual int Opcode() const; + + virtual bool will_overflow(jint v1, jint v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; +}; + +class OverflowSubINode : public OverflowINode { +public: + typedef SubINode MathOp; + + OverflowSubINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {} + virtual int Opcode() const; + + virtual bool will_overflow(jint v1, jint v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; +}; + +class OverflowMulINode : public OverflowINode { +public: + typedef MulINode MathOp; + + OverflowMulINode(Node* in1, Node* in2) : OverflowINode(in1, in2) {} + virtual int Opcode() const; + + virtual bool will_overflow(jint v1, jint v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; +}; + +class OverflowAddLNode : public OverflowLNode { +public: + typedef AddLNode MathOp; + + OverflowAddLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {} + virtual int Opcode() const; + + virtual bool will_overflow(jlong v1, jlong v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; +}; + +class OverflowSubLNode : public OverflowLNode { +public: + typedef SubLNode MathOp; + + OverflowSubLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {} + virtual int Opcode() const; + + virtual bool will_overflow(jlong v1, jlong v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; +}; + +class OverflowMulLNode : public OverflowLNode { +public: + typedef MulLNode MathOp; + + OverflowMulLNode(Node* in1, Node* in2) : OverflowLNode(in1, in2) {} + virtual int Opcode() const; + + virtual bool will_overflow(jlong v1, jlong v2) const; + virtual bool can_overflow(const Type* t1, const Type* t2) const; +}; #endif diff --git a/hotspot/src/share/vm/opto/multnode.cpp b/hotspot/src/share/vm/opto/multnode.cpp index d9e04a2741d..300f6246369 100644 --- a/hotspot/src/share/vm/opto/multnode.cpp +++ b/hotspot/src/share/vm/opto/multnode.cpp @@ -54,11 +54,6 @@ ProjNode* MultiNode::proj_out(uint which_proj) const { assert(Opcode() != Op_If || proj->Opcode() == (which_proj?Op_IfTrue:Op_IfFalse), "bad if #2"); return proj; } - } else if (p->is_FlagsProj()) { - FlagsProjNode *proj = p->as_FlagsProj(); - if (proj->_con == which_proj) { - return proj; - } } else { assert(p == this && this->is_Start(), "else must be proj"); continue; diff --git a/hotspot/src/share/vm/opto/node.hpp b/hotspot/src/share/vm/opto/node.hpp index b04a0fad78e..5f883d5f1cf 100644 --- a/hotspot/src/share/vm/opto/node.hpp +++ b/hotspot/src/share/vm/opto/node.hpp @@ -69,7 +69,6 @@ class EncodePNode; class EncodePKlassNode; class FastLockNode; class FastUnlockNode; -class FlagsProjNode; class IfNode; class IfFalseNode; class IfTrueNode; @@ -100,7 +99,6 @@ class MachSafePointNode; class MachSpillCopyNode; class MachTempNode; class Matcher; -class MathExactNode; class MemBarNode; class MemBarStoreStoreNode; class MemNode; @@ -575,7 +573,6 @@ public: DEFINE_CLASS_ID(MemBar, Multi, 3) DEFINE_CLASS_ID(Initialize, MemBar, 0) DEFINE_CLASS_ID(MemBarStoreStore, MemBar, 1) - DEFINE_CLASS_ID(MathExact, Multi, 4) DEFINE_CLASS_ID(Mach, Node, 1) DEFINE_CLASS_ID(MachReturn, Mach, 0) @@ -632,7 +629,6 @@ public: DEFINE_CLASS_ID(Cmp, Sub, 0) DEFINE_CLASS_ID(FastLock, Cmp, 0) DEFINE_CLASS_ID(FastUnlock, Cmp, 1) - DEFINE_CLASS_ID(FlagsProj, Cmp, 2) DEFINE_CLASS_ID(MergeMem, Node, 7) DEFINE_CLASS_ID(Bool, Node, 8) @@ -736,7 +732,6 @@ public: DEFINE_CLASS_QUERY(EncodePKlass) DEFINE_CLASS_QUERY(FastLock) DEFINE_CLASS_QUERY(FastUnlock) - DEFINE_CLASS_QUERY(FlagsProj) DEFINE_CLASS_QUERY(If) DEFINE_CLASS_QUERY(IfFalse) DEFINE_CLASS_QUERY(IfTrue) @@ -765,7 +760,6 @@ public: DEFINE_CLASS_QUERY(MachSafePoint) DEFINE_CLASS_QUERY(MachSpillCopy) DEFINE_CLASS_QUERY(MachTemp) - DEFINE_CLASS_QUERY(MathExact) DEFINE_CLASS_QUERY(Mem) DEFINE_CLASS_QUERY(MemBar) DEFINE_CLASS_QUERY(MemBarStoreStore) diff --git a/hotspot/src/share/vm/opto/subnode.cpp b/hotspot/src/share/vm/opto/subnode.cpp index fcbead264af..71ffed86691 100644 --- a/hotspot/src/share/vm/opto/subnode.cpp +++ b/hotspot/src/share/vm/opto/subnode.cpp @@ -1126,11 +1126,15 @@ Node *BoolNode::Ideal(PhaseGVN *phase, bool can_reshape) { Node *cmp = in(1); if( !cmp->is_Sub() ) return NULL; int cop = cmp->Opcode(); - if( cop == Op_FastLock || cop == Op_FastUnlock || cop == Op_FlagsProj) return NULL; + if( cop == Op_FastLock || cop == Op_FastUnlock) return NULL; Node *cmp1 = cmp->in(1); Node *cmp2 = cmp->in(2); if( !cmp1 ) return NULL; + if (_test._test == BoolTest::overflow || _test._test == BoolTest::no_overflow) { + return NULL; + } + // Constant on left? Node *con = cmp1; uint op2 = cmp2->Opcode(); diff --git a/hotspot/src/share/vm/opto/type.cpp b/hotspot/src/share/vm/opto/type.cpp index c907fc7124c..b957a227eb6 100644 --- a/hotspot/src/share/vm/opto/type.cpp +++ b/hotspot/src/share/vm/opto/type.cpp @@ -306,6 +306,7 @@ void Type::Initialize_shared(Compile* current) { TypeInt::POS1 = TypeInt::make(1,max_jint, WidenMin); // Positive values TypeInt::INT = TypeInt::make(min_jint,max_jint, WidenMax); // 32-bit integers TypeInt::SYMINT = TypeInt::make(-max_jint,max_jint,WidenMin); // symmetric range + TypeInt::TYPE_DOMAIN = TypeInt::INT; // CmpL is overloaded both as the bytecode computation returning // a trinary (-1,0,+1) integer result AND as an efficient long // compare returning optimizer ideal-type flags. @@ -322,6 +323,7 @@ void Type::Initialize_shared(Compile* current) { TypeLong::LONG = TypeLong::make(min_jlong,max_jlong,WidenMax); // 64-bit integers TypeLong::INT = TypeLong::make((jlong)min_jint,(jlong)max_jint,WidenMin); TypeLong::UINT = TypeLong::make(0,(jlong)max_juint,WidenMin); + TypeLong::TYPE_DOMAIN = TypeLong::LONG; const Type **fboth =(const Type**)shared_type_arena->Amalloc_4(2*sizeof(Type*)); fboth[0] = Type::CONTROL; @@ -1161,6 +1163,7 @@ const TypeInt *TypeInt::POS; // Positive 32-bit integers or zero const TypeInt *TypeInt::POS1; // Positive 32-bit integers const TypeInt *TypeInt::INT; // 32-bit integers const TypeInt *TypeInt::SYMINT; // symmetric range [-max_jint..max_jint] +const TypeInt *TypeInt::TYPE_DOMAIN; // alias for TypeInt::INT //------------------------------TypeInt---------------------------------------- TypeInt::TypeInt( jint lo, jint hi, int w ) : Type(Int), _lo(lo), _hi(hi), _widen(w) { @@ -1418,6 +1421,7 @@ const TypeLong *TypeLong::POS; // >=0 const TypeLong *TypeLong::LONG; // 64-bit integers const TypeLong *TypeLong::INT; // 32-bit subrange const TypeLong *TypeLong::UINT; // 32-bit unsigned subrange +const TypeLong *TypeLong::TYPE_DOMAIN; // alias for TypeLong::LONG //------------------------------TypeLong--------------------------------------- TypeLong::TypeLong( jlong lo, jlong hi, int w ) : Type(Long), _lo(lo), _hi(hi), _widen(w) { diff --git a/hotspot/src/share/vm/opto/type.hpp b/hotspot/src/share/vm/opto/type.hpp index d02792f7bb3..8c30f69795e 100644 --- a/hotspot/src/share/vm/opto/type.hpp +++ b/hotspot/src/share/vm/opto/type.hpp @@ -489,6 +489,7 @@ protected: virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; public: + typedef jint NativeType; virtual bool eq( const Type *t ) const; virtual int hash() const; // Type specific hashing virtual bool singleton(void) const; // TRUE if type is a singleton @@ -531,6 +532,9 @@ public: static const TypeInt *POS1; static const TypeInt *INT; static const TypeInt *SYMINT; // symmetric range [-max_jint..max_jint] + static const TypeInt *TYPE_DOMAIN; // alias for TypeInt::INT + + static const TypeInt *as_self(const Type *t) { return t->is_int(); } #ifndef PRODUCT virtual void dump2( Dict &d, uint depth, outputStream *st ) const; #endif @@ -546,6 +550,7 @@ protected: // Do not kill _widen bits. virtual const Type *filter_helper(const Type *kills, bool include_speculative) const; public: + typedef jlong NativeType; virtual bool eq( const Type *t ) const; virtual int hash() const; // Type specific hashing virtual bool singleton(void) const; // TRUE if type is a singleton @@ -568,6 +573,7 @@ public: virtual bool is_finite() const; // Has a finite value + virtual const Type *xmeet( const Type *t ) const; virtual const Type *xdual() const; // Compute dual right now. virtual const Type *widen( const Type *t, const Type* limit_type ) const; @@ -580,6 +586,11 @@ public: static const TypeLong *LONG; static const TypeLong *INT; // 32-bit subrange [min_jint..max_jint] static const TypeLong *UINT; // 32-bit unsigned [0..max_juint] + static const TypeLong *TYPE_DOMAIN; // alias for TypeLong::LONG + + // static convenience methods. + static const TypeLong *as_self(const Type *t) { return t->is_long(); } + #ifndef PRODUCT virtual void dump2( Dict &d, uint, outputStream *st ) const;// Specialized per-Type dumping #endif diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 32ae760a129..0fd2d70881f 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -1942,15 +1942,6 @@ typedef TwoOopHashtable SymbolTwoOopHashtable; declare_c2_type(CmpF3Node, CmpFNode) \ declare_c2_type(CmpDNode, CmpNode) \ declare_c2_type(CmpD3Node, CmpDNode) \ - declare_c2_type(MathExactNode, MultiNode) \ - declare_c2_type(MathExactINode, MathExactNode) \ - declare_c2_type(AddExactINode, MathExactINode) \ - declare_c2_type(AddExactLNode, MathExactLNode) \ - declare_c2_type(SubExactINode, MathExactINode) \ - declare_c2_type(SubExactLNode, MathExactLNode) \ - declare_c2_type(NegExactINode, MathExactINode) \ - declare_c2_type(MulExactINode, MathExactINode) \ - declare_c2_type(FlagsProjNode, ProjNode) \ declare_c2_type(BoolNode, Node) \ declare_c2_type(AbsNode, Node) \ declare_c2_type(AbsINode, AbsNode) \ @@ -2031,6 +2022,15 @@ typedef TwoOopHashtable SymbolTwoOopHashtable; declare_c2_type(ExtractLNode, ExtractNode) \ declare_c2_type(ExtractFNode, ExtractNode) \ declare_c2_type(ExtractDNode, ExtractNode) \ + declare_c2_type(OverflowNode, CmpNode) \ + declare_c2_type(OverflowINode, OverflowNode) \ + declare_c2_type(OverflowAddINode, OverflowINode) \ + declare_c2_type(OverflowSubINode, OverflowINode) \ + declare_c2_type(OverflowMulINode, OverflowINode) \ + declare_c2_type(OverflowLNode, OverflowNode) \ + declare_c2_type(OverflowAddLNode, OverflowLNode) \ + declare_c2_type(OverflowSubLNode, OverflowLNode) \ + declare_c2_type(OverflowMulLNode, OverflowLNode) \ \ /*********************/ \ /* Adapter Blob Entries */ \ diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactICondTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactICondTest.java index f0835cdb197..8862160d8b4 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/AddExactICondTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactICondTest.java @@ -26,7 +26,7 @@ * @bug 8024924 * @summary Test non constant addExact * @compile AddExactICondTest.java - * @run main AddExactICondTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main AddExactICondTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactIConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactIConstantTest.java index ed8525483b0..77000a1d958 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/AddExactIConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactIConstantTest.java @@ -26,7 +26,7 @@ * @bug 8024924 * @summary Test constant addExact * @compile AddExactIConstantTest.java Verify.java - * @run main AddExactIConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main AddExactIConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactILoadTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactILoadTest.java index 4175a8ab5cc..2d96bb8b8a6 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/AddExactILoadTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactILoadTest.java @@ -26,7 +26,7 @@ * @bug 8024924 * @summary Test non constant addExact * @compile AddExactILoadTest.java Verify.java - * @run main AddExactILoadTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main AddExactILoadTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java index 56da9f40b7e..99aae0d7b21 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactILoopDependentTest.java @@ -26,7 +26,7 @@ * @bug 8024924 * @summary Test non constant addExact * @compile AddExactILoopDependentTest.java Verify.java - * @run main AddExactILoopDependentTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main AddExactILoopDependentTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java index 52e208db0e4..b3a24758569 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactINonConstantTest.java @@ -26,7 +26,7 @@ * @bug 8024924 * @summary Test non constant addExact * @compile AddExactINonConstantTest.java Verify.java - * @run main AddExactINonConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main AddExactINonConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java index 7bb1deba007..d111b66ce82 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactIRepeatTest.java @@ -26,7 +26,7 @@ * @bug 8025657 * @summary Test repeating addExact * @compile AddExactIRepeatTest.java Verify.java - * @run main AddExactIRepeatTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main AddExactIRepeatTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java index 3514ce24ab7..dc751406192 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactLConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test constant addExact * @compile AddExactLConstantTest.java Verify.java - * @run main AddExactLConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main AddExactLConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java index 3e16cb94d95..efd5fd7c92b 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/AddExactLNonConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test non constant addExact * @compile AddExactLNonConstantTest.java Verify.java - * @run main AddExactLNonConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main AddExactLNonConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/CompareTest.java b/hotspot/test/compiler/intrinsics/mathexact/CompareTest.java index c77dd47c184..f6785c07c69 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/CompareTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/CompareTest.java @@ -26,7 +26,7 @@ * @bug 8026722 * @summary Verify that the compare after addExact is a signed compare * @compile CompareTest.java - * @run main CompareTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main CompareTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/DecExactITest.java b/hotspot/test/compiler/intrinsics/mathexact/DecExactITest.java index 2712bed78ab..7e6e1ca3bde 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/DecExactITest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/DecExactITest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test decrementExact * @compile DecExactITest.java Verify.java - * @run main DecExactITest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main DecExactITest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/DecExactLTest.java b/hotspot/test/compiler/intrinsics/mathexact/DecExactLTest.java index ad83dcad208..53a16596e3c 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/DecExactLTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/DecExactLTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test decrementExact * @compile DecExactLTest.java Verify.java - * @run main DecExactLTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main DecExactLTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/GVNTest.java b/hotspot/test/compiler/intrinsics/mathexact/GVNTest.java index 864555e2b3e..23fba15d433 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/GVNTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/GVNTest.java @@ -26,7 +26,7 @@ * @bug 8028207 * @summary Verify that GVN doesn't mess up the two addExacts * @compile GVNTest.java - * @run main GVNTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main GVNTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/IncExactITest.java b/hotspot/test/compiler/intrinsics/mathexact/IncExactITest.java index 41ab825847a..9f7ddbd3211 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/IncExactITest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/IncExactITest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test incrementExact * @compile IncExactITest.java Verify.java - * @run main IncExactITest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main IncExactITest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/IncExactLTest.java b/hotspot/test/compiler/intrinsics/mathexact/IncExactLTest.java index 6ece9792be7..755d81908ce 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/IncExactLTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/IncExactLTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test incrementExact * @compile IncExactLTest.java Verify.java - * @run main IncExactLTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main IncExactLTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactICondTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactICondTest.java index e9bf6b9958e..5f3e1e64568 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/MulExactICondTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactICondTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test multiplyExact as condition * @compile MulExactICondTest.java - * @run main MulExactICondTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main MulExactICondTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java index 6bb74d1f9eb..120bef5e9b9 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactIConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test constant multiplyExact * @compile MulExactIConstantTest.java Verify.java - * @run main MulExactIConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main MulExactIConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactILoadTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactILoadTest.java index 8878b6f1c6d..36aa3d46230 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/MulExactILoadTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactILoadTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test multiplyExact * @compile MulExactILoadTest.java Verify.java - * @run main MulExactILoadTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main MulExactILoadTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java index 7c5c7e7a240..5ba4ad3cfc3 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactILoopDependentTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test loop dependent multiplyExact * @compile MulExactILoopDependentTest.java Verify.java - * @run main MulExactILoopDependentTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main MulExactILoopDependentTest * */ public class MulExactILoopDependentTest { diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java index e924311aa25..e108059885b 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactINonConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test non constant multiplyExact * @compile MulExactINonConstantTest.java Verify.java - * @run main MulExactINonConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main MulExactINonConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java index 5d5a93d05d7..dd14ce21ed6 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactIRepeatTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test repeating multiplyExact * @compile MulExactIRepeatTest.java Verify.java - * @run main MulExactIRepeatTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main MulExactIRepeatTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java index 9668ddfe07e..c687cc276f2 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactLConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test constant mulExact * @compile MulExactLConstantTest.java Verify.java - * @run main MulExactLConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main MulExactLConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java index 3486588c81e..f9d82ed0876 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/MulExactLNonConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test non constant mulExact * @compile MulExactLNonConstantTest.java Verify.java - * @run main MulExactLNonConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main MulExactLNonConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java index 0a5e164ba68..ba49d778762 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactIConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test constant negExact * @compile NegExactIConstantTest.java Verify.java - * @run main NegExactIConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main NegExactIConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactILoadTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactILoadTest.java index e7896835ee1..d7e8215600a 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/NegExactILoadTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactILoadTest.java @@ -26,14 +26,14 @@ * @bug 8026844 * @summary Test negExact * @compile NegExactILoadTest.java Verify.java - * @run main NegExactILoadTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main NegExactILoadTest * */ public class NegExactILoadTest { public static void main(String[] args) { - Verify.LoadTest.init(); - Verify.LoadTest.verify(new Verify.UnaryToBinary(new Verify.NegExactI())); + Verify.LoadTest.init(); + Verify.LoadTest.verify(new Verify.UnaryToBinary(new Verify.NegExactI())); } } diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java index a18b0c17eed..882f80b91a1 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactILoopDependentTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test negExact loop dependent * @compile NegExactILoopDependentTest.java Verify.java - * @run main NegExactILoopDependentTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main NegExactILoopDependentTest * */ public class NegExactILoopDependentTest { diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java index ee87bd82748..6f044f0d969 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactINonConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test non constant negExact * @compile NegExactINonConstantTest.java Verify.java - * @run main NegExactINonConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main NegExactINonConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java index 82e02a960a9..382cd5c5f9e 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactLConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test constant negExact * @compile NegExactLConstantTest.java Verify.java - * @run main NegExactLConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main NegExactLConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java index b7b967dc28e..0bcad8b2b78 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/NegExactLNonConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test constant negExact * @compile NegExactLNonConstantTest.java Verify.java - * @run main NegExactLNonConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main NegExactLNonConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/NestedMathExactTest.java b/hotspot/test/compiler/intrinsics/mathexact/NestedMathExactTest.java index 883fcceacaa..211dc8baff1 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/NestedMathExactTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/NestedMathExactTest.java @@ -26,7 +26,7 @@ * @bug 8027444 * @summary Test nested loops * @compile NestedMathExactTest.java - * @run main NestedMathExactTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main NestedMathExactTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/SplitThruPhiTest.java b/hotspot/test/compiler/intrinsics/mathexact/SplitThruPhiTest.java index 67f3afab007..b3b0c0d7417 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/SplitThruPhiTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/SplitThruPhiTest.java @@ -26,7 +26,7 @@ * @bug 8028198 * @summary Verify that split through phi does the right thing * @compile SplitThruPhiTest.java - * @run main SplitThruPhiTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main SplitThruPhiTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactICondTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactICondTest.java index b4dd4f7daa9..f539bdc7cbe 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/SubExactICondTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactICondTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test subtractExact as condition * @compile SubExactICondTest.java Verify.java - * @run main SubExactICondTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main SubExactICondTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java index 20a27cef161..b450bd90b11 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactIConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test constant subtractExact * @compile SubExactIConstantTest.java Verify.java - * @run main SubExactIConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main SubExactIConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactILoadTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactILoadTest.java index 5be582fd03a..af2ed018258 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/SubExactILoadTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactILoadTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test non constant subtractExact * @compile SubExactILoadTest.java Verify.java - * @run main SubExactILoadTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main SubExactILoadTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java index b4e7b4a30a8..67ebcbca321 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactILoopDependentTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test non constant subtractExact * @compile SubExactILoopDependentTest.java Verify.java - * @run main SubExactILoopDependentTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main SubExactILoopDependentTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java index 82dc81c3d00..b8153810892 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactINonConstantTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test non constant subtractExact * @compile SubExactINonConstantTest.java Verify.java - * @run main SubExactINonConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main SubExactINonConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java index 63e4b3d1876..3c57f6f3f76 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactIRepeatTest.java @@ -26,7 +26,7 @@ * @bug 8026844 * @summary Test repeating subtractExact * @compile SubExactIRepeatTest.java Verify.java - * @run main SubExactIRepeatTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main SubExactIRepeatTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java index 973aa6a3960..ec554d7662b 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactLConstantTest.java @@ -27,7 +27,7 @@ * @bug 8027353 * @summary Test constant subtractExact * @compile SubExactLConstantTest.java Verify.java - * @run main SubExactLConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main SubExactLConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java b/hotspot/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java index bc0c7331b76..86ecf20f366 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/SubExactLNonConstantTest.java @@ -27,7 +27,7 @@ * @bug 8027353 * @summary Test non constant subtractExact * @compile SubExactLNonConstantTest.java Verify.java - * @run main SubExactLNonConstantTest -XX:+IgnoreUnrecognizedVMOptions -XX:+UnlockExperimentalVMOptions -XX:+UseMathExactIntrinsics + * @run main SubExactLNonConstantTest * */ diff --git a/hotspot/test/compiler/intrinsics/mathexact/Verify.java b/hotspot/test/compiler/intrinsics/mathexact/Verify.java index a4d728bfd6b..3936bf1b4f4 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/Verify.java +++ b/hotspot/test/compiler/intrinsics/mathexact/Verify.java @@ -160,6 +160,7 @@ public class Verify { public static class NonConstantTest { public static java.util.Random rnd = new java.util.Random(); + public static int[] values = new int[] { Integer.MAX_VALUE, Integer.MIN_VALUE }; public static void verify(BinaryMethod method) { for (int i = 0; i < 50000; ++i) { @@ -169,6 +170,10 @@ public class Verify { Verify.verifyBinary(rnd1 + 1, rnd2, method); Verify.verifyBinary(rnd1 - 1, rnd2, method); Verify.verifyBinary(rnd1, rnd2 - 1, method); + Verify.verifyBinary(0, values[0], method); + Verify.verifyBinary(values[0], 0, method); + Verify.verifyBinary(0, values[1], method); + Verify.verifyBinary(values[1], 0, method); } } } diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactIntTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactIntTest.java index c55f847d2a2..a2770dcddf3 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactIntTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactIntTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build AddExactIntTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics AddExactIntTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics AddExactIntTest diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactLongTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactLongTest.java index 4823f073f5f..c5756440769 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactLongTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/AddExactLongTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build AddExactLongTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics AddExactLongTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics AddExactLongTest diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactIntTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactIntTest.java index 0b97ab86ae6..19641a1f41a 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactIntTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactIntTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build DecrementExactIntTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics DecrementExactIntTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics DecrementExactIntTest diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactLongTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactLongTest.java index f2429aa9142..a5821698f9d 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactLongTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/DecrementExactLongTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build DecrementExactLongTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics DecrementExactLongTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics DecrementExactLongTest @@ -42,4 +42,4 @@ public class DecrementExactLongTest { public static void main(String[] args) throws Exception { new IntrinsicBase.LongTest(MathIntrinsic.LongIntrinsic.Decrement).test(); } -} \ No newline at end of file +} diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactIntTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactIntTest.java index 714f4e2e04e..bca840ad8f1 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactIntTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactIntTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build IncrementExactIntTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics IncrementExactIntTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics IncrementExactIntTest diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactLongTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactLongTest.java index 19511c49929..5348b774f9b 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactLongTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/IncrementExactLongTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build IncrementExactLongTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics IncrementExactLongTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics IncrementExactLongTest diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactIntTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactIntTest.java index bd433500187..a09c1244905 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactIntTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactIntTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build MultiplyExactIntTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics MultiplyExactIntTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics MultiplyExactIntTest diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactLongTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactLongTest.java index 70651107dae..23154e9ecef 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactLongTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/MultiplyExactLongTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build MultiplyExactLongTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics MultiplyExactLongTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics MultiplyExactLongTest diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactIntTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactIntTest.java index 579c2907e91..f41bb7995a9 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactIntTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactIntTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build NegateExactIntTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics NegateExactIntTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics NegateExactIntTest diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactLongTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactLongTest.java index 6f114f632ab..27af6553036 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactLongTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/NegateExactLongTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build NegateExactLongTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics NegateExactLongTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics NegateExactLongTest diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactIntTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactIntTest.java index d1eaf3919d5..c2cbbc4ef95 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactIntTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactIntTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build SubtractExactIntTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics SubtractExactIntTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics SubtractExactIntTest diff --git a/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactLongTest.java b/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactLongTest.java index fbe8eb1e12e..bee6d3bafc4 100644 --- a/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactLongTest.java +++ b/hotspot/test/compiler/intrinsics/mathexact/sanity/SubtractExactLongTest.java @@ -26,11 +26,11 @@ * @library /testlibrary /testlibrary/whitebox /compiler/whitebox * @build SubtractExactLongTest * @run main ClassFileInstaller sun.hotspot.WhiteBox - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs_neg.log -XX:-UseMathExactIntrinsics SubtractExactLongTest - * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions -XX:+UnlockExperimentalVMOptions + * @run main/othervm -Xbootclasspath/a:. -XX:+UnlockDiagnosticVMOptions * -XX:+IgnoreUnrecognizedVMOptions -XX:+WhiteBoxAPI -XX:+LogCompilation * -XX:CompileCommand=compileonly,MathIntrinsic*::execMathMethod * -XX:LogFile=hs.log -XX:+UseMathExactIntrinsics SubtractExactLongTest From e3931e81eb29872ff7ea664464ffa419e60dd465 Mon Sep 17 00:00:00 2001 From: Niclas Adlertz Date: Tue, 25 Feb 2014 10:26:21 +0100 Subject: [PATCH 153/159] 8032894: Remove dead code in Pressure::lower Remove dead code in Pressure::lower Reviewed-by: kvn, roland --- hotspot/src/share/vm/opto/chaitin.hpp | 46 ++++++++++++++++++++++++--- hotspot/src/share/vm/opto/ifg.cpp | 42 ++++++++++-------------- 2 files changed, 58 insertions(+), 30 deletions(-) diff --git a/hotspot/src/share/vm/opto/chaitin.hpp b/hotspot/src/share/vm/opto/chaitin.hpp index fb114bbd930..545e5882bc4 100644 --- a/hotspot/src/share/vm/opto/chaitin.hpp +++ b/hotspot/src/share/vm/opto/chaitin.hpp @@ -501,8 +501,9 @@ private: // Used for aggressive coalescing. void build_ifg_virtual( ); + // used when computing the register pressure for each block in the CFG. This + // is done during IFG creation. class Pressure { - public: // keeps track of the register pressure at the current // instruction (used when stepping backwards in the block) uint _current_pressure; @@ -518,6 +519,7 @@ private: // number of live ranges that constitute high register pressure const uint _high_pressure_limit; + public: // lower the register pressure and look for a low to high pressure // transition @@ -525,9 +527,6 @@ private: _current_pressure -= lrg.reg_pressure(); if (_current_pressure == _high_pressure_limit) { _high_pressure_index = location; - if (_current_pressure > _final_pressure) { - _final_pressure = _current_pressure + 1; - } } } @@ -540,6 +539,45 @@ private: } } + uint high_pressure_index() const { + return _high_pressure_index; + } + + uint final_pressure() const { + return _final_pressure; + } + + uint current_pressure() const { + return _current_pressure; + } + + uint high_pressure_limit() const { + return _high_pressure_limit; + } + + void lower_high_pressure_index() { + _high_pressure_index--; + } + + void set_high_pressure_index_to_block_start() { + _high_pressure_index = 0; + } + + void check_pressure_at_fatproj(uint fatproj_location, RegMask& fatproj_mask) { + // this pressure is only valid at this instruction, i.e. we don't need to lower + // the register pressure since the fat proj was never live before (going backwards) + uint new_pressure = current_pressure() + fatproj_mask.Size(); + if (new_pressure > final_pressure()) { + _final_pressure = new_pressure; + } + + // if we were at a low pressure and now and the fat proj is at high pressure, record the fat proj location + // as coming from a low to high (to low again) + if (current_pressure() <= high_pressure_limit() && new_pressure > high_pressure_limit()) { + _high_pressure_index = fatproj_location; + } + } + Pressure(uint high_pressure_index, uint high_pressure_limit) : _current_pressure(0) , _high_pressure_index(high_pressure_index) diff --git a/hotspot/src/share/vm/opto/ifg.cpp b/hotspot/src/share/vm/opto/ifg.cpp index 24aab15143f..4b102d68589 100644 --- a/hotspot/src/share/vm/opto/ifg.cpp +++ b/hotspot/src/share/vm/opto/ifg.cpp @@ -439,8 +439,8 @@ void PhaseChaitin::lower_pressure(Block* b, uint location, LRG& lrg, IndexSet* l } } } - assert(int_pressure._current_pressure == count_int_pressure(liveout), "the int pressure is incorrect"); - assert(float_pressure._current_pressure == count_float_pressure(liveout), "the float pressure is incorrect"); + assert(int_pressure.current_pressure() == count_int_pressure(liveout), "the int pressure is incorrect"); + assert(float_pressure.current_pressure() == count_float_pressure(liveout), "the float pressure is incorrect"); } /* Go to the first non-phi index in a block */ @@ -513,8 +513,8 @@ void PhaseChaitin::compute_initial_block_pressure(Block* b, IndexSet* liveout, P raise_pressure(b, lrg, int_pressure, float_pressure); lid = elements.next(); } - assert(int_pressure._current_pressure == count_int_pressure(liveout), "the int pressure is incorrect"); - assert(float_pressure._current_pressure == count_float_pressure(liveout), "the float pressure is incorrect"); + assert(int_pressure.current_pressure() == count_int_pressure(liveout), "the int pressure is incorrect"); + assert(float_pressure.current_pressure() == count_float_pressure(liveout), "the float pressure is incorrect"); } /* @@ -548,17 +548,7 @@ bool PhaseChaitin::remove_node_if_not_used(Block* b, uint location, Node* n, uin void PhaseChaitin::check_for_high_pressure_transition_at_fatproj(uint& block_reg_pressure, uint location, LRG& lrg, Pressure& pressure, const int op_regtype) { RegMask mask_tmp = lrg.mask(); mask_tmp.AND(*Matcher::idealreg2regmask[op_regtype]); - // this pressure is only valid at this instruction, i.e. we don't need to lower - // the register pressure since the fat proj was never live before (going backwards) - uint new_pressure = pressure._current_pressure + mask_tmp.Size(); - if (new_pressure > pressure._final_pressure) { - pressure._final_pressure = new_pressure; - } - // if we were at a low pressure and now at the fat proj is at high pressure, record the fat proj location - // as coming from a low to high (to low again) - if (pressure._current_pressure <= pressure._high_pressure_limit && new_pressure > pressure._high_pressure_limit) { - pressure._high_pressure_index = location; - } + pressure.check_pressure_at_fatproj(location, mask_tmp); } /* @@ -700,8 +690,8 @@ void PhaseChaitin::add_input_to_liveout(Block* b, Node* n, IndexSet* liveout, do // Newly live things assumed live from here to top of block lrg._area += cost; raise_pressure(b, lrg, int_pressure, float_pressure); - assert(int_pressure._current_pressure == count_int_pressure(liveout), "the int pressure is incorrect"); - assert(float_pressure._current_pressure == count_float_pressure(liveout), "the float pressure is incorrect"); + assert(int_pressure.current_pressure() == count_int_pressure(liveout), "the int pressure is incorrect"); + assert(float_pressure.current_pressure() == count_float_pressure(liveout), "the float pressure is incorrect"); } assert(!(lrg._area < 0.0), "negative spill area" ); } @@ -710,13 +700,13 @@ void PhaseChaitin::add_input_to_liveout(Block* b, Node* n, IndexSet* liveout, do /* * If we run off the top of the block with high pressure just record that the * whole block is high pressure. (Even though we might have a transition - * lower down in the block) + * later down in the block) */ void PhaseChaitin::check_for_high_pressure_block(Pressure& pressure) { // current pressure now means the pressure before the first instruction in the block // (since we have stepped through all instructions backwards) - if (pressure._current_pressure > pressure._high_pressure_limit) { - pressure._high_pressure_index = 0; + if (pressure.current_pressure() > pressure.high_pressure_limit()) { + pressure.set_high_pressure_index_to_block_start(); } } @@ -725,7 +715,7 @@ void PhaseChaitin::check_for_high_pressure_block(Pressure& pressure) { * and set the high pressure index for the block */ void PhaseChaitin::adjust_high_pressure_index(Block* b, uint& block_hrp_index, Pressure& pressure) { - uint i = pressure._high_pressure_index; + uint i = pressure.high_pressure_index(); if (i < b->number_of_nodes() && i < b->end_idx() + 1) { Node* cur = b->get_node(i); while (cur->is_Proj() || (cur->is_MachNullCheck()) || cur->is_Catch()) { @@ -789,8 +779,8 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { if (!liveout.member(lid) && n->Opcode() != Op_SafePoint) { if (remove_node_if_not_used(block, location, n, lid, &liveout)) { - float_pressure._high_pressure_index--; - int_pressure._high_pressure_index--; + float_pressure.lower_high_pressure_index(); + int_pressure.lower_high_pressure_index(); continue; } if (lrg._fat_proj) { @@ -837,13 +827,13 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { adjust_high_pressure_index(block, block->_ihrp_index, int_pressure); adjust_high_pressure_index(block, block->_fhrp_index, float_pressure); // set the final_pressure as the register pressure for the block - block->_reg_pressure = int_pressure._final_pressure; - block->_freg_pressure = float_pressure._final_pressure; + block->_reg_pressure = int_pressure.final_pressure(); + block->_freg_pressure = float_pressure.final_pressure(); #ifndef PRODUCT // Gather Register Pressure Statistics if (PrintOptoStatistics) { - if (block->_reg_pressure > int_pressure._high_pressure_limit || block->_freg_pressure > float_pressure._high_pressure_limit) { + if (block->_reg_pressure > int_pressure.high_pressure_limit() || block->_freg_pressure > float_pressure.high_pressure_limit()) { _high_pressure++; } else { _low_pressure++; From a609fe84bb9afc68df4c6e71c77078d1fe8c4f9a Mon Sep 17 00:00:00 2001 From: Albert Noll Date: Tue, 25 Feb 2014 13:52:37 +0100 Subject: [PATCH 154/159] 8034775: Failing to initialize VM when running with negative value for -XX:CICompilerCount Ensure appropriate min. number of compiler threads (1 for non-tiered, and 2 for tiered) Reviewed-by: kvn --- hotspot/src/share/vm/runtime/arguments.cpp | 4 ++ .../startup/NumCompilerThreadsCheck.java | 40 +++++++++++++++++++ 2 files changed, 44 insertions(+) create mode 100644 hotspot/test/compiler/startup/NumCompilerThreadsCheck.java diff --git a/hotspot/src/share/vm/runtime/arguments.cpp b/hotspot/src/share/vm/runtime/arguments.cpp index 5a6de983469..b908439bcd9 100644 --- a/hotspot/src/share/vm/runtime/arguments.cpp +++ b/hotspot/src/share/vm/runtime/arguments.cpp @@ -2388,6 +2388,10 @@ bool Arguments::check_vm_args_consistency() { status &= verify_interval(NmethodSweepFraction, 1, ReservedCodeCacheSize/K, "NmethodSweepFraction"); status &= verify_interval(NmethodSweepActivity, 0, 2000, "NmethodSweepActivity"); + // TieredCompilation needs at least 2 compiler threads. + const int num_min_compiler_threads = (TieredCompilation) ? 2 : 1; + status &=verify_min_value(CICompilerCount, num_min_compiler_threads, "CICompilerCount"); + return status; } diff --git a/hotspot/test/compiler/startup/NumCompilerThreadsCheck.java b/hotspot/test/compiler/startup/NumCompilerThreadsCheck.java new file mode 100644 index 00000000000..e7e92d379ac --- /dev/null +++ b/hotspot/test/compiler/startup/NumCompilerThreadsCheck.java @@ -0,0 +1,40 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8034775 + * @summary Ensures correct minimal number of compiler threads (provided by -XX:CICompilerCount=) + * @library /testlibrary + */ +import com.oracle.java.testlibrary.*; + +public class NumCompilerThreadsCheck { + public static void main(String[] args) throws Exception { + ProcessBuilder pb = ProcessTools.createJavaProcessBuilder("-XX:CICompilerCount=-1"); + OutputAnalyzer out = new OutputAnalyzer(pb.start()); + + String expectedOutput = "CICompilerCount of -1 is invalid"; + out.shouldContain(expectedOutput); + } +} From 532b570e81065ddb1df6f61eb1e0bec82b37472f Mon Sep 17 00:00:00 2001 From: Niclas Adlertz Date: Tue, 25 Feb 2014 14:09:02 +0100 Subject: [PATCH 155/159] 8032656: Tag the MachSpillCopies with purpose information Subclassed the MachSpillCopyNode with different subnodes for different spill purposes to enhance debugging / visualization Reviewed-by: kvn, roland --- hotspot/src/share/vm/opto/chaitin.cpp | 2 +- hotspot/src/share/vm/opto/chaitin.hpp | 9 ++-- hotspot/src/share/vm/opto/coalesce.cpp | 6 +-- hotspot/src/share/vm/opto/machnode.hpp | 61 +++++++++++++++++++++++-- hotspot/src/share/vm/opto/reg_split.cpp | 36 +++++++-------- 5 files changed, 84 insertions(+), 30 deletions(-) diff --git a/hotspot/src/share/vm/opto/chaitin.cpp b/hotspot/src/share/vm/opto/chaitin.cpp index d79b62694f1..0f64bccd6ba 100644 --- a/hotspot/src/share/vm/opto/chaitin.cpp +++ b/hotspot/src/share/vm/opto/chaitin.cpp @@ -1799,7 +1799,7 @@ bool PhaseChaitin::stretch_base_pointer_live_ranges(ResourceArea *a) { Block *phi_block = _cfg.get_block_for_node(phi); if (_cfg.get_block_for_node(phi_block->pred(2)) == block) { const RegMask *mask = C->matcher()->idealreg2spillmask[Op_RegI]; - Node *spill = new (C) MachSpillCopyNode( phi, *mask, *mask ); + Node *spill = new (C) MachSpillCopyNode(MachSpillCopyNode::LoopPhiInput, phi, *mask, *mask); insert_proj( phi_block, 1, spill, maxlrg++ ); n->set_req(1,spill); must_recompute_live = true; diff --git a/hotspot/src/share/vm/opto/chaitin.hpp b/hotspot/src/share/vm/opto/chaitin.hpp index 545e5882bc4..f11b5b1f416 100644 --- a/hotspot/src/share/vm/opto/chaitin.hpp +++ b/hotspot/src/share/vm/opto/chaitin.hpp @@ -34,10 +34,9 @@ #include "opto/phase.hpp" #include "opto/regalloc.hpp" #include "opto/regmask.hpp" +#include "opto/machnode.hpp" class LoopTree; -class MachCallNode; -class MachSafePointNode; class Matcher; class PhaseCFG; class PhaseLive; @@ -424,8 +423,8 @@ class PhaseChaitin : public PhaseRegAlloc { uint _simplified; // Linked list head of simplified LRGs // Helper functions for Split() - uint split_DEF( Node *def, Block *b, int loc, uint max, Node **Reachblock, Node **debug_defs, GrowableArray splits, int slidx ); - uint split_USE( Node *def, Block *b, Node *use, uint useidx, uint max, bool def_down, bool cisc_sp, GrowableArray splits, int slidx ); + uint split_DEF(Node *def, Block *b, int loc, uint max, Node **Reachblock, Node **debug_defs, GrowableArray splits, int slidx ); + uint split_USE(MachSpillCopyNode::SpillType spill_type, Node *def, Block *b, Node *use, uint useidx, uint max, bool def_down, bool cisc_sp, GrowableArray splits, int slidx ); //------------------------------clone_projs------------------------------------ // After cloning some rematerialized instruction, clone any MachProj's that @@ -447,7 +446,7 @@ class PhaseChaitin : public PhaseRegAlloc { int slidx, uint *lrg2reach, Node **Reachblock, bool walkThru); // True if lidx is used before any real register is def'd in the block bool prompt_use( Block *b, uint lidx ); - Node *get_spillcopy_wide( Node *def, Node *use, uint uidx ); + Node *get_spillcopy_wide(MachSpillCopyNode::SpillType spill_type, Node *def, Node *use, uint uidx ); // Insert the spill at chosen location. Skip over any intervening Proj's or // Phis. Skip over a CatchNode and projs, inserting in the fall-through block // instead. Update high-pressure indices. Create a new live range. diff --git a/hotspot/src/share/vm/opto/coalesce.cpp b/hotspot/src/share/vm/opto/coalesce.cpp index bd207b584a1..5579d90c485 100644 --- a/hotspot/src/share/vm/opto/coalesce.cpp +++ b/hotspot/src/share/vm/opto/coalesce.cpp @@ -291,7 +291,7 @@ void PhaseAggressiveCoalesce::insert_copies( Matcher &matcher ) { _phc.clone_projs(pred, pred->end_idx(), m, copy, _phc._lrg_map); } else { const RegMask *rm = C->matcher()->idealreg2spillmask[m->ideal_reg()]; - copy = new (C) MachSpillCopyNode(m, *rm, *rm); + copy = new (C) MachSpillCopyNode(MachSpillCopyNode::PhiInput, m, *rm, *rm); // Find a good place to insert. Kinda tricky, use a subroutine insert_copy_with_overlap(pred,copy,phi_name,src_name); } @@ -325,7 +325,7 @@ void PhaseAggressiveCoalesce::insert_copies( Matcher &matcher ) { l += _phc.clone_projs(b, l, m, copy, _phc._lrg_map); } else { const RegMask *rm = C->matcher()->idealreg2spillmask[m->ideal_reg()]; - copy = new (C) MachSpillCopyNode(m, *rm, *rm); + copy = new (C) MachSpillCopyNode(MachSpillCopyNode::TwoAddress, m, *rm, *rm); // Insert the copy in the basic block, just before us b->insert_node(copy, l++); } @@ -372,7 +372,7 @@ void PhaseAggressiveCoalesce::insert_copies( Matcher &matcher ) { continue; // Live out; do not pre-split // Split the lrg at this use const RegMask *rm = C->matcher()->idealreg2spillmask[inp->ideal_reg()]; - Node *copy = new (C) MachSpillCopyNode( inp, *rm, *rm ); + Node* copy = new (C) MachSpillCopyNode(MachSpillCopyNode::DebugUse, inp, *rm, *rm); // Insert the copy in the use-def chain n->set_req(inpidx, copy ); // Insert the copy in the basic block, just before us diff --git a/hotspot/src/share/vm/opto/machnode.hpp b/hotspot/src/share/vm/opto/machnode.hpp index 5ea42a43fce..55d7e515882 100644 --- a/hotspot/src/share/vm/opto/machnode.hpp +++ b/hotspot/src/share/vm/opto/machnode.hpp @@ -520,12 +520,33 @@ public: // Machine SpillCopy Node. Copies 1 or 2 words from any location to any // location (stack or register). class MachSpillCopyNode : public MachIdealNode { +public: + enum SpillType { + TwoAddress, // Inserted when coalescing of a two-address-instruction node and its input fails + PhiInput, // Inserted when coalescing of a phi node and its input fails + DebugUse, // Inserted as debug info spills to safepoints in non-frequent blocks + LoopPhiInput, // Pre-split compares of loop-phis + Definition, // An lrg marked as spilled will be spilled to memory right after its definition, + // if in high pressure region or the lrg is bound + RegToReg, // A register to register move + RegToMem, // A register to memory move + MemToReg, // A memory to register move + PhiLocationDifferToInputLocation, // When coalescing phi nodes in PhaseChaitin::Split(), a move spill is inserted if + // the phi and its input resides at different locations (i.e. reg or mem) + BasePointerToMem, // Spill base pointer to memory at safepoint + InputToRematerialization, // When rematerializing a node we stretch the inputs live ranges, and they might be + // stretched beyond a new definition point, therefore we split out new copies instead + CallUse, // Spill use at a call + Bound // An lrg marked as spill that is bound and needs to be spilled at a use + }; +private: const RegMask *_in; // RegMask for input const RegMask *_out; // RegMask for output const Type *_type; + const SpillType _spill_type; public: - MachSpillCopyNode( Node *n, const RegMask &in, const RegMask &out ) : - MachIdealNode(), _in(&in), _out(&out), _type(n->bottom_type()) { + MachSpillCopyNode(SpillType spill_type, Node *n, const RegMask &in, const RegMask &out ) : + MachIdealNode(), _spill_type(spill_type), _in(&in), _out(&out), _type(n->bottom_type()) { init_class_id(Class_MachSpillCopy); init_flags(Flag_is_Copy); add_req(NULL); @@ -544,8 +565,42 @@ public: virtual void emit(CodeBuffer &cbuf, PhaseRegAlloc *ra_) const; virtual uint size(PhaseRegAlloc *ra_) const; + #ifndef PRODUCT - virtual const char *Name() const { return "MachSpillCopy"; } + virtual const char *Name() const { + switch (_spill_type) { + case TwoAddress: + return "TwoAddressSpillCopy"; + case PhiInput: + return "PhiInputSpillCopy"; + case DebugUse: + return "DebugUseSpillCopy"; + case LoopPhiInput: + return "LoopPhiInputSpillCopy"; + case Definition: + return "DefinitionSpillCopy"; + case RegToReg: + return "RegToRegSpillCopy"; + case RegToMem: + return "RegToMemSpillCopy"; + case MemToReg: + return "MemToRegSpillCopy"; + case PhiLocationDifferToInputLocation: + return "PhiLocationDifferToInputLocationSpillCopy"; + case BasePointerToMem: + return "BasePointerToMemSpillCopy"; + case InputToRematerialization: + return "InputToRematerializationSpillCopy"; + case CallUse: + return "CallUseSpillCopy"; + case Bound: + return "BoundSpillCopy"; + default: + assert(false, "Must have valid spill type"); + return "MachSpillCopy"; + } + } + virtual void format( PhaseRegAlloc *, outputStream *st ) const; #endif }; diff --git a/hotspot/src/share/vm/opto/reg_split.cpp b/hotspot/src/share/vm/opto/reg_split.cpp index cfcecadd338..7ec346bc6a9 100644 --- a/hotspot/src/share/vm/opto/reg_split.cpp +++ b/hotspot/src/share/vm/opto/reg_split.cpp @@ -55,7 +55,7 @@ static const char out_of_nodes[] = "out of nodes during split"; // Get a SpillCopy node with wide-enough masks. Use the 'wide-mask', the // wide ideal-register spill-mask if possible. If the 'wide-mask' does // not cover the input (or output), use the input (or output) mask instead. -Node *PhaseChaitin::get_spillcopy_wide( Node *def, Node *use, uint uidx ) { +Node *PhaseChaitin::get_spillcopy_wide(MachSpillCopyNode::SpillType spill_type, Node *def, Node *use, uint uidx ) { // If ideal reg doesn't exist we've got a bad schedule happening // that is forcing us to spill something that isn't spillable. // Bail rather than abort @@ -93,7 +93,7 @@ Node *PhaseChaitin::get_spillcopy_wide( Node *def, Node *use, uint uidx ) { // Here we assume a trip through memory is required. w_i_mask = &C->FIRST_STACK_mask(); } - return new (C) MachSpillCopyNode( def, *w_i_mask, *w_o_mask ); + return new (C) MachSpillCopyNode(spill_type, def, *w_i_mask, *w_o_mask ); } //------------------------------insert_proj------------------------------------ @@ -159,7 +159,7 @@ uint PhaseChaitin::split_DEF( Node *def, Block *b, int loc, uint maxlrg, Node ** assert( loc >= 0, "must insert past block head" ); // Get a def-side SpillCopy - Node *spill = get_spillcopy_wide(def,NULL,0); + Node *spill = get_spillcopy_wide(MachSpillCopyNode::Definition, def, NULL, 0); // Did we fail to split?, then bail if (!spill) { return 0; @@ -180,7 +180,7 @@ uint PhaseChaitin::split_DEF( Node *def, Block *b, int loc, uint maxlrg, Node ** //------------------------------split_USE-------------------------------------- // Splits at uses can involve redeffing the LRG, so no CISC Spilling there. // Debug uses want to know if def is already stack enabled. -uint PhaseChaitin::split_USE( Node *def, Block *b, Node *use, uint useidx, uint maxlrg, bool def_down, bool cisc_sp, GrowableArray splits, int slidx ) { +uint PhaseChaitin::split_USE(MachSpillCopyNode::SpillType spill_type, Node *def, Block *b, Node *use, uint useidx, uint maxlrg, bool def_down, bool cisc_sp, GrowableArray splits, int slidx ) { #ifdef ASSERT // Increment the counter for this lrg splits.at_put(slidx, splits.at(slidx)+1); @@ -216,7 +216,7 @@ uint PhaseChaitin::split_USE( Node *def, Block *b, Node *use, uint useidx, uint // DEF is UP, so must copy it DOWN and hook in USE // Insert SpillCopy before the USE, which uses DEF as its input, // and defs a new live range, which is used by this node. - Node *spill = get_spillcopy_wide(def,use,useidx); + Node *spill = get_spillcopy_wide(spill_type, def,use,useidx); // did we fail to split? if (!spill) { // Bail @@ -268,7 +268,7 @@ uint PhaseChaitin::split_USE( Node *def, Block *b, Node *use, uint useidx, uint bindex = b->find_node(use); } - Node *spill = get_spillcopy_wide( def, use, useidx ); + Node *spill = get_spillcopy_wide(spill_type, def, use, useidx ); if( !spill ) return 0; // Bailed out // Insert SpillCopy before the USE, which uses the reaching DEF as // its input, and defs a new live range, which is used by this node. @@ -327,7 +327,7 @@ Node *PhaseChaitin::split_Rematerialize( Node *def, Block *b, uint insidx, uint Block *b_def = _cfg.get_block_for_node(def); int idx_def = b_def->find_node(def); - Node *in_spill = get_spillcopy_wide( in, def, i ); + Node *in_spill = get_spillcopy_wide(MachSpillCopyNode::InputToRematerialization, in, def, i ); if( !in_spill ) return 0; // Bailed out insert_proj(b_def,idx_def,in_spill,maxlrg++); if( b_def == b ) @@ -935,7 +935,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { // This def has been rematerialized a couple of times without // progress. It doesn't care if it lives UP or DOWN, so // spill it down now. - maxlrg = split_USE(def,b,n,inpidx,maxlrg,false,false,splits,slidx); + maxlrg = split_USE(MachSpillCopyNode::BasePointerToMem, def,b,n,inpidx,maxlrg,false,false,splits,slidx); // If it wasn't split bail if (!maxlrg) { return 0; @@ -1015,7 +1015,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { !is_vect && umask.is_misaligned_pair())) { // These need a Split regardless of overlap or pressure // SPLIT - NO DEF - NO CISC SPILL - maxlrg = split_USE(def,b,n,inpidx,maxlrg,dup,false, splits,slidx); + maxlrg = split_USE(MachSpillCopyNode::Bound, def,b,n,inpidx,maxlrg,dup,false, splits,slidx); // If it wasn't split bail if (!maxlrg) { return 0; @@ -1027,7 +1027,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { if (UseFPUForSpilling && n->is_MachCall() && !uup && !dup ) { // The use at the call can force the def down so insert // a split before the use to allow the def more freedom. - maxlrg = split_USE(def,b,n,inpidx,maxlrg,dup,false, splits,slidx); + maxlrg = split_USE(MachSpillCopyNode::CallUse, def,b,n,inpidx,maxlrg,dup,false, splits,slidx); // If it wasn't split bail if (!maxlrg) { return 0; @@ -1063,7 +1063,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { else { // Both are either up or down, and there is no overlap if( dup ) { // If UP, reg->reg copy // COPY ACROSS HERE - NO DEF - NO CISC SPILL - maxlrg = split_USE(def,b,n,inpidx,maxlrg,false,false, splits,slidx); + maxlrg = split_USE(MachSpillCopyNode::RegToReg, def,b,n,inpidx,maxlrg,false,false, splits,slidx); // If it wasn't split bail if (!maxlrg) { return 0; @@ -1075,10 +1075,10 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { // First Split-UP to move value into Register uint def_ideal = def->ideal_reg(); const RegMask* tmp_rm = Matcher::idealreg2regmask[def_ideal]; - Node *spill = new (C) MachSpillCopyNode(def, dmask, *tmp_rm); + Node *spill = new (C) MachSpillCopyNode(MachSpillCopyNode::MemToReg, def, dmask, *tmp_rm); insert_proj( b, insidx, spill, maxlrg ); // Then Split-DOWN as if previous Split was DEF - maxlrg = split_USE(spill,b,n,inpidx,maxlrg,false,false, splits,slidx); + maxlrg = split_USE(MachSpillCopyNode::RegToMem, spill,b,n,inpidx,maxlrg,false,false, splits,slidx); // If it wasn't split bail if (!maxlrg) { return 0; @@ -1103,7 +1103,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { } } // COPY DOWN HERE - NO DEF - NO CISC SPILL - maxlrg = split_USE(def,b,n,inpidx,maxlrg,false,false, splits,slidx); + maxlrg = split_USE(MachSpillCopyNode::RegToMem, def,b,n,inpidx,maxlrg,false,false, splits,slidx); // If it wasn't split bail if (!maxlrg) { return 0; @@ -1118,7 +1118,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { else { // DOWN, Split-UP and check register pressure if( is_high_pressure( b, &lrgs(useidx), insidx ) ) { // COPY UP HERE - NO DEF - CISC SPILL - maxlrg = split_USE(def,b,n,inpidx,maxlrg,true,true, splits,slidx); + maxlrg = split_USE(MachSpillCopyNode::MemToReg, def,b,n,inpidx,maxlrg,true,true, splits,slidx); // If it wasn't split bail if (!maxlrg) { return 0; @@ -1126,7 +1126,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { insidx++; // Reset iterator to skip USE side split } else { // LRP // COPY UP HERE - WITH DEF - NO CISC SPILL - maxlrg = split_USE(def,b,n,inpidx,maxlrg,true,false, splits,slidx); + maxlrg = split_USE(MachSpillCopyNode::MemToReg, def,b,n,inpidx,maxlrg,true,false, splits,slidx); // If it wasn't split bail if (!maxlrg) { return 0; @@ -1229,7 +1229,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { if (C->check_node_count(NodeLimitFudgeFactor, out_of_nodes)) { // Check when generating nodes return 0; } - Node *spill = new (C) MachSpillCopyNode(use,use_rm,def_rm); + Node *spill = new (C) MachSpillCopyNode(MachSpillCopyNode::MemToReg, use,use_rm,def_rm); n->set_req(copyidx,spill); n->as_MachSpillCopy()->set_in_RegMask(def_rm); // Put the spill just before the copy @@ -1336,7 +1336,7 @@ uint PhaseChaitin::Split(uint maxlrg, ResourceArea* split_arena) { // Grab the UP/DOWN sense for the input u1 = UP[pidx][slidx]; if( u1 != (phi_up != 0)) { - maxlrg = split_USE(def, b, phi, i, maxlrg, !u1, false, splits,slidx); + maxlrg = split_USE(MachSpillCopyNode::PhiLocationDifferToInputLocation, def, b, phi, i, maxlrg, !u1, false, splits,slidx); // If it wasn't split bail if (!maxlrg) { return 0; From 5d4b624caf1890475feea060b683d53d525b9e4f Mon Sep 17 00:00:00 2001 From: Niclas Adlertz Date: Tue, 25 Feb 2014 17:51:27 +0100 Subject: [PATCH 156/159] 8033260: assert(lrg._area >= 0.0) failed: negative spill area Change type from float to double on block frequency, and add check for +Inf - +Inf operation Reviewed-by: kvn, roland --- .../classes/sun/jvm/hotspot/opto/Block.java | 8 ++--- hotspot/src/share/vm/opto/block.hpp | 30 +++++++++---------- hotspot/src/share/vm/opto/chaitin.cpp | 2 +- hotspot/src/share/vm/opto/gcm.cpp | 18 +++++------ hotspot/src/share/vm/opto/ifg.cpp | 10 +++++-- hotspot/src/share/vm/runtime/vmStructs.cpp | 4 +-- 6 files changed, 38 insertions(+), 34 deletions(-) diff --git a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Block.java b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Block.java index 156e8def9ca..519eeef4e61 100644 --- a/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Block.java +++ b/hotspot/agent/src/share/classes/sun/jvm/hotspot/opto/Block.java @@ -48,7 +48,7 @@ public class Block extends VMObject { preOrderField = new CIntField(type.getCIntegerField("_pre_order"), 0); domDepthField = new CIntField(type.getCIntegerField("_dom_depth"), 0); idomField = type.getAddressField("_idom"); - freqField = type.getJFloatField("_freq"); + freqField = type.getJDoubleField("_freq"); } private static AddressField nodesField; @@ -57,7 +57,7 @@ public class Block extends VMObject { private static CIntField preOrderField; private static CIntField domDepthField; private static AddressField idomField; - private static JFloatField freqField; + private static JDoubleField freqField; public Block(Address addr) { super(addr); @@ -67,8 +67,8 @@ public class Block extends VMObject { return (int)preOrderField.getValue(getAddress()); } - public float freq() { - return (float)freqField.getValue(getAddress()); + public double freq() { + return (double)freqField.getValue(getAddress()); } public Node_List nodes() { diff --git a/hotspot/src/share/vm/opto/block.hpp b/hotspot/src/share/vm/opto/block.hpp index d085b29df3e..48aa6eeb25d 100644 --- a/hotspot/src/share/vm/opto/block.hpp +++ b/hotspot/src/share/vm/opto/block.hpp @@ -90,9 +90,9 @@ public: class CFGElement : public ResourceObj { friend class VMStructs; public: - float _freq; // Execution frequency (estimate) + double _freq; // Execution frequency (estimate) - CFGElement() : _freq(0.0f) {} + CFGElement() : _freq(0.0) {} virtual bool is_block() { return false; } virtual bool is_loop() { return false; } Block* as_Block() { assert(is_block(), "must be block"); return (Block*)this; } @@ -202,7 +202,7 @@ public: // BLOCK_FREQUENCY is a sentinel to mark uses of constant block frequencies. // It is currently also used to scale such frequencies relative to // FreqCountInvocations relative to the old value of 1500. -#define BLOCK_FREQUENCY(f) ((f * (float) 1500) / FreqCountInvocations) +#define BLOCK_FREQUENCY(f) ((f * (double) 1500) / FreqCountInvocations) // Register Pressure (estimate) for Splitting heuristic uint _reg_pressure; @@ -393,7 +393,7 @@ class PhaseCFG : public Phase { CFGLoop* _root_loop; // Outmost loop frequency - float _outer_loop_frequency; + double _outer_loop_frequency; // Per node latency estimation, valid only during GCM GrowableArray* _node_latency; @@ -508,7 +508,7 @@ class PhaseCFG : public Phase { } // Get the outer most frequency - float get_outer_loop_frequency() const { + double get_outer_loop_frequency() const { return _outer_loop_frequency; } @@ -656,13 +656,13 @@ public: class BlockProbPair VALUE_OBJ_CLASS_SPEC { protected: Block* _target; // block target - float _prob; // probability of edge to block + double _prob; // probability of edge to block public: BlockProbPair() : _target(NULL), _prob(0.0) {} - BlockProbPair(Block* b, float p) : _target(b), _prob(p) {} + BlockProbPair(Block* b, double p) : _target(b), _prob(p) {} Block* get_target() const { return _target; } - float get_prob() const { return _prob; } + double get_prob() const { return _prob; } }; //------------------------------CFGLoop------------------------------------------- @@ -675,8 +675,8 @@ class CFGLoop : public CFGElement { CFGLoop *_child; // first child, use child's sibling to visit all immediately nested loops GrowableArray _members; // list of members of loop GrowableArray _exits; // list of successor blocks and their probabilities - float _exit_prob; // probability any loop exit is taken on a single loop iteration - void update_succ_freq(Block* b, float freq); + double _exit_prob; // probability any loop exit is taken on a single loop iteration + void update_succ_freq(Block* b, double freq); public: CFGLoop(int id) : @@ -702,9 +702,9 @@ class CFGLoop : public CFGElement { void compute_loop_depth(int depth); void compute_freq(); // compute frequency with loop assuming head freq 1.0f void scale_freq(); // scale frequency by loop trip count (including outer loops) - float outer_loop_freq() const; // frequency of outer loop + double outer_loop_freq() const; // frequency of outer loop bool in_loop_nest(Block* b); - float trip_count() const { return 1.0f / _exit_prob; } + double trip_count() const { return 1.0 / _exit_prob; } virtual bool is_loop() { return true; } int id() { return _id; } @@ -723,7 +723,7 @@ class CFGEdge : public ResourceObj { private: Block * _from; // Source basic block Block * _to; // Destination basic block - float _freq; // Execution frequency (estimate) + double _freq; // Execution frequency (estimate) int _state; bool _infrequent; int _from_pct; @@ -742,13 +742,13 @@ class CFGEdge : public ResourceObj { interior // edge is interior to trace (could be backedge) }; - CFGEdge(Block *from, Block *to, float freq, int from_pct, int to_pct) : + CFGEdge(Block *from, Block *to, double freq, int from_pct, int to_pct) : _from(from), _to(to), _freq(freq), _from_pct(from_pct), _to_pct(to_pct), _state(open) { _infrequent = from_infrequent() || to_infrequent(); } - float freq() const { return _freq; } + double freq() const { return _freq; } Block* from() const { return _from; } Block* to () const { return _to; } int infrequent() const { return _infrequent; } diff --git a/hotspot/src/share/vm/opto/chaitin.cpp b/hotspot/src/share/vm/opto/chaitin.cpp index 0f64bccd6ba..5a1040aac48 100644 --- a/hotspot/src/share/vm/opto/chaitin.cpp +++ b/hotspot/src/share/vm/opto/chaitin.cpp @@ -210,7 +210,7 @@ PhaseChaitin::PhaseChaitin(uint unique, PhaseCFG &cfg, Matcher &matcher) { NOT_PRODUCT( Compile::TracePhase t3("ctorChaitin", &_t_ctorChaitin, TimeCompiler); ) - _high_frequency_lrg = MIN2(float(OPTO_LRG_HIGH_FREQ), _cfg.get_outer_loop_frequency()); + _high_frequency_lrg = MIN2(double(OPTO_LRG_HIGH_FREQ), _cfg.get_outer_loop_frequency()); // Build a list of basic blocks, sorted by frequency _blks = NEW_RESOURCE_ARRAY(Block *, _cfg.number_of_blocks()); diff --git a/hotspot/src/share/vm/opto/gcm.cpp b/hotspot/src/share/vm/opto/gcm.cpp index bd9a0304181..fcfb3880e19 100644 --- a/hotspot/src/share/vm/opto/gcm.cpp +++ b/hotspot/src/share/vm/opto/gcm.cpp @@ -1661,10 +1661,10 @@ void CFGLoop::compute_freq() { } assert (_members.length() > 0, "no empty loops"); Block* hd = head(); - hd->_freq = 1.0f; + hd->_freq = 1.0; for (int i = 0; i < _members.length(); i++) { CFGElement* s = _members.at(i); - float freq = s->_freq; + double freq = s->_freq; if (s->is_block()) { Block* b = s->as_Block(); for (uint j = 0; j < b->_num_succs; j++) { @@ -1676,7 +1676,7 @@ void CFGLoop::compute_freq() { assert(lp->_parent == this, "immediate child"); for (int k = 0; k < lp->_exits.length(); k++) { Block* eb = lp->_exits.at(k).get_target(); - float prob = lp->_exits.at(k).get_prob(); + double prob = lp->_exits.at(k).get_prob(); update_succ_freq(eb, freq * prob); } } @@ -1688,7 +1688,7 @@ void CFGLoop::compute_freq() { // inner blocks do not get erroneously scaled. if (_depth != 0) { // Total the exit probabilities for this loop. - float exits_sum = 0.0f; + double exits_sum = 0.0f; for (int i = 0; i < _exits.length(); i++) { exits_sum += _exits.at(i).get_prob(); } @@ -1935,7 +1935,7 @@ void Block::update_uncommon_branch(Block* ub) { //------------------------------update_succ_freq------------------------------- // Update the appropriate frequency associated with block 'b', a successor of // a block in this loop. -void CFGLoop::update_succ_freq(Block* b, float freq) { +void CFGLoop::update_succ_freq(Block* b, double freq) { if (b->_loop == this) { if (b == head()) { // back branch within the loop @@ -1976,11 +1976,11 @@ bool CFGLoop::in_loop_nest(Block* b) { // Scale frequency of loops and blocks by trip counts from outer loops // Do a top down traversal of loop tree (visit outer loops first.) void CFGLoop::scale_freq() { - float loop_freq = _freq * trip_count(); + double loop_freq = _freq * trip_count(); _freq = loop_freq; for (int i = 0; i < _members.length(); i++) { CFGElement* s = _members.at(i); - float block_freq = s->_freq * loop_freq; + double block_freq = s->_freq * loop_freq; if (g_isnan(block_freq) || block_freq < MIN_BLOCK_FREQUENCY) block_freq = MIN_BLOCK_FREQUENCY; s->_freq = block_freq; @@ -1993,7 +1993,7 @@ void CFGLoop::scale_freq() { } // Frequency of outer loop -float CFGLoop::outer_loop_freq() const { +double CFGLoop::outer_loop_freq() const { if (_child != NULL) { return _child->_freq; } @@ -2042,7 +2042,7 @@ void CFGLoop::dump() const { k = 0; } Block *blk = _exits.at(i).get_target(); - float prob = _exits.at(i).get_prob(); + double prob = _exits.at(i).get_prob(); tty->print(" ->%d@%d%%", blk->_pre_order, (int)(prob*100)); } tty->print("\n"); diff --git a/hotspot/src/share/vm/opto/ifg.cpp b/hotspot/src/share/vm/opto/ifg.cpp index 4b102d68589..b84ea45abb7 100644 --- a/hotspot/src/share/vm/opto/ifg.cpp +++ b/hotspot/src/share/vm/opto/ifg.cpp @@ -693,7 +693,7 @@ void PhaseChaitin::add_input_to_liveout(Block* b, Node* n, IndexSet* liveout, do assert(int_pressure.current_pressure() == count_int_pressure(liveout), "the int pressure is incorrect"); assert(float_pressure.current_pressure() == count_float_pressure(liveout), "the float pressure is incorrect"); } - assert(!(lrg._area < 0.0), "negative spill area" ); + assert(lrg._area >= 0.0, "negative spill area" ); } } @@ -762,7 +762,7 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { int inst_count = last_inst - first_inst; double cost = (inst_count <= 0) ? 0.0 : block->_freq * double(inst_count); - assert(!(cost < 0.0), "negative spill cost" ); + assert(cost >= 0.0, "negative spill cost" ); compute_initial_block_pressure(block, &liveout, int_pressure, float_pressure, cost); @@ -789,7 +789,11 @@ uint PhaseChaitin::build_ifg_physical( ResourceArea *a ) { } } else { // A live range ends at its definition, remove the remaining area. - lrg._area -= cost; + // If the cost is +Inf (which might happen in extreme cases), the lrg area will also be +Inf, + // and +Inf - +Inf = NaN. So let's not do that subtraction. + if (g_isfinite(cost)) { + lrg._area -= cost; + } assert(lrg._area >= 0.0, "negative spill area" ); assign_high_score_to_immediate_copies(block, n, lrg, location + 1, last_inst); diff --git a/hotspot/src/share/vm/runtime/vmStructs.cpp b/hotspot/src/share/vm/runtime/vmStructs.cpp index 0fd2d70881f..7044dc9b2b7 100644 --- a/hotspot/src/share/vm/runtime/vmStructs.cpp +++ b/hotspot/src/share/vm/runtime/vmStructs.cpp @@ -1176,9 +1176,9 @@ typedef TwoOopHashtable SymbolTwoOopHashtable; c2_nonstatic_field(Block, _pre_order, uint) \ c2_nonstatic_field(Block, _dom_depth, uint) \ c2_nonstatic_field(Block, _idom, Block*) \ - c2_nonstatic_field(Block, _freq, jfloat) \ + c2_nonstatic_field(Block, _freq, jdouble) \ \ - c2_nonstatic_field(CFGElement, _freq, jfloat) \ + c2_nonstatic_field(CFGElement, _freq, jdouble) \ \ c2_nonstatic_field(Block_List, _cnt, uint) \ \ From 493557fc9099ffe12d8baa9a89e7ad3a61ed8378 Mon Sep 17 00:00:00 2001 From: Roland Westrelin Date: Tue, 25 Feb 2014 18:16:24 +0100 Subject: [PATCH 157/159] 8031752: Failed speculative optimizations should be reattempted when root of compilation is different Support for speculative traps that keep track of the root of the compilation in which a trap occurs. Reviewed-by: kvn, twisti --- hotspot/src/share/vm/ci/ciClassList.hpp | 1 + hotspot/src/share/vm/ci/ciMethodData.cpp | 149 +++++-- hotspot/src/share/vm/ci/ciMethodData.hpp | 58 ++- .../share/vm/interpreter/bytecodeTracer.cpp | 2 +- hotspot/src/share/vm/oops/instanceKlass.cpp | 10 +- hotspot/src/share/vm/oops/instanceKlass.hpp | 2 +- hotspot/src/share/vm/oops/methodData.cpp | 406 +++++++++++++++--- hotspot/src/share/vm/oops/methodData.hpp | 135 ++++-- hotspot/src/share/vm/opto/compile.cpp | 10 +- hotspot/src/share/vm/opto/doCall.cpp | 2 +- hotspot/src/share/vm/opto/graphKit.cpp | 23 +- hotspot/src/share/vm/opto/graphKit.hpp | 2 +- .../src/share/vm/runtime/deoptimization.cpp | 18 +- .../src/share/vm/runtime/deoptimization.hpp | 15 + hotspot/src/share/vm/runtime/globals.hpp | 6 + .../TestSpecTrapClassUnloading.java | 97 +++++ 16 files changed, 772 insertions(+), 164 deletions(-) create mode 100644 hotspot/test/compiler/uncommontrap/TestSpecTrapClassUnloading.java diff --git a/hotspot/src/share/vm/ci/ciClassList.hpp b/hotspot/src/share/vm/ci/ciClassList.hpp index ee82685a4df..1e6816030f7 100644 --- a/hotspot/src/share/vm/ci/ciClassList.hpp +++ b/hotspot/src/share/vm/ci/ciClassList.hpp @@ -103,6 +103,7 @@ friend class ciMethodHandle; \ friend class ciMethodType; \ friend class ciReceiverTypeData; \ friend class ciTypeEntries; \ +friend class ciSpeculativeTrapData; \ friend class ciSymbol; \ friend class ciArray; \ friend class ciObjArray; \ diff --git a/hotspot/src/share/vm/ci/ciMethodData.cpp b/hotspot/src/share/vm/ci/ciMethodData.cpp index 025146885db..950e3d6dd21 100644 --- a/hotspot/src/share/vm/ci/ciMethodData.cpp +++ b/hotspot/src/share/vm/ci/ciMethodData.cpp @@ -78,6 +78,35 @@ ciMethodData::ciMethodData() : ciMetadata(NULL) { _parameters = NULL; } +void ciMethodData::load_extra_data() { + MethodData* mdo = get_MethodData(); + + // speculative trap entries also hold a pointer to a Method so need to be translated + DataLayout* dp_src = mdo->extra_data_base(); + DataLayout* end_src = mdo->extra_data_limit(); + DataLayout* dp_dst = extra_data_base(); + for (;; dp_src = MethodData::next_extra(dp_src), dp_dst = MethodData::next_extra(dp_dst)) { + assert(dp_src < end_src, "moved past end of extra data"); + assert(dp_src->tag() == dp_dst->tag(), err_msg("should be same tags %d != %d", dp_src->tag(), dp_dst->tag())); + switch(dp_src->tag()) { + case DataLayout::speculative_trap_data_tag: { + ciSpeculativeTrapData* data_dst = new ciSpeculativeTrapData(dp_dst); + SpeculativeTrapData* data_src = new SpeculativeTrapData(dp_src); + data_dst->translate_from(data_src); + break; + } + case DataLayout::bit_data_tag: + break; + case DataLayout::no_tag: + case DataLayout::arg_info_data_tag: + // An empty slot or ArgInfoData entry marks the end of the trap data + return; + default: + fatal(err_msg("bad tag = %d", dp_src->tag())); + } + } +} + void ciMethodData::load_data() { MethodData* mdo = get_MethodData(); if (mdo == NULL) { @@ -116,6 +145,8 @@ void ciMethodData::load_data() { parameters->translate_from(mdo->parameters_type_data()); } + load_extra_data(); + // Note: Extra data are all BitData, and do not need translation. _current_mileage = MethodData::mileage_of(mdo->method()); _invocation_counter = mdo->invocation_count(); @@ -156,6 +187,12 @@ void ciReturnTypeEntry::translate_type_data_from(const ReturnTypeEntry* ret) { set_type(translate_klass(k)); } +void ciSpeculativeTrapData::translate_from(const ProfileData* data) { + Method* m = data->as_SpeculativeTrapData()->method(); + ciMethod* ci_m = CURRENT_ENV->get_method(m); + set_method(ci_m); +} + // Get the data at an arbitrary (sort of) data index. ciProfileData* ciMethodData::data_at(int data_index) { if (out_of_bounds(data_index)) { @@ -203,33 +240,65 @@ ciProfileData* ciMethodData::next_data(ciProfileData* current) { return next; } -// Translate a bci to its corresponding data, or NULL. -ciProfileData* ciMethodData::bci_to_data(int bci) { - ciProfileData* data = data_before(bci); - for ( ; is_valid(data); data = next_data(data)) { - if (data->bci() == bci) { - set_hint_di(dp_to_di(data->dp())); - return data; - } else if (data->bci() > bci) { - break; - } - } +ciProfileData* ciMethodData::bci_to_extra_data(int bci, ciMethod* m, bool& two_free_slots) { // bci_to_extra_data(bci) ... DataLayout* dp = data_layout_at(data_size()); DataLayout* end = data_layout_at(data_size() + extra_data_size()); - for (; dp < end; dp = MethodData::next_extra(dp)) { - if (dp->tag() == DataLayout::no_tag) { + two_free_slots = false; + for (;dp < end; dp = MethodData::next_extra(dp)) { + switch(dp->tag()) { + case DataLayout::no_tag: _saw_free_extra_data = true; // observed an empty slot (common case) + two_free_slots = (MethodData::next_extra(dp)->tag() == DataLayout::no_tag); return NULL; + case DataLayout::arg_info_data_tag: + return NULL; // ArgInfoData is at the end of extra data section. + case DataLayout::bit_data_tag: + if (m == NULL && dp->bci() == bci) { + return new ciBitData(dp); + } + break; + case DataLayout::speculative_trap_data_tag: { + ciSpeculativeTrapData* data = new ciSpeculativeTrapData(dp); + // data->method() might be null if the MDO is snapshotted + // concurrently with a trap + if (m != NULL && data->method() == m && dp->bci() == bci) { + return data; + } + break; } - if (dp->tag() == DataLayout::arg_info_data_tag) { - break; // ArgInfoData is at the end of extra data section. + default: + fatal(err_msg("bad tag = %d", dp->tag())); } - if (dp->bci() == bci) { - assert(dp->tag() == DataLayout::bit_data_tag, "sane"); - return new ciBitData(dp); + } + return NULL; +} + +// Translate a bci to its corresponding data, or NULL. +ciProfileData* ciMethodData::bci_to_data(int bci, ciMethod* m) { + // If m is not NULL we look for a SpeculativeTrapData entry + if (m == NULL) { + ciProfileData* data = data_before(bci); + for ( ; is_valid(data); data = next_data(data)) { + if (data->bci() == bci) { + set_hint_di(dp_to_di(data->dp())); + return data; + } else if (data->bci() > bci) { + break; + } } } + bool two_free_slots = false; + ciProfileData* result = bci_to_extra_data(bci, m, two_free_slots); + if (result != NULL) { + return result; + } + if (m != NULL && !two_free_slots) { + // We were looking for a SpeculativeTrapData entry we didn't + // find. Room is not available for more SpeculativeTrapData + // entries, look in the non SpeculativeTrapData entries. + return bci_to_data(bci, NULL); + } return NULL; } @@ -525,18 +594,25 @@ void ciMethodData::print_data_on(outputStream* st) { st->print_cr("--- Extra data:"); DataLayout* dp = data_layout_at(data_size()); DataLayout* end = data_layout_at(data_size() + extra_data_size()); - for (; dp < end; dp = MethodData::next_extra(dp)) { - if (dp->tag() == DataLayout::no_tag) continue; - if (dp->tag() == DataLayout::bit_data_tag) { + for (;; dp = MethodData::next_extra(dp)) { + assert(dp < end, "moved past end of extra data"); + switch (dp->tag()) { + case DataLayout::no_tag: + continue; + case DataLayout::bit_data_tag: data = new BitData(dp); - } else { - assert(dp->tag() == DataLayout::arg_info_data_tag, "must be BitData or ArgInfo"); + break; + case DataLayout::arg_info_data_tag: data = new ciArgInfoData(dp); dp = end; // ArgInfoData is at the end of extra data section. + break; + default: + fatal(err_msg("unexpected tag %d", dp->tag())); } st->print("%d", dp_to_di(data->dp())); st->fill_to(6); data->print_data_on(st); + if (dp >= end) return; } } @@ -569,8 +645,8 @@ void ciReturnTypeEntry::print_data_on(outputStream* st) const { st->cr(); } -void ciCallTypeData::print_data_on(outputStream* st) const { - print_shared(st, "ciCallTypeData"); +void ciCallTypeData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "ciCallTypeData", extra); if (has_arguments()) { tab(st, true); st->print("argument types"); @@ -599,18 +675,18 @@ void ciReceiverTypeData::print_receiver_data_on(outputStream* st) const { } } -void ciReceiverTypeData::print_data_on(outputStream* st) const { - print_shared(st, "ciReceiverTypeData"); +void ciReceiverTypeData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "ciReceiverTypeData", extra); print_receiver_data_on(st); } -void ciVirtualCallData::print_data_on(outputStream* st) const { - print_shared(st, "ciVirtualCallData"); +void ciVirtualCallData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "ciVirtualCallData", extra); rtd_super()->print_receiver_data_on(st); } -void ciVirtualCallTypeData::print_data_on(outputStream* st) const { - print_shared(st, "ciVirtualCallTypeData"); +void ciVirtualCallTypeData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "ciVirtualCallTypeData", extra); rtd_super()->print_receiver_data_on(st); if (has_arguments()) { tab(st, true); @@ -624,8 +700,15 @@ void ciVirtualCallTypeData::print_data_on(outputStream* st) const { } } -void ciParametersTypeData::print_data_on(outputStream* st) const { - st->print_cr("Parametertypes"); +void ciParametersTypeData::print_data_on(outputStream* st, const char* extra) const { + st->print_cr("ciParametersTypeData"); parameters()->print_data_on(st); } + +void ciSpeculativeTrapData::print_data_on(outputStream* st, const char* extra) const { + st->print_cr("ciSpeculativeTrapData"); + tab(st); + method()->print_short_name(st); + st->cr(); +} #endif diff --git a/hotspot/src/share/vm/ci/ciMethodData.hpp b/hotspot/src/share/vm/ci/ciMethodData.hpp index f1a7f2634e4..e5b380fe70f 100644 --- a/hotspot/src/share/vm/ci/ciMethodData.hpp +++ b/hotspot/src/share/vm/ci/ciMethodData.hpp @@ -31,6 +31,7 @@ #include "ci/ciUtilities.hpp" #include "oops/methodData.hpp" #include "oops/oop.inline.hpp" +#include "runtime/deoptimization.hpp" class ciBitData; class ciCounterData; @@ -44,6 +45,7 @@ class ciArgInfoData; class ciCallTypeData; class ciVirtualCallTypeData; class ciParametersTypeData; +class ciSpeculativeTrapData;; typedef ProfileData ciProfileData; @@ -173,7 +175,7 @@ public: } #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra) const; #endif }; @@ -200,7 +202,7 @@ public: } void translate_receiver_data_from(const ProfileData* data); #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra) const; void print_receiver_data_on(outputStream* st) const; #endif }; @@ -225,7 +227,7 @@ public: rtd_super()->translate_receiver_data_from(data); } #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra) const; #endif }; @@ -287,7 +289,7 @@ public: } #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra) const; #endif }; @@ -336,7 +338,26 @@ public: } #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra) const; +#endif +}; + +class ciSpeculativeTrapData : public SpeculativeTrapData { +public: + ciSpeculativeTrapData(DataLayout* layout) : SpeculativeTrapData(layout) {} + + virtual void translate_from(const ProfileData* data); + + ciMethod* method() const { + return (ciMethod*)intptr_at(method_offset); + } + + void set_method(ciMethod* m) { + set_intptr_at(method_offset, (intptr_t)m); + } + +#ifndef PRODUCT + void print_data_on(outputStream* st, const char* extra) const; #endif }; @@ -436,6 +457,16 @@ private: ciArgInfoData *arg_info() const; + address data_base() const { + return (address) _data; + } + DataLayout* limit_data_position() const { + return (DataLayout*)((address)data_base() + _data_size); + } + + void load_extra_data(); + ciProfileData* bci_to_extra_data(int bci, ciMethod* m, bool& two_free_slots); + public: bool is_method_data() const { return true; } @@ -475,9 +506,11 @@ public: ciProfileData* next_data(ciProfileData* current); bool is_valid(ciProfileData* current) { return current != NULL; } - // Get the data at an arbitrary bci, or NULL if there is none. - ciProfileData* bci_to_data(int bci); - ciProfileData* bci_to_extra_data(int bci, bool create_if_missing); + DataLayout* extra_data_base() const { return limit_data_position(); } + + // Get the data at an arbitrary bci, or NULL if there is none. If m + // is not NULL look for a SpeculativeTrapData if any first. + ciProfileData* bci_to_data(int bci, ciMethod* m = NULL); uint overflow_trap_count() const { return _orig.overflow_trap_count(); @@ -496,12 +529,13 @@ public: // Helpful query functions that decode trap_state. int has_trap_at(ciProfileData* data, int reason); - int has_trap_at(int bci, int reason) { - return has_trap_at(bci_to_data(bci), reason); + int has_trap_at(int bci, ciMethod* m, int reason) { + assert((m != NULL) == Deoptimization::reason_is_speculate(reason), "inconsistent method/reason"); + return has_trap_at(bci_to_data(bci, m), reason); } int trap_recompiled_at(ciProfileData* data); - int trap_recompiled_at(int bci) { - return trap_recompiled_at(bci_to_data(bci)); + int trap_recompiled_at(int bci, ciMethod* m) { + return trap_recompiled_at(bci_to_data(bci, m)); } void clear_escape_info(); diff --git a/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp b/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp index 37ac6d1a6e4..1892940f216 100644 --- a/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp +++ b/hotspot/src/share/vm/interpreter/bytecodeTracer.cpp @@ -596,7 +596,7 @@ void BytecodePrinter::bytecode_epilog(int bci, outputStream* st) { if (data != NULL) { st->print(" %d", mdo->dp_to_di(data->dp())); st->fill_to(6); - data->print_data_on(st); + data->print_data_on(st, mdo); } } } diff --git a/hotspot/src/share/vm/oops/instanceKlass.cpp b/hotspot/src/share/vm/oops/instanceKlass.cpp index 62f7ffbf370..7dee4f3dba3 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.cpp +++ b/hotspot/src/share/vm/oops/instanceKlass.cpp @@ -2192,15 +2192,7 @@ void InstanceKlass::clean_method_data(BoolObjectClosure* is_alive) { for (int m = 0; m < methods()->length(); m++) { MethodData* mdo = methods()->at(m)->method_data(); if (mdo != NULL) { - for (ProfileData* data = mdo->first_data(); - mdo->is_valid(data); - data = mdo->next_data(data)) { - data->clean_weak_klass_links(is_alive); - } - ParametersTypeData* parameters = mdo->parameters_type_data(); - if (parameters != NULL) { - parameters->clean_weak_klass_links(is_alive); - } + mdo->clean_method_data(is_alive); } } } diff --git a/hotspot/src/share/vm/oops/instanceKlass.hpp b/hotspot/src/share/vm/oops/instanceKlass.hpp index db14be29a14..b25c75afc3b 100644 --- a/hotspot/src/share/vm/oops/instanceKlass.hpp +++ b/hotspot/src/share/vm/oops/instanceKlass.hpp @@ -306,7 +306,7 @@ class InstanceKlass: public Klass { // three cases: // NULL: no implementor. // A Klass* that's not itself: one implementor. - // Itsef: more than one implementors. + // Itself: more than one implementors. // embedded host klass follows here // The embedded host klass only exists in an anonymous class for // dynamic language support (JSR 292 enabled). The host class grants diff --git a/hotspot/src/share/vm/oops/methodData.cpp b/hotspot/src/share/vm/oops/methodData.cpp index 2da63c08d8c..b226173d832 100644 --- a/hotspot/src/share/vm/oops/methodData.cpp +++ b/hotspot/src/share/vm/oops/methodData.cpp @@ -80,8 +80,42 @@ ProfileData::ProfileData() { _data = NULL; } +char* ProfileData::print_data_on_helper(const MethodData* md) const { + DataLayout* dp = md->extra_data_base(); + DataLayout* end = md->extra_data_limit(); + stringStream ss; + for (;; dp = MethodData::next_extra(dp)) { + assert(dp < end, "moved past end of extra data"); + switch(dp->tag()) { + case DataLayout::speculative_trap_data_tag: + if (dp->bci() == bci()) { + SpeculativeTrapData* data = new SpeculativeTrapData(dp); + int trap = data->trap_state(); + char buf[100]; + ss.print("trap/"); + data->method()->print_short_name(&ss); + ss.print("(%s) ", Deoptimization::format_trap_state(buf, sizeof(buf), trap)); + } + break; + case DataLayout::bit_data_tag: + break; + case DataLayout::no_tag: + case DataLayout::arg_info_data_tag: + return ss.as_string(); + break; + default: + fatal(err_msg("unexpected tag %d", dp->tag())); + } + } + return NULL; +} + +void ProfileData::print_data_on(outputStream* st, const MethodData* md) const { + print_data_on(st, print_data_on_helper(md)); +} + #ifndef PRODUCT -void ProfileData::print_shared(outputStream* st, const char* name) const { +void ProfileData::print_shared(outputStream* st, const char* name, const char* extra) const { st->print("bci: %d", bci()); st->fill_to(tab_width_one); st->print("%s", name); @@ -91,9 +125,13 @@ void ProfileData::print_shared(outputStream* st, const char* name) const { char buf[100]; st->print("trap(%s) ", Deoptimization::format_trap_state(buf, sizeof(buf), trap)); } + if (extra != NULL) { + st->print(extra); + } int flags = data()->flags(); - if (flags != 0) + if (flags != 0) { st->print("flags(%d) ", flags); + } } void ProfileData::tab(outputStream* st, bool first) const { @@ -109,8 +147,8 @@ void ProfileData::tab(outputStream* st, bool first) const { #ifndef PRODUCT -void BitData::print_data_on(outputStream* st) const { - print_shared(st, "BitData"); +void BitData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "BitData", extra); } #endif // !PRODUCT @@ -120,8 +158,8 @@ void BitData::print_data_on(outputStream* st) const { // A CounterData corresponds to a simple counter. #ifndef PRODUCT -void CounterData::print_data_on(outputStream* st) const { - print_shared(st, "CounterData"); +void CounterData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "CounterData", extra); st->print_cr("count(%u)", count()); } #endif // !PRODUCT @@ -150,8 +188,8 @@ void JumpData::post_initialize(BytecodeStream* stream, MethodData* mdo) { } #ifndef PRODUCT -void JumpData::print_data_on(outputStream* st) const { - print_shared(st, "JumpData"); +void JumpData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "JumpData", extra); st->print_cr("taken(%u) displacement(%d)", taken(), displacement()); } #endif // !PRODUCT @@ -332,8 +370,8 @@ void ReturnTypeEntry::print_data_on(outputStream* st) const { st->cr(); } -void CallTypeData::print_data_on(outputStream* st) const { - CounterData::print_data_on(st); +void CallTypeData::print_data_on(outputStream* st, const char* extra) const { + CounterData::print_data_on(st, extra); if (has_arguments()) { tab(st, true); st->print("argument types"); @@ -346,8 +384,8 @@ void CallTypeData::print_data_on(outputStream* st) const { } } -void VirtualCallTypeData::print_data_on(outputStream* st) const { - VirtualCallData::print_data_on(st); +void VirtualCallTypeData::print_data_on(outputStream* st, const char* extra) const { + VirtualCallData::print_data_on(st, extra); if (has_arguments()) { tab(st, true); st->print("argument types"); @@ -400,12 +438,12 @@ void ReceiverTypeData::print_receiver_data_on(outputStream* st) const { } } } -void ReceiverTypeData::print_data_on(outputStream* st) const { - print_shared(st, "ReceiverTypeData"); +void ReceiverTypeData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "ReceiverTypeData", extra); print_receiver_data_on(st); } -void VirtualCallData::print_data_on(outputStream* st) const { - print_shared(st, "VirtualCallData"); +void VirtualCallData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "VirtualCallData", extra); print_receiver_data_on(st); } #endif // !PRODUCT @@ -461,8 +499,8 @@ DataLayout* RetData::advance(MethodData *md, int bci) { #endif // CC_INTERP #ifndef PRODUCT -void RetData::print_data_on(outputStream* st) const { - print_shared(st, "RetData"); +void RetData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "RetData", extra); uint row; int entries = 0; for (row = 0; row < row_limit(); row++) { @@ -496,8 +534,8 @@ void BranchData::post_initialize(BytecodeStream* stream, MethodData* mdo) { } #ifndef PRODUCT -void BranchData::print_data_on(outputStream* st) const { - print_shared(st, "BranchData"); +void BranchData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "BranchData", extra); st->print_cr("taken(%u) displacement(%d)", taken(), displacement()); tab(st); @@ -570,8 +608,8 @@ void MultiBranchData::post_initialize(BytecodeStream* stream, } #ifndef PRODUCT -void MultiBranchData::print_data_on(outputStream* st) const { - print_shared(st, "MultiBranchData"); +void MultiBranchData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "MultiBranchData", extra); st->print_cr("default_count(%u) displacement(%d)", default_count(), default_displacement()); int cases = number_of_cases(); @@ -584,8 +622,8 @@ void MultiBranchData::print_data_on(outputStream* st) const { #endif #ifndef PRODUCT -void ArgInfoData::print_data_on(outputStream* st) const { - print_shared(st, "ArgInfoData"); +void ArgInfoData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "ArgInfoData", extra); int nargs = number_of_args(); for (int i = 0; i < nargs; i++) { st->print(" 0x%x", arg_modified(i)); @@ -616,10 +654,17 @@ bool ParametersTypeData::profiling_enabled() { } #ifndef PRODUCT -void ParametersTypeData::print_data_on(outputStream* st) const { - st->print("parameter types"); +void ParametersTypeData::print_data_on(outputStream* st, const char* extra) const { + st->print("parameter types", extra); _parameters.print_data_on(st); } + +void SpeculativeTrapData::print_data_on(outputStream* st, const char* extra) const { + print_shared(st, "SpeculativeTrapData", extra); + tab(st); + method()->print_short_name(st); + st->cr(); +} #endif // ================================================================== @@ -745,7 +790,27 @@ int MethodData::compute_data_size(BytecodeStream* stream) { return DataLayout::compute_size_in_bytes(cell_count); } -int MethodData::compute_extra_data_count(int data_size, int empty_bc_count) { +bool MethodData::is_speculative_trap_bytecode(Bytecodes::Code code) { + // Bytecodes for which we may use speculation + switch (code) { + case Bytecodes::_checkcast: + case Bytecodes::_instanceof: + case Bytecodes::_aastore: + case Bytecodes::_invokevirtual: + case Bytecodes::_invokeinterface: + case Bytecodes::_if_acmpeq: + case Bytecodes::_if_acmpne: + case Bytecodes::_invokestatic: +#ifdef COMPILER2 + return UseTypeSpeculation; +#endif + default: + return false; + } + return false; +} + +int MethodData::compute_extra_data_count(int data_size, int empty_bc_count, bool needs_speculative_traps) { if (ProfileTraps) { // Assume that up to 3% of BCIs with no MDP will need to allocate one. int extra_data_count = (uint)(empty_bc_count * 3) / 128 + 1; @@ -756,7 +821,18 @@ int MethodData::compute_extra_data_count(int data_size, int empty_bc_count) { extra_data_count = one_percent_of_data; if (extra_data_count > empty_bc_count) extra_data_count = empty_bc_count; // no need for more - return extra_data_count; + + // Make sure we have a minimum number of extra data slots to + // allocate SpeculativeTrapData entries. We would want to have one + // entry per compilation that inlines this method and for which + // some type speculation assumption fails. So the room we need for + // the SpeculativeTrapData entries doesn't directly depend on the + // size of the method. Because it's hard to estimate, we reserve + // space for an arbitrary number of entries. + int spec_data_count = (needs_speculative_traps ? SpecTrapLimitExtraEntries : 0) * + (SpeculativeTrapData::static_cell_count() + DataLayout::header_size_in_cells()); + + return MAX2(extra_data_count, spec_data_count); } else { return 0; } @@ -769,15 +845,17 @@ int MethodData::compute_allocation_size_in_bytes(methodHandle method) { BytecodeStream stream(method); Bytecodes::Code c; int empty_bc_count = 0; // number of bytecodes lacking data + bool needs_speculative_traps = false; while ((c = stream.next()) >= 0) { int size_in_bytes = compute_data_size(&stream); data_size += size_in_bytes; if (size_in_bytes == 0) empty_bc_count += 1; + needs_speculative_traps = needs_speculative_traps || is_speculative_trap_bytecode(c); } int object_size = in_bytes(data_offset()) + data_size; // Add some extra DataLayout cells (at least one) to track stray traps. - int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); + int extra_data_count = compute_extra_data_count(data_size, empty_bc_count, needs_speculative_traps); object_size += extra_data_count * DataLayout::compute_size_in_bytes(0); // Add a cell to record information about modified arguments. @@ -1009,18 +1087,23 @@ MethodData::MethodData(methodHandle method, int size, TRAPS) { _data[0] = 0; // apparently not set below. BytecodeStream stream(method); Bytecodes::Code c; + bool needs_speculative_traps = false; while ((c = stream.next()) >= 0) { int size_in_bytes = initialize_data(&stream, data_size); data_size += size_in_bytes; if (size_in_bytes == 0) empty_bc_count += 1; + needs_speculative_traps = needs_speculative_traps || is_speculative_trap_bytecode(c); } _data_size = data_size; int object_size = in_bytes(data_offset()) + data_size; // Add some extra DataLayout cells (at least one) to track stray traps. - int extra_data_count = compute_extra_data_count(data_size, empty_bc_count); + int extra_data_count = compute_extra_data_count(data_size, empty_bc_count, needs_speculative_traps); int extra_size = extra_data_count * DataLayout::compute_size_in_bytes(0); + // Let's zero the space for the extra data + Copy::zero_to_bytes(((address)_data) + data_size, extra_size); + // Add a cell to record information about modified arguments. // Set up _args_modified array after traps cells so that // the code for traps cells works. @@ -1032,17 +1115,17 @@ MethodData::MethodData(methodHandle method, int size, TRAPS) { int arg_data_size = DataLayout::compute_size_in_bytes(arg_size+1); object_size += extra_size + arg_data_size; - int args_cell = ParametersTypeData::compute_cell_count(method()); + int parms_cell = ParametersTypeData::compute_cell_count(method()); // If we are profiling parameters, we reserver an area near the end // of the MDO after the slots for bytecodes (because there's no bci // for method entry so they don't fit with the framework for the // profiling of bytecodes). We store the offset within the MDO of // this area (or -1 if no parameter is profiled) - if (args_cell > 0) { - object_size += DataLayout::compute_size_in_bytes(args_cell); + if (parms_cell > 0) { + object_size += DataLayout::compute_size_in_bytes(parms_cell); _parameters_type_data_di = data_size + extra_size + arg_data_size; DataLayout *dp = data_layout_at(data_size + extra_size + arg_data_size); - dp->initialize(DataLayout::parameters_type_data_tag, 0, args_cell); + dp->initialize(DataLayout::parameters_type_data_tag, 0, parms_cell); } else { _parameters_type_data_di = -1; } @@ -1133,39 +1216,113 @@ ProfileData* MethodData::bci_to_data(int bci) { break; } } - return bci_to_extra_data(bci, false); + return bci_to_extra_data(bci, NULL, false); } -// Translate a bci to its corresponding extra data, or NULL. -ProfileData* MethodData::bci_to_extra_data(int bci, bool create_if_missing) { - DataLayout* dp = extra_data_base(); - DataLayout* end = extra_data_limit(); - DataLayout* avail = NULL; - for (; dp < end; dp = next_extra(dp)) { +DataLayout* MethodData::next_extra(DataLayout* dp) { + int nb_cells = 0; + switch(dp->tag()) { + case DataLayout::bit_data_tag: + case DataLayout::no_tag: + nb_cells = BitData::static_cell_count(); + break; + case DataLayout::speculative_trap_data_tag: + nb_cells = SpeculativeTrapData::static_cell_count(); + break; + default: + fatal(err_msg("unexpected tag %d", dp->tag())); + } + return (DataLayout*)((address)dp + DataLayout::compute_size_in_bytes(nb_cells)); +} + +ProfileData* MethodData::bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp) { + DataLayout* end = extra_data_limit(); + + for (;; dp = next_extra(dp)) { + assert(dp < end, "moved past end of extra data"); // No need for "OrderAccess::load_acquire" ops, // since the data structure is monotonic. - if (dp->tag() == DataLayout::no_tag) break; - if (dp->tag() == DataLayout::arg_info_data_tag) { - dp = end; // ArgInfoData is at the end of extra data section. + switch(dp->tag()) { + case DataLayout::no_tag: + return NULL; + case DataLayout::arg_info_data_tag: + dp = end; + return NULL; // ArgInfoData is at the end of extra data section. + case DataLayout::bit_data_tag: + if (m == NULL && dp->bci() == bci) { + return new BitData(dp); + } break; - } - if (dp->bci() == bci) { - assert(dp->tag() == DataLayout::bit_data_tag, "sane"); - return new BitData(dp); + case DataLayout::speculative_trap_data_tag: + if (m != NULL) { + SpeculativeTrapData* data = new SpeculativeTrapData(dp); + // data->method() may be null in case of a concurrent + // allocation. Assume it's for the same method and use that + // entry in that case. + if (dp->bci() == bci) { + if (data->method() == NULL) { + return NULL; + } else if (data->method() == m) { + return data; + } + } + } + break; + default: + fatal(err_msg("unexpected tag %d", dp->tag())); } } - if (create_if_missing && dp < end) { - // Allocate this one. There is no mutual exclusion, - // so two threads could allocate different BCIs to the - // same data layout. This means these extra data - // records, like most other MDO contents, must not be - // trusted too much. - DataLayout temp; - temp.initialize(DataLayout::bit_data_tag, bci, 0); - dp->release_set_header(temp.header()); - assert(dp->tag() == DataLayout::bit_data_tag, "sane"); - //NO: assert(dp->bci() == bci, "no concurrent allocation"); - return new BitData(dp); + return NULL; +} + + +// Translate a bci to its corresponding extra data, or NULL. +ProfileData* MethodData::bci_to_extra_data(int bci, Method* m, bool create_if_missing) { + // This code assumes an entry for a SpeculativeTrapData is 2 cells + assert(2*DataLayout::compute_size_in_bytes(BitData::static_cell_count()) == + DataLayout::compute_size_in_bytes(SpeculativeTrapData::static_cell_count()), + "code needs to be adjusted"); + + DataLayout* dp = extra_data_base(); + DataLayout* end = extra_data_limit(); + + // Allocation in the extra data space has to be atomic because not + // all entries have the same size and non atomic concurrent + // allocation would result in a corrupted extra data space. + while (true) { + ProfileData* result = bci_to_extra_data_helper(bci, m, dp); + if (result != NULL) { + return result; + } + + if (create_if_missing && dp < end) { + assert(dp->tag() == DataLayout::no_tag || (dp->tag() == DataLayout::speculative_trap_data_tag && m != NULL), "should be free"); + assert(next_extra(dp)->tag() == DataLayout::no_tag || next_extra(dp)->tag() == DataLayout::arg_info_data_tag, "should be free or arg info"); + u1 tag = m == NULL ? DataLayout::bit_data_tag : DataLayout::speculative_trap_data_tag; + // SpeculativeTrapData is 2 slots. Make sure we have room. + if (m != NULL && next_extra(dp)->tag() != DataLayout::no_tag) { + return NULL; + } + DataLayout temp; + temp.initialize(tag, bci, 0); + // May have been set concurrently + if (dp->header() != temp.header() && !dp->atomic_set_header(temp.header())) { + // Allocation failure because of concurrent allocation. Try + // again. + continue; + } + assert(dp->tag() == tag, "sane"); + assert(dp->bci() == bci, "no concurrent allocation"); + if (tag == DataLayout::bit_data_tag) { + return new BitData(dp); + } else { + // If being allocated concurrently, one trap may be lost + SpeculativeTrapData* data = new SpeculativeTrapData(dp); + data->set_method(m); + return data; + } + } + return NULL; } return NULL; } @@ -1210,25 +1367,35 @@ void MethodData::print_data_on(outputStream* st) const { for ( ; is_valid(data); data = next_data(data)) { st->print("%d", dp_to_di(data->dp())); st->fill_to(6); - data->print_data_on(st); + data->print_data_on(st, this); } st->print_cr("--- Extra data:"); DataLayout* dp = extra_data_base(); DataLayout* end = extra_data_limit(); - for (; dp < end; dp = next_extra(dp)) { + for (;; dp = next_extra(dp)) { + assert(dp < end, "moved past end of extra data"); // No need for "OrderAccess::load_acquire" ops, // since the data structure is monotonic. - if (dp->tag() == DataLayout::no_tag) continue; - if (dp->tag() == DataLayout::bit_data_tag) { + switch(dp->tag()) { + case DataLayout::no_tag: + continue; + case DataLayout::bit_data_tag: data = new BitData(dp); - } else { - assert(dp->tag() == DataLayout::arg_info_data_tag, "must be BitData or ArgInfo"); + break; + case DataLayout::speculative_trap_data_tag: + data = new SpeculativeTrapData(dp); + break; + case DataLayout::arg_info_data_tag: data = new ArgInfoData(dp); dp = end; // ArgInfoData is at the end of extra data section. + break; + default: + fatal(err_msg("unexpected tag %d", dp->tag())); } st->print("%d", dp_to_di(data->dp())); st->fill_to(6); data->print_data_on(st); + if (dp >= end) return; } } #endif @@ -1351,3 +1518,110 @@ bool MethodData::profile_parameters_for_method(methodHandle m) { assert(profile_parameters_jsr292_only(), "inconsistent"); return m->is_compiled_lambda_form(); } + +void MethodData::clean_extra_data_helper(DataLayout* dp, int shift, bool reset) { + if (shift == 0) { + return; + } + if (!reset) { + // Move all cells of trap entry at dp left by "shift" cells + intptr_t* start = (intptr_t*)dp; + intptr_t* end = (intptr_t*)next_extra(dp); + for (intptr_t* ptr = start; ptr < end; ptr++) { + *(ptr-shift) = *ptr; + } + } else { + // Reset "shift" cells stopping at dp + intptr_t* start = ((intptr_t*)dp) - shift; + intptr_t* end = (intptr_t*)dp; + for (intptr_t* ptr = start; ptr < end; ptr++) { + *ptr = 0; + } + } +} + +// Remove SpeculativeTrapData entries that reference an unloaded +// method +void MethodData::clean_extra_data(BoolObjectClosure* is_alive) { + DataLayout* dp = extra_data_base(); + DataLayout* end = extra_data_limit(); + + int shift = 0; + for (; dp < end; dp = next_extra(dp)) { + switch(dp->tag()) { + case DataLayout::speculative_trap_data_tag: { + SpeculativeTrapData* data = new SpeculativeTrapData(dp); + Method* m = data->method(); + assert(m != NULL, "should have a method"); + if (!m->method_holder()->is_loader_alive(is_alive)) { + // "shift" accumulates the number of cells for dead + // SpeculativeTrapData entries that have been seen so + // far. Following entries must be shifted left by that many + // cells to remove the dead SpeculativeTrapData entries. + shift += (int)((intptr_t*)next_extra(dp) - (intptr_t*)dp); + } else { + // Shift this entry left if it follows dead + // SpeculativeTrapData entries + clean_extra_data_helper(dp, shift); + } + break; + } + case DataLayout::bit_data_tag: + // Shift this entry left if it follows dead SpeculativeTrapData + // entries + clean_extra_data_helper(dp, shift); + continue; + case DataLayout::no_tag: + case DataLayout::arg_info_data_tag: + // We are at end of the live trap entries. The previous "shift" + // cells contain entries that are either dead or were shifted + // left. They need to be reset to no_tag + clean_extra_data_helper(dp, shift, true); + return; + default: + fatal(err_msg("unexpected tag %d", dp->tag())); + } + } +} + +// Verify there's no unloaded method referenced by a +// SpeculativeTrapData entry +void MethodData::verify_extra_data_clean(BoolObjectClosure* is_alive) { +#ifdef ASSERT + DataLayout* dp = extra_data_base(); + DataLayout* end = extra_data_limit(); + + for (; dp < end; dp = next_extra(dp)) { + switch(dp->tag()) { + case DataLayout::speculative_trap_data_tag: { + SpeculativeTrapData* data = new SpeculativeTrapData(dp); + Method* m = data->method(); + assert(m != NULL && m->method_holder()->is_loader_alive(is_alive), "Method should exist"); + break; + } + case DataLayout::bit_data_tag: + continue; + case DataLayout::no_tag: + case DataLayout::arg_info_data_tag: + return; + default: + fatal(err_msg("unexpected tag %d", dp->tag())); + } + } +#endif +} + +void MethodData::clean_method_data(BoolObjectClosure* is_alive) { + for (ProfileData* data = first_data(); + is_valid(data); + data = next_data(data)) { + data->clean_weak_klass_links(is_alive); + } + ParametersTypeData* parameters = parameters_type_data(); + if (parameters != NULL) { + parameters->clean_weak_klass_links(is_alive); + } + + clean_extra_data(is_alive); + verify_extra_data_clean(is_alive); +} diff --git a/hotspot/src/share/vm/oops/methodData.hpp b/hotspot/src/share/vm/oops/methodData.hpp index 57790371e7c..76b0708f233 100644 --- a/hotspot/src/share/vm/oops/methodData.hpp +++ b/hotspot/src/share/vm/oops/methodData.hpp @@ -120,7 +120,8 @@ public: arg_info_data_tag, call_type_data_tag, virtual_call_type_data_tag, - parameters_type_data_tag + parameters_type_data_tag, + speculative_trap_data_tag }; enum { @@ -189,8 +190,11 @@ public: void set_header(intptr_t value) { _header._bits = value; } - void release_set_header(intptr_t value) { - OrderAccess::release_store_ptr(&_header._bits, value); + bool atomic_set_header(intptr_t value) { + if (Atomic::cmpxchg_ptr(value, (volatile intptr_t*)&_header._bits, 0) == 0) { + return true; + } + return false; } intptr_t header() { return _header._bits; @@ -271,6 +275,7 @@ class ArrayData; class MultiBranchData; class ArgInfoData; class ParametersTypeData; +class SpeculativeTrapData; // ProfileData // @@ -291,6 +296,8 @@ private: // This is a pointer to a section of profiling data. DataLayout* _data; + char* print_data_on_helper(const MethodData* md) const; + protected: DataLayout* data() { return _data; } const DataLayout* data() const { return _data; } @@ -440,6 +447,7 @@ public: virtual bool is_CallTypeData() const { return false; } virtual bool is_VirtualCallTypeData()const { return false; } virtual bool is_ParametersTypeData() const { return false; } + virtual bool is_SpeculativeTrapData()const { return false; } BitData* as_BitData() const { @@ -494,6 +502,10 @@ public: assert(is_ParametersTypeData(), "wrong type"); return is_ParametersTypeData() ? (ParametersTypeData*)this : NULL; } + SpeculativeTrapData* as_SpeculativeTrapData() const { + assert(is_SpeculativeTrapData(), "wrong type"); + return is_SpeculativeTrapData() ? (SpeculativeTrapData*)this : NULL; + } // Subclass specific initialization @@ -509,12 +521,14 @@ public: // translation here, and the required translators are in the ci subclasses. virtual void translate_from(const ProfileData* data) {} - virtual void print_data_on(outputStream* st) const { + virtual void print_data_on(outputStream* st, const char* extra = NULL) const { ShouldNotReachHere(); } + void print_data_on(outputStream* st, const MethodData* md) const; + #ifndef PRODUCT - void print_shared(outputStream* st, const char* name) const; + void print_shared(outputStream* st, const char* name, const char* extra) const; void tab(outputStream* st, bool first = false) const; #endif }; @@ -576,7 +590,7 @@ public: #endif // CC_INTERP #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra = NULL) const; #endif }; @@ -639,7 +653,7 @@ public: #endif // CC_INTERP #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra = NULL) const; #endif }; @@ -726,7 +740,7 @@ public: void post_initialize(BytecodeStream* stream, MethodData* mdo); #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra = NULL) const; #endif }; @@ -1137,7 +1151,7 @@ public: } #ifndef PRODUCT - virtual void print_data_on(outputStream* st) const; + virtual void print_data_on(outputStream* st, const char* extra = NULL) const; #endif }; @@ -1282,7 +1296,7 @@ public: #ifndef PRODUCT void print_receiver_data_on(outputStream* st) const; - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra = NULL) const; #endif }; @@ -1325,7 +1339,7 @@ public: #endif // CC_INTERP #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra = NULL) const; #endif }; @@ -1451,7 +1465,7 @@ public: } #ifndef PRODUCT - virtual void print_data_on(outputStream* st) const; + virtual void print_data_on(outputStream* st, const char* extra = NULL) const; #endif }; @@ -1554,7 +1568,7 @@ public: void post_initialize(BytecodeStream* stream, MethodData* mdo); #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra = NULL) const; #endif }; @@ -1632,7 +1646,7 @@ public: void post_initialize(BytecodeStream* stream, MethodData* mdo); #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra = NULL) const; #endif }; @@ -1825,7 +1839,7 @@ public: void post_initialize(BytecodeStream* stream, MethodData* mdo); #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra = NULL) const; #endif }; @@ -1852,7 +1866,7 @@ public: } #ifndef PRODUCT - void print_data_on(outputStream* st) const; + void print_data_on(outputStream* st, const char* extra = NULL) const; #endif }; @@ -1913,7 +1927,7 @@ public: } #ifndef PRODUCT - virtual void print_data_on(outputStream* st) const; + virtual void print_data_on(outputStream* st, const char* extra = NULL) const; #endif static ByteSize stack_slot_offset(int i) { @@ -1925,6 +1939,54 @@ public: } }; +// SpeculativeTrapData +// +// A SpeculativeTrapData is used to record traps due to type +// speculation. It records the root of the compilation: that type +// speculation is wrong in the context of one compilation (for +// method1) doesn't mean it's wrong in the context of another one (for +// method2). Type speculation could have more/different data in the +// context of the compilation of method2 and it's worthwhile to try an +// optimization that failed for compilation of method1 in the context +// of compilation of method2. +// Space for SpeculativeTrapData entries is allocated from the extra +// data space in the MDO. If we run out of space, the trap data for +// the ProfileData at that bci is updated. +class SpeculativeTrapData : public ProfileData { +protected: + enum { + method_offset, + speculative_trap_cell_count + }; +public: + SpeculativeTrapData(DataLayout* layout) : ProfileData(layout) { + assert(layout->tag() == DataLayout::speculative_trap_data_tag, "wrong type"); + } + + virtual bool is_SpeculativeTrapData() const { return true; } + + static int static_cell_count() { + return speculative_trap_cell_count; + } + + virtual int cell_count() const { + return static_cell_count(); + } + + // Direct accessor + Method* method() const { + return (Method*)intptr_at(method_offset); + } + + void set_method(Method* m) { + set_intptr_at(method_offset, (intptr_t)m); + } + +#ifndef PRODUCT + virtual void print_data_on(outputStream* st, const char* extra = NULL) const; +#endif +}; + // MethodData* // // A MethodData* holds information which has been collected about @@ -1994,7 +2056,7 @@ public: // Whole-method sticky bits and flags enum { - _trap_hist_limit = 17, // decoupled from Deoptimization::Reason_LIMIT + _trap_hist_limit = 18, // decoupled from Deoptimization::Reason_LIMIT _trap_hist_mask = max_jubyte, _extra_data_count = 4 // extra DataLayout headers, for trap history }; // Public flag values @@ -2049,6 +2111,7 @@ private: // Helper for size computation static int compute_data_size(BytecodeStream* stream); static int bytecode_cell_count(Bytecodes::Code code); + static bool is_speculative_trap_bytecode(Bytecodes::Code code); enum { no_profile_data = -1, variable_cell_count = -2 }; // Helper for initialization @@ -2092,8 +2155,9 @@ private: // What is the index of the first data entry? int first_di() const { return 0; } + ProfileData* bci_to_extra_data_helper(int bci, Method* m, DataLayout*& dp); // Find or create an extra ProfileData: - ProfileData* bci_to_extra_data(int bci, bool create_if_missing); + ProfileData* bci_to_extra_data(int bci, Method* m, bool create_if_missing); // return the argument info cell ArgInfoData *arg_info(); @@ -2116,6 +2180,10 @@ private: static bool profile_parameters_jsr292_only(); static bool profile_all_parameters(); + void clean_extra_data(BoolObjectClosure* is_alive); + void clean_extra_data_helper(DataLayout* dp, int shift, bool reset = false); + void verify_extra_data_clean(BoolObjectClosure* is_alive); + public: static int header_size() { return sizeof(MethodData)/wordSize; @@ -2124,7 +2192,7 @@ public: // Compute the size of a MethodData* before it is created. static int compute_allocation_size_in_bytes(methodHandle method); static int compute_allocation_size_in_words(methodHandle method); - static int compute_extra_data_count(int data_size, int empty_bc_count); + static int compute_extra_data_count(int data_size, int empty_bc_count, bool needs_speculative_traps); // Determine if a given bytecode can have profile information. static bool bytecode_has_profile(Bytecodes::Code code) { @@ -2265,9 +2333,26 @@ public: ProfileData* bci_to_data(int bci); // Same, but try to create an extra_data record if one is needed: - ProfileData* allocate_bci_to_data(int bci) { - ProfileData* data = bci_to_data(bci); - return (data != NULL) ? data : bci_to_extra_data(bci, true); + ProfileData* allocate_bci_to_data(int bci, Method* m) { + ProfileData* data = NULL; + // If m not NULL, try to allocate a SpeculativeTrapData entry + if (m == NULL) { + data = bci_to_data(bci); + } + if (data != NULL) { + return data; + } + data = bci_to_extra_data(bci, m, true); + if (data != NULL) { + return data; + } + // If SpeculativeTrapData allocation fails try to allocate a + // regular entry + data = bci_to_data(bci); + if (data != NULL) { + return data; + } + return bci_to_extra_data(bci, NULL, true); } // Add a handful of extra data records, for trap tracking. @@ -2275,7 +2360,7 @@ public: DataLayout* extra_data_limit() const { return (DataLayout*)((address)this + size_in_bytes()); } int extra_data_size() const { return (address)extra_data_limit() - (address)extra_data_base(); } - static DataLayout* next_extra(DataLayout* dp) { return (DataLayout*)((address)dp + in_bytes(DataLayout::cell_offset(0))); } + static DataLayout* next_extra(DataLayout* dp); // Return (uint)-1 for overflow. uint trap_count(int reason) const { @@ -2375,6 +2460,8 @@ public: static bool profile_return(); static bool profile_parameters(); static bool profile_return_jsr292_only(); + + void clean_method_data(BoolObjectClosure* is_alive); }; #endif // SHARE_VM_OOPS_METHODDATAOOP_HPP diff --git a/hotspot/src/share/vm/opto/compile.cpp b/hotspot/src/share/vm/opto/compile.cpp index f3b798296f4..47acd4c5b49 100644 --- a/hotspot/src/share/vm/opto/compile.cpp +++ b/hotspot/src/share/vm/opto/compile.cpp @@ -3249,7 +3249,8 @@ bool Compile::too_many_traps(ciMethod* method, // because of a transient condition during start-up in the interpreter. return false; } - if (md->has_trap_at(bci, reason) != 0) { + ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL; + if (md->has_trap_at(bci, m, reason) != 0) { // Assume PerBytecodeTrapLimit==0, for a more conservative heuristic. // Also, if there are multiple reasons, or if there is no per-BCI record, // assume the worst. @@ -3267,7 +3268,7 @@ bool Compile::too_many_traps(ciMethod* method, // Less-accurate variant which does not require a method and bci. bool Compile::too_many_traps(Deoptimization::DeoptReason reason, ciMethodData* logmd) { - if (trap_count(reason) >= (uint)PerMethodTrapLimit) { + if (trap_count(reason) >= Deoptimization::per_method_trap_limit(reason)) { // Too many traps globally. // Note that we use cumulative trap_count, not just md->trap_count. if (log()) { @@ -3302,10 +3303,11 @@ bool Compile::too_many_recompiles(ciMethod* method, uint m_cutoff = (uint) PerMethodRecompilationCutoff / 2 + 1; // not zero Deoptimization::DeoptReason per_bc_reason = Deoptimization::reason_recorded_per_bytecode_if_any(reason); + ciMethod* m = Deoptimization::reason_is_speculate(reason) ? this->method() : NULL; if ((per_bc_reason == Deoptimization::Reason_none - || md->has_trap_at(bci, reason) != 0) + || md->has_trap_at(bci, m, reason) != 0) // The trap frequency measure we care about is the recompile count: - && md->trap_recompiled_at(bci) + && md->trap_recompiled_at(bci, m) && md->overflow_recompile_count() >= bc_cutoff) { // Do not emit a trap here if it has already caused recompilations. // Also, if there are multiple reasons, or if there is no per-BCI record, diff --git a/hotspot/src/share/vm/opto/doCall.cpp b/hotspot/src/share/vm/opto/doCall.cpp index e888b550f66..d56f460ea6d 100644 --- a/hotspot/src/share/vm/opto/doCall.cpp +++ b/hotspot/src/share/vm/opto/doCall.cpp @@ -250,7 +250,7 @@ CallGenerator* Compile::call_generator(ciMethod* callee, int vtable_index, bool CallGenerator* miss_cg; Deoptimization::DeoptReason reason = morphism == 2 ? Deoptimization::Reason_bimorphic : - Deoptimization::Reason_class_check; + (speculative_receiver_type == NULL ? Deoptimization::Reason_class_check : Deoptimization::Reason_speculate_class_check); if ((morphism == 1 || (morphism == 2 && next_hit_cg != NULL)) && !too_many_traps(jvms->method(), jvms->bci(), reason) ) { diff --git a/hotspot/src/share/vm/opto/graphKit.cpp b/hotspot/src/share/vm/opto/graphKit.cpp index af4b2f452a2..d2876a93a5e 100644 --- a/hotspot/src/share/vm/opto/graphKit.cpp +++ b/hotspot/src/share/vm/opto/graphKit.cpp @@ -612,9 +612,10 @@ void GraphKit::builtin_throw(Deoptimization::DeoptReason reason, Node* arg) { // Usual case: Bail to interpreter. // Reserve the right to recompile if we haven't seen anything yet. + assert(!Deoptimization::reason_is_speculate(reason), "unsupported"); Deoptimization::DeoptAction action = Deoptimization::Action_maybe_recompile; if (treat_throw_as_hot - && (method()->method_data()->trap_recompiled_at(bci()) + && (method()->method_data()->trap_recompiled_at(bci(), NULL) || C->too_many_traps(reason))) { // We cannot afford to take more traps here. Suffer in the interpreter. if (C->log() != NULL) @@ -2145,7 +2146,7 @@ Node* GraphKit::record_profile_for_speculation(Node* n, ciKlass* exact_kls) { * * @param n receiver node * - * @return node with improved type + * @return node with improved type */ Node* GraphKit::record_profiled_receiver_for_speculation(Node* n) { if (!UseTypeSpeculation) { @@ -2739,12 +2740,14 @@ bool GraphKit::seems_never_null(Node* obj, ciProfileData* data) { // Subsequent type checks will always fold up. Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj, ciKlass* require_klass, - ciKlass* spec_klass, + ciKlass* spec_klass, bool safe_for_replace) { if (!UseTypeProfile || !TypeProfileCasts) return NULL; + Deoptimization::DeoptReason reason = spec_klass == NULL ? Deoptimization::Reason_class_check : Deoptimization::Reason_speculate_class_check; + // Make sure we haven't already deoptimized from this tactic. - if (too_many_traps(Deoptimization::Reason_class_check)) + if (too_many_traps(reason)) return NULL; // (No, this isn't a call, but it's enough like a virtual call @@ -2766,7 +2769,7 @@ Node* GraphKit::maybe_cast_profiled_receiver(Node* not_null_obj, &exact_obj); { PreserveJVMState pjvms(this); set_control(slow_ctl); - uncommon_trap(Deoptimization::Reason_class_check, + uncommon_trap(reason, Deoptimization::Action_maybe_recompile); } if (safe_for_replace) { @@ -2793,8 +2796,10 @@ Node* GraphKit::maybe_cast_profiled_obj(Node* obj, bool not_null) { // type == NULL if profiling tells us this object is always null if (type != NULL) { - if (!too_many_traps(Deoptimization::Reason_null_check) && - !too_many_traps(Deoptimization::Reason_class_check)) { + Deoptimization::DeoptReason class_reason = Deoptimization::Reason_speculate_class_check; + Deoptimization::DeoptReason null_reason = Deoptimization::Reason_null_check; + if (!too_many_traps(null_reason) && + !too_many_traps(class_reason)) { Node* not_null_obj = NULL; // not_null is true if we know the object is not null and // there's no need for a null check @@ -2813,7 +2818,7 @@ Node* GraphKit::maybe_cast_profiled_obj(Node* obj, { PreserveJVMState pjvms(this); set_control(slow_ctl); - uncommon_trap(Deoptimization::Reason_class_check, + uncommon_trap(class_reason, Deoptimization::Action_maybe_recompile); } replace_in_map(not_null_obj, exact_obj); @@ -2882,7 +2887,7 @@ Node* GraphKit::gen_instanceof(Node* obj, Node* superklass, bool safe_for_replac } if (known_statically && UseTypeSpeculation) { - // If we know the type check always succeed then we don't use the + // If we know the type check always succeeds then we don't use the // profiling data at this bytecode. Don't lose it, feed it to the // type system as a speculative type. not_null_obj = record_profiled_receiver_for_speculation(not_null_obj); diff --git a/hotspot/src/share/vm/opto/graphKit.hpp b/hotspot/src/share/vm/opto/graphKit.hpp index e49c4684686..fbbf8c9aa86 100644 --- a/hotspot/src/share/vm/opto/graphKit.hpp +++ b/hotspot/src/share/vm/opto/graphKit.hpp @@ -406,7 +406,7 @@ class GraphKit : public Phase { // Use the type profile to narrow an object type. Node* maybe_cast_profiled_receiver(Node* not_null_obj, ciKlass* require_klass, - ciKlass* spec, + ciKlass* spec, bool safe_for_replace); // Cast obj to type and emit guard unless we had too many traps here already diff --git a/hotspot/src/share/vm/runtime/deoptimization.cpp b/hotspot/src/share/vm/runtime/deoptimization.cpp index 69b9e86c582..b1b078f6491 100644 --- a/hotspot/src/share/vm/runtime/deoptimization.cpp +++ b/hotspot/src/share/vm/runtime/deoptimization.cpp @@ -1489,6 +1489,7 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint tra bool maybe_prior_trap = false; bool maybe_prior_recompile = false; pdata = query_update_method_data(trap_mdo, trap_bci, reason, + nm->method(), //outputs: this_trap_count, maybe_prior_trap, @@ -1534,7 +1535,7 @@ JRT_ENTRY(void, Deoptimization::uncommon_trap_inner(JavaThread* thread, jint tra } // Go back to the compiler if there are too many traps in this method. - if (this_trap_count >= (uint)PerMethodTrapLimit) { + if (this_trap_count >= per_method_trap_limit(reason)) { // If there are too many traps in this method, force a recompile. // This will allow the compiler to see the limit overflow, and // take corrective action, if possible. @@ -1622,6 +1623,7 @@ ProfileData* Deoptimization::query_update_method_data(MethodData* trap_mdo, int trap_bci, Deoptimization::DeoptReason reason, + Method* compiled_method, //outputs: uint& ret_this_trap_count, bool& ret_maybe_prior_trap, @@ -1645,9 +1647,16 @@ Deoptimization::query_update_method_data(MethodData* trap_mdo, // Find the profile data for this BCI. If there isn't one, // try to allocate one from the MDO's set of spares. // This will let us detect a repeated trap at this point. - pdata = trap_mdo->allocate_bci_to_data(trap_bci); + pdata = trap_mdo->allocate_bci_to_data(trap_bci, reason_is_speculate(reason) ? compiled_method : NULL); if (pdata != NULL) { + if (reason_is_speculate(reason) && !pdata->is_SpeculativeTrapData()) { + if (LogCompilation && xtty != NULL) { + ttyLocker ttyl; + // no more room for speculative traps in this MDO + xtty->elem("speculative_traps_oom"); + } + } // Query the trap state of this profile datum. int tstate0 = pdata->trap_state(); if (!trap_state_has_reason(tstate0, per_bc_reason)) @@ -1685,8 +1694,10 @@ Deoptimization::update_method_data_from_interpreter(MethodData* trap_mdo, int tr uint ignore_this_trap_count; bool ignore_maybe_prior_trap; bool ignore_maybe_prior_recompile; + assert(!reason_is_speculate(reason), "reason speculate only used by compiler"); query_update_method_data(trap_mdo, trap_bci, (DeoptReason)reason, + NULL, ignore_this_trap_count, ignore_maybe_prior_trap, ignore_maybe_prior_recompile); @@ -1814,7 +1825,8 @@ const char* Deoptimization::_trap_reason_name[Reason_LIMIT] = { "div0_check", "age", "predicate", - "loop_limit_check" + "loop_limit_check", + "speculate_class_check" }; const char* Deoptimization::_trap_action_name[Action_LIMIT] = { // Note: Keep this in sync. with enum DeoptAction. diff --git a/hotspot/src/share/vm/runtime/deoptimization.hpp b/hotspot/src/share/vm/runtime/deoptimization.hpp index a32e33ca928..f2233c9869b 100644 --- a/hotspot/src/share/vm/runtime/deoptimization.hpp +++ b/hotspot/src/share/vm/runtime/deoptimization.hpp @@ -59,6 +59,7 @@ class Deoptimization : AllStatic { Reason_age, // nmethod too old; tier threshold reached Reason_predicate, // compiler generated predicate failed Reason_loop_limit_check, // compiler generated loop limits check failed + Reason_speculate_class_check, // saw unexpected object class from type speculation Reason_LIMIT, // Note: Keep this enum in sync. with _trap_reason_name. Reason_RECORDED_LIMIT = Reason_bimorphic // some are not recorded per bc @@ -311,10 +312,23 @@ class Deoptimization : AllStatic { return reason; else if (reason == Reason_div0_check) // null check due to divide-by-zero? return Reason_null_check; // recorded per BCI as a null check + else if (reason == Reason_speculate_class_check) + return Reason_class_check; else return Reason_none; } + static bool reason_is_speculate(int reason) { + if (reason == Reason_speculate_class_check) { + return true; + } + return false; + } + + static uint per_method_trap_limit(int reason) { + return reason_is_speculate(reason) ? (uint)PerMethodSpecTrapLimit : (uint)PerMethodTrapLimit; + } + static const char* trap_reason_name(int reason); static const char* trap_action_name(int action); // Format like reason='foo' action='bar' index='123'. @@ -337,6 +351,7 @@ class Deoptimization : AllStatic { static ProfileData* query_update_method_data(MethodData* trap_mdo, int trap_bci, DeoptReason reason, + Method* compiled_method, //outputs: uint& ret_this_trap_count, bool& ret_maybe_prior_trap, diff --git a/hotspot/src/share/vm/runtime/globals.hpp b/hotspot/src/share/vm/runtime/globals.hpp index d9cd10f9c3c..b971907b980 100644 --- a/hotspot/src/share/vm/runtime/globals.hpp +++ b/hotspot/src/share/vm/runtime/globals.hpp @@ -3078,9 +3078,15 @@ class CommandLineFlags { product(intx, PerMethodTrapLimit, 100, \ "Limit on traps (of one kind) in a method (includes inlines)") \ \ + experimental(intx, PerMethodSpecTrapLimit, 5000, \ + "Limit on speculative traps (of one kind) in a method (includes inlines)") \ + \ product(intx, PerBytecodeTrapLimit, 4, \ "Limit on traps (of one kind) at a particular BCI") \ \ + experimental(intx, SpecTrapLimitExtraEntries, 3, \ + "Extra method data trap entries for speculation") \ + \ develop(intx, InlineFrequencyRatio, 20, \ "Ratio of call site execution to caller method invocation") \ \ diff --git a/hotspot/test/compiler/uncommontrap/TestSpecTrapClassUnloading.java b/hotspot/test/compiler/uncommontrap/TestSpecTrapClassUnloading.java new file mode 100644 index 00000000000..11572672afe --- /dev/null +++ b/hotspot/test/compiler/uncommontrap/TestSpecTrapClassUnloading.java @@ -0,0 +1,97 @@ +/* + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. + * + * This code is free software; you can redistribute it and/or modify it + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * 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 8031752 + * @summary speculative traps need to be cleaned up at GC + * @run main/othervm -XX:-TieredCompilation -XX:-UseOnStackReplacement -XX:-BackgroundCompilation -XX:+UnlockExperimentalVMOptions -XX:+UseTypeSpeculation -XX:TypeProfileLevel=222 -XX:CompileCommand=exclude,java.lang.reflect.Method::invoke -XX:CompileCommand=exclude,sun.reflect.DelegatingMethodAccessorImpl::invoke -Xmx1M TestSpecTrapClassUnloading + * + */ + +import java.lang.reflect.Method; + +public class TestSpecTrapClassUnloading { + static class B { + final public boolean m(Object o) { + if (o.getClass() == B.class) { + return true; + } + return false; + } + } + + static class MemoryChunk { + MemoryChunk other; + long[] array; + MemoryChunk(MemoryChunk other) { + other = other; + array = new long[1024 * 1024 * 1024]; + } + } + + static void m1(B b, Object o) { + b.m(o); + } + + static void m2(B b, Object o) { + b.m(o); + } + + public static void main(String[] args) throws Exception { + Method m = B.class.getMethod("m", Object.class); + Object o = new Object(); + B b = new B(); + + // add speculative trap in B.m() for m1 + for (int i = 0; i < 20000; i++) { + m1(b, b); + } + m1(b, o); + + // add speculative trap in B.m() for code generated by reflection + for (int i = 0; i < 20000; i++) { + m.invoke(b, b); + } + m.invoke(b, o); + + m = null; + + // add speculative trap in B.m() for m2 + for (int i = 0; i < 20000; i++) { + m2(b, b); + } + m2(b, o); + + // Exhaust memory which causes the code generated by + // reflection to be unloaded but B.m() is not. + MemoryChunk root = null; + try { + while (true) { + root = new MemoryChunk(root); + } + } catch(OutOfMemoryError e) { + root = null; + } + } +} From 39b5a040cd0ba9af055e48257ae00af3d1d0c5cb Mon Sep 17 00:00:00 2001 From: Albert Noll Date: Wed, 26 Feb 2014 07:44:59 +0100 Subject: [PATCH 158/159] 8032642: [TESTBUG] Fix testbugs in compiler/startup/.* Fixed issues with these tests Reviewed-by: kvn, twisti --- .../compiler/startup/SmallCodeCacheStartup.java | 16 +++++----------- hotspot/test/compiler/startup/StartupOutput.java | 3 +-- 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/hotspot/test/compiler/startup/SmallCodeCacheStartup.java b/hotspot/test/compiler/startup/SmallCodeCacheStartup.java index 7a9a11a0836..5db43673fa8 100644 --- a/hotspot/test/compiler/startup/SmallCodeCacheStartup.java +++ b/hotspot/test/compiler/startup/SmallCodeCacheStartup.java @@ -24,19 +24,13 @@ /* * @test * @bug 8023014 - * @summary Test ensures that there is no crash when compiler initialization fails - * @library /testlibrary - * + * @summary Test ensures that there is no crash if there is not enough ReservedCodeacacheSize + * to initialize all compiler threads. The option -Xcomp gives the VM more time to + * to trigger the old bug. + * @run main/othervm -XX:ReservedCodeCacheSize=3m -XX:CICompilerCount=64 -Xcomp SmallCodeCacheStartup */ -import com.oracle.java.testlibrary.*; - public class SmallCodeCacheStartup { public static void main(String[] args) throws Exception { - ProcessBuilder pb; - OutputAnalyzer out; - - pb = ProcessTools.createJavaProcessBuilder("-XX:ReservedCodeCacheSize=3m", "-XX:CICompilerCount=64", "-version"); - out = new OutputAnalyzer(pb.start()); - out.shouldHaveExitValue(0); + System.out.println("TEST PASSED"); } } diff --git a/hotspot/test/compiler/startup/StartupOutput.java b/hotspot/test/compiler/startup/StartupOutput.java index f677853d51c..e4a1b4cd4c5 100644 --- a/hotspot/test/compiler/startup/StartupOutput.java +++ b/hotspot/test/compiler/startup/StartupOutput.java @@ -25,8 +25,7 @@ * @test * @bug 8026949 * @summary Test ensures correct VM output during startup - * @library ../../testlibrary - * + * @library /testlibrary */ import com.oracle.java.testlibrary.*; From 94a86285a7a3d61a4b278ad11b5bea7c28b94609 Mon Sep 17 00:00:00 2001 From: Niclas Adlertz Date: Wed, 26 Feb 2014 07:46:46 +0100 Subject: [PATCH 159/159] 8010500: [parfait] Possible null pointer dereference at hotspot/src/share/vm/opto/loopnode.hpp Added NULL check for loopnode() in get_pre_loop_end() Reviewed-by: kvn, roland --- hotspot/src/share/vm/opto/superword.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/hotspot/src/share/vm/opto/superword.cpp b/hotspot/src/share/vm/opto/superword.cpp index 96c81bd999c..9363caa1da4 100644 --- a/hotspot/src/share/vm/opto/superword.cpp +++ b/hotspot/src/share/vm/opto/superword.cpp @@ -441,6 +441,7 @@ bool SuperWord::ref_is_alignable(SWPointer& p) { return true; // no induction variable } CountedLoopEndNode* pre_end = get_pre_loop_end(lp()->as_CountedLoop()); + assert(pre_end != NULL, "we must have a correct pre-loop"); assert(pre_end->stride_is_con(), "pre loop stride is constant"); int preloop_stride = pre_end->stride_con(); @@ -1981,7 +1982,7 @@ void SuperWord::align_initial_loop_index(MemNode* align_to_ref) { CountedLoopNode *main_head = lp()->as_CountedLoop(); assert(main_head->is_main_loop(), ""); CountedLoopEndNode* pre_end = get_pre_loop_end(main_head); - assert(pre_end != NULL, ""); + assert(pre_end != NULL, "we must have a correct pre-loop"); Node *pre_opaq1 = pre_end->limit(); assert(pre_opaq1->Opcode() == Op_Opaque1, ""); Opaque1Node *pre_opaq = (Opaque1Node*)pre_opaq1; @@ -2145,7 +2146,8 @@ CountedLoopEndNode* SuperWord::get_pre_loop_end(CountedLoopNode *cl) { if (!p_f->is_IfFalse()) return NULL; if (!p_f->in(0)->is_CountedLoopEnd()) return NULL; CountedLoopEndNode *pre_end = p_f->in(0)->as_CountedLoopEnd(); - if (!pre_end->loopnode()->is_pre_loop()) return NULL; + CountedLoopNode* loop_node = pre_end->loopnode(); + if (loop_node == NULL || !loop_node->is_pre_loop()) return NULL; return pre_end; }