OpenJDK / portola / portola
changeset 40693:364c71c3a981
Merge
author | amurillo |
---|---|
date | Wed, 31 Aug 2016 09:22:54 -0700 |
parents | c78ba191f4bf c74de0698d08 |
children | 759341b4bd03 |
files | jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolver.java jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java jdk/make/data/cryptopolicy/limited/default_local.policy jdk/make/data/cryptopolicy/limited/exempt_local.policy jdk/make/data/cryptopolicy/unlimited/default_US_export.policy jdk/make/data/cryptopolicy/unlimited/default_local.policy jdk/make/gendata/GendataPolicyJars.gmk jdk/test/sun/security/krb5/auto/unreachable.krb5.conf langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocletAbortException.java |
diffstat | 369 files changed, 10683 insertions(+), 3227 deletions(-) [+] |
line wrap: on
line diff
--- a/.hgtags Fri Aug 26 10:02:50 2016 -0700 +++ b/.hgtags Wed Aug 31 09:22:54 2016 -0700 @@ -375,3 +375,4 @@ e613affb88d178dc7c589f1679db113d589bddb4 jdk-9+130 4d2a15091124488080d65848b704e25599b2aaeb jdk-9+131 2e83d21d78cd9c1d52e6cd2599e9c8aa36ea1f52 jdk-9+132 +e17429a7e843c4a4ed3651458d0f950970edcbcc jdk-9+133
--- a/.hgtags-top-repo Fri Aug 26 10:02:50 2016 -0700 +++ b/.hgtags-top-repo Wed Aug 31 09:22:54 2016 -0700 @@ -375,3 +375,4 @@ d94d54a3192fea79234c3ac55cd0b4052d45e954 jdk-9+130 8728756c2f70a79a90188f4019cfd6b9a275765c jdk-9+131 a24702d4d5ab0015a5c553ed57f66fce7d85155e jdk-9+132 +be1218f792a450dfb5d4b1f82616b9d95a6a732e jdk-9+133
--- a/corba/.hgtags Fri Aug 26 10:02:50 2016 -0700 +++ b/corba/.hgtags Wed Aug 31 09:22:54 2016 -0700 @@ -375,3 +375,4 @@ 77f9692d5976ae155773dd3e07533616bb95bae1 jdk-9+130 f7e1d5337c2e550fe553df7a3886bbed80292ecd jdk-9+131 1ab4b9399c4cba584f66c1c088188f2f565fbf9c jdk-9+132 +2021bfedf1c478a4808a7711a6090682a12f4c0e jdk-9+133
--- a/hotspot/.hgtags Fri Aug 26 10:02:50 2016 -0700 +++ b/hotspot/.hgtags Wed Aug 31 09:22:54 2016 -0700 @@ -535,3 +535,4 @@ 7d54c7056328b6a2bf4877458b8f4d8cd870f93b jdk-9+130 943bf73b49c33c2d7cbd796f6a4ae3c7a00ae932 jdk-9+131 713951c08aa26813375175c2ab6cc99ff2a56903 jdk-9+132 +a25e0fb6033245ab075136e744d362ce765464cd jdk-9+133
--- a/hotspot/src/share/vm/gc/g1/g1Analytics.cpp Fri Aug 26 10:02:50 2016 -0700 +++ b/hotspot/src/share/vm/gc/g1/g1Analytics.cpp Wed Aug 31 09:22:54 2016 -0700 @@ -316,14 +316,10 @@ return get_new_size_prediction(_pending_cards_seq); } -double G1Analytics::oldest_known_gc_end_time_sec() const { +double G1Analytics::last_known_gc_end_time_sec() const { return _recent_prev_end_times_for_all_gcs_sec->oldest(); } -double G1Analytics::last_known_gc_end_time_sec() const { - return _recent_prev_end_times_for_all_gcs_sec->last(); -} - void G1Analytics::update_recent_gc_times(double end_time_sec, double pause_time_ms) { _recent_gc_times_ms->add(pause_time_ms);
--- a/hotspot/src/share/vm/gc/g1/g1Analytics.hpp Fri Aug 26 10:02:50 2016 -0700 +++ b/hotspot/src/share/vm/gc/g1/g1Analytics.hpp Wed Aug 31 09:22:54 2016 -0700 @@ -155,7 +155,6 @@ void update_recent_gc_times(double end_time_sec, double elapsed_ms); void compute_pause_time_ratio(double interval_ms, double pause_time_ms); - double oldest_known_gc_end_time_sec() const; double last_known_gc_end_time_sec() const; };
--- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp Fri Aug 26 10:02:50 2016 -0700 +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp Wed Aug 31 09:22:54 2016 -0700 @@ -28,7 +28,6 @@ #include "classfile/symbolTable.hpp" #include "code/codeCache.hpp" #include "code/icBuffer.hpp" -#include "gc/g1/g1Analytics.hpp" #include "gc/g1/bufferingOopClosure.hpp" #include "gc/g1/concurrentG1Refine.hpp" #include "gc/g1/concurrentG1RefineThread.hpp" @@ -2474,19 +2473,8 @@ } jlong G1CollectedHeap::millis_since_last_gc() { - jlong now = os::elapsed_counter() / NANOSECS_PER_MILLISEC; - const G1Analytics* analytics = _g1_policy->analytics(); - double last = analytics->last_known_gc_end_time_sec(); - jlong ret_val = now - (last * 1000); - if (ret_val < 0) { - // See the notes in GenCollectedHeap::millis_since_last_gc() - // for more information about the implementation. - log_warning(gc)("Detected clock going backwards. " - "Milliseconds since last GC would be " JLONG_FORMAT - ". returning zero instead.", ret_val); - return 0; - } - return ret_val; + // assert(false, "NYI"); + return 0; } void G1CollectedHeap::prepare_for_verify() {
--- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp Fri Aug 26 10:02:50 2016 -0700 +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp Wed Aug 31 09:22:54 2016 -0700 @@ -604,7 +604,7 @@ _analytics->report_alloc_rate_ms(alloc_rate_ms); double interval_ms = - (end_time_sec - _analytics->oldest_known_gc_end_time_sec()) * 1000.0; + (end_time_sec - _analytics->last_known_gc_end_time_sec()) * 1000.0; _analytics->update_recent_gc_times(end_time_sec, pause_time_ms); _analytics->compute_pause_time_ratio(interval_ms, pause_time_ms); }
--- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp Fri Aug 26 10:02:50 2016 -0700 +++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp Wed Aug 31 09:22:54 2016 -0700 @@ -1256,21 +1256,21 @@ }; jlong GenCollectedHeap::millis_since_last_gc() { - // javaTimeNanos() is guaranteed to be monotonically non-decreasing - // provided the underlying platform provides such a time source - // (and it is bug free). So we still have to guard against getting - // back a time later than 'now'. + // We need a monotonically non-decreasing time in ms but + // os::javaTimeMillis() does not guarantee monotonicity. jlong now = os::javaTimeNanos() / NANOSECS_PER_MILLISEC; GenTimeOfLastGCClosure tolgc_cl(now); // iterate over generations getting the oldest // time that a generation was collected generation_iterate(&tolgc_cl, false); + // javaTimeNanos() is guaranteed to be monotonically non-decreasing + // provided the underlying platform provides such a time source + // (and it is bug free). So we still have to guard against getting + // back a time later than 'now'. jlong retVal = now - tolgc_cl.time(); if (retVal < 0) { - log_warning(gc)("Detected clock going backwards. " - "Milliseconds since last GC would be " JLONG_FORMAT - ". returning zero instead.", retVal); + NOT_PRODUCT(log_warning(gc)("time warp: " JLONG_FORMAT, retVal);) return 0; } return retVal;
--- a/jaxp/.hgtags Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/.hgtags Wed Aug 31 09:22:54 2016 -0700 @@ -375,3 +375,4 @@ e66cdc2de6b02443911d386fc9217b0d824d0686 jdk-9+130 874082a9b565a7092a40bfa934a6e3e3c3455a60 jdk-9+131 907445d85e680ea410fe2c83c0ec64b5508e4f3e jdk-9+132 +9490ba2e5e41685c858a0ca2a6ec87611eb011c6 jdk-9+133
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,15 +1,15 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 2001-2004 The Apache Software Foundation. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -170,6 +170,14 @@ "Invalid URI ''{0}''."}, /* + * Note to translators: This message is displayed when the URI + * mentioned in the substitution text is not well-formed syntactically. + */ + {ErrorMsg.CATALOG_EXCEPTION, + "JAXP08090001: The CatalogResolver is enabled with the catalog \"{0}\", " + + "but a CatalogException is returned."}, + + /* * Note to translators: The file or URI named in the substitution text * exists but could not be opened. */
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,15 +1,15 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2013, 2016, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 2001-2004 The Apache Software Foundation. + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 + * 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, @@ -17,9 +17,6 @@ * See the License for the specific language governing permissions and * limitations under the License. */ -/* - * $Id: ErrorMsg.java,v 1.2.4.1 2005/09/15 10:18:01 pvedula Exp $ - */ package com.sun.org.apache.xalan.internal.xsltc.compiler.util; @@ -60,6 +57,7 @@ public static final String ARGUMENT_CONVERSION_ERR = "ARGUMENT_CONVERSION_ERR"; public static final String FILE_NOT_FOUND_ERR = "FILE_NOT_FOUND_ERR"; public static final String INVALID_URI_ERR = "INVALID_URI_ERR"; + public static final String CATALOG_EXCEPTION = "CATALOG_EXCEPTION"; public static final String FILE_ACCESS_ERR = "FILE_ACCESS_ERR"; public static final String MISSING_ROOT_ERR = "MISSING_ROOT_ERR"; public static final String NAMESPACE_UNDEF_ERR = "NAMESPACE_UNDEF_ERR";
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java Wed Aug 31 09:22:54 2016 -0700 @@ -51,10 +51,11 @@ import java.util.zip.ZipEntry; import java.util.zip.ZipFile; import javax.xml.XMLConstants; +import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogFeatures.Feature; import javax.xml.catalog.CatalogManager; -import javax.xml.catalog.CatalogUriResolver; +import javax.xml.catalog.CatalogResolver; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; import javax.xml.transform.ErrorListener; @@ -241,7 +242,7 @@ // type checking private Map<String, Class> _xsltcExtensionFunctions; - CatalogUriResolver _catalogUriResolver; + CatalogResolver _catalogUriResolver; CatalogFeatures _catalogFeatures; CatalogFeatures.Builder cfBuilder = CatalogFeatures.builder(); // Catalog features @@ -634,7 +635,7 @@ } // Inefficient, but array is small - for (int i = 0; i < features.length; i++) { + for (int i =0; i < features.length; i++) { if (name.equals(features[i])) { return true; } @@ -923,7 +924,7 @@ String transletClassName = getTransletBaseName(source); if (_packageName != null) - transletClassName = _packageName + "." + transletClassName; + transletClassName = _packageName + "." + transletClassName; if (_jarFileName != null) bytecodes = getBytecodesFromJar(source, transletClassName); @@ -1327,7 +1328,7 @@ if (source == null && _catalogFiles != null && _xmlFeatures.getFeature(JdkXmlFeatures.XmlFeature.USE_CATALOG)) { if (_catalogUriResolver == null) { - _catalogUriResolver = CatalogManager.catalogUriResolver(_catalogFeatures); + _catalogUriResolver = CatalogManager.catalogResolver(_catalogFeatures); } source = _catalogUriResolver.resolve(href, context); } @@ -1340,6 +1341,10 @@ final ErrorMsg msg = new ErrorMsg(ErrorMsg.INVALID_URI_ERR, href + "\n" + e.getMessage(), this); xsltc.getParser().reportError(Constants.FATAL, msg); } + catch (CatalogException e) { + final ErrorMsg msg = new ErrorMsg(ErrorMsg.CATALOG_EXCEPTION, href + "\n" + e.getMessage(), this); + xsltc.getParser().reportError(Constants.FATAL, msg); + } return null; }
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java Wed Aug 31 09:22:54 2016 -0700 @@ -60,9 +60,10 @@ import java.util.Properties; import java.util.StringTokenizer; import javax.xml.XMLConstants; +import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogManager; -import javax.xml.catalog.CatalogUriResolver; +import javax.xml.catalog.CatalogResolver; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -224,7 +225,7 @@ // Catalog features CatalogFeatures _catalogFeatures; - CatalogUriResolver _catalogUriResolver; + CatalogResolver _catalogUriResolver; // Catalog is enabled by default boolean _useCatalog = true; @@ -1337,7 +1338,7 @@ if (resolvedSource == null && _useCatalog && _catalogFeatures.get(CatalogFeatures.Feature.FILES) != null) { if (_catalogUriResolver == null) { - _catalogUriResolver = CatalogManager.catalogUriResolver(_catalogFeatures); + _catalogUriResolver = CatalogManager.catalogResolver(_catalogFeatures); } resolvedSource = _catalogUriResolver.resolve(href, baseURI); } @@ -1350,7 +1351,7 @@ return getDOM(resolvedSource); } - catch (TransformerException e) { + catch (TransformerException | CatalogException e) { if (_errorListener != null) postErrorToListener("File not found: " + e.getMessage()); return(null);
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java Wed Aug 31 09:22:54 2016 -0700 @@ -511,7 +511,8 @@ //fDocumentHandler.endElement(getElementQName(),null); break; default : - throw new InternalError("processing event: " + event); + // Errors should have already been handled by the Scanner + return false; } //System.out.println("here in before calling next");
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java Wed Aug 31 09:22:54 2016 -0700 @@ -20,8 +20,6 @@ package com.sun.org.apache.xerces.internal.impl ; -import com.sun.org.apache.xerces.internal.impl.Constants; -import com.sun.org.apache.xerces.internal.impl.XMLEntityHandler; import com.sun.org.apache.xerces.internal.impl.io.ASCIIReader; import com.sun.org.apache.xerces.internal.impl.io.UCSReader; import com.sun.org.apache.xerces.internal.impl.io.UTF8Reader; @@ -42,7 +40,6 @@ import com.sun.xml.internal.stream.StaxXMLInputSource; import com.sun.xml.internal.stream.XMLEntityStorage; import java.io.*; -import java.lang.reflect.Method; import java.net.HttpURLConnection; import java.net.URISyntaxException; import java.net.URL; @@ -59,7 +56,6 @@ import javax.xml.catalog.CatalogFeatures.Feature; import javax.xml.catalog.CatalogManager; import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogUriResolver; import javax.xml.stream.XMLInputFactory; import javax.xml.transform.Source; import jdk.xml.internal.JdkXmlUtils; @@ -420,7 +416,6 @@ private boolean fUseCatalog = true; CatalogFeatures fCatalogFeatures; CatalogResolver fCatalogResolver; - CatalogUriResolver fCatalogUriResolver; private String fCatalogFile; private String fDefer; @@ -1044,12 +1039,18 @@ } fCatalogFile = fCatalogFeatures.get(Feature.FILES); if (fUseCatalog && fCatalogFile != null) { - if (fCatalogResolver == null) { - fCatalogResolver = CatalogManager.catalogResolver(fCatalogFeatures); - } - InputSource is = fCatalogResolver.resolveEntity(publicId, literalSystemId); - if (is != null && !is.isEmpty()) { - staxInputSource = new StaxXMLInputSource(new XMLInputSource(is, true), true); + try { + if (fCatalogResolver == null) { + fCatalogResolver = CatalogManager.catalogResolver(fCatalogFeatures); + } + InputSource is = fCatalogResolver.resolveEntity(publicId, literalSystemId); + if (is != null && !is.isEmpty()) { + staxInputSource = new StaxXMLInputSource(new XMLInputSource(is, true), true); + } + } catch (CatalogException e) { + fErrorReporter.reportError(XMLMessageFormatter.XML_DOMAIN,"CatalogException", + new Object[]{SecuritySupport.sanitizePath(fCatalogFile)}, + XMLErrorReporter.SEVERITY_FATAL_ERROR, e ); } } } @@ -1140,7 +1141,7 @@ if (fUseCatalog && fCatalogFile != null) { /* since the method can be called from various processors, both - CatalogResolver and CatalogUriResolver are used to attempt to find + EntityResolver and URIResolver are used to attempt to find a match */ InputSource is = null; @@ -1153,13 +1154,20 @@ is = fCatalogResolver.resolveEntity(pid, literalSystemId); } } catch (CatalogException e) {} + if (is != null && !is.isEmpty()) { xmlInputSource = new XMLInputSource(is, true); } else if (literalSystemId != null) { - if (fCatalogUriResolver == null) { - fCatalogUriResolver = CatalogManager.catalogUriResolver(fCatalogFeatures); + if (fCatalogResolver == null) { + fCatalogResolver = CatalogManager.catalogResolver(fCatalogFeatures); } - Source source = fCatalogUriResolver.resolve(literalSystemId, baseSystemId); + + Source source = null; + try { + source = fCatalogResolver.resolve(literalSystemId, baseSystemId); + } catch (CatalogException e) { + throw new XNIException(e); + } if (source != null && !source.isEmpty()) { xmlInputSource = new XMLInputSource(publicId, source.getSystemId(), baseSystemId, true); }
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties Wed Aug 31 09:22:54 2016 -0700 @@ -303,3 +303,5 @@ MaxElementDepthLimit=JAXP00010006: The element \"{0}\" has a depth of \"{1}\" that exceeds the limit \"{2}\" set by \"{3}\". EntityReplacementLimit=JAXP00010007: The total number of nodes in entity references is \"{0}\" that is over the limit \"{1}\" set by \"{2}\". +# Catalog 09 + CatalogException=JAXP00090001: The CatalogResolver is enabled with the catalog \"{0}\", but a CatalogException is returned. \ No newline at end of file
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/EntityResolverWrapper.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/EntityResolverWrapper.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,13 +1,13 @@ /* - * reserved comment block - * DO NOT REMOVE OR ALTER! + * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. */ /* - * Copyright 2001, 2002,2004 The Apache Software Foundation. - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at + * Licensed to the Apache Software Foundation (ASF) under one or more + * contributor license agreements. See the NOTICE file distributed with + * this work for additional information regarding copyright ownership. + * The ASF licenses this file to You under the Apache License, Version 2.0 + * (the "License"); you may not use this file except in compliance with + * the License. You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * @@ -28,6 +28,7 @@ import com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier; import com.sun.org.apache.xerces.internal.xni.parser.XMLEntityResolver; import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; +import javax.xml.catalog.CatalogException; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; @@ -132,6 +133,10 @@ } throw new XNIException(ex); } + + catch (CatalogException e) { + throw new XNIException(e); + } } // unable to resolve entity
--- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 2016, Oracle and/or its affiliates. All rights reserved. */ /* * Licensed to the Apache Software Foundation (ASF) under one or more @@ -75,7 +75,6 @@ import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogManager; import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogUriResolver; import javax.xml.transform.Source; import jdk.xml.internal.JdkXmlUtils; import org.xml.sax.InputSource; @@ -371,7 +370,6 @@ private boolean fUseCatalog = true; CatalogFeatures fCatalogFeatures; CatalogResolver fCatalogResolver; - CatalogUriResolver fCatalogUriResolver; private String fCatalogFile; private String fDefer; @@ -1638,10 +1636,10 @@ */ Source source = null; try { - if (fCatalogUriResolver == null) { - fCatalogUriResolver = CatalogManager.catalogUriResolver(fCatalogFeatures); + if (fCatalogResolver == null) { + fCatalogResolver = CatalogManager.catalogResolver(fCatalogFeatures); } - source = fCatalogUriResolver.resolve(href, fCurrentBaseURI.getExpandedSystemId()); + source = fCatalogResolver.resolve(href, fCurrentBaseURI.getExpandedSystemId()); } catch (CatalogException e) {} if (source != null && !source.isEmpty()) { @@ -1669,7 +1667,7 @@ includedSource.getBaseSystemId(), accept, acceptLanguage); } } - catch (IOException e) { + catch (IOException | CatalogException e) { reportResourceError( "XMLResourceError", new Object[] { href, e.getMessage()});
--- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxEntityResolverWrapper.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxEntityResolverWrapper.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 com.sun.org.apache.xerces.internal.xni.XMLResourceIdentifier; import com.sun.org.apache.xerces.internal.xni.XNIException; import com.sun.org.apache.xerces.internal.xni.parser.XMLInputSource; +import javax.xml.catalog.CatalogException; /** * @@ -58,11 +59,11 @@ public StaxXMLInputSource resolveEntity(XMLResourceIdentifier resourceIdentifier) throws XNIException, java.io.IOException { Object object = null ; - try{ + try { object = fStaxResolver.resolveEntity(resourceIdentifier.getPublicId(), resourceIdentifier.getLiteralSystemId(), resourceIdentifier.getBaseSystemId(), null); return getStaxInputSource(object) ; - }catch(XMLStreamException streamException){ + } catch(XMLStreamException | CatalogException streamException){ throw new XNIException(streamException) ; } }
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,9 +42,9 @@ * <p> * A catalog can be used in two situations: * <ul> - * <li>Locate the replacement text for an external entity; + * <li>Locate the external resources with a public or system identifier; * </li> - * <li>Locate an alternate URI reference for a resource. + * <li>Locate an alternate URI reference with an URI. * </li> * </ul> * <p>
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,17 +77,6 @@ } /** - * Creates an instance of a {@code CatalogUriResolver} using the specified catalog. - * - * @param catalog the catalog instance - * @return an instance of a {@code CatalogResolver} - */ - public static CatalogUriResolver catalogUriResolver(Catalog catalog) { - if (catalog == null) CatalogMessages.reportNPEOnNull("catalog", null); - return new CatalogUriResolverImpl(catalog); - } - - /** * Creates an instance of a {@code CatalogResolver} using the specified feature * settings and path to one or more catalog files. * <p> @@ -115,33 +104,4 @@ Catalog catalog = catalog(features, paths); return new CatalogResolverImpl(catalog); } - - /** - * Creates an instance of a {@code CatalogUriResolver} using the specified - * feature settings and path to one or more catalog files. - * <p> - * If {@code paths} is empty, system property {@code javax.xml.catalog.files} - * will be read to locate the initial list of catalog files. - * <p> - * If more than one catalog files are specified through the paths argument or - * {@code javax.xml.catalog.files} property, the first entry is considered - * the main catalog, while others are treated as alternative catalogs after - * those referenced by the {@code nextCatalog} elements in the main catalog. - * <p> - * As specified in - * <a href="https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html#s.res.fail"> - * XML Catalogs, OASIS Standard V1.1</a>, invalid path entries will be ignored. - * No error will be reported. In case all entries are invalid, the resolver - * will return as no mapping is found. - * - * @param features the catalog features - * @param paths the path(s) to one or more catalogs - * - * @return an instance of a {@code CatalogUriResolver} - * @throws CatalogException If an error occurs while parsing the catalog - */ - public static CatalogUriResolver catalogUriResolver(CatalogFeatures features, String... paths) { - Catalog catalog = catalog(features, paths); - return new CatalogUriResolverImpl(catalog); - } }
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,32 +24,90 @@ */ package javax.xml.catalog; +import java.io.InputStream; +import javax.xml.stream.XMLResolver; +import javax.xml.transform.Source; +import javax.xml.transform.URIResolver; +import org.w3c.dom.ls.LSInput; +import org.w3c.dom.ls.LSResourceResolver; import org.xml.sax.EntityResolver; import org.xml.sax.InputSource; /** - * A SAX EntityResolver that uses catalogs to resolve references. + * A Catalog Resolver that implements SAX {@link org.xml.sax.EntityResolver}, + * StAX {@link javax.xml.stream.XMLResolver}, + * DOM LS {@link org.w3c.dom.ls.LSResourceResolver} used by Schema Validation, and + * Transform {@link javax.xml.transform.URIResolver}, and resolves + * external references using catalogs. + * <p> + * The <a href="https://www.oasis-open.org/committees/download.php/14809/xml-catalogs.html"> + * Catalog Standard</a> distinguished {@code external identifiers} from {@code uri entries} + * as being used to solely identify DTDs, while {@code uri entries} for + * other resources such as stylesheets and schema. The Java APIs, such as + * {@link javax.xml.stream.XMLResolver} and {@link org.w3c.dom.ls.LSResourceResolver} + * however, make no such distinction. + * In consistent with the existing Java API, this CatalogResolver recognizes a + * system identifier as an URI and will search both {@code system} and {@code uri} + * entries in a catalog in order to find a matching entry. + * <p> + * The search is started in the current catalog. If a match is found, + * no further attempt will be made. Only if there is no match in the current + * catalog, will alternate catalogs including delegate and next catalogs be considered. + * <p> + * <h3>Search Order</h3> + * The resolver will first search the system-type of entries with the specified + * {@code systemId}. The system entries include {@code system}, + * {@code rewriteSystem} and {@code systemSuffix} entries. + * <p> + * If no match is found, {@code public} entries may be searched in accordance with + * the {@code prefer} attribute. + * <p> + * <b>The {@code prefer} attribute</b>: if the {@code prefer} is public, + * and there is no match found through the system entries, {@code public} entries + * will be considered. If it is not specified, the {@code prefer} is public + * by default (Note that by the OASIS standard, system entries will always + * be considered before public entries. Prefer public means that public entries + * will be matched when both system and public identifiers are specified. + * In general therefore, prefer public is recommended.) + * <p> + * If no match is found with the {@code systemId} and {@code public} identifier, + * the resolver will continue searching {@code uri} entries + * with the specified {@code systemId} or {@code href}. The {@code uri} entries + * include {@code uri}, {@code rewriteURI}, and {@code uriSuffix} entries. + * + * <p> + * <h3>Error Handling</h3> + * The interfaces that the CatalogResolver extend specified checked exceptions, including: + * <ul> + * <li> + * {@link org.xml.sax.SAXException} and {@link java.io.IOException} by + * {@link org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)} + * </li> + * <li> + * {@link javax.xml.stream.XMLStreamException} by + * {@link javax.xml.stream.XMLResolver#resolveEntity(java.lang.String, java.lang.String, java.lang.String, java.lang.String)} + * </li> + * <li> + * {@link javax.xml.transform.TransformerException} by + * {@link javax.xml.transform.URIResolver#resolve(java.lang.String, java.lang.String)} + * </li> + * </ul> + * <p> + * The CatalogResolver however, will throw {@link javax.xml.catalog.CatalogException} + * only when {@code javax.xml.catalog.resolve} is specified as {@code strict}. + * For applications that expect to handle the checked Exceptions, it may be + * necessary to use a custom resolver to wrap the CatalogResolver or implement it + * with a {@link javax.xml.catalog.Catalog} object. * * @since 9 */ -public interface CatalogResolver extends EntityResolver { +public interface CatalogResolver extends EntityResolver, XMLResolver, + URIResolver, LSResourceResolver { /** - * The method searches through the catalog entries in the main and - * alternative catalogs to attempt to find a match with the specified publicId - * or systemId. - * <p> - * For resolving external entities, system entries will be matched before - * the public entries. - * <p> - * <b>The {@code prefer} attribute</b>: if the {@code prefer} is public, - * and there is no match found through the system entries, public entries - * will be considered. If it is not specified, the {@code prefer} is public - * by default (Note that by the OASIS standard, system entries will always - * be considered first when the external system identifier is specified. - * Prefer public means that public entries will be matched when both system - * and public identifiers are specified. In general therefore, prefer - * public is recommended.) + * Implements {@link org.xml.sax.EntityResolver}. The method searches through + * the catalog entries in the main and alternative catalogs to attempt to find + * a match with the specified {@code publicId} or systemId. * * @param publicId the public identifier of the external entity being * referenced, or null if none was supplied @@ -59,15 +117,123 @@ * requires a system identifier on all external entities, so this value is * always specified. * - * @return a {@link org.xml.sax.InputSource} object if a mapping is found. If no mapping is - * found, returns a {@link org.xml.sax.InputSource} object containing an empty - * {@link java.io.Reader} if the {@code javax.xml.catalog.resolve} property - * is set to {@code ignore}; returns null if the + * @return a {@link org.xml.sax.InputSource} object if a mapping is found. + * If no mapping is found, returns a {@link org.xml.sax.InputSource} object + * containing an empty {@link java.io.Reader} if the + * {@code javax.xml.catalog.resolve} property is set to {@code ignore}; + * returns null if the * {@code javax.xml.catalog.resolve} property is set to {@code continue}. * * @throws CatalogException if no mapping is found and - * {@code javax.xml.catalog.resolve} is specified as strict + * {@code javax.xml.catalog.resolve} is specified as {@code strict} */ @Override public InputSource resolveEntity(String publicId, String systemId); + + + /** + * Implements URIResolver. The method searches through the catalog entries + * in the main and alternative catalogs to attempt to find a match + * with the specified {@code href} attribute. The {@code href} attribute will + * be used literally, with no attempt to be made absolute to the {@code base}. + * <p> + * If the value is an URN, the {@code href} attribute is recognized as a + * {@code publicId}, and used to search {@code public} entries. + * If the value is an URI, it is taken as a {@code systemId}, and used to + * search both {@code system} and {@code uri} entries. + * + * + * @param href the href attribute that specifies the URI of a style sheet, + * which may be relative or absolute + * @param base The base URI against which the href attribute will be made + * absolute if the absolute URI is required + * + * @return a {@link javax.xml.transform.Source} object if a mapping is found. + * If no mapping is found, returns an empty {@link javax.xml.transform.Source} + * object if the {@code javax.xml.catalog.resolve} property is set to + * {@code ignore}; + * returns a {@link javax.xml.transform.Source} object with the original URI + * (href, or href resolved with base if base is not null) if the + * {@code javax.xml.catalog.resolve} property is set to {@code continue}. + * + * @throws CatalogException if no mapping is found and + * {@code javax.xml.catalog.resolve} is specified as {@code strict} + */ + @Override + public Source resolve(String href, String base); + + /** + * Implements {@link javax.xml.stream.XMLResolver}. For the purpose of resolving + * {@code publicId} and {@code systemId}, this method is equivalent to + * {@link #resolveEntity(java.lang.String, java.lang.String) }. + * <p> + * The {@code systemId} will be used literally, with no attempt to be made + * absolute to the {@code baseUri}. The {@code baseUri} and {@code namespace} + * are not used in the search for a match in a catalog. However, a relative + * {@code systemId} in an xml source may have been made absolute by the parser + * with the {@code baseURI}, thus making it unable to find a {@code system} entry. + * In such a case, a {@code systemSuffix} entry is recommended over a + * {@code system} entry. + * + * @param publicId the public identifier of the external entity being + * referenced, or null if none was supplied + * + * @param systemId the system identifier of the external entity being + * referenced. A system identifier is required on all external entities. XML + * requires a system identifier on all external entities, so this value is + * always specified. + * @param baseUri the absolute base URI, not used by the CatalogResolver + * @param namespace the namespace of the entity to resolve, not used by the + * CatalogResolver. + * + * @return an {@link java.io.InputStream} object if a mapping is found; null + * if no mapping is found and the {@code javax.xml.catalog.resolve} property + * is set to {@code continue} or {@code ignore}. Note that for XMLResolver, + * it is not possible to ignore a reference, {@code ignore} is therefore + * treated the same as {@code continue}. + * + * @throws CatalogException if no mapping is found and + * {@code javax.xml.catalog.resolve} is specified as {@code strict} + */ + @Override + public InputStream resolveEntity(String publicId, String systemId, + String baseUri, String namespace); + + /** + * Implements {@link org.w3c.dom.ls.LSResourceResolver}. For the purpose of + * resolving {@code publicId} and {@code systemId}, this method is equivalent + * to {@link #resolveEntity(java.lang.String, java.lang.String) }. + * <p> + * The {@code systemId} will be used literally, with no attempt to be made + * absolute to the {@code baseUri}. The {@code baseUri}, {@code namespaceUri} + * and {@code type} are not used in the search for a match in a catalog. + * However, a relative {@code systemId} in a source may have been made absolute + * by the parser with the {@code baseURI}, thus making it unable to find a + * {@code system} entry. In such a case, a {@code systemSuffix} entry is + * recommended over a {@code system} entry. + * + * @param type the type of the resource being resolved, + * not used by the CatalogResolver + * @param namespaceUri the namespace of the resource being resolved, + * not used by the CatalogResolver + * @param publicId the public identifier of the external entity being + * referenced, or {@code null} if no public identifier was + * supplied or if the resource is not an entity. + * @param systemId the system identifier, an URI reference of the + * external resource being referenced + * @param baseUri the absolute base URI, not used by the CatalogResolver + * + * @return a {@link org.w3c.dom.ls.LSInput} object if a mapping is found; null + * if no mapping is found and the {@code javax.xml.catalog.resolve} property + * is set to {@code continue} or {@code ignore}. Note that for + * {@link org.w3c.dom.ls.LSResourceResolver}, it is not possible to ignore a + * reference, {@code ignore} is therefore treated the same as {@code continue}. + * + * @throws CatalogException if no mapping is found and + * {@code javax.xml.catalog.resolve} is specified as {@code strict} + */ + @Override + public LSInput resolveResource(String type, String namespaceUri, + String publicId, String systemId, String baseUri); + }
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java Wed Aug 31 09:22:54 2016 -0700 @@ -24,15 +24,27 @@ */ package javax.xml.catalog; +import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; +import java.io.IOException; +import java.io.InputStream; +import java.io.Reader; import java.io.StringReader; -import java.util.Iterator; +import java.net.URL; +import javax.xml.parsers.ParserConfigurationException; +import javax.xml.parsers.SAXParserFactory; +import javax.xml.transform.Source; +import javax.xml.transform.sax.SAXSource; +import org.w3c.dom.ls.LSInput; import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.XMLReader; /** - * A SAX EntityResolver/JAXP URIResolver that uses catalogs. + * Implements CatalogResolver. * * <p> - * This class implements both a SAX EntityResolver and a JAXP URIResolver. + * This class implements a SAX EntityResolver, StAX XMLResolver, + * Schema Validation LSResourceResolver and Transform URIResolver. * * * @since 9 @@ -49,9 +61,14 @@ this.catalog = catalog; } + /* + Implements the EntityResolver interface + */ @Override public InputSource resolveEntity(String publicId, String systemId) { + //8150187: NPE expected if the system identifier is null for CatalogResolver CatalogMessages.reportNPEOnNull("systemId", systemId); + //Normalize publicId and systemId systemId = Normalizer.normalizeURI(Util.getNotNullOrEmpty(systemId)); publicId = Normalizer.normalizePublicId(Normalizer.decodeURN(Util.getNotNullOrEmpty(publicId))); @@ -87,4 +104,242 @@ return null; } + /* + Implements the URIResolver interface + */ + CatalogResolverImpl entityResolver; + + @Override + public Source resolve(String href, String base) { + CatalogMessages.reportNPEOnNull("href", href); + + href = Util.getNotNullOrEmpty(href); + base = Util.getNotNullOrEmpty(base); + + String result = null; + CatalogImpl c = (CatalogImpl)catalog; + String uri = Normalizer.normalizeURI(href); + //check whether uri is an urn + if (uri != null && uri.startsWith(Util.URN)) { + String publicId = Normalizer.decodeURN(uri); + if (publicId != null) { + result = Util.resolve(c, publicId, null); + } + } + + //if no match with a public id, continue search for an URI + if (result == null) { + //remove fragment if any. + int hashPos = uri.indexOf("#"); + if (hashPos >= 0) { + uri = uri.substring(0, hashPos); + } + + //search the current catalog + result = Util.resolve(c, null, uri); + } + + //Report error or return the URI as is when no match is found + if (result == null) { + GroupEntry.ResolveType resolveType = c.getResolve(); + switch (resolveType) { + case IGNORE: + return new SAXSource(new InputSource(new StringReader(""))); + case STRICT: + CatalogMessages.reportError(CatalogMessages.ERR_NO_URI_MATCH, + new Object[]{href, base}); + } + try { + URL url = null; + + if (base == null) { + url = new URL(uri); + result = url.toString(); + } else { + URL baseURL = new URL(base); + url = (href.length() == 0 ? baseURL : new URL(baseURL, uri)); + result = url.toString(); + } + } catch (java.net.MalformedURLException mue) { + CatalogMessages.reportError(CatalogMessages.ERR_CREATING_URI, + new Object[]{href, base}); + } + } + + SAXSource source = new SAXSource(); + source.setInputSource(new InputSource(result)); + setEntityResolver(source); + return source; + } + + /** + * Establish an entityResolver for newly resolved URIs. + * <p> + * This is called from the URIResolver to set an EntityResolver on the SAX + * parser to be used for new XML documents that are encountered as a result + * of the document() function, xsl:import, or xsl:include. This is done + * because the XSLT processor calls out to the SAXParserFactory itself to + * create a new SAXParser to parse the new document. The new parser does not + * automatically inherit the EntityResolver of the original (although + * arguably it should). Quote from JAXP specification on Class + * SAXTransformerFactory: + * <p> + * {@code If an application wants to set the ErrorHandler or EntityResolver + * for an XMLReader used during a transformation, it should use a URIResolver + * to return the SAXSource which provides (with getXMLReader) a reference to + * the XMLReader} + * + */ + private void setEntityResolver(SAXSource source) { + XMLReader reader = source.getXMLReader(); + if (reader == null) { + SAXParserFactory spFactory = new SAXParserFactoryImpl(); + spFactory.setNamespaceAware(true); + try { + reader = spFactory.newSAXParser().getXMLReader(); + } catch (ParserConfigurationException | SAXException ex) { + CatalogMessages.reportRunTimeError(CatalogMessages.ERR_PARSER_CONF, ex); + } + } + if (entityResolver != null) { + entityResolver = new CatalogResolverImpl(catalog); + } + reader.setEntityResolver(entityResolver); + source.setXMLReader(reader); + } + + @Override + public InputStream resolveEntity(String publicId, String systemId, String baseUri, String namespace) { + InputSource is = resolveEntity(publicId, systemId); + + if (is != null && !is.isEmpty()) { + + try { + return new URL(is.getSystemId()).openStream(); + } catch (IOException ex) { + //considered as no mapping. + } + + } + + GroupEntry.ResolveType resolveType = ((CatalogImpl) catalog).getResolve(); + switch (resolveType) { + case IGNORE: + return null; + case STRICT: + CatalogMessages.reportError(CatalogMessages.ERR_NO_MATCH, + new Object[]{publicId, systemId}); + } + + //no action, allow the parser to continue + return null; + } + + @Override + public LSInput resolveResource(String type, String namespaceURI, String publicId, String systemId, String baseURI) { + InputSource is = resolveEntity(publicId, systemId); + + if (is != null && !is.isEmpty()) { + return new LSInputImpl(is.getSystemId()); + } + + GroupEntry.ResolveType resolveType = ((CatalogImpl) catalog).getResolve(); + switch (resolveType) { + case IGNORE: + return null; + case STRICT: + CatalogMessages.reportError(CatalogMessages.ERR_NO_MATCH, + new Object[]{publicId, systemId}); + } + + //no action, allow the parser to continue + return null; + } + + /** + * Implements LSInput. All that we need is the systemId since the Catalog + * has already resolved it. + */ + class LSInputImpl implements LSInput { + + private String systemId; + + public LSInputImpl(String systemId) { + this.systemId = systemId; + } + + @Override + public Reader getCharacterStream() { + return null; + } + + @Override + public void setCharacterStream(Reader characterStream) { + } + + @Override + public InputStream getByteStream() { + return null; + } + + @Override + public void setByteStream(InputStream byteStream) { + } + + @Override + public String getStringData() { + return null; + } + + @Override + public void setStringData(String stringData) { + } + + @Override + public String getSystemId() { + return systemId; + } + + @Override + public void setSystemId(String systemId) { + this.systemId = systemId; + } + + @Override + public String getPublicId() { + return null; + } + + @Override + public void setPublicId(String publicId) { + } + + @Override + public String getBaseURI() { + return null; + } + + @Override + public void setBaseURI(String baseURI) { + } + + @Override + public String getEncoding() { + return null; + } + + @Override + public void setEncoding(String encoding) { + } + + @Override + public boolean getCertifiedText() { + return false; + } + + @Override + public void setCertifiedText(boolean certifiedText) { + } + } + }
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolver.java Fri Aug 26 10:02:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,58 +0,0 @@ -/* - * Copyright (c) 2015, 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 javax.xml.catalog; - -import javax.xml.transform.Source; -import javax.xml.transform.URIResolver; - -/** - * A JAXP URIResolver that uses catalogs to resolve references. - * - * @since 9 - */ -public interface CatalogUriResolver extends URIResolver { - - /** - * The method searches through the catalog entries in the main and - * alternative catalogs to attempt to find a match with the specified URI. - * - * @param href an href attribute, which may be relative or absolute - * @param base The base URI against which the href attribute will be made - * absolute if the absolute URI is required - * - * @return a {@link javax.xml.transform.Source} object if a mapping is found. - * If no mapping is found, returns an empty {@link javax.xml.transform.Source} - * object if the {@code javax.xml.catalog.resolve} property is set to - * {@code ignore}; - * returns a {@link javax.xml.transform.Source} object with the original URI - * (href, or href resolved with base if base is not null) if the - * {@code javax.xml.catalog.resolve} property is set to {@code continue}. - * - * @throws CatalogException if no mapping is found and - * {@code javax.xml.catalog.resolve} is specified as strict - */ - @Override - public Source resolve(String href, String base); -}
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java Fri Aug 26 10:02:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,191 +0,0 @@ -/* - * Copyright (c) 2015, 2016, 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 javax.xml.catalog; - -import com.sun.org.apache.xerces.internal.jaxp.SAXParserFactoryImpl; -import java.io.StringReader; -import java.net.URL; -import java.util.Iterator; -import javax.xml.parsers.ParserConfigurationException; -import javax.xml.parsers.SAXParserFactory; -import javax.xml.transform.Source; -import javax.xml.transform.sax.SAXSource; -import org.xml.sax.InputSource; -import org.xml.sax.SAXException; -import org.xml.sax.XMLReader; - -/** - * A SAX EntityResolver/JAXP URIResolver that uses catalogs. - * <p> - * This class implements both a SAX EntityResolver and a JAXP URIResolver. - * - * - * @since 9 - */ -final class CatalogUriResolverImpl implements CatalogUriResolver { - - Catalog catalog; - CatalogResolverImpl entityResolver; - - /** - * Construct an instance of the CatalogResolver from a Catalog. - * - * @param catalog A Catalog. - */ - public CatalogUriResolverImpl(Catalog catalog) { - this.catalog = catalog; - } - - @Override - public Source resolve(String href, String base) { - href = Util.getNotNullOrEmpty(href); - base = Util.getNotNullOrEmpty(base); - - if (href == null) return null; - - String result = null; - CatalogImpl c = (CatalogImpl)catalog; - String uri = Normalizer.normalizeURI(href); - //check whether uri is an urn - if (uri != null && uri.startsWith(Util.URN)) { - String publicId = Normalizer.decodeURN(uri); - if (publicId != null) { - result = Util.resolve(c, publicId, null); - } - } - - //if no match with a public id, continue search for an URI - if (result == null) { - //remove fragment if any. - int hashPos = uri.indexOf("#"); - if (hashPos >= 0) { - uri = uri.substring(0, hashPos); - } - - //search the current catalog - result = resolve(c, uri); - } - - //Report error or return the URI as is when no match is found - if (result == null) { - GroupEntry.ResolveType resolveType = c.getResolve(); - switch (resolveType) { - case IGNORE: - return new SAXSource(new InputSource(new StringReader(""))); - case STRICT: - CatalogMessages.reportError(CatalogMessages.ERR_NO_URI_MATCH, - new Object[]{href, base}); - } - try { - URL url = null; - - if (base == null) { - url = new URL(uri); - result = url.toString(); - } else { - URL baseURL = new URL(base); - url = (href.length() == 0 ? baseURL : new URL(baseURL, uri)); - result = url.toString(); - } - } catch (java.net.MalformedURLException mue) { - CatalogMessages.reportError(CatalogMessages.ERR_CREATING_URI, - new Object[]{href, base}); - } - } - - SAXSource source = new SAXSource(); - source.setInputSource(new InputSource(result)); - setEntityResolver(source); - return source; - } - - /** - * Resolves the publicId or systemId to one specified in the catalog. - * @param catalog the catalog - * @param href an href attribute, which may be relative or absolute - * @return the resolved systemId if a match is found, null otherwise - */ - String resolve(CatalogImpl catalog, String href) { - String result = null; - - //search the current catalog - catalog.reset(); - if (href != null) { - result = catalog.matchURI(href); - } - - //mark the catalog as having been searched before trying alternatives - catalog.markAsSearched(); - - //search alternative catalogs - if (result == null) { - Iterator<Catalog> iter = catalog.catalogs().iterator(); - while (iter.hasNext()) { - result = resolve((CatalogImpl)iter.next(), href); - if (result != null) { - break; - } - } - } - - return result; - } - - /** - * Establish an entityResolver for newly resolved URIs. - * <p> - * This is called from the URIResolver to set an EntityResolver on the SAX - * parser to be used for new XML documents that are encountered as a result - * of the document() function, xsl:import, or xsl:include. This is done - * because the XSLT processor calls out to the SAXParserFactory itself to - * create a new SAXParser to parse the new document. The new parser does not - * automatically inherit the EntityResolver of the original (although - * arguably it should). Quote from JAXP specification on Class - * SAXTransformerFactory: - * <p> - * {@code If an application wants to set the ErrorHandler or EntityResolver - * for an XMLReader used during a transformation, it should use a URIResolver - * to return the SAXSource which provides (with getXMLReader) a reference to - * the XMLReader} - * - */ - private void setEntityResolver(SAXSource source) { - XMLReader reader = source.getXMLReader(); - if (reader == null) { - SAXParserFactory spFactory = new SAXParserFactoryImpl(); - spFactory.setNamespaceAware(true); - try { - reader = spFactory.newSAXParser().getXMLReader(); - } catch (ParserConfigurationException | SAXException ex) { - CatalogMessages.reportRunTimeError(CatalogMessages.ERR_PARSER_CONF, ex); - } - } - if (entityResolver != null) { - entityResolver = new CatalogResolverImpl(catalog); - } - reader.setEntityResolver(entityResolver); - source.setXMLReader(reader); - } -}
--- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java Wed Aug 31 09:22:54 2016 -0700 @@ -55,6 +55,9 @@ * prefer "public": attempts to resolve with a system entry; * attempts to resolve with a public entry if no matching * system entry is found. + * + * If no match is found, continue searching uri entries + * * @param catalog the catalog * @param publicId the publicId * @param systemId the systemId @@ -77,6 +80,10 @@ resolvedSystemId = catalog.matchPublic(publicId); } + if (resolvedSystemId == null && systemId != null) { + resolvedSystemId = catalog.matchURI(systemId); + } + //mark the catalog as having been searched before trying alternatives catalog.markAsSearched();
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -64,4 +64,3 @@ { "catalogReferCircle-left.xml" } }; } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -69,4 +69,3 @@ { Feature.RESOLVE, CatalogTestUtils.RESOLVE_STRICT } }; } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -86,4 +86,3 @@ return (int) method.invoke(catalog); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -100,4 +100,3 @@ return catalogResolver("delegatePublic.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -100,4 +100,3 @@ return catalogResolver("delegateSystem.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateUriTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateUriTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -27,8 +27,8 @@ import static catalog.ResolutionChecker.checkUriResolution; import static catalog.ResolutionChecker.expectExceptionOnUri; +import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogException; -import javax.xml.catalog.CatalogUriResolver; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; @@ -95,8 +95,7 @@ CatalogException.class } }; } - private CatalogUriResolver createResolver() { + private CatalogResolver createResolver() { return catalogUriResolver("delegateUri.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/GroupTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/GroupTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -131,4 +131,3 @@ return catalogResolver(CATALOG_GROUP); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -33,7 +33,6 @@ import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogUriResolver; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; @@ -56,6 +55,7 @@ private static final String CATALOG_DUMMY = "dummy.xml"; private static final String ID_ALICE = "http://remote/dtd/alice/docAlice.dtd"; + private static final String ID_ALICE_URI = "http://remote/dtd/uri/alice/docAlice.dtd"; private static final String ID_DUMMY = "http://remote/dtd/doc.dtd"; @Test(dataProvider = "entityResolver") @@ -79,8 +79,8 @@ } @Test(dataProvider = "uriResolver") - public void testMatchOnUriResolver(CatalogUriResolver resolver) { - checkUriResolution(resolver, ID_ALICE, + public void testMatchOnUriResolver(CatalogResolver resolver) { + checkUriResolution(resolver, ID_ALICE_URI, "http://local/dtd/docAliceURI.dtd"); } @@ -121,4 +121,3 @@ { new String[] { CATALOG_LOADCATALOGFILES } } }; } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/NextCatalogTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/NextCatalogTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -30,7 +30,6 @@ import static catalog.ResolutionChecker.checkUriResolution; import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogUriResolver; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; @@ -154,9 +153,8 @@ CATALOG_NEXTCATALOGRIGHT); } - private CatalogUriResolver createUriResolver() { + private CatalogResolver createUriResolver() { return catalogUriResolver(CATALOG_NEXTCATALOGLEFT, CATALOG_NEXTCATALOGRIGHT); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/NormalizationTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/NormalizationTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -30,7 +30,6 @@ import static catalog.ResolutionChecker.checkUriResolution; import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogUriResolver; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; @@ -111,8 +110,7 @@ return catalogResolver(CATALOG_NORMALIZATION); } - private CatalogUriResolver createUriResolver() { + private CatalogResolver createUriResolver() { return catalogUriResolver(CATALOG_NORMALIZATION); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -81,4 +81,3 @@ "preferFeature.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/PreferTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PreferTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -92,4 +92,3 @@ return catalogResolver("prefer.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -70,4 +70,3 @@ return catalogResolver("publicFamily.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/PublicTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PublicTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -92,4 +92,3 @@ return catalogResolver(CATALOG_PUBLIC); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -38,7 +38,6 @@ import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogFeatures.Feature; import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogUriResolver; import org.testng.annotations.Listeners; import org.testng.annotations.Test; @@ -93,7 +92,7 @@ */ @Test public void testContinueResolutionOnUriResolver() { - CatalogUriResolver resolver = createUriResolver(RESOLVE_CONTINUE); + CatalogResolver resolver = createUriResolver(RESOLVE_CONTINUE); resolver.resolve("http://remote/dtd/bob/docBobDummy.dtd", null); checkUriResolution(resolver, "http://remote/dtd/bob/docBob.dtd", "http://local/base/dtd/docBobURI.dtd"); @@ -123,7 +122,7 @@ return catalogResolver(createFeature(resolve), CATALOG_SYSTEM); } - private CatalogUriResolver createUriResolver(String resolve) { + private CatalogResolver createUriResolver(String resolve) { return catalogUriResolver(createFeature(resolve), CATALOG_URI); } @@ -131,4 +130,3 @@ return builder().with(Feature.RESOLVE, resolve).build(); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -95,4 +95,3 @@ return catalogResolver("rewriteSystem.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteUriTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteUriTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -24,11 +24,11 @@ package catalog; import static catalog.CatalogTestUtils.catalogUriResolver; -import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; +import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogException; -import javax.xml.catalog.CatalogUriResolver; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; @@ -88,11 +88,10 @@ */ @Test(expectedExceptions = CatalogException.class) public void testNoMatch() { - checkNoMatch(createResolver()); + checkNoUriMatch(createResolver()); } - private CatalogUriResolver createResolver() { + private CatalogResolver createResolver() { return catalogUriResolver("rewriteUri.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -36,7 +36,6 @@ import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogUriResolver; import org.testng.annotations.Listeners; import org.testng.annotations.Test; @@ -68,7 +67,7 @@ } /* - * CatalogUriResolver specifies catalog via feature javax.xml.catalog.files. + * CatalogResolver specifies catalog via feature javax.xml.catalog.files. */ @Test public void specifyCatalogOnUriResolver() { @@ -102,7 +101,7 @@ checkSysIdResolution(resolver, ID_SYS, matchedUri); } - private void checkResolutionOnUriResolver(CatalogUriResolver resolver, + private void checkResolutionOnUriResolver(CatalogResolver resolver, String matchedUri) { checkUriResolution(resolver, ID_URI, matchedUri); } @@ -111,4 +110,3 @@ return builder().with(FILES, getCatalogPath(catalogName)).build(); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -84,4 +84,3 @@ return catalogResolver("systemFamily.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -95,4 +95,3 @@ return catalogResolver("systemSuffix.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -92,4 +92,3 @@ return catalogResolver(CATALOG_SYSTEM); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/UriFamilyTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UriFamilyTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -24,11 +24,11 @@ package catalog; import static catalog.CatalogTestUtils.catalogUriResolver; -import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; +import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogException; -import javax.xml.catalog.CatalogUriResolver; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; @@ -58,7 +58,7 @@ return new Object[][] { // The matched URI of the specified URI reference is defined in // a uri entry. - { "http://remote/dtd/alice/docAlice.dtd", + { "http://remote/dtd/uri/alice/docAlice.dtd", "http://local/base/dtd/docAliceURI.dtd" }, // The matched URI of the specified URI reference is defined in @@ -77,11 +77,10 @@ */ @Test(expectedExceptions = CatalogException.class) public void testNoMatch() { - checkNoMatch(createResolver()); + checkNoUriMatch(createResolver()); } - private CatalogUriResolver createResolver() { + private CatalogResolver createResolver() { return catalogUriResolver("uriFamily.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/UriSuffixTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UriSuffixTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -24,11 +24,11 @@ package catalog; import static catalog.CatalogTestUtils.catalogUriResolver; -import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; +import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogException; -import javax.xml.catalog.CatalogUriResolver; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; @@ -88,11 +88,10 @@ */ @Test(expectedExceptions = CatalogException.class) public void testNoMatch() { - checkNoMatch(createResolver()); + checkNoUriMatch(createResolver()); } - private CatalogUriResolver createResolver() { + private CatalogResolver createResolver() { return catalogUriResolver("uriSuffix.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/UriTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UriTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -26,12 +26,12 @@ import static catalog.CatalogTestUtils.CATALOG_URI; import static catalog.CatalogTestUtils.RESOLVE_CONTINUE; import static catalog.CatalogTestUtils.catalogUriResolver; -import static catalog.ResolutionChecker.checkNoMatch; +import static catalog.ResolutionChecker.checkNoUriMatch; import static catalog.ResolutionChecker.checkUriResolution; +import javax.xml.catalog.CatalogResolver; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogFeatures; -import javax.xml.catalog.CatalogUriResolver; import org.testng.annotations.DataProvider; import org.testng.annotations.Listeners; @@ -58,7 +58,7 @@ return new Object[][] { // The matched URI of the specified URI reference is defined in // a uri entry. The match is an absolute path. - { "http://remote/dtd/alice/docAlice.dtd", + { "http://remote/dtd/uri/alice/docAlice.dtd", "http://local/dtd/docAliceURI.dtd" }, // The matched URI of the specified URI reference is defined in @@ -76,7 +76,7 @@ } /* - * Specify base location via method CatalogUriResolver.resolve(href, base). + * Specify base location via method CatalogResolver.resolve(href, base). */ @Test public void testSpecifyBaseByAPI() { @@ -84,7 +84,7 @@ "http://remote/dtd/carl/docCarl.dtd", "http://local/carlBase/dtd/docCarlURI.dtd"); - CatalogUriResolver continueResolver = catalogUriResolver( + CatalogResolver continueResolver = catalogUriResolver( CatalogFeatures.builder().with(CatalogFeatures.Feature.RESOLVE, RESOLVE_CONTINUE).build(), CATALOG_URI); checkUriResolution(continueResolver, "docCarl.dtd", @@ -97,11 +97,10 @@ */ @Test(expectedExceptions = CatalogException.class) public void testNoMatch() { - checkNoMatch(createResolver()); + checkNoUriMatch(createResolver()); } - private CatalogUriResolver createResolver() { + private CatalogResolver createResolver() { return catalogUriResolver(CATALOG_URI); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -67,4 +67,3 @@ return catalogResolver("urnUnwrapping.xml"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -98,8 +98,7 @@ "http://remote/dtd/alice/docAlice.dtd", "http://local/dtd/docAliceSys.dtd"); checkUriResolution(catalogUriResolver(catalogName, CATALOG_URI), - "http://remote/dtd/alice/docAlice.dtd", + "http://remote/dtd/uri/alice/docAlice.dtd", "http://local/dtd/docAliceURI.dtd"); } } -
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/deferFeature.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/deferFeature.xml Wed Aug 31 09:22:54 2016 -0700 @@ -2,7 +2,7 @@ <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> <system systemId="http://remote/dtd/alice/docAlice.dtd" uri="http://local/dtd/docAliceSys.dtd" /> - <uri name="http://remote/dtd/alice/docAlice.dtd" uri="http://local/dtd/docAliceURI.dtd" /> + <uri name="http://remote/dtd/uri/alice/docAlice.dtd" uri="http://local/dtd/docAliceURI.dtd" /> <delegateSystem systemIdStartString="http://remote/dtd/alice/" catalog="delegateSystem-alice.xml" /> <delegatePublic publicIdStartString="-//REMOTE//DTD ALICE DOCALICE" catalog="delegatePublic-alice.xml" />
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uri.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uri.xml Wed Aug 31 09:22:54 2016 -0700 @@ -1,7 +1,7 @@ <?xml version="1.0" encoding="UTF-8"?> <catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog" xml:base="http://local/base/dtd/"> - <uri name="http://remote/dtd/alice/docAlice.dtd" uri="http://local/dtd/docAliceURI.dtd" /> + <uri name="http://remote/dtd/uri/alice/docAlice.dtd" uri="http://local/dtd/docAliceURI.dtd" /> <uri name="http://remote/dtd/bob/docBob.dtd" uri="docBobURI.dtd" />
--- a/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uriFamily.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uriFamily.xml Wed Aug 31 09:22:54 2016 -0700 @@ -4,7 +4,7 @@ <delegateURI uriStartString="http://remote/dtd/alice/" catalog="delegateURI-alice.xml" /> <uriSuffix uriSuffix="docAlice.dtd" uri="docAliceUS.dtd" /> <rewriteURI uriStartString="http://remote/dtd/alice/" rewritePrefix="http://local/base/ru/" /> - <uri name="http://remote/dtd/alice/docAlice.dtd" uri="docAliceURI.dtd" /> + <uri name="http://remote/dtd/uri/alice/docAlice.dtd" uri="docAliceURI.dtd" /> <delegateURI uriStartString="http://remote/dtd/bob/" catalog="delegateURI-bob.xml" /> <uriSuffix uriSuffix="docBob.dtd" uri="docBobUS.dtd" />
--- a/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,7 +42,6 @@ import java.util.Map; import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogUriResolver; /* * This case tests if the properties FILES, DEFER, PREFER, RESOLVE in @@ -96,7 +95,7 @@ } private static void testPropertiesOnUriResolver() { - CatalogUriResolver uriResolver = catalogUriResolver((String[]) null); + CatalogResolver uriResolver = catalogUriResolver((String[]) null); uriResolver.resolve("http://remote/uri/dtd/docDummy.dtd", null); "http://local/base/dtd/docURI.dtd".equals(uriResolver.resolve( "http://remote/dtd/doc.dtd", null).getSystemId());
--- a/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,7 +35,6 @@ import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogManager; import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogUriResolver; import jaxp.library.JAXPTestUtilities; @@ -101,18 +100,18 @@ /* * Creates catalogUriResolver with a set of catalogs. */ - static CatalogUriResolver catalogUriResolver(String... catalogName) { + static CatalogResolver catalogUriResolver(String... catalogName) { return catalogUriResolver(CatalogFeatures.defaults(), catalogName); } /* * Creates catalogUriResolver with a feature and a set of catalogs. */ - static CatalogUriResolver catalogUriResolver( + static CatalogResolver catalogUriResolver( CatalogFeatures features, String... catalogName) { return (catalogName == null) ? - CatalogManager.catalogUriResolver(features) : - CatalogManager.catalogUriResolver(features, getCatalogPaths(catalogName)); + CatalogManager.catalogResolver(features) : + CatalogManager.catalogResolver(features, getCatalogPaths(catalogName)); } // Gets the paths of the specified catalogs.
--- a/jaxp/test/javax/xml/jaxp/libs/catalog/ResolutionChecker.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/libs/catalog/ResolutionChecker.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,7 +24,6 @@ package catalog; import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogUriResolver; import org.testng.Assert; @@ -65,7 +64,7 @@ * Checks the resolution result for specified URI references * with the specified base location. */ - static void checkUriResolution(CatalogUriResolver resolver, + static void checkUriResolution(CatalogResolver resolver, String href, String base, String matchedUri) { Assert.assertEquals(resolver.resolve(href, base).getSystemId(), matchedUri); @@ -74,7 +73,7 @@ /* * Checks the resolution result for specified URI references. */ - static void checkUriResolution(CatalogUriResolver resolver, + static void checkUriResolution(CatalogResolver resolver, String href, String matchedUri) { checkUriResolution(resolver, href, null, matchedUri); } @@ -92,9 +91,9 @@ /* * With strict resolution, if no match is found, - * CatalogUriResolver should throw CatalogException. + * CatalogResolver should throw CatalogException. */ - static void checkNoMatch(CatalogUriResolver resolver) { + static void checkNoUriMatch(CatalogResolver resolver) { resolver.resolve("http://uri/noMatch/docNoMatch.dtd", getNotSpecified(null)); } @@ -139,7 +138,7 @@ * URI reference with a specified base location. */ static <T extends Throwable> void expectExceptionOnUri( - CatalogUriResolver resolver, String href, String base, + CatalogResolver resolver, String href, String base, Class<T> expectedExceptionClass) { expectThrows(expectedExceptionClass, () -> { resolver.resolve(href, base); @@ -151,7 +150,7 @@ * URI reference without any specified base location. */ static <T extends Throwable> void expectExceptionOnUri( - CatalogUriResolver resolver, String href, + CatalogResolver resolver, String href, Class<T> expectedExceptionClass) { expectExceptionOnUri(resolver, href, null, expectedExceptionClass); }
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java Wed Aug 31 09:22:54 2016 -0700 @@ -327,4 +327,3 @@ }; } } -
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.xml Wed Aug 31 09:22:54 2016 -0700 @@ -11,32 +11,32 @@ <!-- public publicId="datatypes" uri="datatypes.dtd"/--> <!-- XInclude --> - <uri name="XI_simple.xml" uri="XI_simple4Catalog.xml"/> - <uri name="XI_utf8.xml" uri="XI_utf8.xml"/> - <uri name="XI_utf8Catalog.xml" uri="XI_utf8Catalog.xml"/> - <uri name="XI_test2.xml" uri="XI_test2.xml"/> + <system systemId="XI_simple.xml" uri="XI_simple4Catalog.xml"/> + <system systemId="XI_utf8.xml" uri="XI_utf8.xml"/> + <system systemId="XI_utf8Catalog.xml" uri="XI_utf8Catalog.xml"/> + <system systemId="XI_test2.xml" uri="XI_test2.xml"/> <system systemId="XI_red.dtd" uri="XI_red.dtd"/> <!-- xsd import can be mapped using the namespace or systemId --> <!--public publicId="http://www.w3.org/XML/1998/namespace" uri="xml.xsd"/--> <!--uri name="http://www.w3.org/XML/1998/namespace" uri="xml.xsd"/--> - <uri name="http://www.w3.org/2001/pathto/xml.xsd" uri="xml.xsd"/> + <system systemId="http://www.w3.org/2001/pathto/xml.xsd" uri="xml.xsd"/> <!-- schema include --> - <uri name="pathto/XSDInclude_person.xsd" uri="XSDInclude_person.xsd"/> - <uri name="pathto/XSDInclude_product.xsd" uri="XSDInclude_product.xsd"/> + <system systemId="pathto/XSDInclude_person.xsd" uri="XSDInclude_person.xsd"/> + <system systemId="pathto/XSDInclude_product.xsd" uri="XSDInclude_product.xsd"/> <!-- for relative path, use Suffix --> <systemSuffix systemIdSuffix="pathto/val_test.xsd" uri="val_test.xsd"/> <!-- XSL import and include --> - <uri name="pathto/XSLImport_html.xsl" uri="XSLImport_html.xsl"/> - <uri name="pathto/XSLInclude_header.xsl" uri="XSLInclude_header.xsl"/> - <uri name="pathto/XSLInclude_footer.xsl" uri="XSLInclude_footer.xsl"/> + <system systemId="pathto/XSLImport_html.xsl" uri="XSLImport_html.xsl"/> + <system systemId="pathto/XSLInclude_header.xsl" uri="XSLInclude_header.xsl"/> + <system systemId="pathto/XSLInclude_footer.xsl" uri="XSLInclude_footer.xsl"/> <!-- and DTDs --> <system systemId="http://openjdk.java.net/xml/catalog/dtd/XSLDTD.dtd" uri="XSLDTD.dtd"/> <system systemId="http://openjdk.java.net/xml/catalog/dtd/include.dtd" uri="include.dtd"/> <!-- XSLT document function --> - <uri name="pathto/DocFunc2.xml" uri="DocFuncCatalog.xml"/> + <system systemId="pathto/DocFunc2.xml" uri="DocFuncCatalog.xml"/> </catalog>
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java Wed Aug 31 09:22:54 2016 -0700 @@ -268,4 +268,3 @@ } } -
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java Wed Aug 31 09:22:54 2016 -0700 @@ -270,4 +270,3 @@ }; } } -
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java Wed Aug 31 09:22:54 2016 -0700 @@ -280,4 +280,3 @@ }; } } -
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java Wed Aug 31 09:22:54 2016 -0700 @@ -269,4 +269,3 @@ }; } } -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,250 @@ +/* + * Copyright (c) 2016, 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 catalog; + +import java.io.File; +import java.io.StringReader; +import javax.xml.transform.Source; +import javax.xml.transform.TransformerException; +import javax.xml.transform.URIResolver; +import javax.xml.transform.dom.DOMSource; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stax.StAXSource; +import javax.xml.transform.stream.StreamSource; +import org.testng.annotations.AfterClass; +import org.testng.annotations.BeforeClass; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; +import org.w3c.dom.ls.LSResourceResolver; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; + +/* + * @test + * @bug 8158084 8163232 + * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @run testng/othervm -DrunSecMngr=true catalog.CatalogSupport5 + * @run testng/othervm catalog.CatalogSupport5 + * @summary extends CatalogSupport tests, verifies that when errors occur, + * relevant checked Exceptions are returned. + */ +/** + * The CatalogResolver will throw CatalogException when there is no match and + * the resolve property is strict. The Exception should be caught with the existing + * mechanisms so that the checked Exception corresponding to the process can be + * returned. + * + * @author huizhe.wang@oracle.com + */ +@Listeners({jaxp.library.FilePolicy.class, jaxp.library.NetAccessPolicy.class}) +public class CatalogSupport5 extends CatalogSupportBase { + + /* + * Initializing fields + */ + @BeforeClass + public void setUpClass() throws Exception { + setUp(); + } + + + /* + Verifies the Catalog support on SAXParser. + */ + @Test(dataProvider = "data_SAXC", expectedExceptions = SAXException.class) + public void testSAXC(boolean setUseCatalog, boolean useCatalog, String catalog, String + xml, MyHandler handler, String expected) throws Exception { + testSAX(setUseCatalog, useCatalog, catalog, xml, handler, expected); + } + + /* + Verifies the Catalog support on XMLReader. + */ + @Test(dataProvider = "data_SAXC", expectedExceptions = SAXException.class) + public void testXMLReaderC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, MyHandler handler, String expected) throws Exception { + testXMLReader(setUseCatalog, useCatalog, catalog, xml, handler, expected); + } + + /* + Verifies the Catalog support on XInclude. + */ + @Test(dataProvider = "data_XIC", expectedExceptions = SAXException.class) + public void testXIncludeC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, MyHandler handler, String expected) throws Exception { + testXInclude(setUseCatalog, useCatalog, catalog, xml, handler, expected); + } + + /* + Verifies the Catalog support on DOM parser. + */ + @Test(dataProvider = "data_DOMC", expectedExceptions = SAXException.class) + public void testDOMC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xml, MyHandler handler, String expected) throws Exception { + testDOM(setUseCatalog, useCatalog, catalog, xml, handler, expected); + } + + /* + Verifies the Catalog support on resolving DTD, xsd import and include in + Schema files. + */ + @Test(dataProvider = "data_SchemaC", expectedExceptions = SAXException.class) + public void testValidationC(boolean setUseCatalog, boolean useCatalog, String catalog, + String xsd, LSResourceResolver resolver) + throws Exception { + testValidation(setUseCatalog, useCatalog, catalog, xsd, resolver) ; + } + + @Test(dataProvider = "data_ValidatorC", expectedExceptions = SAXException.class) + public void testValidatorC(boolean setUseCatalog1, boolean setUseCatalog2, boolean useCatalog, + Source source, LSResourceResolver resolver1, LSResourceResolver resolver2, + String catalog1, String catalog2) + throws Exception { + testValidator(setUseCatalog1, setUseCatalog2, useCatalog, source, + resolver1, resolver2, catalog1, catalog2); + } + + /* + Verifies the Catalog support on resolving DTD, xsl import and include in + XSL files. + */ + @Test(dataProvider = "data_XSLC", expectedExceptions = TransformerException.class) + public void testXSLImportC(boolean setUseCatalog, boolean useCatalog, String catalog, + SAXSource xsl, StreamSource xml, URIResolver resolver, String expected) throws Exception { + + testXSLImport(setUseCatalog, useCatalog, catalog, xsl, xml, resolver, expected); + } + + /* + @bug 8158084 8162442 + Verifies the Catalog support on resolving DTD, xsl import and include in + XSL files. + */ + @Test(dataProvider = "data_XSLC", expectedExceptions = TransformerException.class) + public void testXSLImportWTemplatesC(boolean setUseCatalog, boolean useCatalog, String catalog, + SAXSource xsl, StreamSource xml, URIResolver resolver, String expected) throws Exception { + testXSLImportWTemplates(setUseCatalog, useCatalog, catalog, xsl, xml, resolver, expected); + } + + /* + DataProvider: for testing the SAX parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_SAXC") + public Object[][] getDataSAXC() { + return new Object[][]{ + {false, true, xml_bogus_catalog, xml_system, new MyHandler(elementInSystem), expectedWCatalog} + + }; + } + + /* + DataProvider: for testing XInclude + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_XIC") + public Object[][] getDataXIC() { + return new Object[][]{ + {false, true, xml_bogus_catalog, xml_xInclude, new MyHandler(elementInXISimple), contentInUIutf8Catalog}, + }; + } + + /* + DataProvider: for testing DOM parser + Data: set use_catalog, use_catalog, catalog file, xml file, handler, expected result string + */ + @DataProvider(name = "data_DOMC") + public Object[][] getDataDOMC() { + return new Object[][]{ + {false, true, xml_bogus_catalog, xml_system, new MyHandler(elementInSystem), expectedWCatalog} + }; + } + + /* + DataProvider: for testing Schema validation + Data: set use_catalog, use_catalog, catalog file, xsd file, a LSResourceResolver + */ + @DataProvider(name = "data_SchemaC") + public Object[][] getDataSchemaC() { + + return new Object[][]{ + // for resolving DTD in xsd + {false, true, xml_bogus_catalog, xsd_xmlSchema, null}, + // for resolving xsd import + {false, true, xml_bogus_catalog, xsd_xmlSchema_import, null}, + // for resolving xsd include + {false, true, xml_bogus_catalog, xsd_include_company, null} + }; + } + + /* + DataProvider: for testing Schema Validator + Data: setUseCatalog1, setUseCatalog2, useCatalog, source, resolver1, resolver2, + catalog1, catalog2 + */ + @DataProvider(name = "data_ValidatorC") + public Object[][] getDataValidator() { + DOMSource ds = getDOMSource(xml_val_test, xml_val_test_id, true, true, xml_catalog); + + SAXSource ss = new SAXSource(new InputSource(xml_val_test)); + ss.setSystemId(xml_val_test_id); + + StAXSource stax = getStaxSource(xml_val_test, xml_val_test_id); + StAXSource stax1 = getStaxSource(xml_val_test, xml_val_test_id); + + StreamSource source = new StreamSource(new File(xml_val_test)); + + return new Object[][]{ + // use catalog + {false, false, true, ds, null, null, xml_bogus_catalog, null}, + {false, false, true, ds, null, null, null, xml_bogus_catalog}, + {false, false, true, ss, null, null, xml_bogus_catalog, null}, + {false, false, true, ss, null, null, null, xml_bogus_catalog}, + {false, false, true, stax, null, null, xml_bogus_catalog, null}, + {false, false, true, stax1, null, null, null, xml_bogus_catalog}, + {false, false, true, source, null, null, xml_bogus_catalog, null}, + {false, false, true, source, null, null, null, xml_bogus_catalog}, + }; + } + + /* + DataProvider: for testing XSL import and include + Data: set use_catalog, use_catalog, catalog file, xsl file, xml file, a URIResolver, expected + */ + @DataProvider(name = "data_XSLC") + public Object[][] getDataXSLC() { + SAXSource xslSourceDTD = new SAXSource(new InputSource(new StringReader(xsl_includeDTD))); + StreamSource xmlSourceDTD = new StreamSource(new StringReader(xml_xslDTD)); + + SAXSource xslDocSource = new SAXSource(new InputSource(new File(xsl_doc).toURI().toASCIIString())); + StreamSource xmlDocSource = new StreamSource(new File(xml_doc)); + return new Object[][]{ + // for resolving DTD, import and include in xsl + {false, true, xml_bogus_catalog, xslSourceDTD, xmlSourceDTD, null, ""}, + // for resolving reference by the document function + {false, true, xml_bogus_catalog, xslDocSource, xmlDocSource, null, "Resolved by a catalog"}, + }; + } +}
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java Wed Aug 31 09:22:54 2016 -0700 @@ -35,9 +35,9 @@ import java.io.StringReader; import java.io.StringWriter; import java.io.UnsupportedEncodingException; - import javax.xml.XMLConstants; import javax.xml.catalog.CatalogFeatures; +import javax.xml.catalog.CatalogResolver; import javax.xml.parsers.DocumentBuilder; import javax.xml.parsers.DocumentBuilderFactory; import javax.xml.parsers.ParserConfigurationException; @@ -61,7 +61,6 @@ import javax.xml.validation.Schema; import javax.xml.validation.SchemaFactory; import javax.xml.validation.Validator; - import org.testng.Assert; import org.w3c.dom.Document; import org.w3c.dom.Node; @@ -677,6 +676,29 @@ } + + /** + * Extends MyHandler and overrides resolveEntity with a CatalogResolver + */ + class MyCatalogHandler extends MyHandler { + CatalogResolver cr; + + public MyCatalogHandler(CatalogResolver cr, String elementName) { + super(elementName); + this.cr = cr; + } + + @Override + public InputSource resolveEntity(String publicId, String systemId) { + return cr.resolveEntity(publicId, systemId); + } + @Override + public InputSource resolveEntity(String name, String publicId, + String baseURI, String systemId) { + return cr.resolveEntity(publicId, systemId); + } + } + /** * Extends MyHandler and overrides resolveEntity */ @@ -935,4 +957,3 @@ } } } -
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport_uri.xml Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,43 @@ +<?xml version="1.0" encoding="UTF-8"?> +<catalog xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> + <!-- DTDs and external entities --> + <uri name="http://openjdk.java.net/xml/catalog/dtd/system.dtd" uri="system.dtd"/> + + <!-- XMLSchema refers to XMLSchema.dtd --> + <public publicId="-//W3C//DTD XMLSCHEMA 200102//EN" uri="XMLSchema.dtd"/> + <!-- XMLSchema.dtd refers to datatypes.dtd --> + <uriSuffix uriSuffix="datatypes.dtd" uri="datatypes.dtd"/> + <!-- XMLSchema.dtd refers to datatypes.dtd, can use public entry as well --> + <!-- public publicId="datatypes" uri="datatypes.dtd"/--> + + <!-- XInclude --> + <uri name="XI_simple.xml" uri="XI_simple4Catalog.xml"/> + <uri name="XI_utf8.xml" uri="XI_utf8.xml"/> + <uri name="XI_utf8Catalog.xml" uri="XI_utf8Catalog.xml"/> + <uri name="XI_test2.xml" uri="XI_test2.xml"/> + <uri name="XI_red.dtd" uri="XI_red.dtd"/> + + <!-- xsd import can be mapped using the namespace or systemId --> + <!--public publicId="http://www.w3.org/XML/1998/namespace" uri="xml.xsd"/--> + <!--uri name="http://www.w3.org/XML/1998/namespace" uri="xml.xsd"/--> + <uri name="http://www.w3.org/2001/pathto/xml.xsd" uri="xml.xsd"/> + + <!-- schema include --> + <uri name="pathto/XSDInclude_person.xsd" uri="XSDInclude_person.xsd"/> + <uri name="pathto/XSDInclude_product.xsd" uri="XSDInclude_product.xsd"/> + + <!-- for relative path, use Suffix --> + <uriSuffix uriSuffix="pathto/val_test.xsd" uri="val_test.xsd"/> + + <!-- XSL import and include --> + <uri name="pathto/XSLImport_html.xsl" uri="XSLImport_html.xsl"/> + <uri name="pathto/XSLInclude_header.xsl" uri="XSLInclude_header.xsl"/> + <uri name="pathto/XSLInclude_footer.xsl" uri="XSLInclude_footer.xsl"/> + <!-- and DTDs --> + <uri name="http://openjdk.java.net/xml/catalog/dtd/XSLDTD.dtd" uri="XSLDTD.dtd"/> + <uri name="http://openjdk.java.net/xml/catalog/dtd/include.dtd" uri="include.dtd"/> + + <!-- XSLT document function --> + <uri name="pathto/DocFunc2.xml" uri="DocFuncCatalog.xml"/> +</catalog> +
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -26,23 +26,37 @@ import static jaxp.library.JAXPTestUtilities.getSystemProperty; import static jaxp.library.JAXPTestUtilities.setSystemProperty; +import java.io.File; +import java.io.FileInputStream; import java.io.FilePermission; import java.io.IOException; +import java.io.InputStream; +import java.io.StringReader; +import java.io.StringWriter; import java.nio.file.Paths; import java.util.PropertyPermission; - +import javax.xml.XMLConstants; import javax.xml.catalog.Catalog; import javax.xml.catalog.CatalogException; import javax.xml.catalog.CatalogFeatures; import javax.xml.catalog.CatalogFeatures.Feature; import javax.xml.catalog.CatalogManager; import javax.xml.catalog.CatalogResolver; -import javax.xml.catalog.CatalogUriResolver; import javax.xml.parsers.ParserConfigurationException; import javax.xml.parsers.SAXParser; import javax.xml.parsers.SAXParserFactory; +import javax.xml.stream.XMLInputFactory; +import javax.xml.stream.XMLStreamConstants; +import javax.xml.stream.XMLStreamReader; import javax.xml.transform.Source; - +import javax.xml.transform.Transformer; +import javax.xml.transform.TransformerFactory; +import javax.xml.transform.sax.SAXSource; +import javax.xml.transform.stream.StreamResult; +import javax.xml.transform.stream.StreamSource; +import javax.xml.validation.Schema; +import javax.xml.validation.SchemaFactory; +import javax.xml.validation.Validator; import jaxp.library.JAXPTestUtilities; import org.testng.Assert; @@ -59,29 +73,235 @@ /* * @test - * @bug 8081248 8144966 8146606 8146237 8151154 8150969 8151162 8152527 8154220 + * @bug 8081248 8144966 8146606 8146237 8151154 8150969 8151162 8152527 8154220 8163232 * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest * @run testng/othervm -DrunSecMngr=true catalog.CatalogTest * @run testng/othervm catalog.CatalogTest * @summary Tests basic Catalog functions. */ @Listeners({jaxp.library.FilePolicy.class}) -public class CatalogTest { +public class CatalogTest extends CatalogSupportBase { static final String KEY_FILES = "javax.xml.catalog.files"; - public String filepath; /* * Initializing fields */ @BeforeClass public void setUpClass() throws Exception { - String file1 = getClass().getResource("first_cat.xml").getFile(); - if (getSystemProperty("os.name").contains("Windows")) { - filepath = file1.substring(1, file1.lastIndexOf("/") + 1); - } else { - filepath = file1.substring(0, file1.lastIndexOf("/") + 1); + super.setUp(); + } + + + /* + * @bug 8163232 + * Verifies that the CatalogResolver supports the following XML Resolvers: + javax.xml.stream.XMLResolver + javax.xml.transform.URIResolver + org.w3c.dom.ls.LSResourceResolver + org.xml.sax.EntityResolver + * + * Plus, system and uri entries can equally be used. + */ + + /* + * Verifies the support for org.xml.sax.EntityResolver. + * Expected: the parser returns the expected string. + */ + @Test(dataProvider = "supportXMLResolver") + public void supportEntityResolver(String catalogFile, String xml, String expected) throws Exception { + String xmlSource = getClass().getResource(xml).getFile(); + + CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile); + MyCatalogHandler handler = new MyCatalogHandler(cr, elementInSystem); + SAXParser parser = getSAXParser(false, true, null); + parser.parse(xmlSource, handler); + + Assert.assertEquals(handler.getResult().trim(), expected); + } + + /* + * Verifies the support for javax.xml.stream.XMLResolver. + * Expected: the parser returns the expected string. + */ + @Test(dataProvider = "supportXMLResolver") + public void supportXMLResolver(String catalogFile, String xml, String expected) throws Exception { + String xmlSource = getClass().getResource(xml).getFile(); + + CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile); + + XMLInputFactory xifactory = XMLInputFactory.newInstance(); + xifactory.setProperty(XMLInputFactory.IS_COALESCING, true); + xifactory.setProperty(XMLInputFactory.RESOLVER, cr); + File file = new File(xmlSource); + String systemId = file.toURI().toString(); + InputStream entityxml = new FileInputStream(file); + XMLStreamReader streamReader = xifactory.createXMLStreamReader(systemId, entityxml); + String result = null; + while (streamReader.hasNext()) { + int eventType = streamReader.next(); + if (eventType == XMLStreamConstants.START_ELEMENT) { + eventType = streamReader.next(); + if (eventType == XMLStreamConstants.CHARACTERS) { + result = streamReader.getText(); + } + } } + System.out.println(": expected [" + expected + "] <> actual [" + result.trim() + "]"); + + Assert.assertEquals(result.trim(), expected); + } + + /* + * Verifies the support for org.w3c.dom.ls.LSResourceResolver by ShemaFactory. + * Success: parsing goes through with no error + * Fail: throws Exception if references are not resolved (by the CatalogResolver) + */ + @Test(dataProvider = "supportLSResourceResolver") + public void supportLSResourceResolver(String catalogFile, Source schemaSource) throws SAXException { + + CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile); + + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + factory.setResourceResolver(cr); + Schema schema = factory.newSchema(schemaSource); + + } + + /* + * Verifies the support for org.w3c.dom.ls.LSResourceResolver by Validator. + * Success: parsing goes through with no error + * Fail: throws Exception if references are not resolved (by the CatalogResolver) + */ + @Test(dataProvider = "supportLSResourceResolver1") + public void supportLSResourceResolver1(String catalogFile, Source source) throws Exception { + + CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile); + + SchemaFactory factory = SchemaFactory.newInstance(XMLConstants.W3C_XML_SCHEMA_NS_URI); + Validator validator = factory.newSchema().newValidator(); + validator.setResourceResolver(cr); + validator.validate(source); + } + + /* + * Verifies the support for javax.xml.transform.URIResolver. + * Success: parsing goes through with no error + * Fail: throws Exception if references are not resolved (by the CatalogResolver) + */ + @Test(dataProvider = "supportURIResolver") + public void supportURIResolver(String catalogFile, Source xsl, Source xml, String expected) throws Exception { + + CatalogResolver cr = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile); + + TransformerFactory factory = TransformerFactory.newInstance(); + factory.setURIResolver(cr); + Transformer transformer = factory.newTransformer(xsl); + StringWriter out = new StringWriter(); + transformer.transform(xml, new StreamResult(out)); + if (expected != null) { + Assert.assertTrue(out.toString().contains(expected), "supportURIResolver"); + } + } + + /* + DataProvider: used to verify the support of XML Resolvers. + Data columns: + catalog filepath, xml source file, expected result + */ + @DataProvider(name = "supportXMLResolver") + public Object[][] supportXMLResolver() { + String catalogFile = getClass().getResource("catalog.xml").getFile(); + String catalogFileUri = getClass().getResource("catalog_uri.xml").getFile(); + + return new Object[][]{ + {catalogFile, "system.xml", "Test system entry"}, + {catalogFile, "rewritesystem.xml", "Test rewritesystem entry"}, + {catalogFile, "rewritesystem1.xml", "Test rewritesystem entry"}, + {catalogFile, "systemsuffix.xml", "Test systemsuffix entry"}, + {catalogFile, "delegatesystem.xml", "Test delegatesystem entry"}, + {catalogFile, "public.xml", "Test public entry"}, + {catalogFile, "delegatepublic.xml", "Test delegatepublic entry"}, + // using uri entries + {catalogFileUri, "system.xml", "Test system entry"}, + {catalogFileUri, "rewritesystem.xml", "Test rewritesystem entry"}, + {catalogFileUri, "rewritesystem1.xml", "Test rewritesystem entry"}, + {catalogFileUri, "systemsuffix.xml", "Test systemsuffix entry"}, + {catalogFileUri, "delegateuri.xml", "Test delegateuri entry"}, + {catalogFileUri, "public.xml", "Test public entry"}, + }; + } + + /* + DataProvider: used to verify the support of LSResourceResolver by SchemaFactory. + Data columns: + catalog filepath, schema source file + */ + @DataProvider(name = "supportLSResourceResolver") + public Object[][] supportLSResourceResolver() { + String catalogFile = getClass().getResource("CatalogSupport.xml").getFile(); + String catalogFileUri = getClass().getResource("CatalogSupport_uri.xml").getFile(); + + /* + * XMLSchema.xsd has a reference to XMLSchema.dtd which in turn refers to + * datatypes.dtd + */ + return new Object[][]{ + {catalogFile, new StreamSource(new StringReader(xsd_xmlSchema))}, + {catalogFile, new StreamSource(new StringReader(xsd_xmlSchema_import))}, + {catalogFile, new StreamSource(new StringReader(xsd_include_company))}, + {catalogFileUri, new StreamSource(new StringReader(xsd_xmlSchema))}, + {catalogFileUri, new StreamSource(new StringReader(xsd_xmlSchema_import))}, + {catalogFileUri, new StreamSource(new StringReader(xsd_include_company))}, + }; + } + + /* + DataProvider: used to verify the support of LSResourceResolver by Validator. + Data columns: + catalog filepath, source file + */ + @DataProvider(name = "supportLSResourceResolver1") + public Object[][] supportLSResourceResolver1() { + String catalogFile = getClass().getResource("CatalogSupport.xml").getFile(); + String catalogFileUri = getClass().getResource("CatalogSupport_uri.xml").getFile(); + + /* + * val_test.xml has a reference to system.dtd and val_test.xsd + */ + SAXSource ss = new SAXSource(new InputSource(xml_val_test)); + ss.setSystemId(xml_val_test_id); + + return new Object[][]{ + {catalogFile, ss}, + {catalogFileUri, ss}, + }; + } + + + /* + DataProvider: used to verify the support of LSResourceResolver by Validator. + Data columns: + catalog filepath, xsl source, xml source file + */ + @DataProvider(name = "supportURIResolver") + public Object[][] supportURIResolver() { + String catalogFile = getClass().getResource("CatalogSupport.xml").getFile(); + String catalogFileUri = getClass().getResource("CatalogSupport_uri.xml").getFile(); + SAXSource xslSource = new SAXSource(new InputSource(new File(xsl_doc).toURI().toASCIIString())); + + /* + * val_test.xml has a reference to system.dtd and val_test.xsd + */ + SAXSource ss = new SAXSource(new InputSource(xml_val_test)); + ss.setSystemId(xml_val_test_id); + + return new Object[][]{ + {catalogFile, new SAXSource(new InputSource(new File(xsl_doc).toURI().toASCIIString())), + new StreamSource(new File(xml_doc)), "Resolved by a catalog"}, + {catalogFileUri, new SAXSource(new InputSource(new StringReader(xsl_include))), + new StreamSource(new StringReader(xml_xsl)), null}, + }; } /* @@ -110,7 +330,7 @@ @Test(dataProvider = "resolveUri") public void testMatch1(String cFile, String href, String expectedFile, String expectedUri, String msg) { String catalogFile = getClass().getResource(cFile).getFile(); - CatalogUriResolver cur = CatalogManager.catalogUriResolver(CatalogFeatures.defaults(), catalogFile); + CatalogResolver cur = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalogFile); Source source = cur.resolve(href, null); Assert.assertNotNull(source, "Source returned is null"); Assert.assertEquals(expectedUri, source.getSystemId(), msg); @@ -275,7 +495,7 @@ try { - CatalogUriResolver resolver = CatalogManager.catalogUriResolver(CatalogFeatures.defaults(), catalog); + CatalogResolver resolver = CatalogManager.catalogResolver(CatalogFeatures.defaults(), catalog); String actualSystemId = resolver.resolve("http://remote.com/import/import.xsl", null).getSystemId(); Assert.assertTrue(!actualSystemId.contains("//"), "result contains duplicate slashes"); } catch (Exception e) { @@ -383,7 +603,7 @@ /* - DataProvider: used to verify CatalogUriResolver's resolve function. + DataProvider: used to verify CatalogResolver's resolve function. Data columns: catalog, uri or publicId, expectedFile, expectedUri, msg @@ -571,4 +791,3 @@ } } } -
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalog.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalog.xml Wed Aug 31 09:22:54 2016 -0700 @@ -26,4 +26,4 @@ <system systemId="http://remote/dtd/alice/docAlice.dtd" uri="http://local/dtd/docAliceSys.dtd" /> </group> -</catalog> \ No newline at end of file +</catalog>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalog_uri.xml Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,24 @@ +<?xml version="1.0" encoding="UTF-8"?> +<catalog + xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> + + <!-- using uri entries --> + <uri name="http://openjdk.java.net/xml/catalog/dtd/system.dtd" uri="system.dtd"/> + <rewriteURI uriStartString="http://openjdk.java.net/" + rewritePrefix="files" /> + + <rewriteURI uriStartString="http://openjdk.java.net/xml/catalog/dtd/" + rewritePrefix="files" /> + + <uriSuffix uriSuffix="systemsuffix.dtd" uri="systemsuffix.dtd"/> + + <delegateURI uriStartString="http://java.com/xml/catalog/dtd/" catalog="files/delegatecatalog_uri.xml"/> + + + <uri name="-//OPENJDK//XML CATALOG DTD//1.0" uri="public.dtd"/> + + + <delegateURI uriStartString="-//JAVASE//XML CATALOG DTD//DELEGATEPULIC" catalog="files/delegatecatalog_uri.xml"/> + +</catalog> +
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/delegateuri.xml Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,5 @@ +<?xml version="1.0"?> +<!DOCTYPE catalogtest PUBLIC "-//JAVASE//XML CATALOG DTD//DELEGATEURI" + "http://java.com/xml/catalog/dtd/delegateuri.dtd"> + +<catalogtest>Test &delegateuri; entry</catalogtest>
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegatecatalog.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegatecatalog.xml Wed Aug 31 09:22:54 2016 -0700 @@ -22,4 +22,4 @@ <system systemId="http://java.com/xml/catalog/dtd/delegatesystem.dtd" uri="delegatesystem.dtd"/> -</catalog> \ No newline at end of file +</catalog>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegatecatalog_uri.xml Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,7 @@ +<?xml version="1.0" encoding="UTF-8"?> +<catalog + xmlns="urn:oasis:names:tc:entity:xmlns:xml:catalog"> + + <uri name="http://java.com/xml/catalog/dtd/delegateuri.dtd" uri="delegateuri.dtd"/> + +</catalog>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegateuri.dtd Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,2 @@ + +<!ENTITY delegateuri "delegateuri">
--- a/jaxp/test/javax/xml/jaxp/unittest/catalog/system.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/system.xml Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ <?xml version="1.0"?> -<!DOCTYPE catalogtest PUBLIC "-//OPENJDK//XML CATALOG DTD//1.0" +<!DOCTYPE catalogtest PUBLIC "-//OPENJDK//XML CATALOG DTD SYSTEM//1.0" "http://openjdk.java.net/xml/catalog/dtd/system.dtd"> -<catalogtest>Test &system; entry</catalogtest> \ No newline at end of file +<catalogtest>Test &system; entry</catalogtest>
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/HandleError.java Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,98 @@ +/* + * Copyright (c) 2016, 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 parsers; + +import java.io.StringReader; +import javax.xml.parsers.SAXParser; +import javax.xml.parsers.SAXParserFactory; +import org.xml.sax.InputSource; +import org.xml.sax.SAXException; +import org.xml.sax.SAXParseException; +import org.xml.sax.helpers.DefaultHandler; + +import org.testng.annotations.DataProvider; +import org.testng.annotations.Listeners; +import org.testng.annotations.Test; + +/* + * @test + * @bug 8157797 + * @library /javax/xml/jaxp/libs /javax/xml/jaxp/unittest + * @run testng/othervm -DrunSecMngr=true parsers.HandleError + * @run testng/othervm parsers.HandleError + * @summary Tests that the parser handles errors properly. + */ +@Listeners({jaxp.library.BasePolicy.class}) +public class HandleError { + + /* + * Verifies that the parser returns with no unexpected "java.lang.InternalError" + * when continue-after-fatal-error is requested. + */ + @Test + public void test() throws Exception { + String invalidXml = "<a>"; + SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); + saxParserFactory.setFeature("http://apache.org/xml/features/continue-after-fatal-error", true); + SAXParser parser = saxParserFactory.newSAXParser(); + parser.parse(new InputSource(new StringReader(invalidXml)), new DefaultHandler() { + @Override + public void fatalError(SAXParseException e) throws SAXException { + System.err.printf("%s%n", e.getMessage()); + } + }); + } + + + /* + * Verifies that the parser throws SAXParseException when parsing error is + * encountered when: + * continue-after-fatal-error is not set, the default it false + * continue-after-fatal-error is explicitly set to false + */ + @Test(dataProvider = "setFeature", expectedExceptions = SAXParseException.class) + public void test1(boolean setFeature, boolean value) throws Exception { + String invalidXml = "<a>"; + SAXParserFactory saxParserFactory = SAXParserFactory.newInstance(); + if (setFeature) { + saxParserFactory.setFeature("http://apache.org/xml/features/continue-after-fatal-error", value); + } + SAXParser parser = saxParserFactory.newSAXParser(); + parser.parse(new InputSource(new StringReader(invalidXml)), new DefaultHandler()); + } + + /* + DataProvider: used to set feature "continue-after-fatal-error" + Data columns: + flag to indicate the feature is to be set, the value of the feature + */ + @DataProvider(name = "setFeature") + public Object[][] getFeatureSetting() { + + return new Object[][]{ + {false, false}, + {true, false}, + }; + } +}
--- a/jaxws/.hgtags Fri Aug 26 10:02:50 2016 -0700 +++ b/jaxws/.hgtags Wed Aug 31 09:22:54 2016 -0700 @@ -378,3 +378,4 @@ 39c6293131d91aec7f2f5120395e070a937b8858 jdk-9+130 783e7e2c587f2c7e1b9998a46d90ec196ab2a195 jdk-9+131 9fff2477a4cadf2a9618a76f1f4fe0f20bb5ff3b jdk-9+132 +05e99eefda2b58d1ed176e411302d9d6b35dca16 jdk-9+133
--- a/jdk/make/GenerateClasslist.gmk Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/make/GenerateClasslist.gmk Wed Aug 31 09:22:54 2016 -0700 @@ -50,6 +50,8 @@ CLASSLIST_FILE := $(SUPPORT_OUTPUTDIR)/classlist/classlist +JLI_TRACE_FILE := $(SUPPORT_OUTPUTDIR)/classlist/jli_trace.out + # If an external buildjdk has been supplied, we don't build a separate interim # image, so just use the external build jdk instead. ifeq ($(EXTERNAL_BUILDJDK), true) @@ -59,13 +61,11 @@ $(CLASSLIST_FILE): $(INTERIM_IMAGE_DIR)/bin/java$(EXE_SUFFIX) $(CLASSLIST_JAR) $(call MakeDir, $(@D)) $(call LogInfo, Generating lib/classlist) - $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@.tmp \ + $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@ \ + -Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \ -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \ - build.tools.classlist.HelloClasslist $(LOG_DEBUG) 2>&1 - # Filter out generated classes, remove after JDK-8149977 - $(FIXPATH) $(INTERIM_IMAGE_DIR)/bin/java -XX:DumpLoadedClassList=$@ \ - -Xshare:dump -XX:SharedClassListFile=$@.tmp $(LOG_DEBUG) 2>&1 - $(RM) $@.tmp + build.tools.classlist.HelloClasslist \ + $(LOG_DEBUG) 2>&1 > $(JLI_TRACE_FILE) TARGETS += $(CLASSLIST_FILE)
--- a/jdk/make/data/cryptopolicy/limited/default_local.policy Fri Aug 26 10:02:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,14 +0,0 @@ -// Some countries have import limits on crypto strength. This policy file -// is worldwide importable. - -grant { - permission javax.crypto.CryptoPermission "DES", 64; - permission javax.crypto.CryptoPermission "DESede", *; - permission javax.crypto.CryptoPermission "RC2", 128, - "javax.crypto.spec.RC2ParameterSpec", 128; - permission javax.crypto.CryptoPermission "RC4", 128; - permission javax.crypto.CryptoPermission "RC5", 128, - "javax.crypto.spec.RC5ParameterSpec", *, 12, *; - permission javax.crypto.CryptoPermission "RSA", *; - permission javax.crypto.CryptoPermission *, 128; -};
--- a/jdk/make/data/cryptopolicy/limited/exempt_local.policy Fri Aug 26 10:02:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,13 +0,0 @@ -// Some countries have import limits on crypto strength. So this file -// will be useful. - -grant { - // There is no restriction to any algorithms if KeyRecovery is enforced. - permission javax.crypto.CryptoPermission *, "KeyRecovery"; - - // There is no restriction to any algorithms if KeyEscrow is enforced. - permission javax.crypto.CryptoPermission *, "KeyEscrow"; - - // There is no restriction to any algorithms if KeyWeakening is enforced. - permission javax.crypto.CryptoPermission *, "KeyWeakening"; -};
--- a/jdk/make/data/cryptopolicy/unlimited/default_US_export.policy Fri Aug 26 10:02:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -// Manufacturing policy file. -grant { - // There is no restriction to any algorithms. - permission javax.crypto.CryptoAllPermission; -};
--- a/jdk/make/data/cryptopolicy/unlimited/default_local.policy Fri Aug 26 10:02:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,5 +0,0 @@ -// Country-specific policy file for countries with no limits on crypto strength. -grant { - // There is no restriction to any algorithms. - permission javax.crypto.CryptoAllPermission; -};
--- a/jdk/make/gendata/Gendata-java.base.gmk Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/make/gendata/Gendata-java.base.gmk Wed Aug 31 09:22:54 2016 -0700 @@ -34,7 +34,7 @@ include GendataBlacklistedCerts.gmk -include GendataPolicyJars.gmk +include GendataCryptoPolicy.gmk ################################################################################ @@ -64,13 +64,19 @@ GENDATA_JAVA_SECURITY_SRC := $(JDK_TOPDIR)/src/java.base/share/conf/security/java.security GENDATA_JAVA_SECURITY := $(SUPPORT_OUTPUTDIR)/modules_conf/java.base/security/java.security +ifeq ($(UNLIMITED_CRYPTO), true) + CRYPTO.POLICY := unlimited +else + CRYPTO.POLICY := limited +endif + # RESTRICTED_PKGS_SRC is optionally set in custom extension for this makefile $(GENDATA_JAVA_SECURITY): $(BUILD_TOOLS) $(GENDATA_JAVA_SECURITY_SRC) $(RESTRICTED_PKGS_SRC) $(call LogInfo, Generating java.security) $(call MakeDir, $(@D)) $(TOOL_MAKEJAVASECURITY) $(GENDATA_JAVA_SECURITY_SRC) $@ $(OPENJDK_TARGET_OS) \ - $(OPENJDK_TARGET_CPU_ARCH) $(RESTRICTED_PKGS_SRC) + $(OPENJDK_TARGET_CPU_ARCH) $(CRYPTO.POLICY) $(RESTRICTED_PKGS_SRC) TARGETS += $(GENDATA_JAVA_SECURITY)
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/make/gendata/GendataCryptoPolicy.gmk Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,72 @@ +# +# Copyright (c) 2013, 2016, 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. +# + +# +# In pre-JDK9 releases, Oracle JDK has had a separately downloadable set +# of policy files which has been a nightmare for deployment. +# +# We now create 2 complete initial sets of policy files and package into +# 2 different directories. The crypto.policy Security property will select +# the active policy. +# +# It will be up to the user/deployer to make an informed choice +# as to whether they are legally entitled to use the unlimited policy +# file in their environment. The $(UNLIMITED_CRYPTO) make variable +# determines the default directory/policy. +# + +default: all + +include $(SPEC) +include MakeBase.gmk + + +################################################################################ +POLICY_DIR := $(SUPPORT_OUTPUTDIR)/modules_conf/java.base/security/policy +LIMITED_POLICY_DIR := $(POLICY_DIR)/limited +UNLIMITED_POLICY_DIR := $(POLICY_DIR)/unlimited + +POLICY_SRC_DIR := $(JDK_TOPDIR)/src/java.base/share/conf/security/policy +LIMITED_POLICY_SRC_DIR := $(POLICY_SRC_DIR)/limited +UNLIMITED_POLICY_SRC_DIR := $(POLICY_SRC_DIR)/unlimited + +$(POLICY_DIR)/README.txt: $(POLICY_SRC_DIR)/README.txt + $(install-file) + +$(LIMITED_POLICY_DIR)/%: $(LIMITED_POLICY_SRC_DIR)/% + $(install-file) + +$(UNLIMITED_POLICY_DIR)/%: $(UNLIMITED_POLICY_SRC_DIR)/% + $(install-file) + +TARGETS += \ + $(POLICY_DIR)/README.txt \ + $(LIMITED_POLICY_DIR)/default_US_export.policy \ + $(LIMITED_POLICY_DIR)/default_local.policy \ + $(LIMITED_POLICY_DIR)/exempt_local.policy \ + $(UNLIMITED_POLICY_DIR)/default_US_export.policy \ + $(UNLIMITED_POLICY_DIR)/default_local.policy \ + +################################################################################
--- a/jdk/make/gendata/GendataPolicyJars.gmk Fri Aug 26 10:02:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,150 +0,0 @@ -# -# Copyright (c) 2013, 2016, 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 JarArchive.gmk - - -################################################################################ - -US_EXPORT_POLICY_JAR_DST := \ - $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/security/US_export_policy.jar - -US_EXPORT_POLICY_JAR_LIMITED := \ - $(SUPPORT_OUTPUTDIR)/jce/policy/limited/US_export_policy.jar -US_EXPORT_POLICY_JAR_UNLIMITED := \ - $(SUPPORT_OUTPUTDIR)/jce/policy/unlimited/US_export_policy.jar - -# -# TODO fix so that SetupJarArchive does not write files into SRCS -# then we don't need this extra copying -# -# NOTE: We currently do not place restrictions on our limited export -# policy. This was not a typo. This means we are shipping the same file -# for both limited and unlimited US_export_policy.jar. Only the local -# policy file currently has restrictions. -# -US_EXPORT_POLICY_JAR_SRC_DIR := \ - $(JDK_TOPDIR)/make/data/cryptopolicy/unlimited -US_EXPORT_POLICY_JAR_TMP := \ - $(SUPPORT_OUTPUTDIR)/jce/policy/unlimited/US_export_policy_jar.tmp - -$(US_EXPORT_POLICY_JAR_TMP)/%: $(US_EXPORT_POLICY_JAR_SRC_DIR)/% - $(install-file) - -US_EXPORT_POLICY_JAR_DEPS := \ - $(US_EXPORT_POLICY_JAR_TMP)/default_US_export.policy - -$(eval $(call SetupJarArchive, BUILD_US_EXPORT_POLICY_JAR, \ - DEPENDENCIES := $(US_EXPORT_POLICY_JAR_DEPS), \ - SRCS := $(US_EXPORT_POLICY_JAR_TMP), \ - SUFFIXES := .policy, \ - JAR := $(US_EXPORT_POLICY_JAR_UNLIMITED), \ - EXTRA_MANIFEST_ATTR := Crypto-Strength: unlimited, \ - SKIP_METAINF := true, \ -)) - -$(US_EXPORT_POLICY_JAR_LIMITED): \ - $(US_EXPORT_POLICY_JAR_UNLIMITED) - $(call LogInfo, Copying unlimited $(patsubst $(OUTPUT_ROOT)/%,%,$@)) - $(install-file) - -TARGETS += $(US_EXPORT_POLICY_JAR_LIMITED) $(US_EXPORT_POLICY_JAR_UNLIMITED) - -ifeq ($(UNLIMITED_CRYPTO), true) - $(US_EXPORT_POLICY_JAR_DST): $(US_EXPORT_POLICY_JAR_UNLIMITED) - $(install-file) -else - $(US_EXPORT_POLICY_JAR_DST): $(US_EXPORT_POLICY_JAR_LIMITED) - $(install-file) -endif - -POLICY_JARS += $(US_EXPORT_POLICY_JAR_DST) - -################################################################################ - -LOCAL_POLICY_JAR_DST := \ - $(SUPPORT_OUTPUTDIR)/modules_libs/java.base/security/local_policy.jar - -LOCAL_POLICY_JAR_LIMITED := \ - $(SUPPORT_OUTPUTDIR)/jce/policy/limited/local_policy.jar -LOCAL_POLICY_JAR_UNLIMITED := \ - $(SUPPORT_OUTPUTDIR)/jce/policy/unlimited/local_policy.jar - -# -# TODO fix so that SetupJarArchive does not write files into SRCS -# then we don't need this extra copying -# -LOCAL_POLICY_JAR_LIMITED_TMP := \ - $(SUPPORT_OUTPUTDIR)/jce/policy/limited/local_policy_jar.tmp -LOCAL_POLICY_JAR_UNLIMITED_TMP := \ - $(SUPPORT_OUTPUTDIR)/jce/policy/unlimited/local_policy_jar.tmp - -$(LOCAL_POLICY_JAR_LIMITED_TMP)/%: \ - $(JDK_TOPDIR)/make/data/cryptopolicy/limited/% - $(install-file) - -$(LOCAL_POLICY_JAR_UNLIMITED_TMP)/%: \ - $(JDK_TOPDIR)/make/data/cryptopolicy/unlimited/% - $(install-file) - -$(eval $(call SetupJarArchive, BUILD_LOCAL_POLICY_JAR_LIMITED, \ - DEPENDENCIES := $(LOCAL_POLICY_JAR_LIMITED_TMP)/exempt_local.policy \ - $(LOCAL_POLICY_JAR_LIMITED_TMP)/default_local.policy, \ - SRCS := $(LOCAL_POLICY_JAR_LIMITED_TMP), \ - SUFFIXES := .policy, \ - JAR := $(LOCAL_POLICY_JAR_LIMITED), \ - EXTRA_MANIFEST_ATTR := Crypto-Strength: limited, \ - SKIP_METAINF := true, \ -)) - -$(eval $(call SetupJarArchive, BUILD_LOCAL_POLICY_JAR_UNLIMITED, \ - DEPENDENCIES := $(LOCAL_POLICY_JAR_UNLIMITED_TMP)/default_local.policy, \ - SRCS := $(LOCAL_POLICY_JAR_UNLIMITED_TMP), \ - SUFFIXES := .policy, \ - JAR := $(LOCAL_POLICY_JAR_UNLIMITED), \ - EXTRA_MANIFEST_ATTR := Crypto-Strength: unlimited, \ - SKIP_METAINF := true, \ -)) - -TARGETS += $(LOCAL_POLICY_JAR_LIMITED) $(LOCAL_POLICY_JAR_UNLIMITED) - -ifeq ($(UNLIMITED_CRYPTO), true) - $(LOCAL_POLICY_JAR_DST): $(LOCAL_POLICY_JAR_UNLIMITED) - $(install-file) -else - $(LOCAL_POLICY_JAR_DST): $(LOCAL_POLICY_JAR_LIMITED) - $(install-file) -endif - -POLICY_JARS += $(LOCAL_POLICY_JAR_DST) -TARGETS += $(POLICY_JARS) - -################################################################################ - -$(eval $(call IncludeCustomExtension, jdk, gendata/GendataPolicyJars.gmk))
--- a/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2011, 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2011, 2016, 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,8 +38,6 @@ CFLAGS := $(CFLAGS_JDKLIB) $(addprefix -I, $(LIBJ2PKCS11_SRC)) \ $(LIBJAVA_HEADER_FLAGS) \ -I$(SUPPORT_OUTPUTDIR)/headers/jdk.crypto.pkcs11, \ - DISABLED_WARNINGS_solstudio := E_DECLARATION_IN_CODE, \ - DISABLED_WARNINGS_microsoft := 4013 4267, \ MAPFILE := $(JDK_TOPDIR)/make/mapfiles/libj2pkcs11/mapfile-vers, \ LDFLAGS := $(LDFLAGS_JDKLIB) \ $(call SET_SHARED_LIBRARY_ORIGIN), \
--- a/jdk/make/src/classes/build/tools/makejavasecurity/MakeJavaSecurity.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/make/src/classes/build/tools/makejavasecurity/MakeJavaSecurity.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2016, 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,7 +35,8 @@ * * 1. Adds additional packages to the package.access and * package.definition security properties. - * 2. Filter out platform-unrelated parts + * 2. Filter out platform-unrelated parts. + * 3. Set the JCE jurisdiction policy directory. * * In order to easily maintain platform-related entries, every item * (including the last line) in package.access and package.definition @@ -50,12 +51,13 @@ public static void main(String[] args) throws Exception { - if (args.length < 4) { + if (args.length < 5) { System.err.println("Usage: java MakeJavaSecurity " + "[input java.security file name] " + "[output java.security file name] " + "[openjdk target os] " + "[openjdk target cpu architecture]" + + "[JCE jurisdiction policy directory]" + "[more restricted packages file name?]"); System.exit(1); @@ -63,8 +65,8 @@ // more restricted packages List<String> extraLines; - if (args.length == 5) { - extraLines = Files.readAllLines(Paths.get(args[4])); + if (args.length == 6) { + extraLines = Files.readAllLines(Paths.get(args[5])); } else { extraLines = Collections.emptyList(); } @@ -135,6 +137,16 @@ } } + // Set the JCE policy value + for (int i = 0; i < lines.size(); i++) { + String line = lines.get(i); + int index = line.indexOf("crypto.policydir-tbd"); + if (index >= 0) { + String prefix = line.substring(0, index); + lines.set(i, prefix + args[4]); + } + } + // Clean up the last line of PKG_ACC and PKG_DEF blocks. // Not really necessary since a blank line follows. boolean inBlock = false;
--- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java Wed Aug 31 09:22:54 2016 -0700 @@ -497,6 +497,10 @@ String shortTypes = LambdaForm.shortenSignature(types); String className = SPECIES_CLASS_PREFIX + shortTypes; Class<?> c = BootLoader.loadClassOrNull(className); + if (TRACE_RESOLVE) { + System.out.println("[BMH_RESOLVE] " + shortTypes + + (c != null ? " (success)" : " (fail)") ); + } if (c != null) { return c.asSubclass(BoundMethodHandle.class); } else {
--- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java Wed Aug 31 09:22:54 2016 -0700 @@ -607,7 +607,10 @@ private static MemberName resolveFrom(String name, MethodType type, Class<?> holder) { MemberName member = new MemberName(holder, name, type, REF_invokeStatic); MemberName resolvedMember = MemberName.getFactory().resolveOrNull(REF_invokeStatic, member, holder); - + if (TRACE_RESOLVE) { + System.out.println("[LF_RESOLVE] " + holder.getName() + " " + name + " " + + shortenSignature(basicTypeSignature(type)) + (resolvedMember != null ? " (success)" : " (fail)") ); + } return resolvedMember; }
--- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java Wed Aug 31 09:22:54 2016 -0700 @@ -46,6 +46,7 @@ static final boolean DUMP_CLASS_FILES; static final boolean TRACE_INTERPRETER; static final boolean TRACE_METHOD_LINKAGE; + static final boolean TRACE_RESOLVE; static final int COMPILE_THRESHOLD; static final boolean LOG_LF_COMPILATION_FAILURE; static final int DONT_INLINE_THRESHOLD; @@ -65,6 +66,8 @@ props.getProperty("java.lang.invoke.MethodHandle.TRACE_INTERPRETER")); TRACE_METHOD_LINKAGE = Boolean.parseBoolean( props.getProperty("java.lang.invoke.MethodHandle.TRACE_METHOD_LINKAGE")); + TRACE_RESOLVE = Boolean.parseBoolean( + props.getProperty("java.lang.invoke.MethodHandle.TRACE_RESOLVE")); COMPILE_THRESHOLD = Integer.parseInt( props.getProperty("java.lang.invoke.MethodHandle.COMPILE_THRESHOLD", "0")); LOG_LF_COMPILATION_FAILURE = Boolean.parseBoolean(
--- a/jdk/src/java.base/share/classes/java/net/HttpCookie.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/java.base/share/classes/java/net/HttpCookie.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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 @@ -233,7 +233,7 @@ // if not specify max-age, this cookie should be // discarded when user agent is to be closed, but // it is not expired. - if (maxAge == MAX_AGE_UNSPECIFIED) return false; + if (maxAge < 0) return false; long deltaSecond = (System.currentTimeMillis() - whenCreated) / 1000; if (deltaSecond > maxAge) @@ -952,7 +952,8 @@ String attrName, String attrValue) { if (cookie.getMaxAge() == MAX_AGE_UNSPECIFIED) { - cookie.setMaxAge(cookie.expiryDate2DeltaSeconds(attrValue)); + long delta = cookie.expiryDate2DeltaSeconds(attrValue); + cookie.setMaxAge(delta > 0 ? delta : 0); } } });
--- a/jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java Wed Aug 31 09:22:54 2016 -0700 @@ -29,6 +29,7 @@ import java.util.jar.*; import java.io.*; import java.net.URL; +import java.nio.file.*; import java.security.*; import java.security.Provider.Service; @@ -206,7 +207,7 @@ static { try { - NULL_URL = new URL("http://null.sun.com/"); + NULL_URL = new URL("http://null.oracle.com/"); } catch (Exception e) { throw new RuntimeException(e); } @@ -243,83 +244,94 @@ } } + // This is called from within an doPrivileged block. private static void setupJurisdictionPolicies() throws Exception { - String javaHomeDir = System.getProperty("java.home"); - String sep = File.separator; - String pathToPolicyJar = javaHomeDir + sep + "lib" + sep + - "security" + sep; - File exportJar = new File(pathToPolicyJar, "US_export_policy.jar"); - File importJar = new File(pathToPolicyJar, "local_policy.jar"); + // Sanity check the crypto.policy Security property. Single + // directory entry, no pseudo-directories (".", "..", leading/trailing + // path separators). normalize()/getParent() will help later. + String cryptoPolicyProperty = Security.getProperty("crypto.policy"); + Path cpPath = Paths.get(cryptoPolicyProperty); - if (!exportJar.exists() || !importJar.exists()) { - throw new SecurityException - ("Cannot locate policy or framework files!"); + if ((cryptoPolicyProperty == null) || + (cpPath.getNameCount() != 1) || + (cpPath.compareTo(cpPath.getFileName()) != 0)) { + throw new SecurityException( + "Invalid policy directory name format: " + + cryptoPolicyProperty); } - // Read jurisdiction policies. - CryptoPermissions defaultExport = new CryptoPermissions(); - CryptoPermissions exemptExport = new CryptoPermissions(); - loadPolicies(exportJar, defaultExport, exemptExport); + // Prepend java.home to get the full path. normalize() in + // case an extra "." or ".." snuck in somehow. + String javaHomeProperty = System.getProperty("java.home"); + Path javaHomePolicyPath = Paths.get(javaHomeProperty, "conf", + "security", "policy").normalize(); + Path cryptoPolicyPath = Paths.get(javaHomeProperty, "conf", "security", + "policy", cryptoPolicyProperty).normalize(); - CryptoPermissions defaultImport = new CryptoPermissions(); - CryptoPermissions exemptImport = new CryptoPermissions(); - loadPolicies(importJar, defaultImport, exemptImport); + if (cryptoPolicyPath.getParent().compareTo(javaHomePolicyPath) != 0) { + throw new SecurityException( + "Invalid cryptographic jurisdiction policy directory path: " + + cryptoPolicyProperty); + } - // Merge the export and import policies for default applications. - if (defaultExport.isEmpty() || defaultImport.isEmpty()) { - throw new SecurityException("Missing mandatory jurisdiction " + - "policy files"); + if (!Files.isDirectory(cryptoPolicyPath) + || !Files.isReadable(cryptoPolicyPath)) { + throw new SecurityException( + "Can't read cryptographic policy directory: " + + cryptoPolicyProperty); } - defaultPolicy = defaultExport.getMinimum(defaultImport); - // Merge the export and import policies for exempt applications. - if (exemptExport.isEmpty()) { - exemptPolicy = exemptImport.isEmpty() ? null : exemptImport; - } else { - exemptPolicy = exemptExport.getMinimum(exemptImport); - } - } + try (DirectoryStream<Path> stream = Files.newDirectoryStream( + cryptoPolicyPath, "{default,exempt}_*.policy")) { + for (Path entry : stream) { + try (InputStream is = new BufferedInputStream( + Files.newInputStream(entry))) { + String filename = entry.getFileName().toString(); - /** - * Load the policies from the specified file. Also checks that the - * policies are correctly signed. - */ - private static void loadPolicies(File jarPathName, - CryptoPermissions defaultPolicy, - CryptoPermissions exemptPolicy) - throws Exception { + CryptoPermissions tmpPerms = new CryptoPermissions(); + tmpPerms.load(is); - JarFile jf = new JarFile(jarPathName); - - Enumeration<JarEntry> entries = jf.entries(); - while (entries.hasMoreElements()) { - JarEntry je = entries.nextElement(); - InputStream is = null; - try { - if (je.getName().startsWith("default_")) { - is = jf.getInputStream(je); - defaultPolicy.load(is); - } else if (je.getName().startsWith("exempt_")) { - is = jf.getInputStream(je); - exemptPolicy.load(is); - } else { - continue; - } - } finally { - if (is != null) { - is.close(); + if (filename.startsWith("default_")) { + // Did we find a default perms? + defaultPolicy = ((defaultPolicy == null) ? tmpPerms : + defaultPolicy.getMinimum(tmpPerms)); + } else if (filename.startsWith("exempt_")) { + // Did we find a exempt perms? + exemptPolicy = ((exemptPolicy == null) ? tmpPerms : + exemptPolicy.getMinimum(tmpPerms)); + } else { + // This should never happen. newDirectoryStream + // should only throw return "{default,exempt}_*.policy" + throw new SecurityException( + "Unexpected jurisdiction policy files in : " + + cryptoPolicyProperty); + } + } catch (Exception e) { + throw new SecurityException( + "Couldn't parse jurisdiction policy files in: " + + cryptoPolicyProperty); } } + } catch (DirectoryIteratorException ex) { + // I/O error encountered during the iteration, + // the cause is an IOException + throw new SecurityException( + "Couldn't iterate through the jurisdiction policy files: " + + cryptoPolicyProperty); + } - // Enforce the signer restraint, i.e. signer of JCE framework - // jar should also be the signer of the two jurisdiction policy - // jar files. - ProviderVerifier.verifyPolicySigned(je.getCertificates()); + // Must have a default policy + if ((defaultPolicy == null) || defaultPolicy.isEmpty()) { + throw new SecurityException( + "Missing mandatory jurisdiction policy files: " + + cryptoPolicyProperty); } - // Close and nullify the JarFile reference to help GC. - jf.close(); - jf = null; + + // If there was an empty exempt policy file, ignore it. + if ((exemptPolicy != null) && exemptPolicy.isEmpty()) { + exemptPolicy = null; + } } static CryptoPermissions getDefaultPolicy() {
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java Wed Aug 31 09:22:54 2016 -0700 @@ -47,8 +47,8 @@ private final JrtPath dir; private final DirectoryStream.Filter<? super Path> filter; - private volatile boolean isClosed; - private volatile Iterator<Path> itr; + private boolean isClosed; + private Iterator<Path> itr; JrtDirectoryStream(JrtPath dir, DirectoryStream.Filter<? super java.nio.file.Path> filter) @@ -73,24 +73,22 @@ throw new IllegalStateException(e); } return new Iterator<Path>() { - private Path next; @Override - public synchronized boolean hasNext() { - if (isClosed) - return false; - return itr.hasNext(); + public boolean hasNext() { + synchronized (JrtDirectoryStream.this) { + if (isClosed) + return false; + return itr.hasNext(); + } } @Override - public synchronized Path next() { - if (isClosed) - throw new NoSuchElementException(); - return itr.next(); - } - - @Override - public void remove() { - throw new UnsupportedOperationException(); + public Path next() { + synchronized (JrtDirectoryStream.this) { + if (isClosed) + throw new NoSuchElementException(); + return itr.next(); + } } }; }
--- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java Wed Aug 31 09:22:54 2016 -0700 @@ -119,9 +119,7 @@ @Override public Iterable<Path> getRootDirectories() { - ArrayList<Path> dirs = new ArrayList<>(); - dirs.add(getRootPath()); - return dirs; + return Collections.singleton(getRootPath()); } @Override @@ -159,9 +157,7 @@ @Override public final Iterable<FileStore> getFileStores() { - ArrayList<FileStore> list = new ArrayList<>(1); - list.add(getFileStore(getRootPath())); - return list; + return Collections.singleton(getFileStore(getRootPath())); } private static final Set<String> supportedFileAttributeViews
--- a/jdk/src/java.base/share/conf/security/java.security Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/java.base/share/conf/security/java.security Wed Aug 31 09:22:54 2016 -0700 @@ -804,6 +804,56 @@ # EE386BFB 5A899FA5 AE9F2411 7C4B1FE6 49286651 ECE65381 \ # FFFFFFFF FFFFFFFF, 2} +# Cryptographic Jurisdiction Policy defaults +# +# Due to the import control restrictions of some countries, the default +# JCE policy files allow for strong but "limited" cryptographic key +# lengths to be used. If your country's cryptographic regulations allow, +# the "unlimited" strength policy files can be used instead, which contain +# no restrictions on cryptographic strengths. +# +# If your country has restrictions that don't fit either "limited" or +# "unlimited", an appropriate set of policy files should be created and +# configured before using this distribution. The jurisdiction policy file +# configuration must reflect the cryptographic restrictions appropriate +# for your country. +# +# YOU ARE ADVISED TO CONSULT YOUR EXPORT/IMPORT CONTROL COUNSEL OR ATTORNEY +# TO DETERMINE THE EXACT REQUIREMENTS. +# +# The policy files are flat text files organized into subdirectories of +# <java-home>/conf/security/policy. Each directory contains a complete +# set of policy files. +# +# The "crypto.policy" Security property controls the directory selection, +# and thus the effective cryptographic policy. +# +# The default set of directories is: +# +# limited | unlimited +# +# however other directories can be created and configured. +# +# Within a directory, the effective policy is the combined minimum +# permissions of the grant statements in the file(s) with the filename +# pattern "default_*.policy". At least one grant is required. For +# example: +# +# limited = Export (all) + Import (limited) = Limited +# unlimited = Export (all) + Import (all) = Unlimited +# +# The effective exemption policy is the combined minimum permissions +# of the grant statements in the file(s) with the filename pattern +# "exempt_*.policy". Exemption grants are optional. +# +# limited = grants exemption permissions, by which the +# effective policy can be circumvented. +# e.g. KeyRecovery/Escrow/Weakening. +# +# Please see the JCA documentation for additional information on these +# files and formats. +crypto.policy=crypto.policydir-tbd + # # The policy for the XML Signature secure validation mode. The mode is # enabled by setting the property "org.jcp.xml.dsig.secureValidation" to
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.base/share/conf/security/policy/README.txt Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,35 @@ + + Java(TM) Cryptography Extension Policy Files + for the Java(TM) Platform, Standard Edition Runtime Environment + + README +------------------------------------------------------------------------ + + +The JCE architecture allows flexible cryptographic strength to be +configured via the jurisdiction policy files contained within these +directories. + +Due to import control restrictions of some countries, the default +JCE policy files bundled in this Java Runtime Environment allow +for strong but "limited" cryptographic strengths. For convenience, +this build also contains the "unlimited strength" policy files which +contain no restrictions on cryptographic strengths, but they must be +specifically activated by updating the "crypto.policy" Security property +(e.g. <java-home>/conf/security/java.security) to point to the appropriate +directory. + +Each subdirectory contains a complete policy configuration, and additional +subdirectories can be added/removed to reflect local regulations. + +JCE for Java SE has been through the U.S. export review process. The JCE +framework, along with the various JCE providers that come standard with it +(SunJCE, SunEC, SunPKCS11, SunMSCAPI, etc), is exportable from the +United States. + +You are advised to consult your export/import control counsel or attorney +to determine the exact requirements of your location, and what policy +settings should be used. + +Please see The Java(TM) Cryptography Architecture (JCA) Reference +Guide and the java.security file for more information.
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.base/share/conf/security/policy/limited/default_US_export.policy Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,6 @@ +// Default US Export policy file. + +grant { + // There is no restriction to any algorithms. + permission javax.crypto.CryptoAllPermission; +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.base/share/conf/security/policy/limited/default_local.policy Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,14 @@ +// Some countries have import limits on crypto strength. This policy file +// is worldwide importable. + +grant { + permission javax.crypto.CryptoPermission "DES", 64; + permission javax.crypto.CryptoPermission "DESede", *; + permission javax.crypto.CryptoPermission "RC2", 128, + "javax.crypto.spec.RC2ParameterSpec", 128; + permission javax.crypto.CryptoPermission "RC4", 128; + permission javax.crypto.CryptoPermission "RC5", 128, + "javax.crypto.spec.RC5ParameterSpec", *, 12, *; + permission javax.crypto.CryptoPermission "RSA", *; + permission javax.crypto.CryptoPermission *, 128; +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.base/share/conf/security/policy/limited/exempt_local.policy Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,13 @@ +// Some countries have import limits on crypto strength, but may allow for +// these exemptions if the exemption mechanism is used. + +grant { + // There is no restriction to any algorithms if KeyRecovery is enforced. + permission javax.crypto.CryptoPermission *, "KeyRecovery"; + + // There is no restriction to any algorithms if KeyEscrow is enforced. + permission javax.crypto.CryptoPermission *, "KeyEscrow"; + + // There is no restriction to any algorithms if KeyWeakening is enforced. + permission javax.crypto.CryptoPermission *, "KeyWeakening"; +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.base/share/conf/security/policy/unlimited/default_US_export.policy Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,6 @@ +// Default US Export policy file. + +grant { + // There is no restriction to any algorithms. + permission javax.crypto.CryptoAllPermission; +};
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/src/java.base/share/conf/security/policy/unlimited/default_local.policy Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,6 @@ +// Country-specific policy file for countries with no limits on crypto strength. + +grant { + // There is no restriction to any algorithms. + permission javax.crypto.CryptoAllPermission; +};
--- a/jdk/src/java.base/share/native/libjli/java.c Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/java.base/share/native/libjli/java.c Wed Aug 31 09:22:54 2016 -0700 @@ -556,20 +556,6 @@ JLI_StrCmp(name, "--list-modules") == 0; } -#ifndef OLD_MODULE_OPTIONS -/* - * Old module options for transition - */ -static jboolean -IsOldModuleOption(const char* name) { - return JLI_StrCmp(name, "-modulepath") == 0 || - JLI_StrCmp(name, "-mp") == 0 || - JLI_StrCmp(name, "-upgrademodulepath") == 0 || - JLI_StrCmp(name, "-addmods") == 0 || - JLI_StrCmp(name, "-limitmods") == 0; -} -#endif - /* * Test if the given name is a module-system white-space option that * will be passed to the VM with its corresponding long-form option @@ -584,8 +570,7 @@ JLI_StrCmp(name, "--limit-modules") == 0 || JLI_StrCmp(name, "--add-exports") == 0 || JLI_StrCmp(name, "--add-reads") == 0 || - JLI_StrCmp(name, "--patch-module") == 0 || - IsOldModuleOption(name); + JLI_StrCmp(name, "--patch-module") == 0; } /* @@ -1224,32 +1209,6 @@ } } -#ifndef OLD_MODULE_OPTIONS - // for transition to support both old and new syntax - if (JLI_StrCmp(arg, "-modulepath") == 0 || - JLI_StrCmp(arg, "-mp") == 0) { - option = "--module-path"; - } else if (JLI_StrCmp(arg, "-upgrademodulepath") == 0) { - option = "--upgrade-module-path"; - } else if (JLI_StrCmp(arg, "-addmods") == 0) { - option = "--add-modules"; - } else if (JLI_StrCmp(arg, "-limitmods") == 0) { - option = "--limit-modules"; - } else if (JLI_StrCCmp(arg, "-XaddExports:") == 0) { - option = "--add-exports"; - value = arg + 13; - kind = VM_LONG_OPTION_WITH_ARGUMENT; - } else if (JLI_StrCCmp(arg, "-XaddReads:") == 0) { - option = "--add-reads"; - value = arg + 11; - kind = VM_LONG_OPTION_WITH_ARGUMENT; - } else if (JLI_StrCCmp(arg, "-Xpatch:") == 0) { - option = "--patch-module"; - value = arg + 8; - kind = VM_LONG_OPTION_WITH_ARGUMENT; - } -#endif - *pargc = argc; *pargv = argv; *poption = option; @@ -1340,16 +1299,6 @@ JLI_StrCmp(arg, "--patch-module") == 0) { REPORT_ERROR (has_arg, ARG_ERROR6, arg); } -#ifndef OLD_MODULE_OPTIONS - else if (JLI_StrCmp(arg, "-modulepath") == 0 || - JLI_StrCmp(arg, "-mp") == 0 || - JLI_StrCmp(arg, "-upgrademodulepath") == 0) { - REPORT_ERROR (has_arg, ARG_ERROR4, arg); - } else if (JLI_StrCmp(arg, "-addmods") == 0 || - JLI_StrCmp(arg, "-limitmods") == 0) { - REPORT_ERROR (has_arg, ARG_ERROR6, arg); - } -#endif /* * The following cases will cause the argument parsing to stop */
--- a/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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,10 +75,10 @@ } } try { - card = new CardImpl(this, protocol); + card = new CardImpl(this, protocol); return card; } catch (PCSCException e) { - if (e.code == SCARD_W_REMOVED_CARD) { + if (e.code == SCARD_W_REMOVED_CARD || e.code == SCARD_E_NO_SMARTCARD) { throw new CardNotPresentException("No card present", e); } else { throw new CardException("connect() failed", e);
--- a/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_util.c Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_util.c Wed Aug 31 09:22:54 2016 -0700 @@ -558,7 +558,7 @@ pCharArray = (*env)->GetStringUTFChars(env, jArray, &isCopy); if (pCharArray == NULL) { return; } - *ckpLength = strlen(pCharArray); + *ckpLength = (CK_ULONG) strlen(pCharArray); *ckpArray = (CK_UTF8CHAR_PTR) malloc((*ckpLength + 1) * sizeof(CK_UTF8CHAR)); if (*ckpArray == NULL) { (*env)->ReleaseStringUTFChars(env, (jstring) jArray, pCharArray);
--- a/jdk/src/jdk.crypto.pkcs11/unix/native/libj2pkcs11/j2secmod_md.c Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/jdk.crypto.pkcs11/unix/native/libj2pkcs11/j2secmod_md.c Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2005, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2005, 2016, 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,6 +49,7 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmod_nssGetLibraryHandle (JNIEnv *env, jclass thisClass, jstring jLibName) { + void *hModule; const char *libName = (*env)->GetStringUTFChars(env, jLibName, NULL); if (libName == NULL) { return 0L; @@ -56,9 +57,9 @@ // look up existing handle only, do not load #if defined(AIX) - void *hModule = dlopen(libName, RTLD_LAZY); + hModule = dlopen(libName, RTLD_LAZY); #else - void *hModule = dlopen(libName, RTLD_NOLOAD); + hModule = dlopen(libName, RTLD_NOLOAD); #endif dprintf2("-handle for %s: %u\n", libName, hModule); (*env)->ReleaseStringUTFChars(env, jLibName, libName);
--- a/jdk/src/jdk.crypto.pkcs11/windows/native/libj2pkcs11/j2secmod_md.c Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/jdk.crypto.pkcs11/windows/native/libj2pkcs11/j2secmod_md.c Wed Aug 31 09:22:54 2016 -0700 @@ -31,6 +31,9 @@ #include "j2secmod.h" +extern void throwNullPointerException(JNIEnv *env, const char *message); +extern void throwIOException(JNIEnv *env, const char *message); + void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) { HINSTANCE hModule = (HINSTANCE)jHandle; void *fAddress = GetProcAddress(hModule, functionName);
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java Wed Aug 31 09:22:54 2016 -0700 @@ -78,28 +78,21 @@ private final List<String> args; private final Set<String> modules; - public DefaultExecutableImage(Path home, Set<String> modules) { - this(home, modules, createArgs(home)); - } - - private DefaultExecutableImage(Path home, Set<String> modules, - List<String> args) { + DefaultExecutableImage(Path home, Set<String> modules) { Objects.requireNonNull(home); - Objects.requireNonNull(args); if (!Files.exists(home)) { throw new IllegalArgumentException("Invalid image home"); } this.home = home; this.modules = Collections.unmodifiableSet(modules); - this.args = Collections.unmodifiableList(args); + this.args = createArgs(home); } private static List<String> createArgs(Path home) { Objects.requireNonNull(home); - List<String> javaArgs = new ArrayList<>(); - javaArgs.add(home.resolve("bin"). - resolve(getJavaProcessName()).toString()); - return javaArgs; + Path binDir = home.resolve("bin"); + String java = Files.exists(binDir.resolve("java"))? "java" : "java.exe"; + return List.of(binDir.resolve(java).toString()); } @Override @@ -130,6 +123,7 @@ private final Path root; private final Path mdir; private final Set<String> modules = new HashSet<>(); + private String targetOsName; /** * Default image builder constructor. @@ -171,6 +165,11 @@ @Override public void storeFiles(ResourcePool files) { try { + // populate release properties up-front. targetOsName + // field is assigned from there and used elsewhere. + Properties release = releaseProperties(files); + Path bin = root.resolve("bin"); + files.entries().forEach(f -> { if (!f.type().equals(ResourcePoolEntry.Type.CLASS_OR_RESOURCE)) { try { @@ -186,11 +185,11 @@ modules.add(m.name()); } }); - storeFiles(modules, releaseProperties(files)); + + storeFiles(modules, release); if (Files.getFileStore(root).supportsFileAttributeView(PosixFileAttributeView.class)) { // launchers in the bin directory need execute permission - Path bin = root.resolve("bin"); if (Files.isDirectory(bin)) { Files.list(bin) .filter(f -> !f.toString().endsWith(".diz")) @@ -208,7 +207,11 @@ } } - prepareApplicationFiles(files, modules); + // If native files are stripped completely, <root>/bin dir won't exist! + // So, don't bother generating launcher scripts. + if (Files.isDirectory(bin)) { + prepareApplicationFiles(files, modules); + } } catch (IOException ex) { throw new PluginException(ex); } @@ -226,6 +229,11 @@ props.setProperty("JAVA_VERSION", System.getProperty("java.version")); }); + this.targetOsName = props.getProperty("OS_NAME"); + if (this.targetOsName == null) { + throw new PluginException("TargetPlatform attribute is missing for java.base module"); + } + Optional<ResourcePoolEntry> release = pool.findEntry("/java.base/release"); if (release.isPresent()) { try (InputStream is = release.get().content()) { @@ -373,7 +381,7 @@ Files.createLink(dstFile, target); } - private static String nativeDir(String filename) { + private String nativeDir(String filename) { if (isWindows()) { if (filename.endsWith(".dll") || filename.endsWith(".diz") || filename.endsWith(".pdb") || filename.endsWith(".map")) { @@ -386,8 +394,8 @@ } } - private static boolean isWindows() { - return System.getProperty("os.name").startsWith("Windows"); + private boolean isWindows() { + return targetOsName.startsWith("Windows"); } /** @@ -452,12 +460,10 @@ } } - private static String getJavaProcessName() { - return isWindows() ? "java.exe" : "java"; - } - public static ExecutableImage getExecutableImage(Path root) { - if (Files.exists(root.resolve("bin").resolve(getJavaProcessName()))) { + Path binDir = root.resolve("bin"); + if (Files.exists(binDir.resolve("java")) || + Files.exists(binDir.resolve("java.exe"))) { return new DefaultExecutableImage(root, retrieveModules(root)); } return null;
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathResourcePoolEntry.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/PathResourcePoolEntry.java Wed Aug 31 09:22:54 2016 -0700 @@ -5,7 +5,7 @@ * 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 "Classfile" exception as provided + * 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
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java Wed Aug 31 09:22:54 2016 -0700 @@ -24,14 +24,19 @@ */ package jdk.tools.jlink.internal.plugins; +import java.io.File; +import java.io.IOException; import java.lang.invoke.MethodType; -import java.util.Arrays; +import java.nio.file.Files; +import java.util.ArrayList; import java.util.EnumSet; -import java.util.HashMap; import java.util.List; import java.util.Map; import java.util.Set; +import java.util.TreeMap; +import java.util.TreeSet; import java.util.stream.Collectors; +import java.util.stream.Stream; import jdk.internal.misc.SharedSecrets; import jdk.internal.misc.JavaLangInvokeAccess; import jdk.tools.jlink.plugin.ResourcePoolEntry; @@ -47,12 +52,8 @@ private static final String NAME = "generate-jli-classes"; - private static final String BMH_PARAM = "bmh"; - private static final String BMH_SPECIES_PARAM = "bmh-species"; - private static final String DESCRIPTION = PluginsResourceBundle.getDescription(NAME); - private static final String DMH_PARAM = "dmh"; private static final String DIRECT_HOLDER = "java/lang/invoke/DirectMethodHandle$Holder"; private static final String DMH_INVOKE_VIRTUAL = "invokeVirtual"; private static final String DMH_INVOKE_STATIC = "invokeStatic"; @@ -61,8 +62,6 @@ private static final String DMH_INVOKE_INTERFACE = "invokeInterface"; private static final String DMH_INVOKE_STATIC_INIT = "invokeStaticInit"; - private static final String INVOKERS_PARAM = "invokers"; - private static final String DELEGATING_HOLDER = "java/lang/invoke/DelegatingMethodHandle$Holder"; private static final String BASIC_FORMS_HOLDER = "java/lang/invoke/LambdaForm$Holder"; private static final String INVOKERS_HOLDER = "java/lang/invoke/Invokers$Holder"; @@ -70,12 +69,11 @@ private static final JavaLangInvokeAccess JLIA = SharedSecrets.getJavaLangInvokeAccess(); - List<String> speciesTypes; + Set<String> speciesTypes; - List<String> invokerTypes; + Set<String> invokerTypes; - Map<String, List<String>> dmhMethods; - + Map<String, Set<String>> dmhMethods; public GenerateJLIClassesPlugin() { } @@ -112,8 +110,8 @@ * A better long-term solution is to define and run a set of quick * generators and extracting this list as a step in the build process. */ - public static List<String> defaultSpecies() { - return List.of("LL", "L3", "L4", "L5", "L6", "L7", "L7I", + public static Set<String> defaultSpecies() { + return Set.of("LL", "L3", "L4", "L5", "L6", "L7", "L7I", "L7II", "L7IIL", "L8", "L9", "L10", "L10I", "L10II", "L10IIL", "L11", "L12", "L13", "LI", "D", "L3I", "LIL", "LLI", "LLIL", "LILL", "I", "LLILL"); @@ -122,26 +120,27 @@ /** * @return the default invoker forms to generate. */ - public static List<String> defaultInvokers() { - return List.of("_L", "_I", "I_I", "LI_I", "ILL_I", "LIL_I", "L_L", "LL_V", "LLLL_L"); + private static Set<String> defaultInvokers() { + return Set.of("LL_L", "LL_I", "LILL_I", "L6_L"); } /** * @return the list of default DirectMethodHandle methods to generate. */ - public static Map<String, List<String>> defaultDMHMethods() { + private static Map<String, Set<String>> defaultDMHMethods() { return Map.of( - DMH_INVOKE_VIRTUAL, List.of("_L", "L_L", "LI_I", "LL_V"), - DMH_INVOKE_SPECIAL, List.of("L_I", "L_L", "LF_L", "LD_L", "LL_L", - "L3_L", "L4_L", "L5_L", "L6_L", "L7_L", "LI_I", "LI_L", "LIL_I", - "LII_I", "LII_L", "LLI_L", "LLI_I", "LILI_I", "LIIL_L", - "LIILL_L", "LIILL_I", "LIIL_I", "LILIL_I", "LILILL_I", - "LILII_I", "LI3_I", "LI3L_I", "LI3LL_I", "LI3_L", "LI4_I"), - DMH_INVOKE_STATIC, List.of("II_I", "IL_I", "ILIL_I", "ILII_I", - "_I", "_L", "_V", "D_L", "F_L", "I_I", "II_L", "LI_L", - "L_V", "L_L", "LL_L", "L3_L", "L4_L", "L5_L", "L6_L", - "L7_L", "L8_L", "L9_L", "L9I_L", "L9II_L", "L9IIL_L", - "L10_L", "L11_L", "L12_L", "L13_L", "L13I_L", "L13II_L") + DMH_INVOKE_VIRTUAL, Set.of("L_L", "LL_L", "LLI_I", "L3_V"), + DMH_INVOKE_SPECIAL, Set.of("LL_I", "LL_L", "LLF_L", "LLD_L", "L3_L", + "L4_L", "L5_L", "L6_L", "L7_L", "L8_L", "LLI_I", "LLI_L", + "LLIL_I", "LLII_I", "LLII_L", "L3I_L", "L3I_I", "LLILI_I", + "LLIIL_L", "LLIILL_L", "LLIILL_I", "LLIIL_I", "LLILIL_I", + "LLILILL_I", "LLILII_I", "LLI3_I", "LLI3L_I", "LLI3LL_I", + "LLI3_L", "LLI4_I"), + DMH_INVOKE_STATIC, Set.of("LII_I", "LIL_I", "LILIL_I", "LILII_I", + "L_I", "L_L", "L_V", "LD_L", "LF_L", "LI_I", "LII_L", "LLI_L", + "LL_V", "LL_L", "L3_L", "L4_L", "L5_L", "L6_L", "L7_L", + "L8_L", "L9_L", "L10_L", "L10I_L", "L10II_L", "L10IIL_L", + "L11_L", "L12_L", "L13_L", "L14_L", "L14I_L", "L14II_L") ); } @@ -160,94 +159,110 @@ public void configure(Map<String, String> config) { String mainArgument = config.get(NAME); - // Enable by default - boolean bmhEnabled = true; - boolean dmhEnabled = true; - boolean invokersEnabled = true; - if (mainArgument != null) { - List<String> args = Arrays.asList(mainArgument.split(",")); - if (!args.contains(BMH_PARAM)) { - bmhEnabled = false; - } - if (!args.contains(DMH_PARAM)) { - dmhEnabled = false; - } - if (!args.contains(INVOKERS_PARAM)) { - dmhEnabled = false; - } + if ("none".equals(mainArgument)) { + speciesTypes = Set.of(); + invokerTypes = Set.of(); + dmhMethods = Map.of(); + return; } - if (!bmhEnabled) { - speciesTypes = List.of(); - } else { - String args = config.get(BMH_SPECIES_PARAM); - List<String> bmhSpecies; - if (args != null && !args.isEmpty()) { - bmhSpecies = Arrays.stream(args.split(",")) - .map(String::trim) - .filter(s -> !s.isEmpty()) - .collect(Collectors.toList()); - } else { - bmhSpecies = defaultSpecies(); - } + // Start with the default configuration + Set<String> defaultBMHSpecies = defaultSpecies(); + // Expand BMH species signatures + defaultBMHSpecies = defaultBMHSpecies.stream() + .map(type -> expandSignature(type)) + .collect(Collectors.toSet()); - // Expand BMH species signatures - speciesTypes = bmhSpecies.stream() - .map(type -> expandSignature(type)) - .collect(Collectors.toList()); + Set<String> defaultInvokerTypes = defaultInvokers(); + validateMethodTypes(defaultInvokerTypes); + + Map<String, Set<String>> defaultDmhMethods = defaultDMHMethods(); + for (Set<String> dmhMethodTypes : defaultDmhMethods.values()) { + validateMethodTypes(dmhMethodTypes); } - if (!invokersEnabled) { - invokerTypes = List.of(); + // Extend the default configuration with the contents in the supplied + // input file + if (mainArgument == null || !mainArgument.startsWith("@")) { + speciesTypes = defaultBMHSpecies; + invokerTypes = defaultInvokerTypes; + dmhMethods = defaultDmhMethods; } else { - String args = config.get(INVOKERS_PARAM); - if (args != null && !args.isEmpty()) { - invokerTypes = Arrays.stream(args.split(",")) - .map(String::trim) - .filter(s -> !s.isEmpty()) - .collect(Collectors.toList()); - validateMethodTypes(invokerTypes); - } else { - invokerTypes = defaultInvokers(); - } - - } - // DirectMethodHandles - if (!dmhEnabled) { - dmhMethods = Map.of(); - } else { - dmhMethods = new HashMap<>(); - for (String dmhParam : DMH_METHOD_TYPE_MAP.keySet()) { - String args = config.get(dmhParam); - if (args != null && !args.isEmpty()) { - List<String> dmhMethodTypes = Arrays.stream(args.split(",")) - .map(String::trim) - .filter(s -> !s.isEmpty()) - .collect(Collectors.toList()); - dmhMethods.put(dmhParam, dmhMethodTypes); - validateMethodTypes(dmhMethodTypes); + File file = new File(mainArgument.substring(1)); + if (file.exists()) { + // Use TreeSet/TreeMap to keep things sorted in a deterministic + // order to avoid scrambling the layout on small changes and to + // ease finding methods in the generated code + speciesTypes = new TreeSet<>(defaultBMHSpecies); + invokerTypes = new TreeSet<>(defaultInvokerTypes); + dmhMethods = new TreeMap<>(); + for (Map.Entry<String, Set<String>> entry : defaultDmhMethods.entrySet()) { + dmhMethods.put(entry.getKey(), new TreeSet<>(entry.getValue())); } - } - if (dmhMethods.isEmpty()) { - dmhMethods = defaultDMHMethods(); + fileLines(file) + .map(line -> line.split(" ")) + .forEach(parts -> { + switch (parts[0]) { + case "[BMH_RESOLVE]": + speciesTypes.add(expandSignature(parts[1])); + break; + case "[LF_RESOLVE]": + String methodType = parts[3]; + validateMethodType(methodType); + if (parts[1].contains("Invokers")) { + invokerTypes.add(methodType); + } else if (parts[1].contains("DirectMethodHandle")) { + String dmh = parts[2]; + // ignore getObject etc for now (generated + // by default) + if (DMH_METHOD_TYPE_MAP.containsKey(dmh)) { + addDMHMethodType(dmh, methodType); + } + } + break; + default: break; // ignore + } + }); } } } - void validateMethodTypes(List<String> dmhMethodTypes) { + private void addDMHMethodType(String dmh, String methodType) { + validateMethodType(methodType); + Set<String> methodTypes = dmhMethods.get(dmh); + if (methodTypes == null) { + methodTypes = new TreeSet<>(); + dmhMethods.put(dmh, methodTypes); + } + methodTypes.add(methodType); + } + + private Stream<String> fileLines(File file) { + try { + return Files.lines(file.toPath()); + } catch (IOException io) { + throw new PluginException("Couldn't read file"); + } + } + + private void validateMethodTypes(Set<String> dmhMethodTypes) { for (String type : dmhMethodTypes) { - String[] typeParts = type.split("_"); - // check return type (second part) - if (typeParts.length != 2 || typeParts[1].length() != 1 - || "LJIFDV".indexOf(typeParts[1].charAt(0)) == -1) { - throw new PluginException( - "Method type signature must be of form [LJIFD]*_[LJIFDV]"); - } - // expand and check arguments (first part) - expandSignature(typeParts[0]); + validateMethodType(type); } } + private void validateMethodType(String type) { + String[] typeParts = type.split("_"); + // check return type (second part) + if (typeParts.length != 2 || typeParts[1].length() != 1 + || "LJIFDV".indexOf(typeParts[1].charAt(0)) == -1) { + throw new PluginException( + "Method type signature must be of form [LJIFD]*_[LJIFDV]"); + } + // expand and check arguments (first part) + expandSignature(typeParts[0]); + } + private static void requireBasicType(char c) { if ("LIJFD".indexOf(c) < 0) { throw new PluginException( @@ -295,23 +310,44 @@ private void generateHolderClasses(ResourcePoolBuilder out) { int count = 0; - for (List<String> entry : dmhMethods.values()) { + for (Set<String> entry : dmhMethods.values()) { count += entry.size(); } MethodType[] directMethodTypes = new MethodType[count]; int[] dmhTypes = new int[count]; int index = 0; - for (Map.Entry<String, List<String>> entry : dmhMethods.entrySet()) { + for (Map.Entry<String, Set<String>> entry : dmhMethods.entrySet()) { String dmhType = entry.getKey(); for (String type : entry.getValue()) { - directMethodTypes[index] = asMethodType(type); + // The DMH type to actually ask for is retrieved by removing + // the first argument, which needs to be of Object.class + MethodType mt = asMethodType(type); + if (mt.parameterCount() < 1 || + mt.parameterType(0) != Object.class) { + throw new PluginException( + "DMH type parameter must start with L"); + } + directMethodTypes[index] = mt.dropParameterTypes(0, 1); dmhTypes[index] = DMH_METHOD_TYPE_MAP.get(dmhType); index++; } } MethodType[] invokerMethodTypes = new MethodType[this.invokerTypes.size()]; - for (int i = 0; i < invokerTypes.size(); i++) { - invokerMethodTypes[i] = asMethodType(invokerTypes.get(i)); + int i = 0; + for (String invokerType : invokerTypes) { + // The invoker type to ask for is retrieved by removing the first + // and the last argument, which needs to be of Object.class + MethodType mt = asMethodType(invokerType); + final int lastParam = mt.parameterCount() - 1; + if (mt.parameterCount() < 2 || + mt.parameterType(0) != Object.class || + mt.parameterType(lastParam) != Object.class) { + throw new PluginException( + "Invoker type parameter must start and end with L"); + } + mt = mt.dropParameterTypes(lastParam, lastParam + 1); + invokerMethodTypes[i] = mt.dropParameterTypes(0, 1); + i++; } try { byte[] bytes = JLIA.generateDirectMethodHandleHolderClassBytes(
--- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties Wed Aug 31 09:22:54 2016 -0700 @@ -68,10 +68,12 @@ exclude-resources.description=\ Specify resources to exclude. e.g.: **.jcov,glob:**/META-INF/** -generate-jli-classes.argument=<bmh[:bmh-species=LL,L3,...]> +generate-jli-classes.argument=<none|@filename> generate-jli-classes.description=\ -Concrete java.lang.invoke classes to generate +Takes a file hinting to jlink what java.lang.invoke classes to pre-generate. If\n\ +this flag is not specified a default set of classes will be generated. To \n\ +disable pre-generation specify none as the argument installed-modules.description=Fast loading of module descriptors (always enabled)
--- a/jdk/test/ProblemList.txt Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/ProblemList.txt Wed Aug 31 09:22:54 2016 -0700 @@ -213,8 +213,6 @@ sun/security/pkcs11/ec/TestKeyFactory.java 8026976 generic-all -sun/security/krb5/auto/Unreachable.java 7164518 macosx-all - sun/security/tools/keytool/ListKeychainStore.sh 8156889 macosx-all sun/security/tools/jarsigner/warnings/BadKeyUsageTest.java 8026393 generic-all
--- a/jdk/test/java/lang/ProcessBuilder/Zombies.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/lang/ProcessBuilder/Zombies.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ * @test * @run main/othervm Zombies * @bug 6474073 6180151 - * @key intermittent * @summary Make sure zombies don't get created on Unix * @author Martin Buchholz */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/net/HttpCookie/CookieNegativeMaxAge.java Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,56 @@ +/* + * Copyright (c) 2016, 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 8005068 + * @summary Check that any negative maxAge is treated as "unspecified" and + * if header contains cookie with "expires" attribute in the past then cookie + * is created with maxAge=0 meaning it is specified to be immediately expired. + * @run main CookieNegativeMaxAge + */ + + +import java.net.HttpCookie; +import java.util.List; + +public class CookieNegativeMaxAge { + + public static void main(String... args) { + HttpCookie cookie = new HttpCookie("testCookie", "value"); + cookie.setMaxAge(Integer.MIN_VALUE); + if (cookie.hasExpired()) { + throw new RuntimeException("Cookie has unexpectedly expired"); + } + + List<HttpCookie> cookies = HttpCookie.parse("Set-Cookie: " + + "expiredCookie=value; expires=Thu, 01 Jan 1970 00:00:00 GMT"); + if (cookies.size() == 1) { + if (cookies.get(0).getMaxAge() != 0) { + throw new RuntimeException("Cookie maxAge expected to be 0"); + } + } else { + throw new RuntimeException("Header was incorrectly parsed"); + } + } +}
--- a/jdk/test/java/net/URLPermission/nstest/lookup.sh Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/net/URLPermission/nstest/lookup.sh Wed Aug 31 09:22:54 2016 -0700 @@ -27,6 +27,7 @@ # @build jdk.testlibrary.* # @compile -XDignore.symbol.file=true LookupTest.java # @run shell/timeout=50 lookup.sh +# @key intermittent # OS=`uname -s`
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/java/net/httpclient/ProxyAuthTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,174 @@ +/* + * Copyright (c) 2016, 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 + */ + +/* + * @test + * @bug 8163561 + * @modules java.base/sun.net.www + * @summary Verify that Proxy-Authenticate header is correctly handled + * + * @run main/othervm ProxyAuthTest + */ + +import java.io.BufferedWriter; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.io.OutputStreamWriter; +import java.io.PrintWriter; +import java.net.Authenticator; +import java.net.InetSocketAddress; +import java.net.PasswordAuthentication; +import java.net.ProxySelector; +import java.net.ServerSocket; +import java.net.Socket; +import java.net.URI; +import java.net.http.HttpClient; +import java.net.http.HttpResponse; +import java.util.Base64; + +import sun.net.www.MessageHeader; + +public class ProxyAuthTest { + private static final String AUTH_USER = "user"; + private static final String AUTH_PASSWORD = "password"; + + public static void main(String[] args) throws Exception { + try (ServerSocket ss = new ServerSocket(0)) { + int port = ss.getLocalPort(); + MyProxy proxy = new MyProxy(ss); + (new Thread(proxy)).start(); + System.out.println("Proxy listening port " + port); + + Auth auth = new Auth(); + InetSocketAddress paddr = new InetSocketAddress("localhost", port); + + URI uri = new URI("http://www.google.ie/"); + HttpClient client = HttpClient.create() + .proxy(ProxySelector.of(paddr)) + .authenticator(auth) + .build(); + HttpResponse resp = client.request(uri) + .GET() + .responseAsync() + .get(); + if (resp.statusCode() != 404) { + throw new RuntimeException("Unexpected status code: " + resp.statusCode()); + } + + if (auth.isCalled) { + System.out.println("Authenticator is called"); + } else { + throw new RuntimeException("Authenticator is not called"); + } + + if (!proxy.matched) { + throw new RuntimeException("Proxy authentication failed"); + } + } + } + + static class Auth extends Authenticator { + private volatile boolean isCalled; + + @Override + protected PasswordAuthentication getPasswordAuthentication() { + System.out.println("scheme: " + this.getRequestingScheme()); + isCalled = true; + return new PasswordAuthentication(AUTH_USER, + AUTH_PASSWORD.toCharArray()); + } + } + + static class MyProxy implements Runnable { + final ServerSocket ss; + private volatile boolean matched; + + MyProxy(ServerSocket ss) { + this.ss = ss; + } + + public void run() { + for (int i = 0; i < 2; i++) { + try (Socket s = ss.accept(); + InputStream in = s.getInputStream(); + OutputStream os = s.getOutputStream(); + BufferedWriter writer = new BufferedWriter( + new OutputStreamWriter(os)); + PrintWriter out = new PrintWriter(writer);) { + MessageHeader headers = new MessageHeader(in); + System.out.println("Proxy: received " + headers); + + String authInfo = headers + .findValue("Proxy-Authorization"); + if (authInfo != null) { + authenticate(authInfo); + out.print("HTTP/1.1 404 Not found\r\n"); + out.print("\r\n"); + System.out.println("Proxy: 404"); + out.flush(); + } else { + out.print("HTTP/1.1 407 Proxy Authorization Required\r\n"); + out.print( + "Proxy-Authenticate: Basic realm=\"a fake realm\"\r\n"); + out.print("\r\n"); + System.out.println("Proxy: Authorization required"); + out.flush(); + } + } catch (IOException x) { + System.err.println("Unexpected IOException from proxy."); + x.printStackTrace(); + break; + } + } + } + + private void authenticate(String authInfo) throws IOException { + try { + authInfo.trim(); + int ind = authInfo.indexOf(' '); + String recvdUserPlusPass = authInfo.substring(ind + 1).trim(); + // extract encoded username:passwd + String value = new String( + Base64.getMimeDecoder().decode(recvdUserPlusPass)); + String userPlusPassword = AUTH_USER + ":" + AUTH_PASSWORD; + if (userPlusPassword.equals(value)) { + matched = true; + System.out.println("Proxy: client authentication successful"); + } else { + System.err.println( + "Proxy: client authentication failed, expected [" + + userPlusPassword + "], actual [" + value + + "]"); + } + } catch (Exception e) { + throw new IOException( + "Proxy received invalid Proxy-Authorization value: " + + authInfo); + } + } + } + +} +
--- a/jdk/test/java/nio/channels/FileChannel/Lock.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/nio/channels/FileChannel/Lock.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2001, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2001, 2016, 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 @@ -22,8 +22,8 @@ */ /* @test - * @bug 4429043 4493595 6332756 6709457 - * @summary The FileChannel file locking + * @bug 4429043 4493595 6332756 6709457 7146506 + * @summary Test FileChannel file locking */ import java.io.*; @@ -33,17 +33,14 @@ /** * Testing FileChannel's lock method. */ - public class Lock { public static void main(String[] args) throws Exception { - if (args.length > 0) { - if(args[0].equals("1")) { - MadWriter mw = new MadWriter(args[1], false); - } else { - MadWriter mw = new MadWriter(args[1], true); - } + if (args.length == 2) { + attemptLock(args[1], args[0].equals("2")); return; + } else if (args.length != 0) { + throw new RuntimeException("Wrong number of parameters."); } File blah = File.createTempFile("blah", null); blah.deleteOnExit(); @@ -56,120 +53,128 @@ test2(blah, false); test3(blah); test4(blah); - blah.delete(); } - private static void test2(File blah, boolean b) throws Exception { - RandomAccessFile raf = new RandomAccessFile(blah, "rw"); - FileChannel channel = raf.getChannel(); - FileLock lock; - if (b) - lock = channel.lock(); - else - lock = channel.tryLock(); - lock.release(); - channel.close(); + /** + * Test mutual locking with other process + */ + static void test1(File blah, String str) throws Exception { + try (RandomAccessFile fis = new RandomAccessFile(blah, "rw")) { + FileChannel fc = fis.getChannel(); + FileLock lock = null; + + // grab the lock + if (str.equals("1")) { + lock = fc.lock(0, 10, false); + if (lock == null) + throw new RuntimeException("Lock should not return null"); + try { + fc.lock(5, 10, false); + throw new RuntimeException("Overlapping locks allowed"); + } catch (OverlappingFileLockException e) {} // correct result + } + + // execute the tamperer + String command = System.getProperty("java.home") + + File.separator + "bin" + File.separator + "java"; + String testClasses = System.getProperty("test.classes"); + if (testClasses != null) + command += " -cp " + testClasses; + command += " Lock " + str + " " + blah; + Process p = Runtime.getRuntime().exec(command); + + // evaluate System.out of child process + String s; + boolean hasOutput = false; + InputStreamReader isr; + isr = new InputStreamReader(p.getInputStream()); + BufferedReader br = new BufferedReader(isr); + while ((s = br.readLine()) != null) { + // only throw on Unix as windows over NFS fails... + if ((File.separatorChar == '/') && !s.equals("good")) { + throw new RuntimeException("Failed: " + s); + } + hasOutput = true; + } + + // evaluate System.err in case of System.out of child process + // was empty + if (!hasOutput) { + isr = new InputStreamReader(p.getErrorStream()); + br = new BufferedReader(isr); + if ((s = br.readLine()) != null) { + System.err.println("Error output:"); + System.err.println(s); + while ((s = br.readLine()) != null) { + System.err.println(s); + } + } + throw new RuntimeException("Failed, no output"); + } + + // clean up, check multiple releases + if (lock != null) { + lock.release(); + lock.release(); + } + } } - static void test1(File blah, String str) throws Exception { - - // Grab the lock - RandomAccessFile fis = new RandomAccessFile(blah, "rw"); - FileChannel fc = fis.getChannel(); - FileLock lock = null; - - if (str.equals("1")) { - lock = fc.lock(0, 10, false); - if (lock == null) - throw new RuntimeException("Lock should not return null"); - try { - FileLock lock2 = fc.lock(5, 10, false); - throw new RuntimeException("Overlapping locks allowed"); - } catch (OverlappingFileLockException e) { - // Correct result - } - } - - // Exec the tamperer - String command = System.getProperty("java.home") + - File.separator + "bin" + File.separator + "java"; - String testClasses = System.getProperty("test.classes"); - if (testClasses != null) - command += " -cp " + testClasses; - command += " Lock " + str + " " + blah; - Process p = Runtime.getRuntime().exec(command); - - BufferedReader in = new BufferedReader - (new InputStreamReader(p.getInputStream())); - - String s; - int count = 0; - while ((s = in.readLine()) != null) { - if (!s.equals("good")) { - if (File.separatorChar == '/') { - // Fails on windows over NFS... - throw new RuntimeException("Failed: "+s); - } - } - count++; - } - - if (count == 0) { - in = new BufferedReader(new InputStreamReader(p.getErrorStream())); - while ((s = in.readLine()) != null) { - System.err.println("Error output: " + s); - } - throw new RuntimeException("Failed, no output"); - } - - // Clean up - if (lock != null) { - /* Check multiple releases */ - lock.release(); + /** + * Basic test for FileChannel.lock() and FileChannel.tryLock() + */ + static void test2(File blah, boolean b) throws Exception { + try (RandomAccessFile raf = new RandomAccessFile(blah, "rw")) { + FileChannel channel = raf.getChannel(); + FileLock lock; + if (b) + lock = channel.lock(); + else + lock = channel.tryLock(); lock.release(); } - fc.close(); - fis.close(); } - // The overlap check for file locks should be JVM-wide - private static void test3(File blah) throws Exception { - FileChannel fc1 = new RandomAccessFile(blah, "rw").getChannel(); - FileChannel fc2 = new RandomAccessFile(blah, "rw").getChannel(); + /** + * Test that overlapping file locking is not possible when using different + * FileChannel objects to the same file path + */ + static void test3(File blah) throws Exception { + try (RandomAccessFile raf1 = new RandomAccessFile(blah, "rw"); + RandomAccessFile raf2 = new RandomAccessFile(blah, "rw")) + { + FileChannel fc1 = raf1.getChannel(); + FileChannel fc2 = raf2.getChannel(); - // lock via one channel, and then attempt to lock the same file - // using a second channel - FileLock fl1 = fc1.lock(); - try { - fc2.tryLock(); - throw new RuntimeException("Overlapping locks allowed"); - } catch (OverlappingFileLockException x) { + // lock via one channel, and then attempt to lock the same file + // using a second channel + FileLock fl1 = fc1.lock(); + try { + fc2.tryLock(); + throw new RuntimeException("Overlapping locks allowed"); + } catch (OverlappingFileLockException x) {} + try { + fc2.lock(); + throw new RuntimeException("Overlapping locks allowed"); + } catch (OverlappingFileLockException x) {} + + // release lock and the attempt to lock with the second channel + // should succeed. + fl1.release(); + fc2.lock(); + try { + fc1.lock(); + throw new RuntimeException("Overlapping locks allowed"); + } catch (OverlappingFileLockException x) {} } - try { - fc2.lock(); - throw new RuntimeException("Overlapping locks allowed"); - } catch (OverlappingFileLockException x) { - } - - // release lock and the attempt to lock with the second channel - // should succeed. - fl1.release(); - FileLock fl2 = fc2.lock(); - try { - fc1.lock(); - throw new RuntimeException("Overlapping locks allowed"); - } catch (OverlappingFileLockException x) { - } - - fc1.close(); - fc2.close(); } /** * Test file locking when file is opened for append */ static void test4(File blah) throws Exception { - try (FileChannel fc = new FileOutputStream(blah, true).getChannel()) { + try (FileOutputStream fos = new FileOutputStream(blah, true)) { + FileChannel fc = fos.getChannel(); fc.tryLock().release(); fc.tryLock(0L, 1L, false).release(); fc.lock().release(); @@ -182,30 +187,31 @@ fc.lock(0L, 1L, false).release(); } } + + /** + * Utility method to be run in secondary process which tries to acquire a + * lock on a FileChannel + */ + static void attemptLock(String fileName, + boolean expectsLock) throws Exception + { + File f = new File(fileName); + try (RandomAccessFile raf = new RandomAccessFile(f, "rw")) { + FileChannel fc = raf.getChannel(); + if (fc.tryLock(10, 10, false) == null) { + System.out.println("bad: Failed to grab adjacent lock"); + } + if (fc.tryLock(0, 10, false) == null) { + if (expectsLock) + System.out.println("bad"); + else + System.out.println("good"); + } else { + if (expectsLock) + System.out.println("good"); + else + System.out.println("bad"); + } + } + } } - -class MadWriter { - public MadWriter(String s, boolean b) throws Exception { - File f = new File(s); - RandomAccessFile fos = new RandomAccessFile(f, "rw"); - FileChannel fc = fos.getChannel(); - if (fc.tryLock(10, 10, false) == null) { - System.out.println("bad: Failed to grab adjacent lock"); - } - FileLock lock = fc.tryLock(0, 10, false); - if (lock == null) { - if (b) - System.out.println("bad"); - else - System.out.println("good"); - } else { - if (b) - System.out.println("good"); - else - System.out.println("bad"); - } - fc.close(); - fos.close(); - } - -}
--- a/jdk/test/java/text/Bidi/BidiConformance.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Bidi/BidiConformance.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2009, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2009, 2016, 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 @@ * @test * @bug 6850113 8032446 * @summary confirm the behavior of new Bidi implementation. (Backward compatibility) + * @modules java.desktop */ import java.awt.font.NumericShaper;
--- a/jdk/test/java/text/Bidi/BidiEmbeddingTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Bidi/BidiEmbeddingTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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 @@ * indicate overrides, rather than using bit 7. Also tests Bidi without loading awt classes to * confirm that Bidi can be used without awt. Verify that embedding level 0 is properly mapped * to the base embedding level. + * @modules java.desktop */ import java.awt.Color;
--- a/jdk/test/java/text/Bidi/Bug7042148.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Bidi/Bug7042148.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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 @@ * @test * @bug 7042148 * @summary verify that Bidi.baseIsLeftToRight() returns the correct value even if an incorrect position is set in the given AttributedCharacterIterator. + * @modules java.desktop */ import java.awt.font.*; import java.text.*;
--- a/jdk/test/java/text/Bidi/Bug7051769.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Bidi/Bug7051769.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2011, 2016, 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,6 +26,7 @@ * @bug 7051769 8038092 * @summary verify that Bidi.toString() returns the corect result. * The second run is intended to test lazy SharedSectets init for 8038092 + * @modules java.desktop * @run main Bug7051769 * @run main/othervm -DpreloadBidi=true Bug7051769 */
--- a/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java Wed Aug 31 09:22:54 2016 -0700 @@ -22,9 +22,10 @@ */ /* - @test - @summary test Comparison of New Collators against Old Collators in the en_US locale -*/ + * @test + * @summary test Comparison of New Collators against Old Collators in the en_US locale + * @modules jdk.localedata + */ import java.io.*; import java.util.Enumeration;
--- a/jdk/test/java/text/Collator/APITest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/APITest.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Collation API + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
--- a/jdk/test/java/text/Collator/CollationKeyTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/CollationKeyTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -29,6 +29,7 @@ * RuleBasedCollationKey. This test basically tests on the two features: * 1. Existing code using CollationKey works (backward compatiblility) * 2. CollationKey can be extended by its subclass. + * @modules jdk.localedata */
--- a/jdk/test/java/text/Collator/DanishTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/DanishTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -26,6 +26,7 @@ * @bug 4930708 4174436 5008498 * @library /java/text/testlib * @summary test Danish Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
--- a/jdk/test/java/text/Collator/FinnishTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/FinnishTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Finnish Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
--- a/jdk/test/java/text/Collator/FrenchTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/FrenchTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test French Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
--- a/jdk/test/java/text/Collator/G7Test.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/G7Test.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test G7 Collation + * @modules jdk.localedata */ /* *
--- a/jdk/test/java/text/Collator/JapaneseTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/JapaneseTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test 1.1 02/09/11 * @bug 4176141 4655819 * @summary Regression tests for Japanese Collation + * @modules jdk.localedata */ import java.text.*;
--- a/jdk/test/java/text/Collator/KoreanTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/KoreanTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test 1.1 02/09/12 * @bug 4176141 4655819 * @summary Regression tests for Korean Collation + * @modules jdk.localedata */ import java.text.*;
--- a/jdk/test/java/text/Collator/Regression.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/Regression.java Wed Aug 31 09:22:54 2016 -0700 @@ -29,6 +29,7 @@ * 4133509 4139572 4141640 4179126 4179686 4244884 4663220 * @library /java/text/testlib * @summary Regression tests for Collation and associated classes + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
--- a/jdk/test/java/text/Collator/ThaiTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/ThaiTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Thai Collation + * @modules jdk.localedata */ /* * Copyright (c) 2007, Oracle and/or its affiliates. All rights reserved.
--- a/jdk/test/java/text/Collator/TurkishTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/TurkishTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Turkish Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved
--- a/jdk/test/java/text/Collator/VietnameseTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Collator/VietnameseTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -26,6 +26,7 @@ * @bug 4932968 5015215 * @library /java/text/testlib * @summary test Vietnamese Collation + * @modules jdk.localedata */ /*
--- a/jdk/test/java/text/Format/DateFormat/Bug4823811.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/DateFormat/Bug4823811.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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 @@ * @test * @bug 4823811 8008577 * @summary Confirm that text which includes numbers with a trailing minus sign is parsed correctly. + * @modules jdk.localedata * @run main/othervm -Duser.timezone=GMT+09:00 -Djava.locale.providers=JRE,SPI Bug4823811 */
--- a/jdk/test/java/text/Format/DateFormat/Bug6683975.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/DateFormat/Bug6683975.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2008, 2016, 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 @@ * @test * @bug 6683975 8008577 * @summary Make sure that date is formatted correctlyin th locale. + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=JRE,SPI Bug6683975 */ import java.text.*;
--- a/jdk/test/java/text/Format/DateFormat/Bug8139572.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/DateFormat/Bug8139572.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,6 +26,7 @@ * @bug 8139572 * @summary SimpleDateFormat parse month stand-alone format bug * @compile -encoding utf-8 Bug8139572.java + * @modules jdk.localedata * @run main Bug8139572 */ import java.text.ParseException;
--- a/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2012, 2016, 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 @@ * @test * @bug 7079560 8008577 * @summary Unit test for context-sensitive month names + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=JRE,SPI ContextMonthNamesTest */
--- a/jdk/test/java/text/Format/DateFormat/DateFormatTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/DateFormat/DateFormatTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -26,6 +26,7 @@ * @bug 4052223 4089987 4469904 4326988 4486735 8008577 8045998 8140571 * @summary test DateFormat and SimpleDateFormat. * @library /java/text/testlib + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=COMPAT,SPI DateFormatTest */
--- a/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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,6 +24,7 @@ /** * @test * @bug 8080774 + * @modules jdk.localedata * @run testng/othervm -Djava.locale.providers=JRE,CLDR LocaleDateFormats * @summary This file contains tests for JRE locales date formats */
--- a/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test * @bug 4833268 6253991 8008577 * @summary Test formatting and parsing with non-Gregorian calendars + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=COMPAT,SPI NonGregorianFormatTest */
--- a/jdk/test/java/text/Format/DateFormat/bug4117335.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/DateFormat/bug4117335.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test * * @bug 4117335 4432617 + * @modules jdk.localedata */ import java.text.DateFormatSymbols ;
--- a/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test * @bug 4112090 8008577 * @summary verify that MessageFormat can handle large numbers of arguments + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=COMPAT,SPI LargeMessageFormat */
--- a/jdk/test/java/text/Format/NumberFormat/Bug8132125.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/NumberFormat/Bug8132125.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2015, 2016, 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 @@ * @test * @bug 8132125 * @summary Checks Swiss' number elements + * @modules jdk.localedata */ import java.text.*;
--- a/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test * @bug 4290801 4942982 5102005 8008577 8021121 * @summary Basic tests for currency formatting. + * @modules jdk.localedata * @run main/othervm -Djava.locale.providers=JRE,SPI CurrencyFormat */
--- a/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test International Number Format API + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996, 1997 - All Rights Reserved
--- a/jdk/test/java/text/Format/NumberFormat/NumberRegression.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/NumberFormat/NumberRegression.java Wed Aug 31 09:22:54 2016 -0700 @@ -34,6 +34,7 @@ * @library /java/text/testlib * @build IntlTest HexDumpReader TestUtils * @modules java.base/sun.util.resources + * jdk.localedata * @compile -XDignore.symbol.file NumberRegression.java * @run main/othervm -Djava.locale.providers=COMPAT,SPI NumberRegression */
--- a/jdk/test/java/text/Format/NumberFormat/NumberTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/java/text/Format/NumberFormat/NumberTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -27,6 +27,7 @@ * @summary test NumberFormat * @library /java/text/testlib * @modules java.base/sun.util.resources + * jdk.localedata * @compile -XDignore.symbol.file NumberTest.java * @run main/othervm -Djava.locale.providers=COMPAT,SPI NumberTest */
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/jdk/test/javax/crypto/CryptoPermissions/TestUnlimited.java Wed Aug 31 09:22:54 2016 -0700 @@ -0,0 +1,96 @@ +/* + * Copyright (c) 2016, 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. + */ + +/** + * @test + * @bug 8061842 + * @summary Package jurisdiction policy files as something other than JAR + * @run main/othervm TestUnlimited "" exception + * @run main/othervm TestUnlimited limited fail + * @run main/othervm TestUnlimited unlimited pass + * @run main/othervm TestUnlimited unlimited/ pass + * @run main/othervm TestUnlimited NosuchDir exception + * @run main/othervm TestUnlimited . exception + * @run main/othervm TestUnlimited /tmp/unlimited exception + * @run main/othervm TestUnlimited ../policy/unlimited exception + * @run main/othervm TestUnlimited ./unlimited exception + * @run main/othervm TestUnlimited /unlimited exception + */ +import javax.crypto.*; +import java.security.Security; + +public class TestUnlimited { + + public static void main(String[] args) throws Exception { + /* + * Override the Security property to allow for unlimited policy. + * Would need appropriate permissions if Security Manager were + * active. + */ + if (args.length != 2) { + throw new Exception("Two args required"); + } + + boolean expected = args[1].equals("pass"); + boolean exception = args[1].equals("exception"); + boolean result = false; + + System.out.println("Testing: " + args[0]); + + if (args[0].equals("\"\"")) { + Security.setProperty("crypto.policy", ""); + } else { + Security.setProperty("crypto.policy", args[0]); + } + + /* + * Use the AES as the test Cipher + * If there is an error initializing, we will never get past here. + */ + try { + int maxKeyLen = Cipher.getMaxAllowedKeyLength("AES"); + System.out.println("max AES key len:" + maxKeyLen); + if (maxKeyLen > 128) { + System.out.println("Unlimited policy is active"); + result = true; + } else { + System.out.println("Unlimited policy is NOT active"); + result = false; + } + } catch (Throwable e) { + if (!exception) { + throw new Exception(); + } + } + + System.out.println( + "Expected:\t" + expected + "\nResult:\t\t" + result); + if (expected != result) { + throw new Exception(); + } + + System.out.println("DONE!"); + } +}
--- a/jdk/test/jdk/security/JavaDotSecurity/final_java_security Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/jdk/security/JavaDotSecurity/final_java_security Wed Aug 31 09:22:54 2016 -0700 @@ -10,6 +10,7 @@ foo.6=9a foo.7=10 foo.8=12 +crypto.policy=somepolicy package.access=sun.,\ solaris.,\
--- a/jdk/test/jdk/security/JavaDotSecurity/ifdefs.sh Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/jdk/security/JavaDotSecurity/ifdefs.sh Wed Aug 31 09:22:54 2016 -0700 @@ -46,7 +46,13 @@ fi $JAVAC -d . $TOOLSRC -$JAVA $TOOLNAME $TESTSRC/raw_java_security outfile solaris sparc $TESTSRC/more_restricted +$JAVA $TOOLNAME \ + $TESTSRC/raw_java_security \ + outfile \ + solaris \ + sparc \ + somepolicy \ + $TESTSRC/more_restricted # On Windows, line end could be different. -b is a cross-platform option. -diff -b outfile $TESTSRC/final_java_security \ No newline at end of file +diff -b outfile $TESTSRC/final_java_security
--- a/jdk/test/jdk/security/JavaDotSecurity/raw_java_security Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/jdk/security/JavaDotSecurity/raw_java_security Wed Aug 31 09:22:54 2016 -0700 @@ -44,6 +44,7 @@ #ifndef macosx-x64 foo.tbd=12 #endif +crypto.policy=crypto.policydir-tbd package.access=sun.,\ #ifdef solaris
--- a/jdk/test/sun/security/krb5/auto/Unreachable.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/sun/security/krb5/auto/Unreachable.java Wed Aug 31 09:22:54 2016 -0700 @@ -23,31 +23,108 @@ /* * @test - * @bug 7162687 + * @bug 7162687 8015595 * @key intermittent * @summary enhance KDC server availability detection * @compile -XDignore.symbol.file Unreachable.java - * @run main/othervm/timeout=10 Unreachable + * @run main/othervm Unreachable */ - -import java.io.File; +import java.net.PortUnreachableException; +import java.net.SocketTimeoutException; +import java.net.DatagramPacket; +import java.net.DatagramSocket; +import java.net.InetSocketAddress; +import java.util.concurrent.Callable; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Future; +import java.util.concurrent.TimeUnit; +import java.util.concurrent.TimeoutException; +import java.util.concurrent.Executors; import javax.security.auth.login.LoginException; import sun.security.krb5.Config; public class Unreachable { + // Wait for 20 second until unreachable KDC throws PortUnreachableException. + private static final int TIMEOUT = 20; + private static final String REALM = "RABBIT.HOLE"; + private static final String HOST = "127.0.0.1"; + private static final int PORT = 13434; + private static final String KRB_CONF = "unreachable.krb5.conf"; + public static void main(String[] args) throws Exception { - File f = new File( - System.getProperty("test.src", "."), "unreachable.krb5.conf"); - System.setProperty("java.security.krb5.conf", f.getPath()); - Config.refresh(); - // If PortUnreachableException is not received, the login will consume - // about 3*3*30 seconds and the test will timeout. + // - Only PortUnreachableException will allow to continue execution. + // - SocketTimeoutException may occur on Mac because it will not throw + // PortUnreachableException for unreachable port in which case the Test + // execution will be skipped. + // - For Reachable port, the Test execution will get skipped. + // - Any other Exception will be treated as Test failure. + if (!findPortUnreachableExc()) { + System.out.println(String.format("WARNING: Either a reachable " + + "connection found to %s:%s or SocketTimeoutException " + + "occured which means PortUnreachableException not thrown" + + " by the platform.", HOST, PORT)); + return; + } + KDC kdc = KDC.existing(REALM, HOST, PORT); + KDC.saveConfig(KRB_CONF, kdc); + ExecutorService executor = Executors.newSingleThreadExecutor(); + Future<Exception> future = executor.submit(new Callable<Exception>() { + @Override + public Exception call() { + System.setProperty("java.security.krb5.conf", KRB_CONF); + try { + Config.refresh(); + // If PortUnreachableException is not received, the login + // will consume about 3*3*30 seconds and the test will + // timeout. + try { + Context.fromUserPass("name", "pass".toCharArray(), true); + } catch (LoginException le) { + // This is OK + } + System.out.println("Execution successful."); + } catch (Exception e) { + return e; + } + return null; + } + }); try { - Context.fromUserPass("name", "pass".toCharArray(), true); - } catch (LoginException le) { - // This is OK + Exception ex = null; + if ((ex = future.get(TIMEOUT, TimeUnit.SECONDS)) != null) { + throw new RuntimeException(ex); + } + } catch (TimeoutException e) { + future.cancel(true); + throw new RuntimeException("PortUnreachableException not thrown."); + } finally { + executor.shutdownNow(); } } + + /** + * If the remote destination to which the socket is connected does not + * exist, or is otherwise unreachable, and if an ICMP destination unreachable + * packet has been received for that address, then a subsequent call to + * send or receive may throw a PortUnreachableException. Note, there is no + * guarantee that the exception will be thrown. + */ + private static boolean findPortUnreachableExc() throws Exception { + try { + InetSocketAddress iaddr = new InetSocketAddress(HOST, PORT); + DatagramSocket dgSocket = new DatagramSocket(); + dgSocket.setSoTimeout(5000); + dgSocket.connect(iaddr); + byte[] data = new byte[]{}; + dgSocket.send(new DatagramPacket(data, data.length, iaddr)); + dgSocket.receive(new DatagramPacket(data, data.length)); + } catch (PortUnreachableException e) { + return true; + } catch (SocketTimeoutException e) { + return false; + } + return false; + } }
--- a/jdk/test/sun/security/krb5/auto/unreachable.krb5.conf Fri Aug 26 10:02:50 2016 -0700 +++ /dev/null Thu Jan 01 00:00:00 1970 +0000 @@ -1,9 +0,0 @@ -[libdefaults] - default_realm = RABBIT.HOLE -[realms] - -RABBIT.HOLE = { - kdc = 127.0.0.1:13434 - kdc = 127.0.0.1:13435 - kdc = 127.0.0.1:13436 -}
--- a/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java Wed Aug 31 09:22:54 2016 -0700 @@ -20,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + import java.security.SecureRandom; import java.security.Security; @@ -27,15 +28,15 @@ * @test * @bug 8051408 * @summary make sure nextBytes etc can be called before setSeed + * @run main/othervm -Djava.security.egd=file:/dev/urandom AutoReseed */ public class AutoReseed { public static void main(String[] args) throws Exception { SecureRandom sr; - String old = Security.getProperty("securerandom.drbg.config"); - try { - for (String mech : - new String[]{"Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) { + boolean pass = true; + for (String mech : new String[]{"Hash_DRBG", "HMAC_DRBG", "CTR_DRBG"}) { + try { System.out.println("Testing " + mech + "..."); Security.setProperty("securerandom.drbg.config", mech); @@ -46,9 +47,13 @@ sr.reseed(); sr = SecureRandom.getInstance("DRBG"); sr.generateSeed(10); + } catch (Exception e) { + pass = false; + e.printStackTrace(System.out); } - } finally { - Security.setProperty("securerandom.drbg.config", old); + } + if (!pass) { + throw new RuntimeException("At least one test case failed"); } } }
--- a/jdk/test/sun/security/ssl/SSLSocketImpl/CloseSocket.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/sun/security/ssl/SSLSocketImpl/CloseSocket.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2016, 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,67 +26,96 @@ * @bug 4674913 * @summary Verify that EOFException are correctly handled during the handshake * @author Andreas Sterbenz + * @run main/othervm CloseSocket */ -import java.io.*; -import java.net.*; - -import javax.net.ssl.*; +import javax.net.SocketFactory; +import javax.net.ssl.SSLSocket; +import javax.net.ssl.SSLSocketFactory; +import java.io.IOException; +import java.io.InputStream; +import java.io.OutputStream; +import java.net.ServerSocket; +import java.net.Socket; +import java.util.ArrayList; public class CloseSocket { + private static ArrayList<TestCase> testCases = new ArrayList<>(); + + static { + testCases.add(socket -> socket.startHandshake()); + testCases.add(socket -> { + InputStream in = socket.getInputStream(); + in.read(); + }); + testCases.add(socket -> { + OutputStream out = socket.getOutputStream(); + out.write(43); + }); + } + public static void main(String[] args) throws Exception { - final ServerSocket serverSocket = new ServerSocket(0); - int serverPort = serverSocket.getLocalPort(); - new Thread() { - public void run() { - try { - Socket s = serverSocket.accept(); - System.out.println("Server accepted connection"); - // wait a bit before closing the socket to give - // the client time to send its hello message - Thread.currentThread().sleep(100); - s.close(); - System.out.println("Server closed socket, done."); - } catch (Exception e) { - System.out.println("Server exception:"); - e.printStackTrace(); + try (Server server = new Server()) { + new Thread(server).start(); + + SocketFactory factory = SSLSocketFactory.getDefault(); + try (SSLSocket socket = (SSLSocket) factory.createSocket("localhost", + server.getPort())) { + socket.setSoTimeout(2000); + System.out.println("Client established TCP connection"); + boolean failed = false; + for (TestCase testCase : testCases) { + try { + testCase.test(socket); + System.out.println("ERROR: no exception"); + failed = true; + } catch (IOException e) { + System.out.println("Failed as expected: " + e); + } + } + if (failed) { + throw new Exception("One or more tests failed"); } } - }.start(); - SSLSocketFactory factory = (SSLSocketFactory)SSLSocketFactory.getDefault(); - SSLSocket socket = (SSLSocket)factory.createSocket("localhost", serverPort); - System.out.println("Client established TCP connection"); - boolean failed = false; - try { - System.out.println("Starting handshake..."); - socket.startHandshake(); - System.out.println("ERROR: no exception"); - failed = true; - } catch (IOException e) { - System.out.println("Failed as expected: " + e); - } - try { - System.out.println("Trying read..."); - InputStream in = socket.getInputStream(); - int b = in.read(); - System.out.println("ERROR: no exception, read: " + b); - failed = true; - } catch (IOException e) { - System.out.println("Failed as expected: " + e); - } - try { - System.out.println("Trying read..."); - OutputStream out = socket.getOutputStream(); - out.write(43); - System.out.println("ERROR: no exception"); - failed = true; - } catch (IOException e) { - System.out.println("Failed as expected: " + e); - } - if (failed) { - throw new Exception("One or more tests failed"); } } + static class Server implements AutoCloseable, Runnable { + + final ServerSocket serverSocket; + + Server() throws IOException { + serverSocket = new ServerSocket(0); + } + + public int getPort() { + return serverSocket.getLocalPort(); + } + + @Override + public void run() { + try (Socket s = serverSocket.accept()) { + System.out.println("Server accepted connection"); + // wait a bit before closing the socket to give + // the client time to send its hello message + Thread.currentThread().sleep(100); + s.close(); + System.out.println("Server closed socket, done."); + } catch (Exception e) { + throw new RuntimeException("Problem in test execution", e); + } + } + + @Override + public void close() throws Exception { + if (!serverSocket.isClosed()) { + serverSocket.close(); + } + } + } + + interface TestCase { + void test(SSLSocket socket) throws IOException; + } }
--- a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java Wed Aug 31 09:22:54 2016 -0700 @@ -22,11 +22,15 @@ */ /* - *@test - *@bug 8007572 8008161 - *@summary Test whether the TimeZone generated from JSR310 tzdb is the same - *as the one from the tz data from javazic + * @test + * @bug 8007572 8008161 8157792 + * @summary Test whether the TimeZone generated from JSR310 tzdb is the same + * as the one from the tz data from javazic * @modules java.base/sun.util.calendar + * @build BackEnd Checksum DayOfWeek Gen GenDoc Main Mappings Month + * Rule RuleDay RuleRec Simple TestZoneInfo310 Time Timezone + * TzIDOldMapping Zone ZoneInfoFile ZoneInfoOld ZoneRec Zoneinfo + * @run main TestZoneInfo310 */ import java.io.File; @@ -164,10 +168,6 @@ } for (String zid : zids_new) { - if (zid.equals("Asia/Oral") || zid.equals("Asia/Qyzylorda")) { - // JDK-8157792 tracking this issue - continue; - } ZoneInfoOld zi = toZoneInfoOld(TimeZone.getTimeZone(zid)); ZoneInfoOld ziOLD = (ZoneInfoOld)ZoneInfoOld.getTimeZone(zid); if (! zi.equalsTo(ziOLD)) {
--- a/jdk/test/sun/util/calendar/zi/Zoneinfo.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/sun/util/calendar/zi/Zoneinfo.java Wed Aug 31 09:22:54 2016 -0700 @@ -373,6 +373,7 @@ tz.getOffsetIndex(zrec.getGmtOffset()); int lastGmtOffsetValue = -1; + ZoneRec prevzrec = null; int currentSave = 0; boolean usedZone; for (int zindex = 0; zindex < zone.size(); zindex++) { @@ -441,6 +442,15 @@ currentSave); if (zrec.hasUntil()) { if (transition >= zrec.getUntilTime(currentSave)) { + // If the GMT offset changed from the previous one, + // record fromTime as a transition. + if (!fromTimeUsed && prevzrec != null + && gmtOffset != prevzrec.getGmtOffset()) { + tz.addTransition(fromTime, + tz.getOffsetIndex(gmtOffset+currentSave), + tz.getDstOffsetIndex(currentSave)); + fromTimeUsed = true; // for consistency + } break year_loop; } } @@ -452,8 +462,6 @@ if (fromTime != minTime) { int prevsave; - ZoneRec prevzrec = zone.get(zindex - 1); - // See if until time in the previous // ZoneRec is the same thing as the // local time in the next rule. @@ -555,6 +563,7 @@ fromYear = zrec.getUntilYear(); year = zrec.getUntilYear(); } + prevzrec = zrec; } if (tz.getDSTType() == Timezone.UNDEF_DST) {
--- a/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java Fri Aug 26 10:02:50 2016 -0700 +++ b/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java Wed Aug 31 09:22:54 2016 -0700 @@ -22,6 +22,7 @@ */ import java.nio.file.Path; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @@ -73,50 +74,9 @@ classFilesForSpecies(GenerateJLIClassesPlugin.defaultSpecies()), List.of()); - - // Test a valid set of options - result = JImageGenerator.getJLinkTask() - .modulePath(helper.defaultModulePath()) - .output(helper.createNewImageDir("generate-jli")) - .option("--generate-jli-classes=bmh:bmh-species=LL,L3") - .addMods("java.base") - .call(); - - image = result.assertSuccess(); - - JImageValidator.validate( - image.resolve("lib").resolve("modules"), - classFilesForSpecies(List.of("LL", "L3")), - classFilesForSpecies(List.of("L4"))); - - - // Test disabling BMH species generation - result = JImageGenerator.getJLinkTask() - .modulePath(helper.defaultModulePath()) - .output(helper.createNewImageDir("generate-jli")) - .option("--generate-jli-classes=not-bmh:bmh-species=LL,L3") - .addMods("java.base") - .call(); - - image = result.assertSuccess(); - JImageValidator.validate( - image.resolve("lib").resolve("modules"), - List.of(), - classFilesForSpecies(List.of("LL", "L3", "L4"))); - - - // Test an invalid set of options - result = JImageGenerator.getJLinkTask() - .modulePath(helper.defaultModulePath()) - .output(helper.createNewImageDir("generate-jli")) - .option("--generate-jli-classes=bmh:bmh-species=LL,L7V") - .addMods("java.base") - .call(); - - result.assertFailure(); } - private static List<String> classFilesForSpecies(List<String> species) { + private static List<String> classFilesForSpecies(Collection<String> species) { return species.stream() .map(s -> "/java.base/java/lang/invoke/BoundMethodHandle$Species_" + s + ".class") .collect(Collectors.toList());
--- a/langtools/.hgtags Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/.hgtags Wed Aug 31 09:22:54 2016 -0700 @@ -375,3 +375,4 @@ 3665ebc22a42c8f33777ee025ba0e300e6086a8c jdk-9+130 aebfafc43714d5a27d5064d8a0011eaccde633cf jdk-9+131 2c17b65a37a8d7afdb9f96d5f11b28a3f21c78f2 jdk-9+132 +7efa4b3477b2b93edbdb4abf827b74c6391f056e jdk-9+133
--- a/langtools/make/CompileInterim.gmk Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/make/CompileInterim.gmk Wed Aug 31 09:22:54 2016 -0700 @@ -32,7 +32,7 @@ include SetupJavaCompilers.gmk ################################################################################ -# Setup the rules to build interim langtools, which is compiled by the boot +# Setup the rules to build interim langtools, 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. Each module is compiled separately to allow a modular # boot jdk to override system classes using -Xoverride:. @@ -45,7 +45,8 @@ DISABLE_SJAVAC := true, \ SRC := $(LANGTOOLS_TOPDIR)/src/$(strip $1)/share/classes \ $$(wildcard $(SUPPORT_OUTPUTDIR)/gensrc/$(strip $1)), \ - EXCLUDES := sun com/sun/tools/jdeps com/sun/tools/javap, \ + EXCLUDES := sun com/sun/tools/jdeps com/sun/tools/javap \ + com/sun/tools/jdeprscan, \ EXCLUDE_FILES := module-info.java, \ COPY := .gif .png .xml .css .js javax.tools.JavaCompilerTool, \ BIN := $(BUILDTOOLS_OUTPUTDIR)/override_modules/$(strip $1), \
--- a/langtools/make/build.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/make/build.xml Wed Aug 31 09:22:54 2016 -0700 @@ -88,18 +88,18 @@ <dirset dir="${src.dir}" includes="*.*"/> </pathconvert> - <pathconvert property="xpatch.rest" pathsep=" -Xpatch:"> + <pathconvert property="xpatch.rest" pathsep=" --patch-module="> <regexpmapper from="${file.separator}([^${file.separator}]+)$" to='\1="${build.modules}${file.separator}\1"' /> <dirset dir="${src.dir}" includes="*.*"/> </pathconvert> - <pathconvert property="xpatch.noquotes.rest" pathsep=" -Xpatch:"> + <pathconvert property="xpatch.noquotes.rest" pathsep=" --patch-module="> <regexpmapper from="${file.separator}([^${file.separator}]+)$" to="\1=${build.modules}${file.separator}\1" /> <dirset dir="${src.dir}" includes="*.*"/> </pathconvert> - <property name="xpatch.cmd" value="-Xpatch:${xpatch.rest}"/> - <property name="xpatch.noquotes.cmd" value="-Xpatch:${xpatch.noquotes.rest}"/> + <property name="xpatch.cmd" value="--patch-module=${xpatch.rest}"/> + <property name="xpatch.noquotes.cmd" value="--patch-module=${xpatch.noquotes.rest}"/> <!-- java.marker is set to a marker file to check for within a Java install dir. The best file to check for across Solaris/Linux/Windows/MacOS is one of the @@ -207,7 +207,7 @@ <arg line="-source ${javac.source} -target ${javac.target}" /> <arg value="-d" /> <arg value="${build.modules}" /> - <arg line="${javac.opts} -modulesourcepath ${src.dir}${file.separator}*${file.separator}share${file.separator}classes:${build.gensrc} -m ${modules.names}" /> + <arg line="${javac.opts} --module-source-path ${src.dir}${file.separator}*${file.separator}share${file.separator}classes:${build.gensrc} -m ${modules.names}" /> </exec> <delete> <fileset dir="${build.modules}" includes="**/module-info.class"/>
--- a/langtools/make/diags-examples.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/make/diags-examples.xml Wed Aug 31 09:22:54 2016 -0700 @@ -80,12 +80,12 @@ includeAntRuntime="no" debug="${javac.debug}" debuglevel="${javac.debuglevel}"> - <compilerarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"/> - <compilerarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"/> - <compilerarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED"/> - <compilerarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"/> - <compilerarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"/> - <compilerarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"/> + <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"/> + <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"/> + <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED"/> + <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"/> + <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"/> + <compilerarg line="--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"/> </javac> </target> @@ -111,12 +111,12 @@ <arg value="-showFiles"/> <arg value="-title"/> <arg value="Examples of javac diagnostics"/> - <jvmarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"/> - <jvmarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"/> - <jvmarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED"/> - <jvmarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"/> - <jvmarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"/> - <jvmarg line="-XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"/> + <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.api=ALL-UNNAMED"/> + <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.code=ALL-UNNAMED"/> + <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.file=ALL-UNNAMED"/> + <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.main=ALL-UNNAMED"/> + <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.parser=ALL-UNNAMED"/> + <jvmarg line="--add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED"/> </java> </sequential> </macrodef>
--- a/langtools/make/gendata/Gendata-jdk.compiler.gmk Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/make/gendata/Gendata-jdk.compiler.gmk Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ # -# Copyright (c) 2015, Oracle and/or its affiliates. All rights reserved. +# Copyright (c) 2015, 2016, 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,9 +41,9 @@ ifeq ($(BOOT_JDK_MODULAR), true) COMPILECREATESYMBOLS_ADD_EXPORTS := \ - -XaddExports:jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \ - -XaddExports:jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED \ - -XaddExports:jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED + --add-exports=jdk.compiler/com.sun.tools.javac.util=ALL-UNNAMED \ + --add-exports=jdk.compiler/com.sun.tools.javac.jvm=ALL-UNNAMED \ + --add-exports=jdk.jdeps/com.sun.tools.classfile=ALL-UNNAMED endif $(SUPPORT_OUTPUTDIR)/symbols/ct.sym-files/_the.symbols: \
--- a/langtools/make/intellij/runConfigurations/javah.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/make/intellij/runConfigurations/javah.xml Wed Aug 31 09:22:54 2016 -0700 @@ -2,7 +2,7 @@ <configuration default="false" name="javah" type="Application" factoryName="Application"> <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> <option name="MAIN_CLASS_NAME" value="com.sun.tools.javah.Main" /> - <option name="VM_PARAMETERS" value='@XPATCH@ -XaddExports:jdk.compiler/com.sun.tools.javah=ALL-UNNAMED' /> + <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.compiler/com.sun.tools.javah=ALL-UNNAMED' /> <option name="PROGRAM_PARAMETERS" value="" /> <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
--- a/langtools/make/intellij/runConfigurations/javap.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/make/intellij/runConfigurations/javap.xml Wed Aug 31 09:22:54 2016 -0700 @@ -2,7 +2,7 @@ <configuration default="false" name="javap" type="Application" factoryName="Application"> <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> <option name="MAIN_CLASS_NAME" value="com.sun.tools.javap.Main" /> - <option name="VM_PARAMETERS" value='@XPATCH@ -XaddExports:jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED' /> + <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.jdeps/com.sun.tools.javap=ALL-UNNAMED' /> <option name="PROGRAM_PARAMETERS" value="" /> <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
--- a/langtools/make/intellij/runConfigurations/jshell.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/make/intellij/runConfigurations/jshell.xml Wed Aug 31 09:22:54 2016 -0700 @@ -2,7 +2,7 @@ <configuration default="false" name="jshell" type="Application" factoryName="Application"> <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> <option name="MAIN_CLASS_NAME" value="jdk.internal.jshell.tool.JShellTool" /> - <option name="VM_PARAMETERS" value='@XPATCH@ -XaddExports:jdk.jshell/jdk.internal.jshell.tool=ALL-UNNAMED' /> + <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.jshell/jdk.internal.jshell.tool=ALL-UNNAMED' /> <option name="PROGRAM_PARAMETERS" value="" /> <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
--- a/langtools/make/intellij/runConfigurations/sjavac.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/make/intellij/runConfigurations/sjavac.xml Wed Aug 31 09:22:54 2016 -0700 @@ -2,7 +2,7 @@ <configuration default="false" name="sjavac" type="Application" factoryName="Application"> <extension name="coverage" enabled="false" merge="false" sample_coverage="true" runner="idea" /> <option name="MAIN_CLASS_NAME" value="com.sun.tools.sjavac.Main" /> - <option name="VM_PARAMETERS" value='@XPATCH@ -XaddExports:jdk.compiler/com.sun.tools.sjavac=ALL-UNNAMED' /> + <option name="VM_PARAMETERS" value='@XPATCH@ --add-exports=jdk.compiler/com.sun.tools.sjavac=ALL-UNNAMED' /> <option name="PROGRAM_PARAMETERS" value="" /> <option name="WORKING_DIRECTORY" value="file://$PROJECT_DIR$" /> <option name="ALTERNATIVE_JRE_PATH_ENABLED" value="true" />
--- a/langtools/make/netbeans/langtools/build.xml Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/make/netbeans/langtools/build.xml Wed Aug 31 09:22:54 2016 -0700 @@ -218,11 +218,11 @@ <sequential> <java fork="true" jvm="${langtools.jdk.home}/bin/java" classname="@{mainclass}"> - <jvmarg line="-Xpatch:java.compiler=@{build.modules}/java.compiler"/> - <jvmarg line="-Xpatch:jdk.compiler=@{build.modules}/jdk.compiler"/> - <jvmarg line="-Xpatch:jdk.javadoc=@{build.modules}/jdk.javadoc"/> - <jvmarg line="-Xpatch:jdk.jdeps=@{build.modules}/jdk.jdeps"/> - <jvmarg line="-Xpatch:jdk.jshell=@{build.modules}/jdk.jshell"/> + <jvmarg line="--patch-module=java.compiler=@{build.modules}/java.compiler"/> + <jvmarg line="--patch-module=jdk.compiler=@{build.modules}/jdk.compiler"/> + <jvmarg line="--patch-module=jdk.javadoc=@{build.modules}/jdk.javadoc"/> + <jvmarg line="--patch-module=jdk.jdeps=@{build.modules}/jdk.jdeps"/> + <jvmarg line="--patch-module=jdk.jshell=@{build.modules}/jdk.jshell"/> <jvmarg line="@{jpda.jvmargs}"/> <arg line="@{args}"/> </java>
--- a/langtools/make/tools/crules/DefinedByAnalyzer.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/make/tools/crules/DefinedByAnalyzer.java Wed Aug 31 09:22:54 2016 -0700 @@ -23,10 +23,15 @@ package crules; +import java.util.Arrays; +import java.util.HashSet; +import java.util.Set; + import com.sun.source.util.JavacTask; import com.sun.source.util.TaskEvent.Kind; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.code.Symbol.MethodSymbol; +import com.sun.tools.javac.tree.JCTree.JCClassDecl; import com.sun.tools.javac.tree.JCTree.JCMethodDecl; import com.sun.tools.javac.tree.TreeScanner; import com.sun.tools.javac.util.DefinedBy; @@ -44,8 +49,21 @@ eventKind = Kind.ANALYZE; } + //only java.compiler and jdk.compiler modules implement the APIs, + //so only these need the @DefinedBy annotation: + private static final Set<String> MODULE = new HashSet<>(Arrays.asList( + "java.compiler", + "jdk.compiler" + )); + class DefinedByVisitor extends TreeScanner { @Override + public void visitClassDef(JCClassDecl tree) { + if (MODULE.contains(tree.sym.packge().modle.name.toString())) { + super.visitClassDef(tree); + } + } + @Override public void visitMethodDef(JCMethodDecl tree) { if (!isAPIPackage(packageName(tree.sym))) { boolean seenAPIPackage = false;
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java Wed Aug 31 09:22:54 2016 -0700 @@ -369,6 +369,7 @@ } }; addRootPackageFor(unnamedModule); + unnamedModule.enclosedPackages = unnamedModule.enclosedPackages.prepend(unnamedModule.unnamedPackage); errModule = new ModuleSymbol(names.empty, null) { }; addRootPackageFor(errModule);
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java Wed Aug 31 09:22:54 2016 -0700 @@ -418,10 +418,15 @@ final ListBuffer<Symbol> abstracts = new ListBuffer<>(); for (Symbol sym : membersCache.getSymbols(new DescriptorFilter(origin))) { Type mtype = memberType(origin.type, sym); - if (abstracts.isEmpty() || - (sym.name == abstracts.first().name && + if (abstracts.isEmpty()) { + abstracts.append(sym); + } else if ((sym.name == abstracts.first().name && overrideEquivalent(mtype, memberType(origin.type, abstracts.first())))) { - abstracts.append(sym); + if (!abstracts.stream().filter(msym -> msym.owner.isSubClass(sym.enclClass(), Types.this)) + .map(msym -> memberType(origin.type, msym)) + .anyMatch(abstractMType -> isSubSignature(abstractMType, mtype))) { + abstracts.append(sym); + } } else { //the target method(s) should be the only abstract members of t throw failure("not.a.functional.intf.1", origin,
--- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java Wed Aug 31 09:22:54 2016 -0700 @@ -61,6 +61,7 @@ import java.util.Set; import java.util.function.BiFunction; import java.util.function.BiPredicate; +import java.util.stream.Collectors; import com.sun.tools.javac.main.Option; @@ -1475,16 +1476,11 @@ //not a throws undet var return false; } - Infer infer = inferenceContext.infer; - for (Type db : t.getBounds(InferenceBound.UPPER)) { - if (t.isInterface()) continue; - if (infer.types.asSuper(infer.syms.runtimeExceptionType, db.tsym) == null) { - //upper bound is not a supertype of RuntimeException - give up - return false; - } - } - - return true; + Types types = inferenceContext.types; + Symtab syms = inferenceContext.infer.syms; + return t.getBounds(InferenceBound.UPPER).stream() + .filter(b -> !inferenceContext.free(b)) + .allMatch(u -> types.isSubtype(syms.runtimeExceptionType, u)); } @Override
--- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java Wed Aug 31 09:22:54 2016 -0700 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2003, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2003, 2016, 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 @@ -124,7 +124,7 @@ /** * Build the documentation. * - * @throws IOException if there was a problem writing the output. + * @throws IOException if there is a problem writing the output */ public abstract void build() throws IOException;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTaskImpl.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTaskImpl.java Wed Aug 31 09:22:54 2016 -0700 @@ -34,8 +34,6 @@ import com.sun.tools.javac.util.ClientCodeException; import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import jdk.javadoc.internal.tool.Start; /** @@ -68,14 +66,12 @@ setLocale(Locale.getDefault()); } - @DefinedBy(Api.COMPILER) public void setLocale(Locale locale) { if (used.get()) throw new IllegalStateException(); this.locale = locale; } - @DefinedBy(Api.COMPILER) public Boolean call() { if (!used.getAndSet(true)) { initContext();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java Wed Aug 31 09:22:54 2016 -0700 @@ -49,8 +49,6 @@ import com.sun.tools.javac.file.BaseFileManager; import com.sun.tools.javac.util.ClientCodeException; import com.sun.tools.javac.util.Context; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.Log; import jdk.javadoc.internal.tool.ToolOption; @@ -64,7 +62,7 @@ * or deletion without notice.</b></p> */ public class JavadocTool implements DocumentationTool { - @Override @DefinedBy(Api.COMPILER) + @Override public DocumentationTask getTask( Writer out, JavaFileManager fileManager, @@ -129,7 +127,7 @@ } // TODO: used shared static method in JavacFileManager - @Override @DefinedBy(Api.COMPILER) + @Override public StandardJavaFileManager getStandardFileManager( DiagnosticListener<? super JavaFileObject> diagnosticListener, Locale locale, @@ -145,7 +143,7 @@ return new JavacFileManager(context, true, charset); } - @Override @DefinedBy(Api.COMPILER) + @Override public int run(InputStream in, OutputStream out, OutputStream err, String... arguments) { PrintWriter err_pw = new PrintWriter(err == null ? System.err : err, true); PrintWriter out_pw = new PrintWriter(out == null ? System.out : out); @@ -157,13 +155,13 @@ } } - @Override @DefinedBy(Api.COMPILER) + @Override public Set<SourceVersion> getSourceVersions() { return Collections.unmodifiableSet( EnumSet.range(SourceVersion.RELEASE_3, SourceVersion.latest())); } - @Override @DefinedBy(Api.COMPILER) + @Override public int isSupportedOption(String option) { if (option == null) throw new NullPointerException();
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -39,8 +39,6 @@ import javax.lang.model.type.TypeVariable; import javax.lang.model.util.SimpleTypeVisitor9; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.toolkit.Content; @@ -314,27 +312,27 @@ SimpleTypeVisitor9<Boolean, Void> stv = new SimpleTypeVisitor9<Boolean, Void>() { boolean foundTypeVariable = false; - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitArray(ArrayType t, Void p) { visit(t.getComponentType()); buf.append(utils.getDimension(t)); return foundTypeVariable; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitTypeVariable(TypeVariable t, Void p) { buf.append(utils.asTypeElement(t).getQualifiedName()); foundTypeVariable = true; return foundTypeVariable; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitDeclared(DeclaredType t, Void p) { buf.append(utils.getQualifiedTypeName(t)); return foundTypeVariable; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Boolean defaultAction(TypeMirror e, Void p) { buf.append(e); return foundTypeVariable;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -26,7 +26,6 @@ package jdk.javadoc.internal.doclets.formats.html; import java.io.*; -import java.nio.file.*; import java.util.*; import java.util.zip.*; @@ -38,7 +37,6 @@ import javax.lang.model.util.SimpleElementVisitor9; import com.sun.source.doctree.DocTree; -import com.sun.tools.javac.util.DefinedBy; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; @@ -46,9 +44,9 @@ import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; /** @@ -93,6 +91,7 @@ * * @return a content tree for the tree label */ + @Override protected Content getNavLinkIndex() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.indexLabel); return li; @@ -183,7 +182,7 @@ SearchIndexItem si = new SearchIndexItem(); new SimpleElementVisitor9<Void, Void>() { - @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL) + @Override public Void visitModule(ModuleElement e, Void p) { if (configuration.showModules) { addDescription(e, dl, si); @@ -192,21 +191,21 @@ return null; } - @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL) + @Override public Void visitPackage(PackageElement e, Void p) { addDescription(e, dl, si); configuration.packageSearchIndex.add(si); return null; } - @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL) + @Override public Void visitType(TypeElement e, Void p) { addDescription(e, dl, si); configuration.typeSearchIndex.add(si); return null; } - @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL) + @Override protected Void defaultAction(Element e, Void p) { addDescription(e, dl, si); configuration.memberSearchIndex.add(si); @@ -242,6 +241,7 @@ * * @param pkg the package to be documented * @param dlTree the content tree to which the description will be added + * @param si the search index item to be updated */ protected void addDescription(PackageElement pkg, Content dlTree, SearchIndexItem si) { Content link = getPackageLink(pkg, new StringContent(utils.getPackageName(pkg))); @@ -265,6 +265,7 @@ * * @param typeElement the class being documented * @param dlTree the content tree to which the description will be added + * @param si the search index item to be updated */ protected void addDescription(TypeElement typeElement, Content dlTree, SearchIndexItem si) { Content link = getLink(new LinkInfoImpl(configuration, @@ -332,9 +333,9 @@ } protected void addDescription(SearchIndexItem sii, Content dlTree) { - String path = pathToRoot.isEmpty() ? "" : pathToRoot.getPath() + "/"; - path += sii.getUrl(); - HtmlTree labelLink = HtmlTree.A(path, new StringContent(sii.getLabel())); + String siiPath = pathToRoot.isEmpty() ? "" : pathToRoot.getPath() + "/"; + siiPath += sii.getUrl(); + HtmlTree labelLink = HtmlTree.A(siiPath, new StringContent(sii.getLabel())); Content dt = HtmlTree.DT(HtmlTree.SPAN(HtmlStyle.searchTagLink, labelLink)); dt.addContent(" - "); dt.addContent(contents.getContent("doclet.Search_tag_in", sii.getHolder())); @@ -430,7 +431,10 @@ return "I:" + getName(unicode); } - protected void createSearchIndexFiles() { + /** + * @throws DocFileIOException if there is a problem creating any of the search index files + */ + protected void createSearchIndexFiles() throws DocFileIOException { if (configuration.showModules) { createSearchIndexFile(DocPaths.MODULE_SEARCH_INDEX_JSON, DocPaths.MODULE_SEARCH_INDEX_ZIP, configuration.moduleSearchIndex); @@ -445,54 +449,37 @@ configuration.tagSearchIndex); } + /** + * @throws DocFileIOException if there is a problem creating the search index file + */ protected void createSearchIndexFile(DocPath searchIndexFile, DocPath searchIndexZip, - List<SearchIndexItem> searchIndex) { + List<SearchIndexItem> searchIndex) throws DocFileIOException { if (!searchIndex.isEmpty()) { - try { - StringBuilder searchVar = new StringBuilder("["); - boolean first = true; - DocFile searchFile = DocFile.createFileForOutput(configuration, searchIndexFile); - Path p = Paths.get(searchFile.getPath()); - for (SearchIndexItem item : searchIndex) { - if (first) { - searchVar.append(item.toString()); - first = false; - } else { - searchVar.append(",").append(item.toString()); - } + StringBuilder searchVar = new StringBuilder("["); + boolean first = true; + for (SearchIndexItem item : searchIndex) { + if (first) { + searchVar.append(item.toString()); + first = false; + } else { + searchVar.append(",").append(item.toString()); } - searchVar.append("]"); - Files.write(p, searchVar.toString().getBytes()); - DocFile zipFile = DocFile.createFileForOutput(configuration, searchIndexZip); - try (FileOutputStream fos = new FileOutputStream(zipFile.getPath()); - ZipOutputStream zos = new ZipOutputStream(fos)) { - zipFile(searchFile.getPath(), searchIndexFile, zos); + } + searchVar.append("]"); + + DocFile zipFile = DocFile.createFileForOutput(configuration, searchIndexZip); + try (OutputStream fos = zipFile.openOutputStream(); + ZipOutputStream zos = new ZipOutputStream(fos)) { + try { + ZipEntry ze = new ZipEntry(searchIndexFile.getPath()); + zos.putNextEntry(ze); + zos.write(searchVar.toString().getBytes()); + } finally { + zos.closeEntry(); } - Files.delete(p); } catch (IOException ie) { - throw new DocletAbortException(ie); + throw new DocFileIOException(zipFile, DocFileIOException.Mode.WRITE, ie); } } } - - protected void zipFile(String inputFile, DocPath file, ZipOutputStream zos) { - try { - try { - ZipEntry ze = new ZipEntry(file.getPath()); - zos.putNextEntry(ze); - try (FileInputStream fis = new FileInputStream(new File(inputFile))) { - byte[] buf = new byte[2048]; - int len = fis.read(buf); - while (len > 0) { - zos.write(buf, 0, len); - len = fis.read(buf); - } - } - } finally { - zos.closeEntry(); - } - } catch (IOException e) { - throw new DocletAbortException(e); - } - } }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.Map; import java.util.Set; import java.util.SortedMap; @@ -39,6 +38,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; /** @@ -123,8 +123,9 @@ * * @param title the title of the window. * @param includeScript boolean set true if windowtitle script is to be included + * @throws DocFileIOException if there is a problem building the module index file */ - protected void buildModuleIndexFile(String title, boolean includeScript) throws IOException { + protected void buildModuleIndexFile(String title, boolean includeScript) throws DocFileIOException { String windowOverview = configuration.getText(title); Content body = getBody(includeScript, getWindowTitle(windowOverview)); addNavigationBarHeader(body); @@ -144,9 +145,10 @@ * @param title the title of the window. * @param includeScript boolean set true if windowtitle script is to be included * @param mdle the name of the module being documented + * @throws DocFileIOException if there is an exception building the module packages index file */ protected void buildModulePackagesIndexFile(String title, - boolean includeScript, ModuleElement mdle) throws IOException { + boolean includeScript, ModuleElement mdle) throws DocFileIOException { String windowOverview = configuration.getText(title); Content body = getBody(includeScript, getWindowTitle(windowOverview)); addNavigationBarHeader(body); @@ -163,8 +165,7 @@ * * @param body the document tree to which the overview will be added */ - protected void addOverview(Content body) throws IOException { - } + protected void addOverview(Content body) { } /** * Adds the frame or non-frame module index to the documentation tree. @@ -259,6 +260,7 @@ * * @return a Content object to be added to the documentation tree */ + @Override protected Content getNavLinkContents() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.overviewLabel); return li; @@ -269,22 +271,19 @@ * * @param div the document tree to which the all classes link will be added */ - protected void addAllClassesLink(Content div) { - } + protected void addAllClassesLink(Content div) { } /** * Do nothing. This will be overridden in ModuleIndexFrameWriter. * * @param div the document tree to which the all packages link will be added */ - protected void addAllPackagesLink(Content div) { - } + protected void addAllPackagesLink(Content div) { } /** * Do nothing. This will be overridden in ModulePackageIndexFrameWriter. * * @param div the document tree to which the all modules link will be added */ - protected void addAllModulesLink(Content div) { - } + protected void addAllModulesLink(Content div) { } }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.*; import javax.lang.model.element.PackageElement; @@ -36,6 +35,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; /** @@ -109,8 +109,9 @@ * * @param title the title of the window. * @param includeScript boolean set true if windowtitle script is to be included + * @throws DocFileIOException if there is a problem building the package index file */ - protected void buildPackageIndexFile(String title, boolean includeScript) throws IOException { + protected void buildPackageIndexFile(String title, boolean includeScript) throws DocFileIOException { String windowOverview = configuration.getText(title); Content body = getBody(includeScript, getWindowTitle(windowOverview)); addNavigationBarHeader(body); @@ -127,8 +128,7 @@ * * @param body the document tree to which the overview will be added */ - protected void addOverview(Content body) throws IOException { - } + protected void addOverview(Content body) { } /** * Adds the frame or non-frame package index to the documentation tree. @@ -190,6 +190,7 @@ * * @return a Content object to be added to the documentation tree */ + @Override protected Content getNavLinkContents() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.overviewLabel); return li;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.*; import javax.lang.model.element.TypeElement; @@ -37,7 +36,6 @@ import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** @@ -67,8 +65,6 @@ * @param configuration The current configuration * @param filename File to be generated. * @param classtree Tree built by {@link ClassTree}. - * @throws IOException - * @throws DocletAbortException */ protected AbstractTreeWriter(ConfigurationImpl configuration, DocPath filename, ClassTree classtree) {
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.IOException; import javax.lang.model.element.Element; import javax.lang.model.element.TypeElement; @@ -35,10 +34,9 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.Messages; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; @@ -75,8 +73,6 @@ * @param configuration The current configuration * @param filename Path to the file which is getting generated. * @param indexbuilder Unicode based Index from {@link IndexBuilder} - * @throws IOException - * @throws DocletAbortException */ public AllClassesFrameWriter(ConfigurationImpl configuration, DocPath filename, IndexBuilder indexbuilder) { @@ -90,10 +86,10 @@ * destination directory. * * @param indexBuilder IndexBuilder object for all classes index. - * @throws DocletAbortException + * @throws DocFileIOException */ public static void generate(ConfigurationImpl configuration, - IndexBuilder indexBuilder) { + IndexBuilder indexBuilder) throws DocFileIOException { if (configuration.frames) { generate(configuration, indexBuilder, DocPaths.ALLCLASSES_FRAME, true); generate(configuration, indexBuilder, DocPaths.ALLCLASSES_NOFRAME, false); @@ -103,27 +99,19 @@ } private static void generate(ConfigurationImpl configuration, IndexBuilder indexBuilder, - DocPath fileName, boolean wantFrames) { - try { - AllClassesFrameWriter allclassgen = new AllClassesFrameWriter(configuration, - fileName, indexBuilder); - allclassgen.buildAllClassesFile(wantFrames); - allclassgen = new AllClassesFrameWriter(configuration, - fileName, indexBuilder); - allclassgen.buildAllClassesFile(false); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), fileName); - throw new DocletAbortException(exc); - } + DocPath fileName, boolean wantFrames) throws DocFileIOException { + AllClassesFrameWriter allclassgen = new AllClassesFrameWriter(configuration, + fileName, indexBuilder); + allclassgen.buildAllClassesFile(wantFrames); + allclassgen = new AllClassesFrameWriter(configuration, + fileName, indexBuilder); } /** * Print all the classes in the file. * @param wantFrames True if we want frames. */ - protected void buildAllClassesFile(boolean wantFrames) throws IOException { + protected void buildAllClassesFile(boolean wantFrames) throws DocFileIOException { String label = configuration.getText("doclet.All_Classes"); Content body = getBody(false, getWindowTitle(label)); Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING,
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.IOException; import java.util.List; import javax.lang.model.element.PackageElement; @@ -42,9 +41,9 @@ import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; /** @@ -78,11 +77,9 @@ * @param annotationType the annotation type being documented. * @param prevType the previous class that was documented. * @param nextType the next class being documented. - * @throws java.lang.Exception */ public AnnotationTypeWriterImpl(ConfigurationImpl configuration, - TypeElement annotationType, TypeMirror prevType, TypeMirror nextType) - throws Exception { + TypeElement annotationType, TypeMirror prevType, TypeMirror nextType) { super(configuration, DocPath.forClass(configuration.utils, annotationType)); this.annotationType = annotationType; configuration.currentTypeElement = annotationType; @@ -243,7 +240,7 @@ * {@inheritDoc} */ @Override - public void printDocument(Content contentTree) throws IOException { + public void printDocument(Content contentTree) throws DocFileIOException { printHtmlDocument(configuration.metakeywords.getMetaKeywords(annotationType), true, contentTree); } @@ -352,22 +349,17 @@ */ @Override protected void addSummaryDetailLinks(Content subDiv) { - try { - Content div = HtmlTree.DIV(getNavSummaryLinks()); - div.addContent(getNavDetailLinks()); - subDiv.addContent(div); - } catch (Exception e) { - throw new DocletAbortException(e); - } + Content div = HtmlTree.DIV(getNavSummaryLinks()); + div.addContent(getNavDetailLinks()); + subDiv.addContent(div); } /** * Get summary links for navigation bar. * * @return the content tree for the navigation summary links - * @throws java.lang.Exception */ - protected Content getNavSummaryLinks() throws Exception { + protected Content getNavSummaryLinks() { Content li = HtmlTree.LI(contents.summaryLabel); li.addContent(Contents.SPACE); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); @@ -417,9 +409,8 @@ * Get detail links for the navigation bar. * * @return the content tree for the detail links - * @throws java.lang.Exception */ - protected Content getNavDetailLinks() throws Exception { + protected Content getNavDetailLinks() { Content li = HtmlTree.LI(contents.detailLabel); li.addContent(Contents.SPACE); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.IOException; import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; @@ -47,12 +46,11 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; import jdk.javadoc.internal.doclets.toolkit.util.ClassUseMapper; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** * Generate class usage information. @@ -112,12 +110,10 @@ * Constructor. * * @param filename the file to be generated. - * @throws IOException - * @throws DocletAbortException */ public ClassUseWriter(ConfigurationImpl configuration, ClassUseMapper mapper, DocPath filename, - TypeElement typeElement) throws IOException { + TypeElement typeElement) { super(configuration, filename); this.typeElement = typeElement; if (mapper.classToPackageAnnotations.containsKey(typeElement)) { @@ -175,9 +171,12 @@ /** * Write out class use pages. - * @throws DocletAbortException + * + * @param configuration the configuration for this doclet + * @param classtree the class tree hierarchy + * @throws DocFileIOException if there is an error while generating the documentation */ - public static void generate(ConfigurationImpl configuration, ClassTree classtree) { + public static void generate(ConfigurationImpl configuration, ClassTree classtree) throws DocFileIOException { ClassUseMapper mapper = new ClassUseMapper(configuration, classtree); for (TypeElement aClass : configuration.docEnv.getIncludedTypeElements()) { // If -nodeprecated option is set and the containing package is marked @@ -217,28 +216,25 @@ /** * Generate a class page. + * + * @throws DocFileIOException if there is a problem while generating the documentation */ public static void generate(ConfigurationImpl configuration, ClassUseMapper mapper, - TypeElement typeElement) { + TypeElement typeElement) throws DocFileIOException { ClassUseWriter clsgen; DocPath path = DocPath.forPackage(configuration.utils, typeElement) .resolve(DocPaths.CLASS_USE) .resolve(DocPath.forName(configuration.utils, typeElement)); - try { - clsgen = new ClassUseWriter(configuration, mapper, path, typeElement); - clsgen.generateClassUseFile(); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), path.getPath()); - throw new DocletAbortException(exc); - } + clsgen = new ClassUseWriter(configuration, mapper, path, typeElement); + clsgen.generateClassUseFile(); } /** * Generate the class use elements. + * + * @throws DocFileIOException if there is a problem while generating the documentation */ - protected void generateClassUseFile() throws IOException { + protected void generateClassUseFile() throws DocFileIOException { HtmlTree body = getClassUseHeader(); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.classUseContainer); @@ -270,7 +266,7 @@ * * @param contentTree the content tree to which the class use information will be added */ - protected void addClassUse(Content contentTree) throws IOException { + protected void addClassUse(Content contentTree) { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.blockList); if (configuration.packages.size() > 1) { @@ -286,7 +282,7 @@ * * @param contentTree the content tree to which the packages elements will be added */ - protected void addPackageList(Content contentTree) throws IOException { + protected void addPackageList(Content contentTree) { Content caption = getTableCaption(configuration.getContent( "doclet.ClassUse_Packages.that.use.0", getLink(new LinkInfoImpl(configuration, @@ -314,7 +310,7 @@ * * @param contentTree the content tree to which the package annotation elements will be added */ - protected void addPackageAnnotationList(Content contentTree) throws IOException { + protected void addPackageAnnotationList(Content contentTree) { if (!utils.isAnnotationType(typeElement) || pkgToPackageAnnotations == null || pkgToPackageAnnotations.isEmpty()) { @@ -352,7 +348,7 @@ * * @param contentTree the content tree to which the class elements will be added */ - protected void addClassList(Content contentTree) throws IOException { + protected void addClassList(Content contentTree) { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.blockList); for (PackageElement pkg : pkgSet) { @@ -383,7 +379,7 @@ * @param pkg the package that uses the given class * @param contentTree the content tree to which the package use information will be added */ - protected void addPackageUse(PackageElement pkg, Content contentTree) throws IOException { + protected void addPackageUse(PackageElement pkg, Content contentTree) { Content tdFirst = HtmlTree.TD(HtmlStyle.colFirst, getHyperLink(getPackageAnchorName(pkg), new StringContent(utils.getPackageName(pkg)))); contentTree.addContent(tdFirst); @@ -399,7 +395,7 @@ * @param pkg the package that uses the given class * @param contentTree the content tree to which the class use information will be added */ - protected void addClassUse(PackageElement pkg, Content contentTree) throws IOException { + protected void addClassUse(PackageElement pkg, Content contentTree) { Content classLink = getLink(new LinkInfoImpl(configuration, LinkInfoImpl.Kind.CLASS_USE_HEADER, typeElement)); Content pkgLink = getPackageLink(pkg, utils.getPackageName(pkg));
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.IOException; import java.util.*; import javax.lang.model.element.AnnotationMirror; @@ -37,8 +36,6 @@ import javax.lang.model.util.SimpleElementVisitor8; import com.sun.source.doctree.DocTree; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; @@ -50,9 +47,9 @@ import jdk.javadoc.internal.doclets.toolkit.taglets.ParamTaglet; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.Kind; @@ -91,11 +88,9 @@ * @param prevClass the previous class that was documented. * @param nextClass the next class being documented. * @param classTree the class tree for the given class. - * @throws java.io.IOException */ public ClassWriterImpl(ConfigurationImpl configuration, TypeElement typeElement, - TypeElement prevClass, TypeElement nextClass, ClassTree classTree) - throws IOException { + TypeElement prevClass, TypeElement nextClass, ClassTree classTree) { super(configuration, DocPath.forClass(configuration.utils, typeElement)); this.typeElement = typeElement; configuration.currentTypeElement = typeElement; @@ -272,7 +267,7 @@ * {@inheritDoc} */ @Override - public void printDocument(Content contentTree) throws IOException { + public void printDocument(Content contentTree) throws DocFileIOException { printHtmlDocument(configuration.metakeywords.getMetaKeywords(typeElement), true, contentTree); } @@ -563,7 +558,7 @@ if (outerClass == null) return; new SimpleElementVisitor8<Void, Void>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitType(TypeElement e, Void p) { Content label = utils.isInterface(e) ? contents.enclosingInterfaceLabel @@ -677,14 +672,11 @@ * * @param subDiv the content tree to which the summary detail links will be added */ + @Override protected void addSummaryDetailLinks(Content subDiv) { - try { - Content div = HtmlTree.DIV(getNavSummaryLinks()); - div.addContent(getNavDetailLinks()); - subDiv.addContent(div); - } catch (Exception e) { - throw new DocletAbortException(e); - } + Content div = HtmlTree.DIV(getNavSummaryLinks()); + div.addContent(getNavDetailLinks()); + subDiv.addContent(div); } /** @@ -692,7 +684,7 @@ * * @return the content tree for the navigation summary links */ - protected Content getNavSummaryLinks() throws Exception { + protected Content getNavSummaryLinks() { Content li = HtmlTree.LI(contents.summaryLabel); li.addContent(Contents.SPACE); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); @@ -727,9 +719,8 @@ * Get detail links for the navigation bar. * * @return the content tree for the detail links - * @throws java.lang.Exception */ - protected Content getNavDetailLinks() throws Exception { + protected Content getNavDetailLinks() { Content li = HtmlTree.LI(contents.detailLabel); li.addContent(Contents.SPACE); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li);
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java Wed Aug 31 09:22:54 2016 -0700 @@ -50,7 +50,6 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.Utils; import static javax.tools.Diagnostic.Kind.*;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java Wed Aug 31 09:22:54 2016 -0700 @@ -41,6 +41,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.ConstantsSummaryWriter; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocLink; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; @@ -379,7 +380,8 @@ /** * {@inheritDoc} */ - public void printDocument(Content contentTree) throws IOException { + @Override + public void printDocument(Content contentTree) throws DocFileIOException { printHtmlDocument(null, true, contentTree); } }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.ArrayList; import java.util.EnumMap; import java.util.List; @@ -35,13 +34,11 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder; +import jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder.DeprElementKind; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; - -import static jdk.javadoc.internal.doclets.toolkit.util.DeprecatedAPIListBuilder.*; /** * Generate File to list all the deprecated classes and class members with the @@ -189,11 +186,11 @@ /** * Constructor. * - * @param filename the file to be generated. + * @param configuration the configuration for this doclet + * @param filename the file to be generated */ - public DeprecatedListWriter(ConfigurationImpl configuration, - DocPath filename) throws IOException { + public DeprecatedListWriter(ConfigurationImpl configuration, DocPath filename) { super(configuration, filename); this.configuration = configuration; NestedClassWriterImpl classW = new NestedClassWriterImpl(this); @@ -236,29 +233,23 @@ * Then instantiate DeprecatedListWriter and generate File. * * @param configuration the current configuration of the doclet. + * @throws DocFileIOException if there is a problem writing the deprecated list */ - public static void generate(ConfigurationImpl configuration) { + public static void generate(ConfigurationImpl configuration) throws DocFileIOException { DocPath filename = DocPaths.DEPRECATED_LIST; - try { - DeprecatedListWriter depr = - new DeprecatedListWriter(configuration, filename); - depr.generateDeprecatedListFile( - new DeprecatedAPIListBuilder(configuration)); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), filename); - throw new DocletAbortException(exc); - } + DeprecatedListWriter depr = new DeprecatedListWriter(configuration, filename); + depr.generateDeprecatedListFile( + new DeprecatedAPIListBuilder(configuration)); } /** * Generate the deprecated API list. * * @param deprapi list of deprecated API built already. + * @throws DocFileIOException if there is a problem writing the deprecated list */ protected void generateDeprecatedListFile(DeprecatedAPIListBuilder deprapi) - throws IOException { + throws DocFileIOException { HtmlTree body = getHeader(); HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN() @@ -378,6 +369,7 @@ * * @return a content tree for the deprecated label */ + @Override protected Content getNavLinkDeprecated() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.deprecatedLabel); return li;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,17 +25,14 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; - import jdk.javadoc.internal.doclets.formats.html.markup.HtmlAttr; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.Messages; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** @@ -67,7 +64,6 @@ * * @param configuration for this run * @param filename File to be generated. - * @throws java.io.IOException */ public FrameOutputWriter(ConfigurationImpl configuration, DocPath filename) { super(configuration, filename); @@ -79,28 +75,20 @@ * file which will have the description of all the frames in the * documentation. The name of the generated file is "index.html" which is * the default first file for Html documents. - * @throws DocletAbortException + * @param configuration the configuration for this doclet + * @throws DocFileIOException if there is a problem generating the frame file */ - public static void generate(ConfigurationImpl configuration) { - FrameOutputWriter framegen; - DocPath filename = DocPath.empty; - try { - filename = DocPaths.INDEX; - framegen = new FrameOutputWriter(configuration, filename); - framegen.generateFrameFile(); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), filename); - throw new DocletAbortException(exc); - } + public static void generate(ConfigurationImpl configuration) throws DocFileIOException { + FrameOutputWriter framegen = new FrameOutputWriter(configuration, DocPaths.INDEX); + framegen.generateFrameFile(); } /** * Generate the constants in the "index.html" file. Print the frame details * as well as warning if browser is not supporting the Html frames. + * @throws DocFileIOException if there is a problem generating the frame file */ - protected void generateFrameFile() throws IOException { + protected void generateFrameFile() throws DocFileIOException { Content frame = getFrameDetails(); HtmlTree body = new HtmlTree(HtmlTag.BODY); body.addAttr(HtmlAttr.ONLOAD, "loadFrames()");
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,18 +25,15 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; - import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.Messages; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** @@ -68,27 +65,21 @@ * file. The name of the generated file is "help-doc.html". The help file * will get generated if and only if "-helpfile" and "-nohelp" is not used * on the command line. - * @throws DocletAbortException + * + * @throws DocFileIOException if there is a problem while generating the documentation */ - public static void generate(ConfigurationImpl configuration) { - HelpWriter helpgen; - DocPath filename = DocPath.empty; - try { - filename = DocPaths.HELP_DOC; - helpgen = new HelpWriter(configuration, filename); - helpgen.generateHelpFile(); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), filename); - throw new DocletAbortException(exc); - } + public static void generate(ConfigurationImpl configuration) throws DocFileIOException { + DocPath filename = DocPaths.HELP_DOC; + HelpWriter helpgen = new HelpWriter(configuration, filename); + helpgen.generateHelpFile(); } /** * Generate the help file contents. + * + * @throws DocFileIOException if there is a problem while generating the documentation */ - protected void generateHelpFile() throws IOException { + protected void generateHelpFile() throws DocFileIOException { String title = configuration.getText("doclet.Window_Help_title"); HtmlTree body = getBody(true, getWindowTitle(title)); HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER))
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.*; import javax.lang.model.element.ModuleElement; @@ -36,14 +35,14 @@ import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.doclet.Reporter; import jdk.javadoc.internal.doclets.toolkit.AbstractDoclet; -import jdk.javadoc.internal.doclets.toolkit.Configuration; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; /** @@ -92,25 +91,27 @@ * Create the configuration instance. * Override this method to use a different * configuration. + * @return the configuration for this doclet */ @Override // defined by AbstractDoclet - public Configuration configuration() { + public ConfigurationImpl configuration() { return configuration; } /** * Start the generation of files. Call generate methods in the individual - * writers, which will in turn genrate the documentation files. Call the + * writers, which will in turn generate the documentation files. Call the * TreeWriter generation first to ensure the Class Hierarchy is built * first and then can be used in the later generation. * * For new format. * + * @throws DocletException if there is a problem while writing the other files * @see jdk.doclet.DocletEnvironment */ @Override // defined by AbstractDoclet protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree) - throws Exception { + throws DocletException { super.generateOtherFiles(docEnv, classtree); if (configuration.linksource) { SourceToHTMLConverter.convertRoot(configuration, @@ -191,7 +192,7 @@ } } - protected void copyJqueryFiles() { + protected void copyJqueryFiles() throws DocletException { List<String> files = Arrays.asList( "jquery-1.10.2.js", "jquery-ui.js", @@ -232,7 +233,8 @@ * {@inheritDoc} */ @Override // defined by AbstractDoclet - protected void generateClassFiles(SortedSet<TypeElement> arr, ClassTree classtree) { + protected void generateClassFiles(SortedSet<TypeElement> arr, ClassTree classtree) + throws DocletException { List<TypeElement> list = new ArrayList<>(arr); ListIterator<TypeElement> iterator = list.listIterator(); TypeElement klass = null; @@ -241,32 +243,24 @@ klass = iterator.next(); TypeElement next = iterator.nextIndex() == list.size() ? null : list.get(iterator.nextIndex()); + if (utils.isHidden(klass) || !(configuration.isGeneratedDoc(klass) && utils.isIncluded(klass))) { continue; } - try { - if (utils.isAnnotationType(klass)) { - AbstractBuilder annotationTypeBuilder = - configuration.getBuilderFactory() - .getAnnotationTypeBuilder(klass, - prev == null ? null : prev.asType(), - next == null ? null : next.asType()); - annotationTypeBuilder.build(); - } else { - AbstractBuilder classBuilder = - configuration.getBuilderFactory().getClassBuilder(klass, - prev, next, classtree); - classBuilder.build(); - } - } catch (IOException e) { - throw new DocletAbortException(e); - } catch (DocletAbortException de) { - de.printStackTrace(); - throw de; - } catch (Exception e) { - e.printStackTrace(); - throw new DocletAbortException(e); + + if (utils.isAnnotationType(klass)) { + AbstractBuilder annotationTypeBuilder = + configuration.getBuilderFactory() + .getAnnotationTypeBuilder(klass, + prev == null ? null : prev.asType(), + next == null ? null : next.asType()); + annotationTypeBuilder.build(); + } else { + AbstractBuilder classBuilder = + configuration.getBuilderFactory().getClassBuilder(klass, + prev, next, classtree); + classBuilder.build(); } } } @@ -275,7 +269,7 @@ * {@inheritDoc} */ @Override // defined by AbstractDoclet - protected void generateModuleFiles() throws Exception { + protected void generateModuleFiles() throws DocletException { if (configuration.showModules) { if (configuration.frames) { ModuleIndexFrameWriter.generate(configuration); @@ -313,7 +307,7 @@ * {@inheritDoc} */ @Override // defined by AbstractDoclet - protected void generatePackageFiles(ClassTree classtree) throws Exception { + protected void generatePackageFiles(ClassTree classtree) throws DocletException { Set<PackageElement> packages = configuration.packages; if (packages.size() > 1 && configuration.frames) { PackageIndexFrameWriter.generate(configuration); @@ -356,24 +350,18 @@ return configuration.getSupportedOptions(); } - private void performCopy(String filename) { + private void performCopy(String filename) throws DocFileIOException { if (filename.isEmpty()) return; - try { - DocFile fromfile = DocFile.createFileForInput(configuration, filename); - DocPath path = DocPath.create(fromfile.getName()); - DocFile toFile = DocFile.createFileForOutput(configuration, path); - if (toFile.isSameFile(fromfile)) - return; + DocFile fromfile = DocFile.createFileForInput(configuration, filename); + DocPath path = DocPath.create(fromfile.getName()); + DocFile toFile = DocFile.createFileForOutput(configuration, path); + if (toFile.isSameFile(fromfile)) + return; - messages.notice("doclet.Copying_File_0_To_File_1", - fromfile.toString(), path.getPath()); - toFile.copyFile(fromfile); - } catch (IOException exc) { - messages.error("doclet.perform_copy_exception_encountered", - exc.toString()); - throw new DocletAbortException(exc); - } + messages.notice("doclet.Copying_File_0_To_File_1", + fromfile.toString(), path.getPath()); + toFile.copyFile(fromfile); } }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.text.SimpleDateFormat; import java.util.*; import java.util.regex.Matcher; @@ -55,16 +54,14 @@ import com.sun.source.doctree.EndElementTree; import com.sun.source.doctree.EntityTree; import com.sun.source.doctree.ErroneousTree; +import com.sun.source.doctree.IndexTree; import com.sun.source.doctree.InheritDocTree; -import com.sun.source.doctree.IndexTree; import com.sun.source.doctree.LinkTree; import com.sun.source.doctree.LiteralTree; import com.sun.source.doctree.SeeTree; import com.sun.source.doctree.StartElementTree; import com.sun.source.doctree.TextTree; import com.sun.source.util.SimpleDocTreeVisitor; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import jdk.javadoc.internal.doclets.formats.html.markup.Comment; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; @@ -87,14 +84,15 @@ import jdk.javadoc.internal.doclets.toolkit.Resources; import jdk.javadoc.internal.doclets.toolkit.taglets.DocRootTaglet; import jdk.javadoc.internal.doclets.toolkit.taglets.TagletWriter; +import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocLink; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; import jdk.javadoc.internal.doclets.toolkit.util.ImplementedMethods; import jdk.javadoc.internal.doclets.toolkit.util.Utils; -import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import static com.sun.source.doctree.AttributeTree.ValueKind.*; import static com.sun.source.doctree.DocTree.Kind.*; @@ -439,9 +437,10 @@ * @param includeScript true if printing windowtitle script * false for files that appear in the left-hand frames * @param body the body htmltree to be included in the document + * @throws DocFileIOException if there is a problem writing the file */ public void printHtmlDocument(List<String> metakeywords, boolean includeScript, - Content body) throws IOException { + Content body) throws DocFileIOException { Content htmlDocType = configuration.isOutputHtml5() ? DocType.HTML5 : DocType.TRANSITIONAL; @@ -1834,7 +1833,7 @@ return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitAttribute(AttributeTree node, Content c) { StringBuilder sb = new StringBuilder(SPACER).append(node.getName()); if (node.getValueKind() == ValueKind.EMPTY) { @@ -1883,7 +1882,7 @@ return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitComment(CommentTree node, Content c) { if (isFirstSentence && isFirst(node)) { commentRemoved = true; @@ -1901,7 +1900,7 @@ return content; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitDocRoot(DocRootTree node, Content c) { Content docRootContent = TagletWriter.getInlineTagOutput(element, configuration.tagletManager, @@ -1916,20 +1915,20 @@ return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitEndElement(EndElementTree node, Content c) { RawHtml rawHtml = new RawHtml("</" + node.getName() + ">"); result.addContent(rawHtml); return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitEntity(EntityTree node, Content c) { result.addContent(new RawHtml(node.toString())); return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitErroneous(ErroneousTree node, Content c) { messages.warning(ch.getDocTreePath(node), "doclet.tag.invalid_usage", node); @@ -1937,7 +1936,7 @@ return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitInheritDoc(InheritDocTree node, Content c) { Content output = TagletWriter.getInlineTagOutput(element, configuration.tagletManager, holderTag, @@ -1947,7 +1946,7 @@ return (isFirstSentence && !output.isEmpty()); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitIndex(IndexTree node, Content p) { Content output = TagletWriter.getInlineTagOutput(element, configuration.tagletManager, holderTag, tag, @@ -1958,14 +1957,14 @@ return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitLink(LinkTree node, Content c) { // we need to pass the DocTreeImpl here, so ignore node result.addContent(seeTagToContent(element, tag)); return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitLiteral(LiteralTree node, Content c) { String s = node.getBody().toString(); Content content = new StringContent(utils.normalizeNewlines(s)); @@ -1975,14 +1974,14 @@ return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitSee(SeeTree node, Content c) { // we need to pass the DocTreeImpl here, so ignore node result.addContent(seeTagToContent(element, tag)); return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitStartElement(StartElementTree node, Content c) { String text = "<" + node.getName(); RawHtml rawHtml = new RawHtml(utils.normalizeNewlines(text)); @@ -2010,7 +2009,7 @@ return utils.normalizeNewlines(text); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitText(TextTree node, Content c) { String text = node.getBody(); result.addContent(new RawHtml(textCleanup(text, isLast(node), commentRemoved))); @@ -2018,7 +2017,7 @@ return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override protected Boolean defaultAction(DocTree node, Content c) { Content output = TagletWriter.getInlineTagOutput(element, configuration.tagletManager, holderTag, tag, @@ -2096,27 +2095,27 @@ } DocPath redirectPathFromRoot = new SimpleElementVisitor9<DocPath, Void>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public DocPath visitType(TypeElement e, Void p) { return DocPath.forPackage(utils.containingPackage(e)); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public DocPath visitPackage(PackageElement e, Void p) { return DocPath.forPackage(e); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public DocPath visitVariable(VariableElement e, Void p) { return DocPath.forPackage(utils.containingPackage(e)); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public DocPath visitExecutable(ExecutableElement e, Void p) { return DocPath.forPackage(utils.containingPackage(e)); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected DocPath defaultAction(Element e, Void p) { return null; } @@ -2180,8 +2179,8 @@ head.addContent(javascript); if (configuration.createindex) { if (pathToRoot != null && script != null) { - String path = pathToRoot.isEmpty() ? "." : pathToRoot.getPath(); - script.addContent(new RawHtml("var pathtoroot = \"" + path + "/\";loadScripts(document, \'script\');")); + String ptrPath = pathToRoot.isEmpty() ? "." : pathToRoot.getPath(); + script.addContent(new RawHtml("var pathtoroot = \"" + ptrPath + "/\";loadScripts(document, \'script\');")); } addJQueryFile(head, DocPaths.JSZIP_MIN); addJQueryFile(head, DocPaths.JSZIPUTILS_MIN); @@ -2377,13 +2376,13 @@ List<AnnotationValue> annotationTypeValues = new ArrayList<>(); new SimpleAnnotationValueVisitor9<Void, List<AnnotationValue>>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitArray(List<? extends AnnotationValue> vals, List<AnnotationValue> p) { p.addAll(vals); return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Void defaultAction(Object o, List<AnnotationValue> p) { p.add(annotationValue); return null; @@ -2405,7 +2404,7 @@ List<AnnotationValue> annotationTypeValues = new ArrayList<>(); for (AnnotationValue a : pairs.values()) { new SimpleAnnotationValueVisitor9<Void, List<AnnotationValue>>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitArray(List<? extends AnnotationValue> vals, List<AnnotationValue> annotationTypeValues) { for (AnnotationValue av : vals) { annotationTypeValues.add(av); @@ -2481,12 +2480,12 @@ AnnotationValue annotationValue = map.get(element); List<AnnotationValue> annotationTypeValues = new ArrayList<>(); new SimpleAnnotationValueVisitor9<Void, AnnotationValue>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitArray(List<? extends AnnotationValue> vals, AnnotationValue p) { annotationTypeValues.addAll(vals); return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Void defaultAction(Object o, AnnotationValue p) { annotationTypeValues.add(p); return null; @@ -2519,13 +2518,13 @@ for (ExecutableElement ee : pairs.keySet()) { annotationValue = pairs.get(ee); boolean rvalue = new SimpleAnnotationValueVisitor9<Boolean, Void>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitArray(List<? extends AnnotationValue> vals, Void p) { if (vals.size() > 1) { if (vals.get(0) instanceof AnnotationMirror) { isContainerDocumented = true; return new SimpleAnnotationValueVisitor9<Boolean, Void>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitAnnotation(AnnotationMirror a, Void p) { isContainerDocumented = true; Element asElement = a.getAnnotationType().asElement(); @@ -2534,7 +2533,7 @@ } return true; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Boolean defaultAction(Object o, Void p) { return false; } @@ -2544,7 +2543,7 @@ return false; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Boolean defaultAction(Object o, Void p) { return false; } @@ -2559,10 +2558,10 @@ private Content annotationValueToContent(AnnotationValue annotationValue) { return new SimpleAnnotationValueVisitor9<Content, Void>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Content visitType(TypeMirror t, Void p) { return new SimpleTypeVisitor9<Content, Void>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Content visitDeclared(DeclaredType t, Void p) { LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.ANNOTATION, t); @@ -2572,13 +2571,13 @@ linkInfo.label = new StringContent(name + utils.getDimension(t) + ".class"); return getLink(linkInfo); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Content defaultAction(TypeMirror e, Void p) { return new StringContent(t + utils.getDimension(t) + ".class"); } }.visit(t); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Content visitAnnotation(AnnotationMirror a, Void p) { List<Content> list = getAnnotations(0, a, false); ContentBuilder buf = new ContentBuilder(); @@ -2587,12 +2586,12 @@ } return buf; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Content visitEnumConstant(VariableElement c, Void p) { return getDocLink(LinkInfoImpl.Kind.ANNOTATION, c, c.getSimpleName(), false); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Content visitArray(List<? extends AnnotationValue> vals, Void p) { ContentBuilder buf = new ContentBuilder(); String sep = ""; @@ -2603,7 +2602,7 @@ } return buf; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Content defaultAction(Object o, Void p) { return new StringContent(annotationValue.toString()); } @@ -2615,6 +2614,7 @@ * * @return the configuration for this doclet. */ + @Override public Configuration configuration() { return configuration; }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,8 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.IOException; - import jdk.javadoc.internal.doclets.formats.html.markup.Comment; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.DocType; @@ -37,10 +35,9 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.Messages; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import static jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocWriter.CONTENT_TYPE; @@ -53,28 +50,23 @@ */ public class IndexRedirectWriter extends HtmlDocletWriter { - public static void generate(ConfigurationImpl configuration) { + public static void generate(ConfigurationImpl configuration) + throws DocFileIOException { IndexRedirectWriter indexRedirect; - DocPath filename = DocPath.empty; - try { - filename = DocPaths.INDEX; + DocPath filename = DocPaths.INDEX; indexRedirect = new IndexRedirectWriter(configuration, filename); indexRedirect.generateIndexFile(); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error( - "doclet.exception_encountered", - exc.toString(), filename); - throw new DocletAbortException(exc); - } } - IndexRedirectWriter(ConfigurationImpl configuration, DocPath filename) - throws IOException { + IndexRedirectWriter(ConfigurationImpl configuration, DocPath filename) { super(configuration, filename); } - void generateIndexFile() throws IOException { + /** + * Generate an index file that redirects to an alternate file. + * @throws DocFileIOException if there is a problem generating the file + */ + void generateIndexFile() throws DocFileIOException { Content htmlDocType = configuration.isOutputHtml5() ? DocType.HTML5 : DocType.TRANSITIONAL;
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.*; import javax.lang.model.element.ModuleElement; @@ -39,8 +38,8 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** @@ -76,8 +75,7 @@ * @param configuration the configuration of the doclet. * @param moduleElement moduleElement under consideration. */ - public ModuleFrameWriter(ConfigurationImpl configuration, ModuleElement moduleElement) - throws IOException { + public ModuleFrameWriter(ConfigurationImpl configuration, ModuleElement moduleElement) { super(configuration, DocPaths.moduleTypeFrame(moduleElement)); this.mdle = moduleElement; if (configuration.getSpecifiedPackages().isEmpty()) { @@ -91,35 +89,29 @@ * * @param configuration the current configuration of the doclet. * @param moduleElement The package for which "module_name-type-frame.html" is to be generated. + * @throws DocFileIOException if there is a problem generating the module summary file */ - public static void generate(ConfigurationImpl configuration, ModuleElement moduleElement) { - ModuleFrameWriter mdlgen; - try { - mdlgen = new ModuleFrameWriter(configuration, moduleElement); - String mdlName = moduleElement.getQualifiedName().toString(); - Content mdlLabel = new StringContent(mdlName); - HtmlTree body = mdlgen.getBody(false, mdlgen.getWindowTitle(mdlName)); - HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) - ? HtmlTree.MAIN() - : body; - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, - mdlgen.getHyperLink(DocPaths.moduleSummary(moduleElement), mdlLabel, "", "classFrame")); - htmlTree.addContent(heading); - HtmlTree div = new HtmlTree(HtmlTag.DIV); - div.addStyle(HtmlStyle.indexContainer); - mdlgen.addClassListing(div); - htmlTree.addContent(div); - if (configuration.allowTag(HtmlTag.MAIN)) { - body.addContent(htmlTree); - } - mdlgen.printHtmlDocument( - configuration.metakeywords.getMetaKeywordsForModule(moduleElement), false, body); - } catch (IOException exc) { - configuration.messages.error( - "doclet.exception_encountered", - exc.toString(), DocPaths.moduleTypeFrame(moduleElement).getPath()); - throw new DocletAbortException(exc); + public static void generate(ConfigurationImpl configuration, ModuleElement moduleElement) + throws DocFileIOException { + ModuleFrameWriter mdlgen = new ModuleFrameWriter(configuration, moduleElement); + String mdlName = moduleElement.getQualifiedName().toString(); + Content mdlLabel = new StringContent(mdlName); + HtmlTree body = mdlgen.getBody(false, mdlgen.getWindowTitle(mdlName)); + HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) + ? HtmlTree.MAIN() + : body; + Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, + mdlgen.getHyperLink(DocPaths.moduleSummary(moduleElement), mdlLabel, "", "classFrame")); + htmlTree.addContent(heading); + HtmlTree div = new HtmlTree(HtmlTag.DIV); + div.addStyle(HtmlStyle.indexContainer); + mdlgen.addClassListing(div); + htmlTree.addContent(div); + if (configuration.allowTag(HtmlTag.MAIN)) { + body.addContent(htmlTree); } + mdlgen.printHtmlDocument( + configuration.metakeywords.getMetaKeywordsForModule(moduleElement), false, body); } /**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.Map; import java.util.Set; @@ -39,10 +38,9 @@ import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.Messages; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** * Generate the module index for the left-hand frame in the generated output. @@ -65,27 +63,19 @@ * @param filename Name of the module index file to be generated. */ public ModuleIndexFrameWriter(ConfigurationImpl configuration, - DocPath filename) throws IOException { + DocPath filename) { super(configuration, filename); } /** * Generate the module index file named "module-overview-frame.html". - * @throws DocletAbortException + * @throws DocFileIOException * @param configuration the configuration object */ - public static void generate(ConfigurationImpl configuration) { - ModuleIndexFrameWriter modulegen; + public static void generate(ConfigurationImpl configuration) throws DocFileIOException { DocPath filename = DocPaths.MODULE_OVERVIEW_FRAME; - try { - modulegen = new ModuleIndexFrameWriter(configuration, filename); - modulegen.buildModuleIndexFile("doclet.Window_Overview", false); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), filename); - throw new DocletAbortException(exc); - } + ModuleIndexFrameWriter modulegen = new ModuleIndexFrameWriter(configuration, filename); + modulegen.buildModuleIndexFile("doclet.Window_Overview", false); } /**
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,13 +25,11 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.*; import javax.lang.model.element.ModuleElement; import javax.lang.model.element.PackageElement; -import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.internal.doclets.formats.html.markup.ContentBuilder; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTag; @@ -39,10 +37,9 @@ import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.Messages; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.Group; /** @@ -68,15 +65,14 @@ /** * HTML tree for main tag. */ - private HtmlTree htmlTree = HtmlTree.MAIN(); + private final HtmlTree htmlTree = HtmlTree.MAIN(); /** * Construct the ModuleIndexWriter. * @param configuration the configuration object * @param filename the name of the generated file - * @throws java.io.IOException */ - public ModuleIndexWriter(ConfigurationImpl configuration, DocPath filename) throws IOException { + public ModuleIndexWriter(ConfigurationImpl configuration, DocPath filename) { super(configuration, filename); modules = configuration.modules; } @@ -85,20 +81,12 @@ * Generate the module index page for the right-hand frame. * * @param configuration the current configuration of the doclet. + * @throws DocFileIOException if there is a problem generating the module index page */ - public static void generate(ConfigurationImpl configuration) { - ModuleIndexWriter mdlgen; + public static void generate(ConfigurationImpl configuration) throws DocFileIOException { DocPath filename = DocPaths.overviewSummary(configuration.frames); - try { - mdlgen = new ModuleIndexWriter(configuration, filename); - mdlgen.buildModuleIndexFile("doclet.Window_Overview_Summary", true); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error( - "doclet.exception_encountered", - exc.toString(), filename); - throw new DocletAbortException(exc); - } + ModuleIndexWriter mdlgen = new ModuleIndexWriter(configuration, filename); + mdlgen.buildModuleIndexFile("doclet.Window_Overview_Summary", true); } /** @@ -106,6 +94,7 @@ * * @param body the documentation tree to which the index will be added */ + @Override protected void addIndex(Content body) { if (modules != null && !modules.isEmpty()) { addIndexContents(configuration.getText("doclet.Modules"), @@ -190,6 +179,7 @@ * * @param body the documentation tree to which the overview header will be added */ + @Override protected void addOverviewHeader(Content body) { addConfigurationTitle(body); if (!utils.getBody(configuration.overviewElement).isEmpty()) { @@ -233,9 +223,9 @@ * "-overview" option on the command line. * * @param body the documentation tree to which the overview will be added - * @throws java.io.IOException */ - protected void addOverview(Content body) throws IOException { + @Override + protected void addOverview(Content body) { HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.contentContainer); addOverviewComment(div); @@ -254,6 +244,7 @@ * * @param body the documentation tree to which the navigation bar header will be added */ + @Override protected void addNavigationBarHeader(Content body) { Content htmlTree = (configuration.allowTag(HtmlTag.HEADER)) ? HtmlTree.HEADER() @@ -271,6 +262,7 @@ * * @param body the documentation tree to which the navigation bar footer will be added */ + @Override protected void addNavigationBarFooter(Content body) { Content htmltree = (configuration.allowTag(HtmlTag.FOOTER)) ? HtmlTree.FOOTER() @@ -282,10 +274,12 @@ } } + @Override protected void addModulePackagesList(Map<ModuleElement, Set<PackageElement>> modules, String text, String tableSummary, Content body, ModuleElement mdle) { } + @Override protected void addModulesList(Map<ModuleElement, Set<PackageElement>> modules, String text, String tableSummary, Content body) { }
--- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java Fri Aug 26 10:02:50 2016 -0700 +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java Wed Aug 31 09:22:54 2016 -0700 @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.IOException; import java.util.ArrayList; import java.util.List; import java.util.Map; @@ -41,10 +40,9 @@ import jdk.javadoc.internal.doclets.formats.html.markup.RawHtml; import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.Messages; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPath; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** * Generate the module package index for the left-hand frame in the generated output. @@ -66,29 +64,20 @@ * @param configuration the configuration object * @param filename Name of the package index file to be generated. */ - public ModulePackageIndexFrameWriter(ConfigurationImpl configu