From 8b735ce29a7aff663519645e323a12d151322cbf Mon Sep 17 00:00:00 2001 From: Alexander Zvegintsev Date: Tue, 16 Aug 2016 22:10:12 +0300 Subject: [PATCH 01/87] 8155691: Update GIFlib library to the latest up-to-date Reviewed-by: serb --- .../native/libsplashscreen/giflib/dgif_lib.c | 20 +++- .../native/libsplashscreen/giflib/gif_lib.h | 5 +- .../native/libsplashscreen/giflib/gifalloc.c | 27 ++--- .../giflib/openbsd-reallocarray.c | 106 ++++++++++++++++++ 4 files changed, 139 insertions(+), 19 deletions(-) create mode 100644 jdk/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c index 2d3d88225e9..1c1b217654e 100644 --- a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/dgif_lib.c @@ -114,7 +114,7 @@ DGifOpenFileHandle(int FileHandle, int *Error) GifFile->SavedImages = NULL; GifFile->SColorMap = NULL; - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); + Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType)); if (Private == NULL) { if (Error != NULL) *Error = D_GIF_ERR_NOT_ENOUGH_MEM; @@ -122,6 +122,9 @@ DGifOpenFileHandle(int FileHandle, int *Error) free((char *)GifFile); return NULL; } + + /*@i1@*/memset(Private, '\0', sizeof(GifFilePrivateType)); + #ifdef _WIN32 _setmode(FileHandle, O_BINARY); /* Make sure it is in binary mode. */ #endif /* _WIN32 */ @@ -197,13 +200,14 @@ DGifOpen(void *userData, InputFunc readFunc, int *Error) GifFile->SavedImages = NULL; GifFile->SColorMap = NULL; - Private = (GifFilePrivateType *)malloc(sizeof(GifFilePrivateType)); + Private = (GifFilePrivateType *)calloc(1, sizeof(GifFilePrivateType)); if (!Private) { if (Error != NULL) *Error = D_GIF_ERR_NOT_ENOUGH_MEM; free((char *)GifFile); return NULL; } + /*@i1@*/memset(Private, '\0', sizeof(GifFilePrivateType)); GifFile->Private = (void *)Private; Private->FileHandle = 0; @@ -417,8 +421,8 @@ DGifGetImageDesc(GifFileType *GifFile) if (GifFile->SavedImages) { SavedImage* new_saved_images = - (SavedImage *)realloc(GifFile->SavedImages, - sizeof(SavedImage) * (GifFile->ImageCount + 1)); + (SavedImage *)reallocarray(GifFile->SavedImages, + (GifFile->ImageCount + 1), sizeof(SavedImage)); if (new_saved_images == NULL) { GifFile->Error = D_GIF_ERR_NOT_ENOUGH_MEM; return GIF_ERROR; @@ -788,6 +792,12 @@ DGifSetupDecompress(GifFileType *GifFile) } BitsPerPixel = CodeSize; + /* this can only happen on a severely malformed GIF */ + if (BitsPerPixel > 8) { + GifFile->Error = D_GIF_ERR_READ_FAILED; /* somewhat bogus error code */ + return GIF_ERROR; /* Failed to read Code size. */ + } + Private->Buf[0] = 0; /* Input Buffer empty. */ Private->BitsPerPixel = BitsPerPixel; Private->ClearCode = (1 << BitsPerPixel); @@ -1123,7 +1133,7 @@ DGifSlurp(GifFileType *GifFile) if (ImageSize > (SIZE_MAX / sizeof(GifPixelType))) { return GIF_ERROR; } - sp->RasterBits = (unsigned char *)malloc(ImageSize * + sp->RasterBits = (unsigned char *)reallocarray(NULL, ImageSize, sizeof(GifPixelType)); if (sp->RasterBits == NULL) { diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h index aa356362bf6..e8d7090bd10 100644 --- a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gif_lib.h @@ -37,7 +37,7 @@ extern "C" { #define GIFLIB_MAJOR 5 #define GIFLIB_MINOR 1 -#define GIFLIB_RELEASE 1 +#define GIFLIB_RELEASE 4 #define GIF_ERROR 0 #define GIF_OK 1 @@ -274,6 +274,9 @@ extern ColorMapObject *GifUnionColorMap(const ColorMapObject *ColorIn1, GifPixelType ColorTransIn2[]); extern int GifBitSize(int n); +extern void * reallocarray(void *optr, size_t nmemb, size_t size); + + /****************************************************************************** Support for the in-core structures allocation (slurp mode). ******************************************************************************/ diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c index f7a6a3d8f28..cc784d19bd8 100644 --- a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/gifalloc.c @@ -212,8 +212,8 @@ GifUnionColorMap(const ColorMapObject *ColorIn1, /* perhaps we can shrink the map? */ if (RoundUpTo < ColorUnion->ColorCount) { - GifColorType *new_map = (GifColorType *)realloc(Map, - sizeof(GifColorType) * RoundUpTo); + GifColorType *new_map = (GifColorType *)reallocarray(Map, + RoundUpTo, sizeof(GifColorType)); if( new_map == NULL ) { GifFreeMapObject(ColorUnion); return ((ColorMapObject *) NULL); @@ -256,9 +256,9 @@ GifAddExtensionBlock(int *ExtensionBlockCount, if (*ExtensionBlocks == NULL) *ExtensionBlocks=(ExtensionBlock *)malloc(sizeof(ExtensionBlock)); else { - ExtensionBlock* ep_new = (ExtensionBlock *)realloc(*ExtensionBlocks, - sizeof(ExtensionBlock) * - (*ExtensionBlockCount + 1)); + ExtensionBlock* ep_new = (ExtensionBlock *)reallocarray + (*ExtensionBlocks, (*ExtensionBlockCount + 1), + sizeof(ExtensionBlock)); if( ep_new == NULL ) return (GIF_ERROR); *ExtensionBlocks = ep_new; @@ -349,8 +349,8 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) if (GifFile->SavedImages == NULL) GifFile->SavedImages = (SavedImage *)malloc(sizeof(SavedImage)); else - GifFile->SavedImages = (SavedImage *)realloc(GifFile->SavedImages, - sizeof(SavedImage) * (GifFile->ImageCount + 1)); + GifFile->SavedImages = (SavedImage *)reallocarray(GifFile->SavedImages, + (GifFile->ImageCount + 1), sizeof(SavedImage)); if (GifFile->SavedImages == NULL) return ((SavedImage *)NULL); @@ -379,9 +379,10 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) } /* next, the raster */ - sp->RasterBits = (unsigned char *)malloc(sizeof(GifPixelType) * - CopyFrom->ImageDesc.Height * - CopyFrom->ImageDesc.Width); + sp->RasterBits = (unsigned char *)reallocarray(NULL, + (CopyFrom->ImageDesc.Height * + CopyFrom->ImageDesc.Width), + sizeof(GifPixelType)); if (sp->RasterBits == NULL) { FreeLastSavedImage(GifFile); return (SavedImage *)(NULL); @@ -392,9 +393,9 @@ GifMakeSavedImage(GifFileType *GifFile, const SavedImage *CopyFrom) /* finally, the extension blocks */ if (sp->ExtensionBlocks != NULL) { - sp->ExtensionBlocks = (ExtensionBlock *)malloc( - sizeof(ExtensionBlock) * - CopyFrom->ExtensionBlockCount); + sp->ExtensionBlocks = (ExtensionBlock *)reallocarray(NULL, + CopyFrom->ExtensionBlockCount, + sizeof(ExtensionBlock)); if (sp->ExtensionBlocks == NULL) { FreeLastSavedImage(GifFile); return (SavedImage *)(NULL); diff --git a/jdk/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c new file mode 100644 index 00000000000..1087671c27b --- /dev/null +++ b/jdk/src/java.desktop/share/native/libsplashscreen/giflib/openbsd-reallocarray.c @@ -0,0 +1,106 @@ +/* + * 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. + */ + +/* $OpenBSD: reallocarray.c,v 1.1 2014/05/08 21:43:49 deraadt Exp $ */ +/* + * Copyright (c) 2008 Otto Moerbeek + * + * Permission to use, copy, modify, and distribute this software for any + * purpose with or without fee is hereby granted, provided that the above + * copyright notice and this permission notice appear in all copies. + * + * THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES + * WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF + * MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR + * ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES + * WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN + * ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF + * OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + */ + +#include +#include +#include +#include + +/* + * This is sqrt(SIZE_MAX+1), as s1*s2 <= SIZE_MAX + * if both s1 < MUL_NO_OVERFLOW and s2 < MUL_NO_OVERFLOW + */ +#define MUL_NO_OVERFLOW ((size_t)1 << (sizeof(size_t) * 4)) + +void * +reallocarray(void *optr, size_t nmemb, size_t size) +{ + if ((nmemb >= MUL_NO_OVERFLOW || size >= MUL_NO_OVERFLOW) && + nmemb > 0 && SIZE_MAX / nmemb < size) { + errno = ENOMEM; + return NULL; + } + /* + * Head off variations in realloc behavior on different + * platforms (reported by MarkR ) + * + * The behaviour of reallocarray is implementation-defined if + * nmemb or size is zero. It can return NULL or non-NULL + * depending on the platform. + * https://www.securecoding.cert.org/confluence/display/c/MEM04-C.Beware+of+zero-lengthallocations + * + * Here are some extracts from realloc man pages on different platforms. + * + * void realloc( void memblock, size_t size ); + * + * Windows: + * + * If there is not enough available memory to expand the block + * to the given size, the original block is left unchanged, + * and NULL is returned. If size is zero, then the block + * pointed to by memblock is freed; the return value is NULL, + * and memblock is left pointing at a freed block. + * + * OpenBSD: + * + * If size or nmemb is equal to 0, a unique pointer to an + * access protected, zero sized object is returned. Access via + * this pointer will generate a SIGSEGV exception. + * + * Linux: + * + * If size was equal to 0, either NULL or a pointer suitable + * to be passed to free() is returned. + * + * OS X: + * + * If size is zero and ptr is not NULL, a new, minimum sized + * object is allocated and the original object is freed. + * + * It looks like images with zero width or height can trigger + * this, and fuzzing behaviour will differ by platform, so + * fuzzing on one platform may not detect zero-size allocation + * problems on other platforms. + */ + if (size == 0 || nmemb == 0) + return NULL; + return realloc(optr, size * nmemb); +} From c47ae75e1b43624e922c62515f09bc9953011f31 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 16 Aug 2016 23:07:35 +0300 Subject: [PATCH 02/87] 8159898: Negative array size in java/beans/Introspector/Test8027905.java Reviewed-by: alexsch, yan --- .../Window/OwnedWindowsLeak/OwnedWindowsLeak.java | 14 ++++++-------- jdk/test/java/beans/Introspector/Test8027905.java | 1 + 2 files changed, 7 insertions(+), 8 deletions(-) diff --git a/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java b/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java index 0b6da116ede..81fdd4b049b 100644 --- a/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java +++ b/jdk/test/java/awt/Window/OwnedWindowsLeak/OwnedWindowsLeak.java @@ -27,16 +27,14 @@ @bug 6758673 @summary Tests that windows are removed from owner's child windows list @author art: area=awt.toplevel - @run main OwnedWindowsLeak + @run main/othervm -mx128m OwnedWindowsLeak */ -import java.awt.*; -import java.awt.event.*; - -import java.lang.ref.*; -import java.lang.reflect.*; - -import java.util.*; +import java.awt.Frame; +import java.awt.Window; +import java.lang.ref.WeakReference; +import java.lang.reflect.Field; +import java.util.Vector; public class OwnedWindowsLeak { diff --git a/jdk/test/java/beans/Introspector/Test8027905.java b/jdk/test/java/beans/Introspector/Test8027905.java index 6c91694b4df..60318f34555 100644 --- a/jdk/test/java/beans/Introspector/Test8027905.java +++ b/jdk/test/java/beans/Introspector/Test8027905.java @@ -28,6 +28,7 @@ import java.beans.PropertyDescriptor; * @bug 8027905 * @summary Tests that GC does not affect a property type * @author Sergey Malenkov + * @run main/othervm -mx16m Test8027905 */ public class Test8027905 { From 71b91c6ce137d3b667dde9f88af290839eed3b30 Mon Sep 17 00:00:00 2001 From: Avik Niyogi Date: Wed, 17 Aug 2016 14:42:14 +0530 Subject: [PATCH 03/87] 8163169: [PIT][TEST_BUG] fix to JDK-8161470 doesn't work Reviewed-by: alexsch, rchamyal --- .../swing/JRadioButton/FocusTraversal/FocusTraversal.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java b/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java index f7146318ad0..4c773c0f7b1 100644 --- a/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java +++ b/jdk/test/javax/swing/JRadioButton/FocusTraversal/FocusTraversal.java @@ -23,7 +23,7 @@ /* @test * @key headful - * @bug 8129940 8132770 8161470 + * @bug 8129940 8132770 8161470 8163169 * @summary JRadioButton should run custom FocusTraversalKeys for all LaFs * @run main FocusTraversal */ @@ -61,6 +61,7 @@ public class FocusTraversal { public static void main(String[] args) throws Exception { robot = new Robot(); + robot.setAutoDelay(100); robot.waitForIdle(); UIManager.LookAndFeelInfo[] lookAndFeelArray = UIManager.getInstalledLookAndFeels(); From b446df55a53941cb9801bb927119fe95cda0165c Mon Sep 17 00:00:00 2001 From: Rajeev Chamyal Date: Wed, 17 Aug 2016 14:48:13 +0530 Subject: [PATCH 04/87] 8161913: [PIT] java/awt/Window/8159168/SetShapeTest.java mostly fails Reviewed-by: alexsch, aniyogi --- .../java/awt/Window/8159168/SetShapeTest.java | 44 ++++++++++--------- 1 file changed, 23 insertions(+), 21 deletions(-) diff --git a/jdk/test/java/awt/Window/8159168/SetShapeTest.java b/jdk/test/java/awt/Window/8159168/SetShapeTest.java index 19670a5f46e..9baaea1d084 100644 --- a/jdk/test/java/awt/Window/8159168/SetShapeTest.java +++ b/jdk/test/java/awt/Window/8159168/SetShapeTest.java @@ -1,29 +1,30 @@ /* -* 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. + * 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 8159168 + * @key headful + * @bug 8159168 8161913 * @summary [hidpi] Window.setShape() works incorrectly on HiDPI * @run main/othervm -Dsun.java2d.uiScale=2 SetShapeTest */ @@ -50,6 +51,7 @@ public class SetShapeTest { Rectangle rect = window.getBounds(); rect.x += rect.width - 10; rect.y += rect.height - 10; + robot.delay(1000); Color c = robot.getPixelColor(rect.x, rect.y); try { if (!c.equals(Color.RED)) { From cd6bfaf6d226d0e5563557a535313beb4522e852 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 18 Aug 2016 10:46:48 +0530 Subject: [PATCH 05/87] 8164205: [PIT][TEST_BUG] test javax/print/attribute/ServiceDlgPageRangeTest.java doesn't compile Reviewed-by: prr --- jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java b/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java index b35d687b7c0..ab17680cefc 100644 --- a/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java +++ b/jdk/test/javax/print/attribute/ServiceDlgPageRangeTest.java @@ -22,13 +22,15 @@ */ /* * @test - * @bug 5080098 + * @bug 5080098 8164205 * @summary Verify if PageRanges option is disabled for Non service-formatted * flavors. * @run main/manual ServiceDlgPageRangeTest */ import java.awt.BorderLayout; import java.awt.FlowLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import javax.print.DocFlavor; import javax.print.PrintService; import javax.print.PrintServiceLookup; From 5390af7c2b6df679d28752a2aae19bf010f3f436 Mon Sep 17 00:00:00 2001 From: Jayathirth D V Date: Fri, 19 Aug 2016 12:22:23 +0530 Subject: [PATCH 06/87] 8163258: Getting NullPointerException from ImageIO.getReaderWriterInfo due to failure to check for null Reviewed-by: prr, psadhukhan --- .../share/classes/javax/imageio/ImageIO.java | 7 +- .../imageio/GetReaderWriterInfoNullTest.java | 161 ++++++++++++++++++ 2 files changed, 166 insertions(+), 2 deletions(-) create mode 100644 jdk/test/javax/imageio/GetReaderWriterInfoNullTest.java diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java b/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java index 7af7b77be77..523a857dbc1 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/ImageIO.java @@ -462,10 +462,13 @@ public final class ImageIO { return new String[0]; } - HashSet s = new HashSet(); + HashSet s = new HashSet<>(); while (iter.hasNext()) { ImageReaderWriterSpi spi = iter.next(); - Collections.addAll(s, spiInfo.info(spi)); + String[] info = spiInfo.info(spi); + if (info != null) { + Collections.addAll(s, info); + } } return s.toArray(new String[s.size()]); diff --git a/jdk/test/javax/imageio/GetReaderWriterInfoNullTest.java b/jdk/test/javax/imageio/GetReaderWriterInfoNullTest.java new file mode 100644 index 00000000000..5e9679cfe7f --- /dev/null +++ b/jdk/test/javax/imageio/GetReaderWriterInfoNullTest.java @@ -0,0 +1,161 @@ +/* + * 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 8163258 + * @summary Test verifies that when we create our own ImageReaderSpi + * implementaion with MIMEType or FileSuffix as null, it should + * not throw NullPointerException when we call + * ImageIO.getReaderMIMETypes() or ImageIO.getReaderFileSuffixes(). + * @run main GetReaderWriterInfoNullTest + */ + +import java.awt.image.BufferedImage; +import java.io.IOException; +import java.util.Iterator; +import java.util.Locale; +import javax.imageio.IIOException; +import javax.imageio.ImageReadParam; +import javax.imageio.ImageReader; +import javax.imageio.ImageTypeSpecifier; +import javax.imageio.metadata.IIOMetadata; +import javax.imageio.spi.ImageReaderSpi; +import javax.imageio.stream.ImageInputStream; +import javax.imageio.ImageIO; +import javax.imageio.spi.IIORegistry; + +class TestImageReaderSpi extends ImageReaderSpi { + + public TestImageReaderSpi(String[] FORMATNAMES, String[] SUFFIXES, + String[] MIMETYPES) { + super("J Duke", // vendor + "1.0", // version + FORMATNAMES, // format names + SUFFIXES, // file suffixes + MIMETYPES, // mimetypes + "readTest.TestImageReader", // reader class name + new Class[] { ImageInputStream.class }, // input types + null, // writer class names. + true, // supports native metadata, + null, // [no] native stream metadata format + null, // [no] native stream metadata class + null, // [no] native extra stream metadata format + null, // [no] native extra stream metadata class + true, // supports standard metadata, + null, // metadata format name, + null, // metadata format class name + null, // [no] extra image metadata format + null // [no] extra image metadata format class + ); + } + + @Override + public boolean canDecodeInput(Object source) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public String getDescription(Locale locale) { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public ImageReader createReaderInstance(Object extension) + throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + +} + +class TestImageReader extends ImageReader { + + public TestImageReader(ImageReaderSpi originatingProvider) { + super(originatingProvider); + } + + @Override + public int getNumImages(boolean allowSearch) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getWidth(int imageIndex) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public int getHeight(int imageIndex) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public Iterator getImageTypes(int imageIndex) + throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IIOMetadata getStreamMetadata() throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public IIOMetadata getImageMetadata(int imageIndex) throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } + + @Override + public BufferedImage read(int imageIndex, ImageReadParam param) + throws IOException { + throw new UnsupportedOperationException("Not supported yet."); + } +} +public class GetReaderWriterInfoNullTest { + static final String[] FORMATNAMES = {"readTest"}; + static final String[] SUFFIXES = {"readTest"}; + static final String[] MIMETYPES = {"readTest"}; + public static void main (String[] args) throws IIOException { + // Verify getReaderMIMETypes() behavior by keeping MIMEType as null. + TestImageReaderSpi mimeNullReadSpi = + new TestImageReaderSpi(FORMATNAMES, SUFFIXES, null); + IIORegistry.getDefaultInstance(). + registerServiceProvider(mimeNullReadSpi); + ImageIO.getReaderMIMETypes(); + IIORegistry.getDefaultInstance(). + deregisterServiceProvider(mimeNullReadSpi); + + /* + * Verify getReaderFileSuffixes() behavior by keeping + * file suffix as null. + */ + TestImageReaderSpi suffixNullReadSpi = + new TestImageReaderSpi(FORMATNAMES, null, MIMETYPES); + IIORegistry.getDefaultInstance(). + registerServiceProvider(suffixNullReadSpi); + ImageIO.getReaderFileSuffixes(); + IIORegistry.getDefaultInstance(). + deregisterServiceProvider(suffixNullReadSpi); + } +} + From 966cbcfce3b8fb280faa8747d8eccba8d8085ac7 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Fri, 19 Aug 2016 16:48:53 +0400 Subject: [PATCH 07/87] 8151303: [macosx] [hidpi] JButton's low-res. icon is visible when clicking on it 8156182: [macosx] HiDPI/Retina icons do not work for disabled JButton/JMenuItem etc Reviewed-by: flar, prr --- .../classes/com/apple/laf/AquaUtils.java | 28 ++-- .../share/classes/javax/swing/GrayFilter.java | 12 +- .../awt/image/MultiResolutionCachedImage.java | 53 ++++++- .../image/MultiResolutionToolkitImage.java | 8 ++ .../MultiResolutionDisabledImageTest.java | 119 ++++++++++++++++ .../JButton/8151303/PressedIconTest.java | 132 ++++++++++++++++++ 6 files changed, 335 insertions(+), 17 deletions(-) create mode 100644 jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionDisabledImageTest.java create mode 100644 jdk/test/javax/swing/JButton/8151303/PressedIconTest.java diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java index 67520fcc30b..65c38cca879 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java @@ -105,38 +105,44 @@ final class AquaUtils { } static Image generateSelectedDarkImage(final Image image) { - final ImageProducer prod = new FilteredImageSource(image.getSource(), new IconImageFilter() { + final ImageFilter filter = new IconImageFilter() { @Override int getGreyFor(final int gray) { return gray * 75 / 100; } - }); - return Toolkit.getDefaultToolkit().createImage(prod); + }; + return map(image, filter); } static Image generateDisabledImage(final Image image) { - final ImageProducer prod = new FilteredImageSource(image.getSource(), new IconImageFilter() { + final ImageFilter filter = new IconImageFilter() { @Override int getGreyFor(final int gray) { return 255 - ((255 - gray) * 65 / 100); } - }); - return Toolkit.getDefaultToolkit().createImage(prod); + }; + return map(image, filter); } static Image generateLightenedImage(final Image image, final int percent) { final GrayFilter filter = new GrayFilter(true, percent); - return (image instanceof MultiResolutionCachedImage) - ? ((MultiResolutionCachedImage) image).map( - rv -> generateLightenedImage(rv, filter)) - : generateLightenedImage(image, filter); + return map(image, filter); } - static Image generateLightenedImage(Image image, ImageFilter filter) { + static Image generateFilteredImage(Image image, ImageFilter filter) { final ImageProducer prod = new FilteredImageSource(image.getSource(), filter); return Toolkit.getDefaultToolkit().createImage(prod); } + private static Image map(Image image, ImageFilter filter) { + if (image instanceof MultiResolutionImage) { + return MultiResolutionCachedImage + .map((MultiResolutionImage) image, + (img) -> generateFilteredImage(img, filter)); + } + return generateFilteredImage(image, filter); + } + private abstract static class IconImageFilter extends RGBImageFilter { IconImageFilter() { super(); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java b/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java index af5947e5eec..65fddf32df9 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/GrayFilter.java @@ -26,6 +26,7 @@ package javax.swing; import java.awt.*; import java.awt.image.*; +import sun.awt.image.MultiResolutionCachedImage; /** * An image filter that "disables" an image by turning @@ -48,7 +49,16 @@ public class GrayFilter extends RGBImageFilter { * @param i an {@code Image} to be created as disabled * @return the new grayscale image created from {@code i} */ - public static Image createDisabledImage (Image i) { + public static Image createDisabledImage(Image i) { + if (i instanceof MultiResolutionImage) { + return MultiResolutionCachedImage + .map((MultiResolutionImage) i, + (img) -> createDisabledImageImpl(img)); + } + return createDisabledImageImpl(i); + } + + private static Image createDisabledImageImpl(Image i) { GrayFilter filter = new GrayFilter(true, 50); ImageProducer prod = new FilteredImageSource(i.getSource(), filter); Image grayImage = Toolkit.getDefaultToolkit().createImage(prod); diff --git a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java index 8d8acdcf0a3..76bbfcff0f5 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionCachedImage.java @@ -33,6 +33,7 @@ import java.util.List; import java.util.function.Function; import java.util.function.BiFunction; import java.util.stream.Collectors; +import java.awt.image.MultiResolutionImage; import java.awt.image.AbstractMultiResolutionImage; public class MultiResolutionCachedImage extends AbstractMultiResolutionImage { @@ -44,17 +45,30 @@ public class MultiResolutionCachedImage extends AbstractMultiResolutionImage { private int availableInfo; public MultiResolutionCachedImage(int baseImageWidth, int baseImageHeight, - BiFunction mapper) { - this(baseImageWidth, baseImageHeight, new Dimension[]{new Dimension( - baseImageWidth, baseImageHeight) + BiFunction mapper) + { + this(baseImageWidth, baseImageHeight, + new Dimension[]{new Dimension( baseImageWidth, baseImageHeight) }, mapper); } public MultiResolutionCachedImage(int baseImageWidth, int baseImageHeight, - Dimension2D[] sizes, BiFunction mapper) { + Dimension2D[] sizes, + BiFunction mapper) + { + this(baseImageWidth, baseImageHeight, sizes, mapper, true); + } + + private MultiResolutionCachedImage(int baseImageWidth, int baseImageHeight, + Dimension2D[] sizes, + BiFunction mapper, + boolean copySizes) + { this.baseImageWidth = baseImageWidth; this.baseImageHeight = baseImageHeight; - this.sizes = (sizes == null) ? null : Arrays.copyOf(sizes, sizes.length); + this.sizes = (copySizes && sizes != null) + ? Arrays.copyOf(sizes, sizes.length) + : sizes; this.mapper = mapper; } @@ -99,6 +113,35 @@ public class MultiResolutionCachedImage extends AbstractMultiResolutionImage { mapper.apply(getResolutionVariant(width, height))); } + public static Image map(MultiResolutionImage mrImage, + Function mapper) { + + if (mrImage instanceof MultiResolutionToolkitImage) { + MultiResolutionToolkitImage mrtImage = + (MultiResolutionToolkitImage) mrImage; + return MultiResolutionToolkitImage.map(mrtImage, mapper); + } + + BiFunction sizeMapper + = (w, h) -> mapper.apply(mrImage.getResolutionVariant(w, h)); + + if (mrImage instanceof MultiResolutionCachedImage) { + MultiResolutionCachedImage mrcImage + = (MultiResolutionCachedImage) mrImage; + + return new MultiResolutionCachedImage(mrcImage.baseImageWidth, + mrcImage.baseImageHeight, + mrcImage.sizes, + sizeMapper, + false); + } + + Image image = (Image) mrImage; + int width = image.getWidth(null); + int height = image.getHeight(null); + return new MultiResolutionCachedImage(width, height, sizeMapper); + } + @Override public int getWidth(ImageObserver observer) { updateInfo(observer, ImageObserver.WIDTH); diff --git a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java index 26a86916824..dfe08735a15 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/image/MultiResolutionToolkitImage.java @@ -29,6 +29,7 @@ import java.awt.image.ImageObserver; import java.awt.image.MultiResolutionImage; import java.util.Arrays; import java.util.List; +import java.util.function.Function; import sun.awt.SoftCache; public class MultiResolutionToolkitImage extends ToolkitImage implements MultiResolutionImage { @@ -47,6 +48,13 @@ public class MultiResolutionToolkitImage extends ToolkitImage implements MultiRe ? this : resolutionVariant; } + public static Image map(MultiResolutionToolkitImage mrImage, + Function mapper) { + Image baseImage = mapper.apply(mrImage); + Image rvImage = mapper.apply(mrImage.resolutionVariant); + return new MultiResolutionToolkitImage(baseImage, rvImage); + } + private static void checkSize(double width, double height) { if (width <= 0 || height <= 0) { throw new IllegalArgumentException(String.format( diff --git a/jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionDisabledImageTest.java b/jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionDisabledImageTest.java new file mode 100644 index 00000000000..ce5c44d0d8a --- /dev/null +++ b/jdk/test/java/awt/image/MultiResolutionImage/MultiResolutionDisabledImageTest.java @@ -0,0 +1,119 @@ +/* + * 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. + */ + +import java.awt.Color; +import java.awt.Frame; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.Image; +import java.awt.MediaTracker; +import java.awt.Toolkit; +import java.awt.image.BaseMultiResolutionImage; +import java.awt.image.BufferedImage; +import java.io.File; +import javax.imageio.ImageIO; +import javax.swing.GrayFilter; +import java.awt.image.MultiResolutionImage; +import javax.swing.JLabel; + +/** + * @test + * @bug 8156182 + * @summary [macosx] HiDPI/Retina icons do not work for disabled + * JButton/JMenuItem etc. + * @run main/othervm -Dsun.java2d.uiScale=2 MultiResolutionDisabledImageTest + */ +public class MultiResolutionDisabledImageTest { + + private static final String IMAGE_NAME_1X = "image.png"; + private static final String IMAGE_NAME_2X = "image@2x.png"; + private static final int IMAGE_SIZE = 100; + private static final Color COLOR_1X = Color.GREEN; + private static final Color COLOR_2X = Color.BLUE; + + public static void main(String[] args) throws Exception { + + Image baseMRImage = new BaseMultiResolutionImage(createImage(1), + createImage(2)); + testMRDisabledImage(baseMRImage); + + saveImages(); + Image toolkitMRImage = Toolkit.getDefaultToolkit().getImage(IMAGE_NAME_1X); + + if (toolkitMRImage instanceof MultiResolutionImage) { + testMRDisabledImage(toolkitMRImage); + } + } + + private static void testMRDisabledImage(Image image) throws Exception { + + Image disabledImage = GrayFilter.createDisabledImage(image); + MediaTracker mediaTracker = new MediaTracker(new JLabel()); + mediaTracker.addImage(disabledImage, 0); + mediaTracker.waitForID(0); + + BufferedImage buffImage = new BufferedImage(IMAGE_SIZE, + IMAGE_SIZE, + BufferedImage.TYPE_INT_RGB); + + int x = IMAGE_SIZE / 2; + int y = IMAGE_SIZE / 2; + + Graphics2D g = buffImage.createGraphics(); + + g.scale(1, 1); + g.drawImage(disabledImage, 0, 0, null); + int rgb1x = buffImage.getRGB(x, y); + + g.scale(2, 2); + g.drawImage(disabledImage, 0, 0, null); + int rgb2x = buffImage.getRGB(x, y); + + g.dispose(); + + if (rgb1x == rgb2x) { + throw new RuntimeException("Disabled image is the same for the base" + + "image and the resolution variant"); + } + + } + + private static BufferedImage createImage(int scale) throws Exception { + BufferedImage image = new BufferedImage(scale * 200, scale * 300, + BufferedImage.TYPE_INT_RGB); + Graphics g = image.createGraphics(); + g.setColor(scale == 1 ? COLOR_1X : COLOR_2X); + g.fillRect(0, 0, scale * 200, scale * 300); + g.dispose(); + return image; + } + + private static void saveImages() throws Exception { + saveImage(createImage(1), IMAGE_NAME_1X); + saveImage(createImage(2), IMAGE_NAME_2X); + } + + private static void saveImage(BufferedImage image, String name) throws Exception { + ImageIO.write(image, "png", new File(name)); + } +} diff --git a/jdk/test/javax/swing/JButton/8151303/PressedIconTest.java b/jdk/test/javax/swing/JButton/8151303/PressedIconTest.java new file mode 100644 index 00000000000..9bf4065b099 --- /dev/null +++ b/jdk/test/javax/swing/JButton/8151303/PressedIconTest.java @@ -0,0 +1,132 @@ +/* + * 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. + */ + +import java.awt.BorderLayout; +import java.awt.Color; +import java.awt.Dimension; +import java.awt.Graphics; +import java.awt.Point; +import java.awt.Robot; +import java.awt.event.InputEvent; +import java.awt.image.BaseMultiResolutionImage; +import java.awt.image.BufferedImage; +import javax.swing.Icon; +import javax.swing.ImageIcon; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.JToggleButton; +import javax.swing.SwingUtilities; + +/** + * @test + * @bug 8151303 + * @summary [macosx] [hidpi] JButton's low-res. icon is visible when clicking on it + * @run main/othervm PressedIconTest + * @run main/othervm -Dsun.java2d.uiScale=2 PressedIconTest + */ +public class PressedIconTest { + + private final static int IMAGE_SIZE = 300; + + private final static Color COLOR_1X = Color.RED; + private final static Color COLOR_2X = Color.BLUE; + private static JFrame frame; + private static volatile double scale = -1; + private static volatile int centerX; + private static volatile int centerY; + + public static void main(String[] args) throws Exception { + Robot robot = new Robot(); + robot.setAutoDelay(50); + + SwingUtilities.invokeAndWait(() -> createAndShowGUI()); + robot.waitForIdle(); + + SwingUtilities.invokeAndWait(() -> { + scale = frame.getGraphicsConfiguration().getDefaultTransform() + .getScaleX(); + Point location = frame.getLocation(); + Dimension size = frame.getSize(); + centerX = location.x + size.width / 2; + centerY = location.y + size.height / 2; + }); + robot.waitForIdle(); + + robot.mouseMove(centerX, centerY); + robot.mousePress(InputEvent.BUTTON1_MASK); + robot.waitForIdle(); + Thread.sleep(100); + Color color = robot.getPixelColor(centerX, centerY); + robot.mouseRelease(InputEvent.BUTTON1_MASK); + + SwingUtilities.invokeAndWait(() -> frame.dispose()); + + if ((scale == 1 && !similar(color, COLOR_1X)) + || (scale == 2 && !similar(color, COLOR_2X))) { + throw new RuntimeException("Colors are different!"); + } + } + + private static void createAndShowGUI() { + frame = new JFrame(); + frame.setSize(IMAGE_SIZE, IMAGE_SIZE); + frame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + + JPanel panel = new JPanel(new BorderLayout()); + + BufferedImage img1x = generateImage(1, COLOR_1X); + + BufferedImage img2x = generateImage(2, COLOR_2X); + BaseMultiResolutionImage mri = new BaseMultiResolutionImage( + new BufferedImage[]{img1x, img2x}); + Icon mrIcon = new ImageIcon(mri); + + JToggleButton button = new JToggleButton(); + button.setIcon(mrIcon); + panel.add(button, BorderLayout.CENTER); + + frame.getContentPane().add(panel); + frame.setVisible(true); + } + + private static boolean similar(Color c1, Color c2) { + return similar(c1.getRed(), c2.getRed()) + && similar(c1.getGreen(), c2.getGreen()) + && similar(c1.getBlue(), c2.getBlue()); + } + + private static boolean similar(int n, int m) { + return Math.abs(n - m) <= 50; + } + + private static BufferedImage generateImage(int scale, Color c) { + + int size = IMAGE_SIZE * scale; + BufferedImage img = new BufferedImage(size, size, BufferedImage.TYPE_INT_RGB); + Graphics g = img.createGraphics(); + g.setColor(c); + g.fillRect(0, 0, size, size); + g.dispose(); + return img; + } +} From a5e760b81c90c3e73072c3936496fb59e44623e7 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Sat, 20 Aug 2016 18:35:37 +0300 Subject: [PATCH 08/87] 8148109: [SWT] Provide a supported mechanism to use EmbeddedFrame Reviewed-by: alanb, prr --- jdk/make/mapfiles/libawt/mapfile-mawt-vers | 6 ++- jdk/make/mapfiles/libawt/mapfile-vers-linux | 6 ++- jdk/make/mapfiles/libawt_xawt/mapfile-vers | 3 ++ .../libawt_lwawt/awt/awt_DrawingSurface.m | 48 +++++++++++++++++- .../java.desktop/macosx/native/libjawt/jawt.m | 12 +++-- .../java.desktop/share/native/include/jawt.h | 49 ++++++++++++++++++- .../native/common/awt/awt_DrawingSurface.h | 13 ++++- .../libawt_xawt/awt/awt_DrawingSurface.c | 47 +++++++++++++++++- .../java.desktop/unix/native/libjawt/jawt.c | 8 ++- .../libawt/windows/awt_DrawingSurface.cpp | 46 ++++++++++++++++- .../libawt/windows/awt_DrawingSurface.h | 12 ++++- .../windows/native/libjawt/jawt.cpp | 11 ++++- 12 files changed, 245 insertions(+), 16 deletions(-) diff --git a/jdk/make/mapfiles/libawt/mapfile-mawt-vers b/jdk/make/mapfiles/libawt/mapfile-mawt-vers index 247e29698e2..32eb88df678 100644 --- a/jdk/make/mapfiles/libawt/mapfile-mawt-vers +++ b/jdk/make/mapfiles/libawt/mapfile-mawt-vers @@ -1,5 +1,5 @@ # -# Copyright (c) 2001, 2014, 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 @@ -238,6 +238,10 @@ SUNWprivate_1.1 { awt_GetDrawingSurface; awt_FreeDrawingSurface; awt_GetComponent; + awt_CreateEmbeddedFrame; + awt_SetBounds; + awt_SynthesizeWindowActivation; + X11SurfaceData_GetOps; getDefaultConfig; diff --git a/jdk/make/mapfiles/libawt/mapfile-vers-linux b/jdk/make/mapfiles/libawt/mapfile-vers-linux index 5645cbd18d9..a1f8d9b6e0e 100644 --- a/jdk/make/mapfiles/libawt/mapfile-vers-linux +++ b/jdk/make/mapfiles/libawt/mapfile-vers-linux @@ -1,5 +1,5 @@ # -# Copyright (c) 2002, 2014, 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 @@ -264,6 +264,10 @@ SUNWprivate_1.1 { awt_GetDrawingSurface; awt_FreeDrawingSurface; awt_GetComponent; + awt_CreateEmbeddedFrame; + awt_SetBounds; + awt_SynthesizeWindowActivation; + X11SurfaceData_GetOps; getDefaultConfig; diff --git a/jdk/make/mapfiles/libawt_xawt/mapfile-vers b/jdk/make/mapfiles/libawt_xawt/mapfile-vers index 461c1ba9f48..04113dcf031 100644 --- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers @@ -458,6 +458,9 @@ SUNWprivate_1.1 { awt_Unlock; awt_Lock; awt_GetComponent; + awt_CreateEmbeddedFrame; + awt_SetBounds; + awt_SynthesizeWindowActivation; #XAWT entry point for CDE Java_sun_awt_motif_XsessionWMcommand; diff --git a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m index f444bc9b693..fb2cb86a617 100644 --- a/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m +++ b/jdk/src/java.desktop/macosx/native/libawt_lwawt/awt/awt_DrawingSurface.m @@ -1,5 +1,5 @@ /* - * Copyright (c) 2011, 2012, 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 @@ -27,6 +27,8 @@ #import "AWTSurfaceLayers.h" +#import "jni_util.h" + JNIEXPORT JAWT_DrawingSurfaceInfo* JNICALL awt_DrawingSurface_GetDrawingSurfaceInfo (JAWT_DrawingSurface* ds) { @@ -130,3 +132,47 @@ JNIEXPORT jobject JNICALL awt_GetComponent // TODO: implement return NULL; } + +// EmbeddedFrame support + +static char *const embeddedClassName = "sun/lwawt/macosx/CViewEmbeddedFrame"; + +JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame +(JNIEnv* env, void* platformInfo) +{ + static jmethodID mid = NULL; + static jclass cls; + if (mid == NULL) { + cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL_RETURN(cls, NULL); + mid = (*env)->GetMethodID(env, cls, "", "(J)V"); + CHECK_NULL_RETURN(mid, NULL); + } + return (*env)->NewObject(env, cls, mid, platformInfo); +} + +JNIEXPORT void JNICALL awt_SetBounds +(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h); +} + +JNIEXPORT void JNICALL awt_SynthesizeWindowActivation +(JNIEnv *env, jobject embeddedFrame, jboolean doActivate) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate); +} diff --git a/jdk/src/java.desktop/macosx/native/libjawt/jawt.m b/jdk/src/java.desktop/macosx/native/libjawt/jawt.m index cd9f52a8e5e..773c6482caa 100644 --- a/jdk/src/java.desktop/macosx/native/libjawt/jawt.m +++ b/jdk/src/java.desktop/macosx/native/libjawt/jawt.m @@ -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 @@ -46,8 +46,9 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT return JNI_FALSE; } - if (awt->version != (JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER) && - awt->version != JAWT_VERSION_1_7) + if (awt->version != (JAWT_VERSION_1_4 | JAWT_MACOSX_USE_CALAYER) + && awt->version != JAWT_VERSION_1_7 + && awt->version != JAWT_VERSION_9) { return JNI_FALSE; } @@ -58,6 +59,11 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT awt->Lock = awt_Lock; awt->Unlock = awt_Unlock; awt->GetComponent = awt_GetComponent; + if (awt->version >= JAWT_VERSION_9) { + awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame; + awt->SetBounds = awt_SetBounds; + awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation; + } } return JNI_TRUE; diff --git a/jdk/src/java.desktop/share/native/include/jawt.h b/jdk/src/java.desktop/share/native/include/jawt.h index e0f682f4305..8cb2cb8564d 100644 --- a/jdk/src/java.desktop/share/native/include/jawt.h +++ b/jdk/src/java.desktop/share/native/include/jawt.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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,7 +33,7 @@ extern "C" { #endif /* - * AWT native interface (new in JDK 1.3) + * AWT native interface. * * The AWT native interface allows a native C or C++ application a means * by which to access native structures in AWT. This is to facilitate moving @@ -279,6 +279,50 @@ typedef struct jawt { */ jobject (JNICALL *GetComponent)(JNIEnv* env, void* platformInfo); + /** + * Since 9 + * Creates a java.awt.Frame placed in a native container. Container is + * referenced by the native platform handle. For example on Windows this + * corresponds to an HWND. For other platforms, see the appropriate + * machine-dependent header file for a description. The reference returned + * by this function is a local reference that is only valid in this + * environment. This function returns a NULL reference if no frame could be + * created with matching platform information. + */ + jobject (JNICALL *CreateEmbeddedFrame) (JNIEnv *env, void* platformInfo); + + /** + * Since 9 + * Moves and resizes the embedded frame. The new location of the top-left + * corner is specified by x and y parameters relative to the native parent + * component. The new size is specified by width and height. + * + * The embedded frame should be created by CreateEmbeddedFrame() method, or + * this function will not have any effect. + * + * java.awt.Component.setLocation() and java.awt.Component.setBounds() for + * EmbeddedFrame really don't move it within the native parent. These + * methods always locate the embedded frame at (0, 0) for backward + * compatibility. To allow moving embedded frames this method was + * introduced, and it works just the same way as setLocation() and + * setBounds() for usual, non-embedded components. + * + * Using usual get/setLocation() and get/setBounds() together with this new + * method is not recommended. + */ + void (JNICALL *SetBounds) (JNIEnv *env, jobject embeddedFrame, + jint x, jint y, jint w, jint h); + /** + * Since 9 + * Synthesize a native message to activate or deactivate an EmbeddedFrame + * window depending on the value of parameter doActivate, if "true" + * activates the window; otherwise, deactivates the window. + * + * The embedded frame should be created by CreateEmbeddedFrame() method, or + * this function will not have any effect. + */ + void (JNICALL *SynthesizeWindowActivation) (JNIEnv *env, + jobject embeddedFrame, jboolean doActivate); } JAWT; /* @@ -291,6 +335,7 @@ jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt); #define JAWT_VERSION_1_3 0x00010003 #define JAWT_VERSION_1_4 0x00010004 #define JAWT_VERSION_1_7 0x00010007 +#define JAWT_VERSION_9 0x00090000 #ifdef __cplusplus } /* extern "C" */ diff --git a/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h b/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h index bb59b4658c7..bdc9830b07b 100644 --- a/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h +++ b/jdk/src/java.desktop/unix/native/common/awt/awt_DrawingSurface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2001, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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,7 +28,6 @@ #include #include -#include _JNI_IMPORT_OR_EXPORT_ JAWT_DrawingSurface* JNICALL awt_GetDrawingSurface(JNIEnv* env, jobject target); @@ -45,4 +44,14 @@ _JNI_IMPORT_OR_EXPORT_ void JNICALL _JNI_IMPORT_OR_EXPORT_ jobject JNICALL awt_GetComponent(JNIEnv* env, void* platformInfo); +_JNI_IMPORT_OR_EXPORT_ jobject JNICALL + awt_CreateEmbeddedFrame(JNIEnv* env, void* platformInfo); + +_JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SetBounds(JNIEnv *env, jobject embeddedFrame, jint x, jint y, + jint w, jint h); + +_JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SynthesizeWindowActivation(JNIEnv *env, jobject embeddedFrame, + jboolean doActivate); #endif /* !_AWT_DRAWING_SURFACE_H_ */ diff --git a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c index de7e8488985..1cc09c9acac 100644 --- a/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c +++ b/jdk/src/java.desktop/unix/native/libawt_xawt/awt/awt_DrawingSurface.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -383,3 +383,48 @@ JNIEXPORT jobject JNICALL return target; } + +// EmbeddedFrame support + +static char *const embeddedClassName = "sun/awt/X11/XEmbeddedFrame"; + +JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame +(JNIEnv* env, void* platformInfo) +{ + static jmethodID mid = NULL; + static jclass cls; + if (mid == NULL) { + cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL_RETURN(cls, NULL); + mid = (*env)->GetMethodID(env, cls, "", "(JZ)V"); + CHECK_NULL_RETURN(mid, NULL); + } + return (*env)->NewObject(env, cls, mid, platformInfo, JNI_TRUE); +} + + +JNIEXPORT void JNICALL awt_SetBounds +(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "setBoundsPrivate", "(IIII)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, x, y, w, h); +} + +JNIEXPORT void JNICALL awt_SynthesizeWindowActivation +(JNIEnv *env, jobject embeddedFrame, jboolean doActivate) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = (*env)->FindClass(env, embeddedClassName); + CHECK_NULL(cls); + mid = (*env)->GetMethodID(env, cls, "synthesizeWindowActivation", "(Z)V"); + CHECK_NULL(mid); + } + (*env)->CallVoidMethod(env, embeddedFrame, mid, doActivate); +} diff --git a/jdk/src/java.desktop/unix/native/libjawt/jawt.c b/jdk/src/java.desktop/unix/native/libjawt/jawt.c index b6a5240a7c1..59e9a55cff2 100644 --- a/jdk/src/java.desktop/unix/native/libjawt/jawt.c +++ b/jdk/src/java.desktop/unix/native/libjawt/jawt.c @@ -45,7 +45,8 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) if (awt->version != JAWT_VERSION_1_3 && awt->version != JAWT_VERSION_1_4 - && awt->version != JAWT_VERSION_1_7) { + && awt->version != JAWT_VERSION_1_7 + && awt->version != JAWT_VERSION_9) { return JNI_FALSE; } @@ -55,6 +56,11 @@ JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) awt->Lock = awt_Lock; awt->Unlock = awt_Unlock; awt->GetComponent = awt_GetComponent; + if (awt->version >= JAWT_VERSION_9) { + awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame; + awt->SetBounds = awt_SetBounds; + awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation; + } } return JNI_TRUE; diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp index 05549673564..019295ac2b5 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1996, 2008, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1996, 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 @@ -272,3 +272,47 @@ extern "C" JNIEXPORT void JNICALL DSUnlockAWT(JNIEnv* env) { // Do nothing on Windows } + +// EmbeddedFrame support + +static char *const embeddedClassName = "sun/awt/windows/WEmbeddedFrame"; + +JNIEXPORT jobject JNICALL awt_CreateEmbeddedFrame +(JNIEnv* env, void* platformInfo) +{ + static jmethodID mid = NULL; + static jclass cls; + if (mid == NULL) { + cls = env->FindClass(embeddedClassName); + CHECK_NULL_RETURN(cls, NULL); + mid = env->GetMethodID(cls, "", "(J)V"); + CHECK_NULL_RETURN(mid, NULL); + } + return env->NewObject(cls, mid, platformInfo); +} + +JNIEXPORT void JNICALL awt_SetBounds +(JNIEnv *env, jobject embeddedFrame, jint x, jint y, jint w, jint h) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = env->FindClass(embeddedClassName); + CHECK_NULL(cls); + mid = env->GetMethodID(cls, "setBoundsPrivate", "(IIII)V"); + CHECK_NULL(mid); + } + env->CallVoidMethod(embeddedFrame, mid, x, y, w, h); +} + +JNIEXPORT void JNICALL awt_SynthesizeWindowActivation +(JNIEnv *env, jobject embeddedFrame, jboolean doActivate) +{ + static jmethodID mid = NULL; + if (mid == NULL) { + jclass cls = env->FindClass(embeddedClassName); + CHECK_NULL(cls); + mid = env->GetMethodID(cls, "synthesizeWindowActivation", "(Z)V"); + CHECK_NULL(mid); + } + env->CallVoidMethod(embeddedFrame, mid, doActivate); +} diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h index cd135b947e2..a2a510797e9 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_DrawingSurface.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2010, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -162,6 +162,16 @@ extern "C" { jobject JNICALL DSGetComponent( JNIEnv* env, void* platformInfo); + _JNI_IMPORT_OR_EXPORT_ jobject JNICALL + awt_CreateEmbeddedFrame(JNIEnv* env, void* platformInfo); + + _JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SetBounds(JNIEnv *env, jobject embeddedFrame, jint x, + jint y, jint w, jint h); + + _JNI_IMPORT_OR_EXPORT_ void JNICALL + awt_SynthesizeWindowActivation(JNIEnv *env, jobject embeddedFrame, + jboolean doActivate); #ifdef __cplusplus } /* extern "C" */ #endif diff --git a/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp b/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp index 218b7dd0864..1393dfcf8f6 100644 --- a/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp +++ b/jdk/src/java.desktop/windows/native/libjawt/jawt.cpp @@ -1,5 +1,5 @@ /* - * Copyright (c) 1999, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1999, 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 @@ -46,7 +46,9 @@ extern "C" JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) } if (awt->version != JAWT_VERSION_1_3 - && awt->version != JAWT_VERSION_1_4) { + && awt->version != JAWT_VERSION_1_4 + && awt->version != JAWT_VERSION_1_7 + && awt->version != JAWT_VERSION_9) { return JNI_FALSE; } @@ -56,6 +58,11 @@ extern "C" JNIEXPORT jboolean JNICALL JAWT_GetAWT(JNIEnv* env, JAWT* awt) awt->Lock = DSLockAWT; awt->Unlock = DSUnlockAWT; awt->GetComponent = DSGetComponent; + if (awt->version >= JAWT_VERSION_9) { + awt->CreateEmbeddedFrame = awt_CreateEmbeddedFrame; + awt->SetBounds = awt_SetBounds; + awt->SynthesizeWindowActivation = awt_SynthesizeWindowActivation; + } } return JNI_TRUE; From 67814435553f08f7aa30f69dfd4f16e116f66ce6 Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Mon, 22 Aug 2016 01:35:40 +0300 Subject: [PATCH 09/87] 8164104: Cleanup of javaclient related mapfiles Reviewed-by: prr --- jdk/make/mapfiles/libawt/mapfile-mawt-vers | 478 ++++++++-------- jdk/make/mapfiles/libawt/mapfile-vers | 300 +++++----- jdk/make/mapfiles/libawt/mapfile-vers-linux | 521 +++++++++--------- .../mapfiles/libawt_headless/mapfile-vers | 147 +++-- jdk/make/mapfiles/libawt_xawt/mapfile-vers | 127 +++-- jdk/make/mapfiles/libjawt/mapfile-vers | 8 +- jdk/make/mapfiles/libjpeg/mapfile-vers | 48 +- jdk/make/mapfiles/libjsound/mapfile-vers | 112 ++-- jdk/make/mapfiles/libjsoundalsa/mapfile-vers | 106 ++-- .../mapfiles/libsplashscreen/mapfile-vers | 38 +- 10 files changed, 939 insertions(+), 946 deletions(-) diff --git a/jdk/make/mapfiles/libawt/mapfile-mawt-vers b/jdk/make/mapfiles/libawt/mapfile-mawt-vers index 32eb88df678..0200c499f79 100644 --- a/jdk/make/mapfiles/libawt/mapfile-mawt-vers +++ b/jdk/make/mapfiles/libawt/mapfile-mawt-vers @@ -22,263 +22,261 @@ # or visit www.oracle.com if you need additional information or have any # questions. # -# Java_java_awt_KeyboardFocusManager_getGlobalHeavyweightFocusOwner; # Define public interface. # These are the libmawt exports. See mapfile-vers for the libawt exports SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; - Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; - Java_java_awt_AWTEvent_nativeSetSource; - Java_java_awt_Checkbox_initIDs; - Java_java_awt_Component_initIDs; - Java_java_awt_Dialog_initIDs; - Java_java_awt_Font_initIDs; - Java_java_awt_KeyboardFocusManager_initIDs; - Java_java_awt_Menu_initIDs; - Java_java_awt_MenuComponent_initIDs; - Java_java_awt_MenuItem_initIDs; - Java_java_awt_Scrollbar_initIDs; - Java_java_awt_ScrollPane_initIDs; - Java_java_awt_TextArea_initIDs; - Java_sun_awt_FontDescriptor_initIDs; - Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; - Java_sun_awt_UNIXToolkit_check_1gtk; - Java_sun_awt_UNIXToolkit_load_1gtk; - Java_sun_awt_UNIXToolkit_unload_1gtk; - Java_sun_awt_UNIXToolkit_load_1stock_1icon; - Java_sun_awt_UNIXToolkit_load_1gtk_1icon; - Java_sun_awt_UNIXToolkit_nativeSync; - Java_sun_awt_X11InputMethod_disposeXIC; - Java_sun_awt_X11InputMethod_isCompositionEnabledNative; - Java_sun_awt_X11InputMethod_resetXIC; - Java_sun_awt_X11InputMethod_setCompositionEnabledNative; - Java_sun_awt_X11InputMethod_turnoffStatusWindow; - Java_sun_awt_SunToolkit_closeSplashScreen; - Java_sun_awt_PlatformFont_initIDs; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_dispose; - Java_sun_awt_X11GraphicsConfig_pGetBounds; - Java_sun_awt_X11GraphicsConfig_getNumColors; - Java_sun_awt_X11GraphicsConfig_getXResolution; - Java_sun_awt_X11GraphicsConfig_getYResolution; - Java_sun_awt_X11GraphicsConfig_createBackBuffer; - Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; - Java_sun_awt_X11GraphicsConfig_swapBuffers; - Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; - Java_sun_awt_X11GraphicsDevice_isDBESupported; - Java_sun_awt_X11GraphicsDevice_getDisplay; - Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; - Java_sun_awt_X11GraphicsDevice_getNumConfigs; - Java_sun_awt_X11GraphicsDevice_initIDs; - Java_sun_awt_X11GraphicsDevice_initXrandrExtension; - Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; - Java_sun_awt_X11GraphicsDevice_enumDisplayModes; - Java_sun_awt_X11GraphicsDevice_configDisplayMode; - Java_sun_awt_X11GraphicsDevice_resetNativeData; - Java_sun_awt_X11GraphicsEnvironment_checkShmExt; - Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; - Java_sun_awt_X11GraphicsEnvironment_getDisplayString; - Java_sun_awt_X11GraphicsEnvironment_getNumScreens; - Java_sun_awt_X11GraphicsEnvironment_initDisplay; - Java_sun_awt_X11GraphicsEnvironment_initGLX; - Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; - Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; - Java_sun_awt_X11GraphicsEnvironment_initXRender; - Java_java_awt_AWTEvent_initIDs; - Java_java_awt_Button_initIDs; - Java_java_awt_Container_initIDs; - Java_java_awt_Cursor_finalizeImpl; - Java_java_awt_Cursor_initIDs; - Java_java_awt_Event_initIDs; - Java_java_awt_event_InputEvent_initIDs; - Java_java_awt_event_KeyEvent_initIDs; - Java_java_awt_FileDialog_initIDs; - Java_java_awt_Frame_initIDs; - Java_java_awt_Insets_initIDs; - Java_java_awt_TextField_initIDs; - Java_java_awt_Window_initIDs; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_initIDs; - Java_sun_awt_X11GraphicsConfig_makeColorModel; - Java_sun_awt_X11GraphicsDevice_getConfigVisualId; - Java_sun_awt_X11GraphicsDevice_getConfigColormap; - Java_sun_awt_X11GraphicsDevice_getConfigDepth; + Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; + Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; + Java_java_awt_AWTEvent_nativeSetSource; + Java_java_awt_Checkbox_initIDs; + Java_java_awt_Component_initIDs; + Java_java_awt_Dialog_initIDs; + Java_java_awt_Font_initIDs; + Java_java_awt_KeyboardFocusManager_initIDs; + Java_java_awt_Menu_initIDs; + Java_java_awt_MenuComponent_initIDs; + Java_java_awt_MenuItem_initIDs; + Java_java_awt_Scrollbar_initIDs; + Java_java_awt_ScrollPane_initIDs; + Java_java_awt_TextArea_initIDs; + Java_sun_awt_FontDescriptor_initIDs; + Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; + Java_sun_awt_UNIXToolkit_check_1gtk; + Java_sun_awt_UNIXToolkit_load_1gtk; + Java_sun_awt_UNIXToolkit_unload_1gtk; + Java_sun_awt_UNIXToolkit_load_1stock_1icon; + Java_sun_awt_UNIXToolkit_load_1gtk_1icon; + Java_sun_awt_UNIXToolkit_nativeSync; + Java_sun_awt_X11InputMethod_disposeXIC; + Java_sun_awt_X11InputMethod_isCompositionEnabledNative; + Java_sun_awt_X11InputMethod_resetXIC; + Java_sun_awt_X11InputMethod_setCompositionEnabledNative; + Java_sun_awt_X11InputMethod_turnoffStatusWindow; + Java_sun_awt_SunToolkit_closeSplashScreen; + Java_sun_awt_PlatformFont_initIDs; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_dispose; + Java_sun_awt_X11GraphicsConfig_pGetBounds; + Java_sun_awt_X11GraphicsConfig_getNumColors; + Java_sun_awt_X11GraphicsConfig_getXResolution; + Java_sun_awt_X11GraphicsConfig_getYResolution; + Java_sun_awt_X11GraphicsConfig_createBackBuffer; + Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; + Java_sun_awt_X11GraphicsConfig_swapBuffers; + Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; + Java_sun_awt_X11GraphicsDevice_isDBESupported; + Java_sun_awt_X11GraphicsDevice_getDisplay; + Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; + Java_sun_awt_X11GraphicsDevice_getNumConfigs; + Java_sun_awt_X11GraphicsDevice_initIDs; + Java_sun_awt_X11GraphicsDevice_initXrandrExtension; + Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; + Java_sun_awt_X11GraphicsDevice_enumDisplayModes; + Java_sun_awt_X11GraphicsDevice_configDisplayMode; + Java_sun_awt_X11GraphicsDevice_resetNativeData; + Java_sun_awt_X11GraphicsEnvironment_checkShmExt; + Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; + Java_sun_awt_X11GraphicsEnvironment_getDisplayString; + Java_sun_awt_X11GraphicsEnvironment_getNumScreens; + Java_sun_awt_X11GraphicsEnvironment_initDisplay; + Java_sun_awt_X11GraphicsEnvironment_initGLX; + Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; + Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; + Java_sun_awt_X11GraphicsEnvironment_initXRender; + Java_java_awt_AWTEvent_initIDs; + Java_java_awt_Button_initIDs; + Java_java_awt_Container_initIDs; + Java_java_awt_Cursor_finalizeImpl; + Java_java_awt_Cursor_initIDs; + Java_java_awt_Event_initIDs; + Java_java_awt_event_InputEvent_initIDs; + Java_java_awt_event_KeyEvent_initIDs; + Java_java_awt_FileDialog_initIDs; + Java_java_awt_Frame_initIDs; + Java_java_awt_Insets_initIDs; + Java_java_awt_TextField_initIDs; + Java_java_awt_Window_initIDs; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_initIDs; + Java_sun_awt_X11GraphicsConfig_makeColorModel; + Java_sun_awt_X11GraphicsDevice_getConfigVisualId; + Java_sun_awt_X11GraphicsDevice_getConfigColormap; + Java_sun_awt_X11GraphicsDevice_getConfigDepth; - Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; - Java_sun_java2d_x11_X11PMBlitLoops_updateBitmask; - Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; - Java_sun_java2d_x11_X11Renderer_XFillSpans; - Java_sun_java2d_x11_X11Renderer_XDrawArc; - Java_sun_java2d_x11_X11Renderer_XDrawLine; - Java_sun_java2d_x11_X11Renderer_XDrawOval; - Java_sun_java2d_x11_X11Renderer_XDrawPoly; - Java_sun_java2d_x11_X11Renderer_XDrawRect; - Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; - Java_sun_java2d_x11_X11Renderer_XDoPath; - Java_sun_java2d_x11_X11Renderer_XFillArc; - Java_sun_java2d_x11_X11Renderer_XFillOval; - Java_sun_java2d_x11_X11Renderer_XFillPoly; - Java_sun_java2d_x11_X11Renderer_XFillRect; - Java_sun_java2d_x11_X11Renderer_XFillRoundRect; - Java_sun_java2d_x11_X11Renderer_devCopyArea; - Java_sun_java2d_x11_X11SurfaceData_initIDs; - Java_sun_java2d_x11_X11SurfaceData_initOps; - Java_sun_java2d_x11_X11SurfaceData_initSurface; - Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable; - Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; - Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; - Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; - Java_sun_java2d_x11_X11SurfaceData_XSetForeground; + Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; + Java_sun_java2d_x11_X11PMBlitLoops_updateBitmask; + Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; + Java_sun_java2d_x11_X11Renderer_XFillSpans; + Java_sun_java2d_x11_X11Renderer_XDrawArc; + Java_sun_java2d_x11_X11Renderer_XDrawLine; + Java_sun_java2d_x11_X11Renderer_XDrawOval; + Java_sun_java2d_x11_X11Renderer_XDrawPoly; + Java_sun_java2d_x11_X11Renderer_XDrawRect; + Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; + Java_sun_java2d_x11_X11Renderer_XDoPath; + Java_sun_java2d_x11_X11Renderer_XFillArc; + Java_sun_java2d_x11_X11Renderer_XFillOval; + Java_sun_java2d_x11_X11Renderer_XFillPoly; + Java_sun_java2d_x11_X11Renderer_XFillRect; + Java_sun_java2d_x11_X11Renderer_XFillRoundRect; + Java_sun_java2d_x11_X11Renderer_devCopyArea; + Java_sun_java2d_x11_X11SurfaceData_initIDs; + Java_sun_java2d_x11_X11SurfaceData_initOps; + Java_sun_java2d_x11_X11SurfaceData_initSurface; + Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable; + Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; + Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; + Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; + Java_sun_java2d_x11_X11SurfaceData_XSetForeground; - Java_sun_java2d_x11_XSurfaceData_initOps; - Java_sun_java2d_x11_XSurfaceData_XCreateGC; - Java_sun_java2d_x11_XSurfaceData_XResetClip; - Java_sun_java2d_x11_XSurfaceData_XSetClip; - Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; - Java_sun_java2d_x11_XSurfaceData_isDrawableValid; - Java_sun_java2d_x11_XSurfaceData_setInvalid; - Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; - Java_sun_java2d_xr_XRSurfaceData_initXRPicture; - Java_sun_java2d_xr_XRSurfaceData_initIDs; - Java_sun_java2d_xr_XRSurfaceData_XRInitSurface; - Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; - Java_sun_java2d_xr_XRBackendNative_initIDs; - Java_sun_java2d_xr_XIDGenerator_bufferXIDs; - Java_sun_java2d_xr_XRBackendNative_freeGC; - Java_sun_java2d_xr_XRBackendNative_createGC; - Java_sun_java2d_xr_XRBackendNative_createPixmap; - Java_sun_java2d_xr_XRBackendNative_createPictureNative; - Java_sun_java2d_xr_XRBackendNative_freePicture; - Java_sun_java2d_xr_XRBackendNative_freePixmap; - Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; - Java_sun_java2d_xr_XRBackendNative_setGCExposures; - Java_sun_java2d_xr_XRBackendNative_setGCForeground; - Java_sun_java2d_xr_XRBackendNative_copyArea; - Java_sun_java2d_xr_XRBackendNative_renderComposite; - Java_sun_java2d_xr_XRBackendNative_renderRectangle; - Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; - Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_setFilter; - Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; - Java_sun_java2d_xr_XRBackendNative_putMaskNative; - Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; - Java_sun_java2d_xr_XRBackendNative_setGCMode; - Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; - Java_sun_java2d_xr_XRUtils_initFormatPtrs; - Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; - XRT_DrawGlyphList; + Java_sun_java2d_x11_XSurfaceData_initOps; + Java_sun_java2d_x11_XSurfaceData_XCreateGC; + Java_sun_java2d_x11_XSurfaceData_XResetClip; + Java_sun_java2d_x11_XSurfaceData_XSetClip; + Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; + Java_sun_java2d_x11_XSurfaceData_isDrawableValid; + Java_sun_java2d_x11_XSurfaceData_setInvalid; + Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; + Java_sun_java2d_xr_XRSurfaceData_initXRPicture; + Java_sun_java2d_xr_XRSurfaceData_initIDs; + Java_sun_java2d_xr_XRSurfaceData_XRInitSurface; + Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; + Java_sun_java2d_xr_XRBackendNative_initIDs; + Java_sun_java2d_xr_XIDGenerator_bufferXIDs; + Java_sun_java2d_xr_XRBackendNative_freeGC; + Java_sun_java2d_xr_XRBackendNative_createGC; + Java_sun_java2d_xr_XRBackendNative_createPixmap; + Java_sun_java2d_xr_XRBackendNative_createPictureNative; + Java_sun_java2d_xr_XRBackendNative_freePicture; + Java_sun_java2d_xr_XRBackendNative_freePixmap; + Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; + Java_sun_java2d_xr_XRBackendNative_setGCExposures; + Java_sun_java2d_xr_XRBackendNative_setGCForeground; + Java_sun_java2d_xr_XRBackendNative_copyArea; + Java_sun_java2d_xr_XRBackendNative_renderComposite; + Java_sun_java2d_xr_XRBackendNative_renderRectangle; + Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; + Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_setFilter; + Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; + Java_sun_java2d_xr_XRBackendNative_putMaskNative; + Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; + Java_sun_java2d_xr_XRBackendNative_setGCMode; + Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; + Java_sun_java2d_xr_XRUtils_initFormatPtrs; + Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; + XRT_DrawGlyphList; - Java_sun_java2d_opengl_OGLContext_getOGLIdString; - Java_sun_java2d_opengl_OGLMaskFill_maskFill; - Java_sun_java2d_opengl_OGLRenderer_drawPoly; - Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer; - Java_sun_java2d_opengl_OGLSurfaceData_initTexture; - Java_sun_java2d_opengl_OGLSurfaceData_initFBObject; - Java_sun_java2d_opengl_OGLSurfaceData_initFlipBackbuffer; - Java_sun_java2d_opengl_OGLSurfaceData_getTextureID; - Java_sun_java2d_opengl_OGLSurfaceData_getTextureTarget; - Java_sun_java2d_opengl_OGLTextRenderer_drawGlyphList; - Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo; - Java_sun_java2d_opengl_GLXGraphicsConfig_initConfig; - Java_sun_java2d_opengl_GLXGraphicsConfig_getOGLCapabilities; - Java_sun_java2d_opengl_GLXSurfaceData_initOps; + Java_sun_java2d_opengl_OGLContext_getOGLIdString; + Java_sun_java2d_opengl_OGLMaskFill_maskFill; + Java_sun_java2d_opengl_OGLRenderer_drawPoly; + Java_sun_java2d_opengl_OGLRenderQueue_flushBuffer; + Java_sun_java2d_opengl_OGLSurfaceData_initTexture; + Java_sun_java2d_opengl_OGLSurfaceData_initFBObject; + Java_sun_java2d_opengl_OGLSurfaceData_initFlipBackbuffer; + Java_sun_java2d_opengl_OGLSurfaceData_getTextureID; + Java_sun_java2d_opengl_OGLSurfaceData_getTextureTarget; + Java_sun_java2d_opengl_OGLTextRenderer_drawGlyphList; + Java_sun_java2d_opengl_GLXGraphicsConfig_getGLXConfigInfo; + Java_sun_java2d_opengl_GLXGraphicsConfig_initConfig; + Java_sun_java2d_opengl_GLXGraphicsConfig_getOGLCapabilities; + Java_sun_java2d_opengl_GLXSurfaceData_initOps; - Java_sun_print_CUPSPrinter_initIDs; - Java_sun_print_CUPSPrinter_getCupsServer; - Java_sun_print_CUPSPrinter_getCupsPort; - Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; - Java_sun_print_CUPSPrinter_canConnect; - Java_sun_print_CUPSPrinter_getMedia; - Java_sun_print_CUPSPrinter_getPageSizes; - Java_sun_print_CUPSPrinter_getResolutions; + Java_sun_print_CUPSPrinter_initIDs; + Java_sun_print_CUPSPrinter_getCupsServer; + Java_sun_print_CUPSPrinter_getCupsPort; + Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; + Java_sun_print_CUPSPrinter_canConnect; + Java_sun_print_CUPSPrinter_getMedia; + Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box_1gap; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1check; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1expander; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1extension; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1flat_1box; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1focus; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1handle; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1hline; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1option; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1shadow; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1slider; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1vline; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1background; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1switch_1theme; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1get_1gtk_1setting; - Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeSetRangeValue; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetXThickness; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetYThickness; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetColorForState; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue; - Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box_1gap; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1check; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1expander; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1extension; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1flat_1box; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1focus; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1handle; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1hline; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1option; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1shadow; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1slider; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1vline; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1background; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeStartPainting; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeFinishPainting; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1switch_1theme; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1get_1gtk_1setting; + Java_com_sun_java_swing_plaf_gtk_GTKEngine_nativeSetRangeValue; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetXThickness; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetYThickness; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetColorForState; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetClassValue; + Java_com_sun_java_swing_plaf_gtk_GTKStyle_nativeGetPangoFontName; - awt_display; - awt_Lock; - awt_Unlock; - awt_GetDrawingSurface; - awt_FreeDrawingSurface; - awt_GetComponent; + awt_display; + awt_Lock; + awt_Unlock; + awt_GetDrawingSurface; + awt_FreeDrawingSurface; + awt_GetComponent; awt_CreateEmbeddedFrame; awt_SetBounds; awt_SynthesizeWindowActivation; + X11SurfaceData_GetOps; + getDefaultConfig; + Java_sun_font_FontConfigManager_getFontConfig; + Java_sun_font_FontConfigManager_getFontConfigAASettings; + Java_sun_awt_FcFontManager_getFontPathNative; + Java_sun_font_SunFontManager_populateFontFileNameMap; - X11SurfaceData_GetOps; - getDefaultConfig; - Java_sun_font_FontConfigManager_getFontConfig; - Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_FcFontManager_getFontPathNative; - Java_sun_font_SunFontManager_populateFontFileNameMap; + # CDE private entry point + Java_sun_awt_motif_XsessionWMcommand; + Java_sun_awt_motif_XsessionWMcommand_New; - # CDE private entry point - Java_sun_awt_motif_XsessionWMcommand; - Java_sun_awt_motif_XsessionWMcommand_New; + # libfontmanager entry points + AWTIsHeadless; + AWTCountFonts; + AWTLoadFont; + AWTFreeFont; + AWTFontAscent; + AWTFontDescent; + AWTFontMinByte1; + AWTFontMaxByte1; + AWTFontMinCharOrByte2; + AWTFontMaxCharOrByte2; + AWTFontDefaultChar; + AWTFontPerChar; + AWTFontMaxBounds; + AWTFontTextExtents16; + AWTFreeChar; + AWTFontGenerateImage; + AWTCharAdvance; + AWTCharLBearing; + AWTCharRBearing; + AWTCharAscent; + AWTCharDescent; + AWTDrawGlyphList; + AccelGlyphCache_RemoveAllCellInfos; - # libfontmanager entry points - AWTIsHeadless; - AWTCountFonts; - AWTLoadFont; - AWTFreeFont; - AWTFontAscent; - AWTFontDescent; - AWTFontMinByte1; - AWTFontMaxByte1; - AWTFontMinCharOrByte2; - AWTFontMaxCharOrByte2; - AWTFontDefaultChar; - AWTFontPerChar; - AWTFontMaxBounds; - AWTFontTextExtents16; - AWTFreeChar; - AWTFontGenerateImage; - AWTCharAdvance; - AWTCharLBearing; - AWTCharRBearing; - AWTCharAscent; - AWTCharDescent; - AWTDrawGlyphList; - AccelGlyphCache_RemoveAllCellInfos; - - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt/mapfile-vers b/jdk/make/mapfiles/libawt/mapfile-vers index 4624977e75c..9d8a34d3f37 100644 --- a/jdk/make/mapfiles/libawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt/mapfile-vers @@ -27,163 +27,163 @@ # These are the libawt exports, mapfile-mawt-vers contains the libmawt exports. SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_java_awt_CheckboxMenuItem_initIDs; - Java_java_awt_Color_initIDs; - Java_java_awt_FontMetrics_initIDs; - Java_java_awt_image_BufferedImage_initIDs; - Java_sun_awt_image_DataBufferNative_getElem; - Java_sun_awt_image_DataBufferNative_setElem; - Java_java_awt_image_ColorModel_initIDs; - Java_java_awt_image_IndexColorModel_initIDs; - Java_java_awt_image_Kernel_initIDs; - Java_java_awt_image_Raster_initIDs; - Java_java_awt_image_SampleModel_initIDs; - Java_java_awt_Label_initIDs; - Java_java_awt_MenuBar_initIDs; - Java_java_awt_ScrollPaneAdjustable_initIDs; - Java_java_awt_Toolkit_initIDs; - Java_sun_awt_DebugSettings_setCTracingOn__Z; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; - Java_sun_awt_image_ByteComponentRaster_initIDs; - Java_sun_awt_image_GifImageDecoder_initIDs; - Java_sun_awt_image_GifImageDecoder_parseImage; - Java_sun_awt_image_ImageRepresentation_initIDs; - Java_sun_awt_image_ImageRepresentation_setDiffICM; - Java_sun_awt_image_ImageRepresentation_setICMpixels; - Java_sun_awt_image_ImagingLib_convolveBI; - Java_sun_awt_image_ImagingLib_convolveRaster; - Java_sun_awt_image_ImagingLib_init; - Java_sun_awt_image_ImagingLib_transformBI; - Java_sun_awt_image_ImagingLib_transformRaster; - Java_sun_awt_image_IntegerComponentRaster_initIDs; - Java_sun_awt_image_ShortComponentRaster_initIDs; - Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile; - Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; - Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; - Java_sun_java2d_pipe_SpanClipRenderer_fillTile; - Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; - Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; - Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; - Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_closePath; - Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; - Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; - Java_sun_java2d_pipe_ShapeSpanIterator_dispose; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; - Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; - Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; - Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; - Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; - Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; - Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; - Java_sun_java2d_pipe_ShapeSpanIterator_setRule; - Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; + Java_java_awt_CheckboxMenuItem_initIDs; + Java_java_awt_Color_initIDs; + Java_java_awt_FontMetrics_initIDs; + Java_java_awt_image_BufferedImage_initIDs; + Java_sun_awt_image_DataBufferNative_getElem; + Java_sun_awt_image_DataBufferNative_setElem; + Java_java_awt_image_ColorModel_initIDs; + Java_java_awt_image_IndexColorModel_initIDs; + Java_java_awt_image_Kernel_initIDs; + Java_java_awt_image_Raster_initIDs; + Java_java_awt_image_SampleModel_initIDs; + Java_java_awt_Label_initIDs; + Java_java_awt_MenuBar_initIDs; + Java_java_awt_ScrollPaneAdjustable_initIDs; + Java_java_awt_Toolkit_initIDs; + Java_sun_awt_DebugSettings_setCTracingOn__Z; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; + Java_sun_awt_image_ByteComponentRaster_initIDs; + Java_sun_awt_image_GifImageDecoder_initIDs; + Java_sun_awt_image_GifImageDecoder_parseImage; + Java_sun_awt_image_ImageRepresentation_initIDs; + Java_sun_awt_image_ImageRepresentation_setDiffICM; + Java_sun_awt_image_ImageRepresentation_setICMpixels; + Java_sun_awt_image_ImagingLib_convolveBI; + Java_sun_awt_image_ImagingLib_convolveRaster; + Java_sun_awt_image_ImagingLib_init; + Java_sun_awt_image_ImagingLib_transformBI; + Java_sun_awt_image_ImagingLib_transformRaster; + Java_sun_awt_image_IntegerComponentRaster_initIDs; + Java_sun_awt_image_ShortComponentRaster_initIDs; + Java_sun_java2d_pipe_BufferedMaskBlit_enqueueTile; + Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; + Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; + Java_sun_java2d_pipe_SpanClipRenderer_fillTile; + Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; + Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; + Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; + Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_closePath; + Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; + Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; + Java_sun_java2d_pipe_ShapeSpanIterator_dispose; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; + Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; + Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; + Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; + Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; + Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; + Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; + Java_sun_java2d_pipe_ShapeSpanIterator_setRule; + Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; - Java_java_awt_Choice_initIDs; - Java_java_awt_Dimension_initIDs; - Java_java_awt_event_MouseEvent_initIDs; - Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; - Java_java_awt_Rectangle_initIDs; - Java_sun_awt_image_BufImgSurfaceData_initIDs; - Java_sun_awt_image_BufImgSurfaceData_initRaster; - Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; - Java_sun_awt_image_BytePackedRaster_initIDs; - Java_sun_awt_image_ImagingLib_lookupByteBI; - Java_sun_awt_image_ImagingLib_lookupByteRaster; - Java_sun_java2d_SurfaceData_initIDs; - Java_sun_java2d_SurfaceData_isOpaqueGray; - Java_sun_java2d_Disposer_initIDs; - Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; - Java_sun_java2d_loops_BlitBg_BlitBg; - Java_sun_java2d_loops_Blit_Blit; - Java_sun_java2d_loops_ScaledBlit_Scale; - Java_sun_java2d_loops_DrawLine_DrawLine; - Java_sun_java2d_loops_DrawPolygons_DrawPolygons; - Java_sun_java2d_loops_DrawPath_DrawPath; - Java_sun_java2d_loops_FillPath_FillPath; + Java_java_awt_Choice_initIDs; + Java_java_awt_Dimension_initIDs; + Java_java_awt_event_MouseEvent_initIDs; + Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; + Java_java_awt_Rectangle_initIDs; + Java_sun_awt_image_BufImgSurfaceData_initIDs; + Java_sun_awt_image_BufImgSurfaceData_initRaster; + Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; + Java_sun_awt_image_BytePackedRaster_initIDs; + Java_sun_awt_image_ImagingLib_lookupByteBI; + Java_sun_awt_image_ImagingLib_lookupByteRaster; + Java_sun_java2d_SurfaceData_initIDs; + Java_sun_java2d_SurfaceData_isOpaqueGray; + Java_sun_java2d_Disposer_initIDs; + Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; + Java_sun_java2d_loops_BlitBg_BlitBg; + Java_sun_java2d_loops_Blit_Blit; + Java_sun_java2d_loops_ScaledBlit_Scale; + Java_sun_java2d_loops_DrawLine_DrawLine; + Java_sun_java2d_loops_DrawPolygons_DrawPolygons; + Java_sun_java2d_loops_DrawPath_DrawPath; + Java_sun_java2d_loops_FillPath_FillPath; - Java_sun_java2d_loops_DrawRect_DrawRect; - Java_sun_java2d_loops_FillRect_FillRect; - Java_sun_java2d_loops_FillSpans_FillSpans; - Java_sun_java2d_loops_FillParallelogram_FillParallelogram; - Java_sun_java2d_loops_DrawParallelogram_DrawParallelogram; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; - Java_sun_java2d_loops_MaskBlit_MaskBlit; - Java_sun_java2d_loops_MaskFill_MaskFill; - Java_sun_java2d_loops_MaskFill_FillAAPgram; - Java_sun_java2d_loops_MaskFill_DrawAAPgram; - Java_sun_java2d_loops_TransformHelper_Transform; - Java_sun_java2d_pipe_Region_initIDs; - Java_sun_java2d_pipe_SpanClipRenderer_initIDs; - sun_awt_image_GifImageDecoder_initIDs; + Java_sun_java2d_loops_DrawRect_DrawRect; + Java_sun_java2d_loops_FillRect_FillRect; + Java_sun_java2d_loops_FillSpans_FillSpans; + Java_sun_java2d_loops_FillParallelogram_FillParallelogram; + Java_sun_java2d_loops_DrawParallelogram_DrawParallelogram; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; + Java_sun_java2d_loops_MaskBlit_MaskBlit; + Java_sun_java2d_loops_MaskFill_MaskFill; + Java_sun_java2d_loops_MaskFill_FillAAPgram; + Java_sun_java2d_loops_MaskFill_DrawAAPgram; + Java_sun_java2d_loops_TransformHelper_Transform; + Java_sun_java2d_pipe_Region_initIDs; + Java_sun_java2d_pipe_SpanClipRenderer_initIDs; + sun_awt_image_GifImageDecoder_initIDs; - # libmawt entry points - SurfaceData_InitOps; - SurfaceData_ThrowInvalidPipeException; - SurfaceData_IntersectBlitBounds; - SurfaceData_IntersectBoundsXYXY; - Region_GetBounds; - Region_GetInfo; - Region_StartIteration; - Region_CountIterationRects; - Region_NextIteration; - Region_EndIteration; - RegionToYXBandedRectangles; - GrPrim_CompGetXorInfo; - GrPrim_CompGetAlphaInfo; - J2dTraceImpl; - J2dTraceInit; - img_makePalette; - initInverseGrayLut; - make_dither_arrays; - make_uns_ordered_dither_array; + # libmawt entry points + SurfaceData_InitOps; + SurfaceData_ThrowInvalidPipeException; + SurfaceData_IntersectBlitBounds; + SurfaceData_IntersectBoundsXYXY; + Region_GetBounds; + Region_GetInfo; + Region_StartIteration; + Region_CountIterationRects; + Region_NextIteration; + Region_EndIteration; + RegionToYXBandedRectangles; + GrPrim_CompGetXorInfo; + GrPrim_CompGetAlphaInfo; + J2dTraceImpl; + J2dTraceInit; + img_makePalette; + initInverseGrayLut; + make_dither_arrays; + make_uns_ordered_dither_array; - # variables exported to libmawt - std_img_oda_red; - std_img_oda_blue; - std_img_oda_green; - std_odas_computed; - g_CMpDataID; - colorValueID; - mul8table; - div8table; - jvm; + # variables exported to libmawt + std_img_oda_red; + std_img_oda_blue; + std_img_oda_green; + std_odas_computed; + g_CMpDataID; + colorValueID; + mul8table; + div8table; + jvm; - # ProcessPath entry points and data - doDrawPath; - doFillPath; - path2DNumTypesID; - path2DTypesID; - path2DWindingRuleID; - path2DFloatCoordsID; - sg2dStrokeHintID; - sunHints_INTVAL_STROKE_PURE; + # ProcessPath entry points and data + doDrawPath; + doFillPath; + path2DNumTypesID; + path2DTypesID; + path2DWindingRuleID; + path2DFloatCoordsID; + sg2dStrokeHintID; + sunHints_INTVAL_STROKE_PURE; - # CDE private entry points - # These are in awt_LoadLibrary.c and falls through to libmawt. - # Evidently CDE needs this for backward compatability. - Java_sun_awt_motif_XsessionWMcommand; - Java_sun_awt_motif_XsessionWMcommand_New; + # CDE private entry points + # These are in awt_LoadLibrary.c and falls through to libmawt. + # Evidently CDE needs this for backward compatability. + Java_sun_awt_motif_XsessionWMcommand; + Java_sun_awt_motif_XsessionWMcommand_New; - # libfontmanager entry points - AWTIsHeadless; - GrPrim_Sg2dGetCompInfo; - GrPrim_Sg2dGetClip; - GetNativePrim; - SurfaceData_IntersectBounds; - SurfaceData_GetOps; - Disposer_AddRecord; - GrPrim_Sg2dGetEaRGB; - GrPrim_Sg2dGetPixel; - GrPrim_Sg2dGetLCDTextContrast; + # libfontmanager entry points + AWTIsHeadless; + GrPrim_Sg2dGetCompInfo; + GrPrim_Sg2dGetClip; + GetNativePrim; + SurfaceData_IntersectBounds; + SurfaceData_GetOps; + Disposer_AddRecord; + GrPrim_Sg2dGetEaRGB; + GrPrim_Sg2dGetPixel; + GrPrim_Sg2dGetLCDTextContrast; - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt/mapfile-vers-linux b/jdk/make/mapfiles/libawt/mapfile-vers-linux index a1f8d9b6e0e..90e12f075b1 100644 --- a/jdk/make/mapfiles/libawt/mapfile-vers-linux +++ b/jdk/make/mapfiles/libawt/mapfile-vers-linux @@ -27,281 +27,278 @@ # Linux port does not use mawt, all public symbols are in libawt.so SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_java_awt_CheckboxMenuItem_initIDs; - Java_java_awt_Color_initIDs; - Java_java_awt_FontMetrics_initIDs; - Java_java_awt_image_BufferedImage_initIDs; - Java_sun_awt_image_DataBufferNative_getElem; - Java_sun_awt_image_DataBufferNative_setElem; - Java_java_awt_image_ColorModel_initIDs; - Java_java_awt_image_IndexColorModel_initIDs; - Java_java_awt_image_Kernel_initIDs; - Java_java_awt_image_Raster_initIDs; - Java_java_awt_image_SampleModel_initIDs; - Java_java_awt_Label_initIDs; - Java_java_awt_MenuBar_initIDs; - Java_java_awt_ScrollPaneAdjustable_initIDs; - Java_java_awt_Toolkit_initIDs; - Java_java_awt_TrayIcon_initIDs; - Java_sun_awt_DebugSettings_setCTracingOn__Z; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; - Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; - Java_sun_awt_image_ByteComponentRaster_initIDs; - Java_sun_awt_image_GifImageDecoder_initIDs; - Java_sun_awt_image_GifImageDecoder_parseImage; - Java_sun_awt_image_Image_initIDs; - Java_sun_awt_image_ImageRepresentation_initIDs; - Java_sun_awt_image_ImageRepresentation_setDiffICM; - Java_sun_awt_image_ImageRepresentation_setICMpixels; - Java_sun_awt_image_ImagingLib_convolveBI; - Java_sun_awt_image_ImagingLib_convolveRaster; - Java_sun_awt_image_ImagingLib_init; - Java_sun_awt_image_ImagingLib_transformBI; - Java_sun_awt_image_ImagingLib_transformRaster; - Java_sun_awt_image_IntegerComponentRaster_initIDs; - Java_sun_awt_image_ShortComponentRaster_initIDs; - Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; - Java_sun_java2d_pipe_SpanClipRenderer_fillTile; - Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; - Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; - Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; - Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; - Java_sun_java2d_pipe_ShapeSpanIterator_closePath; - Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; - Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; - Java_sun_java2d_pipe_ShapeSpanIterator_dispose; - Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; - Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; - Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; - Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; - Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; - Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; - Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; - Java_sun_java2d_pipe_ShapeSpanIterator_setRule; - Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; + Java_java_awt_CheckboxMenuItem_initIDs; + Java_java_awt_Color_initIDs; + Java_java_awt_FontMetrics_initIDs; + Java_java_awt_image_BufferedImage_initIDs; + Java_sun_awt_image_DataBufferNative_getElem; + Java_sun_awt_image_DataBufferNative_setElem; + Java_java_awt_image_ColorModel_initIDs; + Java_java_awt_image_IndexColorModel_initIDs; + Java_java_awt_image_Kernel_initIDs; + Java_java_awt_image_Raster_initIDs; + Java_java_awt_image_SampleModel_initIDs; + Java_java_awt_Label_initIDs; + Java_java_awt_MenuBar_initIDs; + Java_java_awt_ScrollPaneAdjustable_initIDs; + Java_java_awt_Toolkit_initIDs; + Java_java_awt_TrayIcon_initIDs; + Java_sun_awt_DebugSettings_setCTracingOn__Z; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2; + Java_sun_awt_DebugSettings_setCTracingOn__ZLjava_lang_String_2I; + Java_sun_awt_image_ByteComponentRaster_initIDs; + Java_sun_awt_image_GifImageDecoder_initIDs; + Java_sun_awt_image_GifImageDecoder_parseImage; + Java_sun_awt_image_Image_initIDs; + Java_sun_awt_image_ImageRepresentation_initIDs; + Java_sun_awt_image_ImageRepresentation_setDiffICM; + Java_sun_awt_image_ImageRepresentation_setICMpixels; + Java_sun_awt_image_ImagingLib_convolveBI; + Java_sun_awt_image_ImagingLib_convolveRaster; + Java_sun_awt_image_ImagingLib_init; + Java_sun_awt_image_ImagingLib_transformBI; + Java_sun_awt_image_ImagingLib_transformRaster; + Java_sun_awt_image_IntegerComponentRaster_initIDs; + Java_sun_awt_image_ShortComponentRaster_initIDs; + Java_sun_java2d_pipe_SpanClipRenderer_eraseTile; + Java_sun_java2d_pipe_SpanClipRenderer_fillTile; + Java_sun_java2d_pipe_ShapeSpanIterator_addSegment; + Java_sun_java2d_pipe_ShapeSpanIterator_moveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_lineTo; + Java_sun_java2d_pipe_ShapeSpanIterator_quadTo; + Java_sun_java2d_pipe_ShapeSpanIterator_curveTo; + Java_sun_java2d_pipe_ShapeSpanIterator_closePath; + Java_sun_java2d_pipe_ShapeSpanIterator_pathDone; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeConsumer; + Java_sun_java2d_pipe_ShapeSpanIterator_appendPoly; + Java_sun_java2d_pipe_ShapeSpanIterator_dispose; + Java_sun_java2d_pipe_ShapeSpanIterator_getNativeIterator; + Java_sun_java2d_pipe_ShapeSpanIterator_getPathBox; + Java_sun_java2d_pipe_ShapeSpanIterator_initIDs; + Java_sun_java2d_pipe_ShapeSpanIterator_intersectClipBox; + Java_sun_java2d_pipe_ShapeSpanIterator_nextSpan; + Java_sun_java2d_pipe_ShapeSpanIterator_setNormalize; + Java_sun_java2d_pipe_ShapeSpanIterator_setOutputAreaXYXY; + Java_sun_java2d_pipe_ShapeSpanIterator_setRule; + Java_sun_java2d_pipe_ShapeSpanIterator_skipDownTo; - Java_java_awt_Choice_initIDs; - Java_java_awt_Dimension_initIDs; - Java_java_awt_event_MouseEvent_initIDs; - Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; - Java_java_awt_Rectangle_initIDs; - Java_sun_awt_image_BufImgSurfaceData_getSurfaceData; - Java_sun_awt_image_BufImgSurfaceData_initIDs; - Java_sun_awt_image_BufImgSurfaceData_initRaster; - Java_sun_awt_image_BufImgSurfaceData_setSurfaceData; - Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; - Java_sun_awt_image_BytePackedRaster_initIDs; - Java_sun_awt_image_ImagingLib_lookupByteBI; - Java_sun_awt_image_ImagingLib_lookupByteRaster; - Java_sun_java2d_SurfaceData_initIDs; - Java_sun_java2d_SurfaceData_isOpaqueGray; - Java_sun_java2d_Disposer_initIDs; - Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; - Java_sun_java2d_loops_BlitBg_BlitBg; - Java_sun_java2d_loops_Blit_Blit; - Java_sun_java2d_loops_ScaledBlit_Scale; - Java_sun_java2d_loops_DrawLine_DrawLine; - Java_sun_java2d_loops_DrawPolygons_DrawPolygons; - Java_sun_java2d_loops_DrawRect_DrawRect; - Java_sun_java2d_loops_FillRect_FillRect; - Java_sun_java2d_loops_FillSpans_FillSpans; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; - Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; - Java_sun_java2d_loops_MaskBlit_MaskBlit; - Java_sun_java2d_loops_MaskFill_MaskFill; - Java_sun_java2d_loops_MaskFill_FillAAPgram; - Java_sun_java2d_loops_MaskFill_DrawAAPgram; - Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; - Java_sun_java2d_pipe_SpanClipRenderer_initIDs; - sun_awt_image_GifImageDecoder_initIDs; + Java_java_awt_Choice_initIDs; + Java_java_awt_Dimension_initIDs; + Java_java_awt_event_MouseEvent_initIDs; + Java_java_awt_image_SinglePixelPackedSampleModel_initIDs; + Java_java_awt_Rectangle_initIDs; + Java_sun_awt_image_BufImgSurfaceData_getSurfaceData; + Java_sun_awt_image_BufImgSurfaceData_initIDs; + Java_sun_awt_image_BufImgSurfaceData_initRaster; + Java_sun_awt_image_BufImgSurfaceData_setSurfaceData; + Java_sun_awt_image_BufImgSurfaceData_freeNativeICMData; + Java_sun_awt_image_BytePackedRaster_initIDs; + Java_sun_awt_image_ImagingLib_lookupByteBI; + Java_sun_awt_image_ImagingLib_lookupByteRaster; + Java_sun_java2d_SurfaceData_initIDs; + Java_sun_java2d_SurfaceData_isOpaqueGray; + Java_sun_java2d_Disposer_initIDs; + Java_sun_java2d_DefaultDisposerRecord_invokeNativeDispose; + Java_sun_java2d_loops_BlitBg_BlitBg; + Java_sun_java2d_loops_Blit_Blit; + Java_sun_java2d_loops_ScaledBlit_Scale; + Java_sun_java2d_loops_DrawLine_DrawLine; + Java_sun_java2d_loops_DrawPolygons_DrawPolygons; + Java_sun_java2d_loops_DrawRect_DrawRect; + Java_sun_java2d_loops_FillRect_FillRect; + Java_sun_java2d_loops_FillSpans_FillSpans; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_initIDs; + Java_sun_java2d_loops_GraphicsPrimitiveMgr_registerNativeLoops; + Java_sun_java2d_loops_MaskBlit_MaskBlit; + Java_sun_java2d_loops_MaskFill_MaskFill; + Java_sun_java2d_loops_MaskFill_FillAAPgram; + Java_sun_java2d_loops_MaskFill_DrawAAPgram; + Java_sun_java2d_pipe_BufferedRenderPipe_fillSpans; + Java_sun_java2d_pipe_SpanClipRenderer_initIDs; + sun_awt_image_GifImageDecoder_initIDs; - # libmawt entry points - SurfaceData_InitOps; - SurfaceData_ThrowInvalidPipeException; - Region_GetBounds; - Region_GetInfo; - Region_StartIteration; - Region_CountIterationRects; - Region_NextIteration; - Region_EndIteration; - GrPrim_CompGetXorInfo; - GrPrim_CompGetAlphaInfo; - img_makePalette; - initInverseGrayLut; - make_dither_arrays; - make_uns_ordered_dither_array; + # libmawt entry points + SurfaceData_InitOps; + SurfaceData_ThrowInvalidPipeException; + Region_GetBounds; + Region_GetInfo; + Region_StartIteration; + Region_CountIterationRects; + Region_NextIteration; + Region_EndIteration; + GrPrim_CompGetXorInfo; + GrPrim_CompGetAlphaInfo; + img_makePalette; + initInverseGrayLut; + make_dither_arrays; + make_uns_ordered_dither_array; - # variables exported to libmawt - std_img_oda_red; - std_img_oda_blue; - std_img_oda_green; - std_odas_computed; - g_CMpDataID; - colorValueID; - jvm; + # variables exported to libmawt + std_img_oda_red; + std_img_oda_blue; + std_img_oda_green; + std_odas_computed; + g_CMpDataID; + colorValueID; + jvm; - # CDE private entry point - # This is in awt_LoadLibrary.c and falls through to libmawt. - # Evidently CDE needs this for backward compatability. - Java_sun_awt_motif_XsessionWMcommand; + # CDE private entry point + # This is in awt_LoadLibrary.c and falls through to libmawt. + # Evidently CDE needs this for backward compatability. + Java_sun_awt_motif_XsessionWMcommand; - # libfontmanager entry points - AWTIsHeadless; - GrPrim_Sg2dGetCompInfo; - GrPrim_Sg2dGetClip; - GetNativePrim; - SurfaceData_IntersectBounds; - SurfaceData_GetOps; - Disposer_AddRecord; - GrPrim_Sg2dGetEaRGB; - GrPrim_Sg2dGetPixel; - GrPrim_Sg2dGetLCDTextContrast; + # libfontmanager entry points + AWTIsHeadless; + GrPrim_Sg2dGetCompInfo; + GrPrim_Sg2dGetClip; + GetNativePrim; + SurfaceData_IntersectBounds; + SurfaceData_GetOps; + Disposer_AddRecord; + GrPrim_Sg2dGetEaRGB; + GrPrim_Sg2dGetPixel; + GrPrim_Sg2dGetLCDTextContrast; - Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; - Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; - Java_java_awt_AWTEvent_nativeSetSource; - Java_java_awt_Checkbox_initIDs; - Java_java_awt_Component_initIDs; - Java_java_awt_Dialog_initIDs; - Java_java_awt_Font_initIDs; - Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; - Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; - Java_java_awt_KeyboardFocusManager_initIDs; - Java_java_awt_Menu_initIDs; - Java_java_awt_MenuComponent_initIDs; - Java_java_awt_MenuItem_initIDs; - Java_java_awt_Scrollbar_initIDs; - Java_java_awt_ScrollPane_initIDs; - Java_java_awt_TextArea_initIDs; - Java_sun_awt_FontDescriptor_initIDs; - Java_sun_awt_X11InputMethod_disposeXIC; - Java_sun_awt_X11InputMethod_isCompositionEnabledNative; - Java_sun_awt_X11InputMethod_resetXIC; - Java_sun_awt_X11InputMethod_setCompositionEnabledNative; - Java_sun_awt_X11InputMethod_turnoffStatusWindow; - Java_sun_awt_SunToolkit_closeSplashScreen; - Java_sun_awt_PlatformFont_initIDs; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_dispose; - Java_sun_awt_X11GraphicsConfig_pGetBounds; - Java_sun_awt_X11GraphicsConfig_getNumColors; - Java_sun_awt_X11GraphicsConfig_getXResolution; - Java_sun_awt_X11GraphicsConfig_getYResolution; - Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; - Java_sun_awt_X11GraphicsDevice_isDBESupported; - Java_sun_awt_X11GraphicsDevice_getDisplay; - Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; - Java_sun_awt_X11GraphicsDevice_getNumConfigs; - Java_sun_awt_X11GraphicsDevice_initIDs; - Java_sun_awt_X11GraphicsDevice_initXrandrExtension; - Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; - Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; - Java_sun_awt_X11GraphicsDevice_enumDisplayModes; - Java_sun_awt_X11GraphicsDevice_configDisplayMode; - Java_sun_awt_X11GraphicsDevice_resetNativeData; - Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor; - Java_sun_awt_X11GraphicsEnvironment_checkShmExt; - Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; - Java_sun_awt_X11GraphicsEnvironment_getDisplayString; - Java_sun_awt_X11GraphicsEnvironment_getNumScreens; - Java_sun_awt_X11GraphicsEnvironment_initDisplay; - Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; - Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; - Java_sun_awt_X11GraphicsEnvironment_initXRender; + Java_sun_awt_DefaultMouseInfoPeer_fillPointWithCoords; + Java_sun_awt_DefaultMouseInfoPeer_isWindowUnderMouse; + Java_java_awt_AWTEvent_nativeSetSource; + Java_java_awt_Checkbox_initIDs; + Java_java_awt_Component_initIDs; + Java_java_awt_Dialog_initIDs; + Java_java_awt_Font_initIDs; + Java_sun_awt_KeyboardFocusManagerPeerImpl_clearNativeGlobalFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusOwner; + Java_sun_awt_KeyboardFocusManagerPeerImpl_getNativeFocusedWindow; + Java_java_awt_KeyboardFocusManager_initIDs; + Java_java_awt_Menu_initIDs; + Java_java_awt_MenuComponent_initIDs; + Java_java_awt_MenuItem_initIDs; + Java_java_awt_Scrollbar_initIDs; + Java_java_awt_ScrollPane_initIDs; + Java_java_awt_TextArea_initIDs; + Java_sun_awt_FontDescriptor_initIDs; + Java_sun_awt_X11InputMethod_disposeXIC; + Java_sun_awt_X11InputMethod_isCompositionEnabledNative; + Java_sun_awt_X11InputMethod_resetXIC; + Java_sun_awt_X11InputMethod_setCompositionEnabledNative; + Java_sun_awt_X11InputMethod_turnoffStatusWindow; + Java_sun_awt_SunToolkit_closeSplashScreen; + Java_sun_awt_PlatformFont_initIDs; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_dispose; + Java_sun_awt_X11GraphicsConfig_pGetBounds; + Java_sun_awt_X11GraphicsConfig_getNumColors; + Java_sun_awt_X11GraphicsConfig_getXResolution; + Java_sun_awt_X11GraphicsConfig_getYResolution; + Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; + Java_sun_awt_X11GraphicsDevice_isDBESupported; + Java_sun_awt_X11GraphicsDevice_getDisplay; + Java_sun_awt_X11GraphicsDevice_getDoubleBufferVisuals; + Java_sun_awt_X11GraphicsDevice_getNumConfigs; + Java_sun_awt_X11GraphicsDevice_initIDs; + Java_sun_awt_X11GraphicsDevice_initXrandrExtension; + Java_sun_awt_X11GraphicsDevice_enterFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_exitFullScreenExclusive; + Java_sun_awt_X11GraphicsDevice_getCurrentDisplayMode; + Java_sun_awt_X11GraphicsDevice_enumDisplayModes; + Java_sun_awt_X11GraphicsDevice_configDisplayMode; + Java_sun_awt_X11GraphicsDevice_resetNativeData; + Java_sun_awt_X11GraphicsDevice_getNativeScaleFactor; + Java_sun_awt_X11GraphicsEnvironment_checkShmExt; + Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; + Java_sun_awt_X11GraphicsEnvironment_getDisplayString; + Java_sun_awt_X11GraphicsEnvironment_getNumScreens; + Java_sun_awt_X11GraphicsEnvironment_initDisplay; + Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; + Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; + Java_sun_awt_X11GraphicsEnvironment_initXRender; - - - Java_java_awt_AWTEvent_initIDs; - Java_java_awt_Button_initIDs; - Java_java_awt_Container_initIDs; - Java_java_awt_Cursor_finalizeImpl; - Java_java_awt_Cursor_initIDs; - Java_java_awt_Event_initIDs; - Java_java_awt_event_InputEvent_initIDs; - Java_java_awt_event_KeyEvent_initIDs; - Java_java_awt_FileDialog_initIDs; - Java_java_awt_Frame_initIDs; - Java_java_awt_Insets_initIDs; - Java_java_awt_TextField_initIDs; - Java_java_awt_Window_initIDs; - Java_sun_awt_motif_X11OffScreenImage_updateBitmask; - Java_sun_awt_X11GraphicsConfig_init; - Java_sun_awt_X11GraphicsConfig_initIDs; - Java_sun_awt_X11GraphicsConfig_makeColorModel; - Java_sun_awt_X11GraphicsDevice_getConfigVisualId; - Java_sun_awt_X11PMBlitLoops_Blit; - Java_sun_awt_X11PMBlitBgLoops_nativeBlitBg; - Java_sun_awt_X11Renderer_devFillSpans; - Java_sun_awt_X11Renderer_doDrawArc; - Java_sun_awt_X11Renderer_doDrawLine; - Java_sun_awt_X11Renderer_doDrawOval; - Java_sun_awt_X11Renderer_doDrawPoly; - Java_sun_awt_X11Renderer_doDrawRect; - Java_sun_awt_X11Renderer_doDrawRoundRect; - Java_sun_awt_X11Renderer_doFillArc; - Java_sun_awt_X11Renderer_doFillOval; - Java_sun_awt_X11Renderer_doFillPoly; - Java_sun_awt_X11Renderer_doFillRect; - Java_sun_awt_X11Renderer_doFillRoundRect; - Java_sun_awt_X11Renderer_devCopyArea; - Java_sun_awt_X11SurfaceData_initIDs; - Java_sun_awt_X11SurfaceData_initOps; - Java_sun_awt_X11SurfaceData_initSurface; - Java_sun_awt_X11SurfaceData_isDgaAvailable; - Java_sun_awt_X11SurfaceData_setInvalid; - Java_sun_awt_X11SurfaceData_flushNativeSurface; - awt_display; - awt_lock; - awt_Lock; - awt_Unlock; - awt_GetDrawingSurface; - awt_FreeDrawingSurface; - awt_GetComponent; + Java_java_awt_AWTEvent_initIDs; + Java_java_awt_Button_initIDs; + Java_java_awt_Container_initIDs; + Java_java_awt_Cursor_finalizeImpl; + Java_java_awt_Cursor_initIDs; + Java_java_awt_Event_initIDs; + Java_java_awt_event_InputEvent_initIDs; + Java_java_awt_event_KeyEvent_initIDs; + Java_java_awt_FileDialog_initIDs; + Java_java_awt_Frame_initIDs; + Java_java_awt_Insets_initIDs; + Java_java_awt_TextField_initIDs; + Java_java_awt_Window_initIDs; + Java_sun_awt_motif_X11OffScreenImage_updateBitmask; + Java_sun_awt_X11GraphicsConfig_init; + Java_sun_awt_X11GraphicsConfig_initIDs; + Java_sun_awt_X11GraphicsConfig_makeColorModel; + Java_sun_awt_X11GraphicsDevice_getConfigVisualId; + Java_sun_awt_X11PMBlitLoops_Blit; + Java_sun_awt_X11PMBlitBgLoops_nativeBlitBg; + Java_sun_awt_X11Renderer_devFillSpans; + Java_sun_awt_X11Renderer_doDrawArc; + Java_sun_awt_X11Renderer_doDrawLine; + Java_sun_awt_X11Renderer_doDrawOval; + Java_sun_awt_X11Renderer_doDrawPoly; + Java_sun_awt_X11Renderer_doDrawRect; + Java_sun_awt_X11Renderer_doDrawRoundRect; + Java_sun_awt_X11Renderer_doFillArc; + Java_sun_awt_X11Renderer_doFillOval; + Java_sun_awt_X11Renderer_doFillPoly; + Java_sun_awt_X11Renderer_doFillRect; + Java_sun_awt_X11Renderer_doFillRoundRect; + Java_sun_awt_X11Renderer_devCopyArea; + Java_sun_awt_X11SurfaceData_initIDs; + Java_sun_awt_X11SurfaceData_initOps; + Java_sun_awt_X11SurfaceData_initSurface; + Java_sun_awt_X11SurfaceData_isDgaAvailable; + Java_sun_awt_X11SurfaceData_setInvalid; + Java_sun_awt_X11SurfaceData_flushNativeSurface; + awt_display; + awt_lock; + awt_Lock; + awt_Unlock; + awt_GetDrawingSurface; + awt_FreeDrawingSurface; + awt_GetComponent; awt_CreateEmbeddedFrame; awt_SetBounds; awt_SynthesizeWindowActivation; + X11SurfaceData_GetOps; + getDefaultConfig; + Java_sun_font_FontConfigManager_getFontConfig; + Java_sun_font_FontConfigManager_getFontConfigAASettings; + Java_sun_awt_FcFontManager_getFontPathNative; + Java_sun_font_SunFontManager_populateFontFileNameMap; - X11SurfaceData_GetOps; - getDefaultConfig; - Java_sun_font_FontConfigManager_getFontConfig; - Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_awt_FcFontManager_getFontPathNative; - Java_sun_font_SunFontManager_populateFontFileNameMap; + # CDE private entry point + Java_sun_awt_motif_XsessionWMcommand; - # CDE private entry point - Java_sun_awt_motif_XsessionWMcommand; + # libfontmanager entry points + AWTIsHeadless; + AWTCountFonts; + AWTLoadFont; + AWTFreeFont; + AWTFontMinByte1; + AWTFontMaxByte1; + AWTFontMinCharOrByte2; + AWTFontMaxCharOrByte2; + AWTFontDefaultChar; + AWTFontPerChar; + AWTFontMaxBounds; + AWTFontTextExtents16; + AWTFreeChar; + AWTFontGenerateImage; + AWTCharAdvance; + AWTCharLBearing; + AWTCharRBearing; + AWTCharAscent; + AWTCharDescent; + AWTDrawGlyphList; + AccelGlyphCache_RemoveAllCellInfos; - # libfontmanager entry points - AWTIsHeadless; - AWTCountFonts; - AWTLoadFont; - AWTFreeFont; - AWTFontMinByte1; - AWTFontMaxByte1; - AWTFontMinCharOrByte2; - AWTFontMaxCharOrByte2; - AWTFontDefaultChar; - AWTFontPerChar; - AWTFontMaxBounds; - AWTFontTextExtents16; - AWTFreeChar; - AWTFontGenerateImage; - AWTCharAdvance; - AWTCharLBearing; - AWTCharRBearing; - AWTCharAscent; - AWTCharDescent; - AWTDrawGlyphList; - AccelGlyphCache_RemoveAllCellInfos; - - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt_headless/mapfile-vers b/jdk/make/mapfiles/libawt_headless/mapfile-vers index ac5101042a2..4ec723ffe0a 100644 --- a/jdk/make/mapfiles/libawt_headless/mapfile-vers +++ b/jdk/make/mapfiles/libawt_headless/mapfile-vers @@ -26,85 +26,84 @@ # Define public interface. SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; - Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; - Java_sun_java2d_x11_X11Renderer_XFillSpans; - Java_sun_java2d_x11_X11Renderer_XDrawArc; - Java_sun_java2d_x11_X11Renderer_XDrawLine; - Java_sun_java2d_x11_X11Renderer_XDrawOval; - Java_sun_java2d_x11_X11Renderer_XDrawPoly; - Java_sun_java2d_x11_X11Renderer_XDrawRect; - Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; - Java_sun_java2d_x11_X11Renderer_XDoPath; - Java_sun_java2d_x11_X11Renderer_XFillArc; - Java_sun_java2d_x11_X11Renderer_XFillOval; - Java_sun_java2d_x11_X11Renderer_XFillPoly; - Java_sun_java2d_x11_X11Renderer_XFillRect; - Java_sun_java2d_x11_X11Renderer_XFillRoundRect; - Java_sun_java2d_x11_X11Renderer_devCopyArea; - Java_sun_java2d_x11_X11SurfaceData_initIDs; - Java_sun_java2d_x11_X11SurfaceData_initSurface; - Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; - Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; - Java_sun_java2d_x11_X11SurfaceData_XSetForeground; + Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; + Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; + Java_sun_java2d_x11_X11Renderer_XFillSpans; + Java_sun_java2d_x11_X11Renderer_XDrawArc; + Java_sun_java2d_x11_X11Renderer_XDrawLine; + Java_sun_java2d_x11_X11Renderer_XDrawOval; + Java_sun_java2d_x11_X11Renderer_XDrawPoly; + Java_sun_java2d_x11_X11Renderer_XDrawRect; + Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; + Java_sun_java2d_x11_X11Renderer_XDoPath; + Java_sun_java2d_x11_X11Renderer_XFillArc; + Java_sun_java2d_x11_X11Renderer_XFillOval; + Java_sun_java2d_x11_X11Renderer_XFillPoly; + Java_sun_java2d_x11_X11Renderer_XFillRect; + Java_sun_java2d_x11_X11Renderer_XFillRoundRect; + Java_sun_java2d_x11_X11Renderer_devCopyArea; + Java_sun_java2d_x11_X11SurfaceData_initIDs; + Java_sun_java2d_x11_X11SurfaceData_initSurface; + Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; + Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; + Java_sun_java2d_x11_X11SurfaceData_XSetForeground; - Java_sun_java2d_x11_XSurfaceData_initOps; - Java_sun_java2d_x11_XSurfaceData_XCreateGC; - Java_sun_java2d_x11_XSurfaceData_XResetClip; - Java_sun_java2d_x11_XSurfaceData_XSetClip; - Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; - Java_sun_java2d_x11_XSurfaceData_isDrawableValid; - Java_sun_java2d_x11_XSurfaceData_setInvalid; - Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; + Java_sun_java2d_x11_XSurfaceData_initOps; + Java_sun_java2d_x11_XSurfaceData_XCreateGC; + Java_sun_java2d_x11_XSurfaceData_XResetClip; + Java_sun_java2d_x11_XSurfaceData_XSetClip; + Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; + Java_sun_java2d_x11_XSurfaceData_isDrawableValid; + Java_sun_java2d_x11_XSurfaceData_setInvalid; + Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; - X11SurfaceData_GetOps; - Java_java_awt_Font_initIDs; - Java_sun_font_FontConfigManager_getFontConfig; - Java_sun_font_FontConfigManager_getFontConfigAASettings; - Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_FcFontManager_getFontPathNative; + X11SurfaceData_GetOps; + Java_java_awt_Font_initIDs; + Java_sun_font_FontConfigManager_getFontConfig; + Java_sun_font_FontConfigManager_getFontConfigAASettings; + Java_sun_font_FontConfigManager_getFontConfigVersion; + Java_sun_awt_FcFontManager_getFontPathNative; - Java_sun_awt_FontDescriptor_initIDs; - Java_sun_awt_PlatformFont_initIDs; + Java_sun_awt_FontDescriptor_initIDs; + Java_sun_awt_PlatformFont_initIDs; - Java_sun_print_CUPSPrinter_initIDs; - Java_sun_print_CUPSPrinter_getCupsServer; - Java_sun_print_CUPSPrinter_getCupsPort; - Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; - Java_sun_print_CUPSPrinter_canConnect; - Java_sun_print_CUPSPrinter_getMedia; - Java_sun_print_CUPSPrinter_getPageSizes; - Java_sun_print_CUPSPrinter_getResolutions; + Java_sun_print_CUPSPrinter_initIDs; + Java_sun_print_CUPSPrinter_getCupsServer; + Java_sun_print_CUPSPrinter_getCupsPort; + Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; + Java_sun_print_CUPSPrinter_canConnect; + Java_sun_print_CUPSPrinter_getMedia; + Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; - # libfontmanager entry points - AWTIsHeadless; - AWTCountFonts; - AWTLoadFont; - AWTFreeFont; - AWTFontAscent; - AWTFontDescent; - AWTFontMinByte1; - AWTFontMaxByte1; - AWTFontMinCharOrByte2; - AWTFontMaxCharOrByte2; - AWTFontDefaultChar; - AWTFontPerChar; - AWTFontMaxBounds; - AWTFontTextExtents16; - AWTFreeChar; - AWTFontGenerateImage; - AWTCharAdvance; - AWTCharLBearing; - AWTCharRBearing; - AWTCharAscent; - AWTCharDescent; - AWTDrawGlyphList; - AccelGlyphCache_RemoveAllCellInfos; + # libfontmanager entry points + AWTIsHeadless; + AWTCountFonts; + AWTLoadFont; + AWTFreeFont; + AWTFontAscent; + AWTFontDescent; + AWTFontMinByte1; + AWTFontMaxByte1; + AWTFontMinCharOrByte2; + AWTFontMaxCharOrByte2; + AWTFontDefaultChar; + AWTFontPerChar; + AWTFontMaxBounds; + AWTFontTextExtents16; + AWTFreeChar; + AWTFontGenerateImage; + AWTCharAdvance; + AWTCharLBearing; + AWTCharRBearing; + AWTCharAscent; + AWTCharDescent; + AWTDrawGlyphList; + AccelGlyphCache_RemoveAllCellInfos; - - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libawt_xawt/mapfile-vers b/jdk/make/mapfiles/libawt_xawt/mapfile-vers index 04113dcf031..b56b47b8ce8 100644 --- a/jdk/make/mapfiles/libawt_xawt/mapfile-vers +++ b/jdk/make/mapfiles/libawt_xawt/mapfile-vers @@ -26,7 +26,7 @@ # Define public interface. SUNWprivate_1.1 { - global: + global: JNI_OnLoad; Java_sun_awt_X11_XlibWrapper_copyIntArray; Java_sun_awt_X11_XlibWrapper_copyLongArray; @@ -58,8 +58,8 @@ SUNWprivate_1.1 { Java_sun_awt_X11_XlibWrapper_XSetLocaleModifiers; Java_sun_awt_X11_XlibWrapper_XPeekEvent; Java_sun_awt_X11_XlibWrapper_DefaultScreen; - Java_sun_awt_X11_XlibWrapper_ScreenOfDisplay; - Java_sun_awt_X11_XlibWrapper_DoesBackingStore; + Java_sun_awt_X11_XlibWrapper_ScreenOfDisplay; + Java_sun_awt_X11_XlibWrapper_DoesBackingStore; Java_sun_awt_X11_XlibWrapper_RootWindow; Java_sun_awt_X11_XlibWrapper_DisplayHeight; Java_sun_awt_X11_XlibWrapper_DisplayWidthMM; @@ -172,7 +172,7 @@ SUNWprivate_1.1 { Java_java_awt_Scrollbar_initIDs; Java_java_awt_Window_initIDs; Java_java_awt_Frame_initIDs; - Java_sun_awt_SunToolkit_closeSplashScreen; + Java_sun_awt_SunToolkit_closeSplashScreen; Java_sun_awt_UNIXToolkit_check_1gtk; Java_sun_awt_UNIXToolkit_load_1gtk; Java_sun_awt_UNIXToolkit_unload_1gtk; @@ -196,17 +196,16 @@ SUNWprivate_1.1 { Java_sun_font_FontConfigManager_getFontConfig; Java_sun_font_FontConfigManager_getFontConfigAASettings; Java_sun_font_FontConfigManager_getFontConfigVersion; - Java_sun_awt_FcFontManager_getFontPathNative; + Java_sun_awt_FcFontManager_getFontPathNative; Java_sun_awt_X11GraphicsEnvironment_initDisplay; Java_sun_awt_X11GraphicsEnvironment_initGLX; - Java_sun_awt_X11GraphicsEnvironment_initXRender; + Java_sun_awt_X11GraphicsEnvironment_initXRender; Java_sun_awt_X11GraphicsEnvironment_checkShmExt; Java_sun_awt_X11GraphicsEnvironment_getNumScreens; Java_sun_awt_X11GraphicsEnvironment_getDefaultScreenNum; Java_sun_awt_X11GraphicsEnvironment_pRunningXinerama; Java_sun_awt_X11GraphicsEnvironment_getXineramaCenterPoint; Java_sun_awt_X11GraphicsEnvironment_getDisplayString; -# Java_sun_awt_X11GraphicsEnvironment_getNativeFonts; Java_sun_awt_X11GraphicsDevice_initIDs; Java_sun_awt_X11GraphicsDevice_getConfigVisualId; Java_sun_awt_X11GraphicsDevice_getConfigDepth; @@ -231,16 +230,16 @@ SUNWprivate_1.1 { Java_sun_awt_X11GraphicsConfig_makeColorModel; Java_sun_awt_X11GraphicsConfig_pGetBounds; Java_sun_awt_X11GraphicsConfig_createBackBuffer; - Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; - Java_sun_awt_X11GraphicsConfig_swapBuffers; - Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; + Java_sun_awt_X11GraphicsConfig_destroyBackBuffer; + Java_sun_awt_X11GraphicsConfig_swapBuffers; + Java_sun_awt_X11GraphicsConfig_isTranslucencyCapable; Java_sun_awt_X11_XToolkit_getTrayIconDisplayTimeout; Java_java_awt_Insets_initIDs; Java_java_awt_KeyboardFocusManager_initIDs; Java_java_awt_Font_initIDs; # libfontmanager entry points AWTIsHeadless; - AWTCountFonts; + AWTCountFonts; AWTLoadFont; AWTFreeFont; AWTFontAscent; @@ -303,7 +302,7 @@ SUNWprivate_1.1 { Java_sun_awt_X11_XlibWrapper_XGetIconSizes; Java_sun_awt_X11_XlibWrapper_XKeycodeToKeysym; Java_sun_awt_X11_XlibWrapper_XKeysymToKeycode; - Java_sun_awt_X11_XlibWrapper_XQueryKeymap; + Java_sun_awt_X11_XlibWrapper_XQueryKeymap; Java_sun_awt_X11_XlibWrapper_XkbGetEffectiveGroup; Java_sun_awt_X11_XlibWrapper_XkbSelectEvents; Java_sun_awt_X11_XlibWrapper_XkbSelectEventDetails; @@ -350,23 +349,23 @@ SUNWprivate_1.1 { Java_sun_java2d_x11_X11PMBlitBgLoops_nativeBlitBg; Java_sun_java2d_x11_X11PMBlitLoops_nativeBlit; Java_sun_java2d_x11_X11PMBlitLoops_updateBitmask; - Java_sun_java2d_x11_X11Renderer_XFillSpans; - Java_sun_java2d_x11_X11Renderer_XDrawArc; - Java_sun_java2d_x11_X11Renderer_XDrawLine; - Java_sun_java2d_x11_X11Renderer_XDrawOval; - Java_sun_java2d_x11_X11Renderer_XDrawPoly; - Java_sun_java2d_x11_X11Renderer_XDrawRect; - Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; + Java_sun_java2d_x11_X11Renderer_XFillSpans; + Java_sun_java2d_x11_X11Renderer_XDrawArc; + Java_sun_java2d_x11_X11Renderer_XDrawLine; + Java_sun_java2d_x11_X11Renderer_XDrawOval; + Java_sun_java2d_x11_X11Renderer_XDrawPoly; + Java_sun_java2d_x11_X11Renderer_XDrawRect; + Java_sun_java2d_x11_X11Renderer_XDrawRoundRect; Java_sun_java2d_x11_X11Renderer_XDoPath; - Java_sun_java2d_x11_X11Renderer_XFillArc; - Java_sun_java2d_x11_X11Renderer_XFillOval; - Java_sun_java2d_x11_X11Renderer_XFillPoly; - Java_sun_java2d_x11_X11Renderer_XFillRect; - Java_sun_java2d_x11_X11Renderer_XFillRoundRect; + Java_sun_java2d_x11_X11Renderer_XFillArc; + Java_sun_java2d_x11_X11Renderer_XFillOval; + Java_sun_java2d_x11_X11Renderer_XFillPoly; + Java_sun_java2d_x11_X11Renderer_XFillRect; + Java_sun_java2d_x11_X11Renderer_XFillRoundRect; Java_sun_java2d_x11_X11Renderer_devCopyArea; Java_sun_java2d_x11_X11SurfaceData_initIDs; Java_sun_java2d_x11_X11SurfaceData_isDgaAvailable; - Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; + Java_sun_java2d_x11_X11SurfaceData_isShmPMAvailable; Java_sun_java2d_x11_X11SurfaceData_initSurface; Java_sun_java2d_x11_X11SurfaceData_XSetCopyMode; Java_sun_java2d_x11_X11SurfaceData_XSetXorMode; @@ -377,40 +376,40 @@ SUNWprivate_1.1 { Java_sun_java2d_x11_XSurfaceData_XResetClip; Java_sun_java2d_x11_XSurfaceData_XSetClip; Java_sun_java2d_x11_XSurfaceData_flushNativeSurface; - Java_sun_java2d_x11_XSurfaceData_isDrawableValid; + Java_sun_java2d_x11_XSurfaceData_isDrawableValid; Java_sun_java2d_x11_XSurfaceData_setInvalid; Java_sun_java2d_x11_XSurfaceData_XSetGraphicsExposures; Java_sun_java2d_xr_XRSurfaceData_initXRPicture; Java_sun_java2d_xr_XRSurfaceData_initIDs; Java_sun_java2d_xr_XRSurfaceData_XRInitSurface; - Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; - Java_sun_java2d_xr_XRBackendNative_initIDs; - Java_sun_java2d_xr_XRBackendNative_freeGC; - Java_sun_java2d_xr_XRBackendNative_createGC; - Java_sun_java2d_xr_XRBackendNative_createPixmap; - Java_sun_java2d_xr_XRBackendNative_createPictureNative; - Java_sun_java2d_xr_XRBackendNative_freePicture; - Java_sun_java2d_xr_XRBackendNative_freePixmap; - Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; - Java_sun_java2d_xr_XRBackendNative_setGCExposures; - Java_sun_java2d_xr_XRBackendNative_setGCForeground; - Java_sun_java2d_xr_XRBackendNative_copyArea; - Java_sun_java2d_xr_XRBackendNative_renderComposite; - Java_sun_java2d_xr_XRBackendNative_renderRectangle; - Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; - Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; - Java_sun_java2d_xr_XRBackendNative_setFilter; - Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; - Java_sun_java2d_xr_XRBackendNative_putMaskNative; - Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; - Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; - Java_sun_java2d_xr_XRBackendNative_setGCMode; - Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; - Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; + Java_sun_java2d_xr_XRSurfaceData_freeXSDOPicture; + Java_sun_java2d_xr_XRBackendNative_initIDs; + Java_sun_java2d_xr_XRBackendNative_freeGC; + Java_sun_java2d_xr_XRBackendNative_createGC; + Java_sun_java2d_xr_XRBackendNative_createPixmap; + Java_sun_java2d_xr_XRBackendNative_createPictureNative; + Java_sun_java2d_xr_XRBackendNative_freePicture; + Java_sun_java2d_xr_XRBackendNative_freePixmap; + Java_sun_java2d_xr_XRBackendNative_setPictureRepeat; + Java_sun_java2d_xr_XRBackendNative_setGCExposures; + Java_sun_java2d_xr_XRBackendNative_setGCForeground; + Java_sun_java2d_xr_XRBackendNative_copyArea; + Java_sun_java2d_xr_XRBackendNative_renderComposite; + Java_sun_java2d_xr_XRBackendNative_renderRectangle; + Java_sun_java2d_xr_XRBackendNative_XRenderRectanglesNative; + Java_sun_java2d_xr_XRBackendNative_XRSetTransformNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateLinearGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_XRCreateRadialGradientPaintNative; + Java_sun_java2d_xr_XRBackendNative_setFilter; + Java_sun_java2d_xr_XRBackendNative_XRSetClipNative; + Java_sun_java2d_xr_XRBackendNative_putMaskNative; + Java_sun_java2d_xr_XRBackendNative_XRAddGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRFreeGlyphsNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCreateGlyphSetNative; + Java_sun_java2d_xr_XRBackendNative_XRenderCompositeTextNative; + Java_sun_java2d_xr_XRBackendNative_setGCMode; + Java_sun_java2d_xr_XRBackendNative_GCRectanglesNative; + Java_sun_java2d_xr_XRBackendNative_renderCompositeTrapezoidsNative; Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1arrow; Java_com_sun_java_swing_plaf_gtk_GTKEngine_native_1paint_1box; @@ -444,14 +443,14 @@ SUNWprivate_1.1 { Java_sun_awt_X11_GtkFileDialogPeer_toFront; Java_sun_awt_X11_GtkFileDialogPeer_setBounds; - Java_sun_print_CUPSPrinter_initIDs; - Java_sun_print_CUPSPrinter_getCupsServer; - Java_sun_print_CUPSPrinter_getCupsPort; - Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; - Java_sun_print_CUPSPrinter_canConnect; - Java_sun_print_CUPSPrinter_getMedia; - Java_sun_print_CUPSPrinter_getPageSizes; - Java_sun_print_CUPSPrinter_getResolutions; + Java_sun_print_CUPSPrinter_initIDs; + Java_sun_print_CUPSPrinter_getCupsServer; + Java_sun_print_CUPSPrinter_getCupsPort; + Java_sun_print_CUPSPrinter_getCupsDefaultPrinter; + Java_sun_print_CUPSPrinter_canConnect; + Java_sun_print_CUPSPrinter_getMedia; + Java_sun_print_CUPSPrinter_getPageSizes; + Java_sun_print_CUPSPrinter_getResolutions; awt_GetDrawingSurface; awt_FreeDrawingSurface; @@ -466,6 +465,6 @@ SUNWprivate_1.1 { Java_sun_awt_motif_XsessionWMcommand; Java_sun_awt_motif_XsessionWMcommand_New; - local: - *; + local: + *; }; diff --git a/jdk/make/mapfiles/libjawt/mapfile-vers b/jdk/make/mapfiles/libjawt/mapfile-vers index 1a79df0c34d..ee0ef4202cc 100644 --- a/jdk/make/mapfiles/libjawt/mapfile-vers +++ b/jdk/make/mapfiles/libjawt/mapfile-vers @@ -26,8 +26,8 @@ # Define library interface. SUNWprivate_1.1 { - global: - JAWT_GetAWT; - local: - *; + global: + JAWT_GetAWT; + local: + *; }; diff --git a/jdk/make/mapfiles/libjpeg/mapfile-vers b/jdk/make/mapfiles/libjpeg/mapfile-vers index 4534fa0944b..b82e7574598 100644 --- a/jdk/make/mapfiles/libjpeg/mapfile-vers +++ b/jdk/make/mapfiles/libjpeg/mapfile-vers @@ -26,30 +26,30 @@ # Define public interface. SUNWprivate_1.1 { - global: - JNI_OnLoad; + global: + JNI_OnLoad; - Java_sun_awt_image_JPEGImageDecoder_initIDs; - Java_sun_awt_image_JPEGImageDecoder_readImage; + Java_sun_awt_image_JPEGImageDecoder_initIDs; + Java_sun_awt_image_JPEGImageDecoder_readImage; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initReaderIDs; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initJPEGImageReader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setSource; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setOutColorSpace; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_abortRead; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetReader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_disposeReader; - Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetLibraryState; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initWriterIDs; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initJPEGImageWriter; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_setDest; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeTables; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_abortWrite; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_resetWriter; - Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_disposeWriter; - local: - *; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initReaderIDs; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_initJPEGImageReader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setSource; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImageHeader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_setOutColorSpace; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_readImage; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_abortRead; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetReader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_disposeReader; + Java_com_sun_imageio_plugins_jpeg_JPEGImageReader_resetLibraryState; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initWriterIDs; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_initJPEGImageWriter; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_setDest; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeTables; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_writeImage; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_abortWrite; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_resetWriter; + Java_com_sun_imageio_plugins_jpeg_JPEGImageWriter_disposeWriter; + local: + *; }; diff --git a/jdk/make/mapfiles/libjsound/mapfile-vers b/jdk/make/mapfiles/libjsound/mapfile-vers index b8ebf0d8af3..4cd03a758b1 100644 --- a/jdk/make/mapfiles/libjsound/mapfile-vers +++ b/jdk/make/mapfiles/libjsound/mapfile-vers @@ -26,60 +26,60 @@ # Define library interface. SUNWprivate_1.1 { - global: - Java_com_sun_media_sound_DirectAudioDevice_nAvailable; - Java_com_sun_media_sound_DirectAudioDevice_nClose; - Java_com_sun_media_sound_DirectAudioDevice_nFlush; - Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; - Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; - Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; - Java_com_sun_media_sound_DirectAudioDevice_nOpen; - Java_com_sun_media_sound_DirectAudioDevice_nRead; - Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; - Java_com_sun_media_sound_DirectAudioDevice_nService; - Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nStart; - Java_com_sun_media_sound_DirectAudioDevice_nStop; - Java_com_sun_media_sound_DirectAudioDevice_nWrite; - Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; - Java_com_sun_media_sound_MidiInDevice_nClose; - Java_com_sun_media_sound_MidiInDevice_nGetMessages; - Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiInDevice_nOpen; - Java_com_sun_media_sound_MidiInDevice_nStart; - Java_com_sun_media_sound_MidiInDevice_nStop; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; - Java_com_sun_media_sound_MidiOutDevice_nClose; - Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiOutDevice_nOpen; - Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; - Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; - Java_com_sun_media_sound_Platform_nGetExtraLibraries; - Java_com_sun_media_sound_Platform_nGetLibraryForFeature; - Java_com_sun_media_sound_Platform_nIsBigEndian; - Java_com_sun_media_sound_PortMixer_nClose; - Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlGetIntValue; - Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlSetIntValue; - Java_com_sun_media_sound_PortMixer_nGetControls; - Java_com_sun_media_sound_PortMixer_nGetPortCount; - Java_com_sun_media_sound_PortMixer_nGetPortName; - Java_com_sun_media_sound_PortMixer_nGetPortType; - Java_com_sun_media_sound_PortMixer_nOpen; - Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; - Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; - local: - *; + global: + Java_com_sun_media_sound_DirectAudioDevice_nAvailable; + Java_com_sun_media_sound_DirectAudioDevice_nClose; + Java_com_sun_media_sound_DirectAudioDevice_nFlush; + Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; + Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; + Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; + Java_com_sun_media_sound_DirectAudioDevice_nOpen; + Java_com_sun_media_sound_DirectAudioDevice_nRead; + Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; + Java_com_sun_media_sound_DirectAudioDevice_nService; + Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nStart; + Java_com_sun_media_sound_DirectAudioDevice_nStop; + Java_com_sun_media_sound_DirectAudioDevice_nWrite; + Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; + Java_com_sun_media_sound_MidiInDevice_nClose; + Java_com_sun_media_sound_MidiInDevice_nGetMessages; + Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiInDevice_nOpen; + Java_com_sun_media_sound_MidiInDevice_nStart; + Java_com_sun_media_sound_MidiInDevice_nStop; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; + Java_com_sun_media_sound_MidiOutDevice_nClose; + Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiOutDevice_nOpen; + Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; + Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; + Java_com_sun_media_sound_Platform_nGetExtraLibraries; + Java_com_sun_media_sound_Platform_nGetLibraryForFeature; + Java_com_sun_media_sound_Platform_nIsBigEndian; + Java_com_sun_media_sound_PortMixer_nClose; + Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlGetIntValue; + Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlSetIntValue; + Java_com_sun_media_sound_PortMixer_nGetControls; + Java_com_sun_media_sound_PortMixer_nGetPortCount; + Java_com_sun_media_sound_PortMixer_nGetPortName; + Java_com_sun_media_sound_PortMixer_nGetPortType; + Java_com_sun_media_sound_PortMixer_nOpen; + Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; + Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; + local: + *; }; diff --git a/jdk/make/mapfiles/libjsoundalsa/mapfile-vers b/jdk/make/mapfiles/libjsoundalsa/mapfile-vers index 1b1c8f75be6..6228f8ad23e 100644 --- a/jdk/make/mapfiles/libjsoundalsa/mapfile-vers +++ b/jdk/make/mapfiles/libjsoundalsa/mapfile-vers @@ -26,57 +26,57 @@ # Define library interface. SUNWprivate_1.1 { - global: - Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; - Java_com_sun_media_sound_DirectAudioDevice_nAvailable; - Java_com_sun_media_sound_DirectAudioDevice_nClose; - Java_com_sun_media_sound_DirectAudioDevice_nFlush; - Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; - Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; - Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; - Java_com_sun_media_sound_DirectAudioDevice_nOpen; - Java_com_sun_media_sound_DirectAudioDevice_nRead; - Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; - Java_com_sun_media_sound_DirectAudioDevice_nService; - Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; - Java_com_sun_media_sound_DirectAudioDevice_nStart; - Java_com_sun_media_sound_DirectAudioDevice_nStop; - Java_com_sun_media_sound_DirectAudioDevice_nWrite; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; - Java_com_sun_media_sound_MidiInDevice_nClose; - Java_com_sun_media_sound_MidiInDevice_nGetMessages; - Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiInDevice_nOpen; - Java_com_sun_media_sound_MidiInDevice_nStart; - Java_com_sun_media_sound_MidiInDevice_nStop; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; - Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; - Java_com_sun_media_sound_MidiOutDevice_nClose; - Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; - Java_com_sun_media_sound_MidiOutDevice_nOpen; - Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; - Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; - Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; - Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; - Java_com_sun_media_sound_PortMixer_nClose; - Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlGetIntValue; - Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; - Java_com_sun_media_sound_PortMixer_nControlSetIntValue; - Java_com_sun_media_sound_PortMixer_nGetControls; - Java_com_sun_media_sound_PortMixer_nGetPortCount; - Java_com_sun_media_sound_PortMixer_nGetPortName; - Java_com_sun_media_sound_PortMixer_nGetPortType; - Java_com_sun_media_sound_PortMixer_nOpen; - local: - *; + global: + Java_com_sun_media_sound_DirectAudioDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_DirectAudioDeviceProvider_nNewDirectAudioDeviceInfo; + Java_com_sun_media_sound_DirectAudioDevice_nAvailable; + Java_com_sun_media_sound_DirectAudioDevice_nClose; + Java_com_sun_media_sound_DirectAudioDevice_nFlush; + Java_com_sun_media_sound_DirectAudioDevice_nGetBufferSize; + Java_com_sun_media_sound_DirectAudioDevice_nGetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nGetFormats; + Java_com_sun_media_sound_DirectAudioDevice_nIsStillDraining; + Java_com_sun_media_sound_DirectAudioDevice_nOpen; + Java_com_sun_media_sound_DirectAudioDevice_nRead; + Java_com_sun_media_sound_DirectAudioDevice_nRequiresServicing; + Java_com_sun_media_sound_DirectAudioDevice_nService; + Java_com_sun_media_sound_DirectAudioDevice_nSetBytePosition; + Java_com_sun_media_sound_DirectAudioDevice_nStart; + Java_com_sun_media_sound_DirectAudioDevice_nStop; + Java_com_sun_media_sound_DirectAudioDevice_nWrite; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiInDeviceProvider_nGetVersion; + Java_com_sun_media_sound_MidiInDevice_nClose; + Java_com_sun_media_sound_MidiInDevice_nGetMessages; + Java_com_sun_media_sound_MidiInDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiInDevice_nOpen; + Java_com_sun_media_sound_MidiInDevice_nStart; + Java_com_sun_media_sound_MidiInDevice_nStop; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetDescription; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetName; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetNumDevices; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVendor; + Java_com_sun_media_sound_MidiOutDeviceProvider_nGetVersion; + Java_com_sun_media_sound_MidiOutDevice_nClose; + Java_com_sun_media_sound_MidiOutDevice_nGetTimeStamp; + Java_com_sun_media_sound_MidiOutDevice_nOpen; + Java_com_sun_media_sound_MidiOutDevice_nSendLongMessage; + Java_com_sun_media_sound_MidiOutDevice_nSendShortMessage; + Java_com_sun_media_sound_PortMixerProvider_nGetNumDevices; + Java_com_sun_media_sound_PortMixerProvider_nNewPortMixerInfo; + Java_com_sun_media_sound_PortMixer_nClose; + Java_com_sun_media_sound_PortMixer_nControlGetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlGetIntValue; + Java_com_sun_media_sound_PortMixer_nControlSetFloatValue; + Java_com_sun_media_sound_PortMixer_nControlSetIntValue; + Java_com_sun_media_sound_PortMixer_nGetControls; + Java_com_sun_media_sound_PortMixer_nGetPortCount; + Java_com_sun_media_sound_PortMixer_nGetPortName; + Java_com_sun_media_sound_PortMixer_nGetPortType; + Java_com_sun_media_sound_PortMixer_nOpen; + local: + *; }; diff --git a/jdk/make/mapfiles/libsplashscreen/mapfile-vers b/jdk/make/mapfiles/libsplashscreen/mapfile-vers index fec7b037f0d..b948ef474a6 100644 --- a/jdk/make/mapfiles/libsplashscreen/mapfile-vers +++ b/jdk/make/mapfiles/libsplashscreen/mapfile-vers @@ -26,24 +26,24 @@ # Define public interface. SUNWprivate_1.1 { - global: - Java_java_awt_SplashScreen__1update; - Java_java_awt_SplashScreen__1isVisible; - Java_java_awt_SplashScreen__1getBounds; - Java_java_awt_SplashScreen__1getInstance; - Java_java_awt_SplashScreen__1close; - Java_java_awt_SplashScreen__1getImageFileName; - Java_java_awt_SplashScreen__1getImageJarName; - Java_java_awt_SplashScreen__1setImageData; - Java_java_awt_SplashScreen__1getScaleFactor; + global: + Java_java_awt_SplashScreen__1update; + Java_java_awt_SplashScreen__1isVisible; + Java_java_awt_SplashScreen__1getBounds; + Java_java_awt_SplashScreen__1getInstance; + Java_java_awt_SplashScreen__1close; + Java_java_awt_SplashScreen__1getImageFileName; + Java_java_awt_SplashScreen__1getImageJarName; + Java_java_awt_SplashScreen__1setImageData; + Java_java_awt_SplashScreen__1getScaleFactor; - SplashLoadMemory; - SplashLoadFile; - SplashInit; - SplashClose; - SplashSetFileJarName; - SplashSetScaleFactor; - SplashGetScaledImageName; - local: - *; + SplashLoadMemory; + SplashLoadFile; + SplashInit; + SplashClose; + SplashSetFileJarName; + SplashSetScaleFactor; + SplashGetScaledImageName; + local: + *; }; From f149873fe6b00027b567a9a056593b296a4f50b1 Mon Sep 17 00:00:00 2001 From: Rajeev Chamyal Date: Mon, 22 Aug 2016 14:41:36 +0530 Subject: [PATCH 10/87] 8163160: [PIT][TEST_BUG] Some issues in java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java Reviewed-by: serb, yan --- .../multiresolution/MultiResolutionIcon/IconTest.java | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java b/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java index 985041f6a1c..6083366e925 100644 --- a/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java +++ b/jdk/test/java/awt/image/multiresolution/MultiResolutionIcon/IconTest.java @@ -23,10 +23,10 @@ /** * @test - * @bug 8147648 + * @bug 8147648 8163160 * @summary [hidpi] multiresolution image: wrong resolution variant is used as * icon in the Unity panel - * @run main/othervm -Dsun.java2d.uiScale=2 IconTest + * @run main/manual/othervm -Dsun.java2d.uiScale=2 IconTest */ import java.awt.Color; import java.awt.Graphics; @@ -67,7 +67,7 @@ public class IconTest { if (g != null) { g.setColor(c); g.fillRect(0, 0, x, x); - g.setColor(Color.YELLOW); + g.setColor(Color.GREEN); g.drawRect(0, 0, x-1, x-1); } } finally { @@ -91,7 +91,8 @@ public class IconTest { GridBagConstraints gbc = new GridBagConstraints(); String instructions = "INSTRUCTIONS:
" - + "Check if test button and unity icons are both blue with yellow border.

" + + "Check if test button icon and unity icon are both " + + "blue with green border.

" + "If Icon color is blue press pass" + " else press fail.

"; From 66b521e8a9547a032a04e58016aeb3adfcb28574 Mon Sep 17 00:00:00 2001 From: Manajit Halder Date: Mon, 22 Aug 2016 18:23:46 +0530 Subject: [PATCH 11/87] 8156099: [macosx] Drag and drop of link from web browser, DataFlavor types application/x-java-url and text/uri-list, getTransferData returns null Reviewed-by: mcherkas, serb --- .../sun/lwawt/macosx/CDataTransferer.java | 31 ++- .../dnd/URLDragTest/DragLinkFromBrowser.java | 232 ++++++++++++++++++ 2 files changed, 257 insertions(+), 6 deletions(-) create mode 100644 jdk/test/java/awt/dnd/URLDragTest/DragLinkFromBrowser.java diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java index 3f05185c091..150c6e92ad1 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CDataTransferer.java @@ -36,7 +36,7 @@ import java.nio.charset.Charset; import java.text.Normalizer; import java.text.Normalizer.Form; import java.util.*; - +import java.util.regex.*; import java.awt.datatransfer.*; import sun.awt.datatransfer.*; @@ -129,12 +129,21 @@ public class CDataTransferer extends DataTransferer { long format, Transferable transferable) throws IOException { if (format == CF_URL && URL.class.equals(flavor.getRepresentationClass())) { - String[] strings = dragQueryFile(bytes); - if(strings == null || strings.length == 0) { - return null; + String charset = Charset.defaultCharset().name(); + if (transferable != null && transferable.isDataFlavorSupported(javaTextEncodingFlavor)) { + try { + charset = new String((byte[]) transferable.getTransferData(javaTextEncodingFlavor), "UTF-8"); + } catch (UnsupportedFlavorException cannotHappen) { + } } - return new URL(strings[0]); - } else if(isUriListFlavor(flavor)) { + + String xml = new String(bytes, charset); + // macosx pasteboard returns a property list that consists of one URL + // let's extract it. + return new URL(extractURL(xml)); + } + + if(isUriListFlavor(flavor) && format == CF_FILE) { // dragQueryFile works fine with files and url, // it parses and extracts values from property list. // maxosx always returns property list for @@ -156,6 +165,16 @@ public class CDataTransferer extends DataTransferer { return super.translateBytes(bytes, flavor, format, transferable); } + private String extractURL(String xml) { + Pattern urlExtractorPattern = Pattern.compile("(.*)"); + Matcher matcher = urlExtractorPattern.matcher(xml); + if (matcher.find()) { + return matcher.group(1); + } else { + return null; + } + } + @Override protected synchronized Long getFormatForNativeAsLong(String str) { Long format = predefinedClipboardNameMap.get(str); diff --git a/jdk/test/java/awt/dnd/URLDragTest/DragLinkFromBrowser.java b/jdk/test/java/awt/dnd/URLDragTest/DragLinkFromBrowser.java new file mode 100644 index 00000000000..6eacad3a7a3 --- /dev/null +++ b/jdk/test/java/awt/dnd/URLDragTest/DragLinkFromBrowser.java @@ -0,0 +1,232 @@ +/* + * 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 8156099 + @summary Drag and drop of link from web browser, DataFlavor types + application/x-java-url and text/uri-list, getTransferData returns null + @run main/manual DragLinkFromBrowser + */ + +import java.awt.Frame; +import java.awt.Button; +import java.awt.Panel; +import java.awt.TextArea; +import java.awt.Color; +import java.awt.GridBagConstraints; +import java.awt.GridBagLayout; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.datatransfer.DataFlavor; +import java.awt.datatransfer.Transferable; +import java.awt.datatransfer.UnsupportedFlavorException; +import java.io.IOException; +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.TransferHandler; +import javax.swing.SwingUtilities; +import javax.swing.JOptionPane; + +public class DragLinkFromBrowser implements ActionListener { + + private static GridBagLayout layout; + private static Panel mainControlPanel; + private static Panel resultButtonPanel; + private static TextArea instructionTextArea; + private static Button passButton; + private static Button failButton; + private static Frame mainFrame; + private static Thread mainThread = null; + private static volatile boolean testPassed = false; + private static volatile boolean isInterrupted = false; + private static volatile String failMessage; + private static final int testTimeOut = 300000; + private static JFrame urlFrame; + private static JPanel urlPanel; + + public static void dragLinkFromWebBrowser() { + + SwingUtilities.invokeLater(new Runnable() { + @Override + public void run() { + + urlFrame = new JFrame(); + urlPanel = new JPanel(); + failMessage = "Dragging link from web browser Failed. " + + "getTransferData returns null"; + urlFrame.getContentPane().add(urlPanel); + urlPanel.setTransferHandler(new TransferHandler() { + @Override + public boolean canImport(final TransferSupport support) { + return true; + } + + @Override + public boolean importData(final TransferSupport support) { + final Transferable transferable = + support.getTransferable(); + final DataFlavor[] flavors + = transferable.getTransferDataFlavors(); + + for (final DataFlavor flavor : flavors) { + try { + final Object transferData + = transferable.getTransferData(flavor); + + if (transferData == null) { + JOptionPane.showMessageDialog(urlPanel, + failMessage); + break; + } else { + String flavorMessage = flavor.toString(); + String transferDataMessage = + transferData.toString(); + if (flavorMessage.contains("error") + || transferDataMessage.contains("null")) { + JOptionPane.showMessageDialog(urlPanel, + failMessage); + break; + } + } + } catch (UnsupportedFlavorException e) { + testFailed("UnsupportedFlavorException - " + + "test Failed"); + } catch (IOException e) { + testFailed("IOException - test Failed"); + } + } + + return true; + } + }); + + urlFrame.setBounds(500, 10, 200, 200); + urlFrame.setVisible(true); + } + }); + } + + private void createInstructionUI() { + mainFrame = new Frame("Drag and drop link from web browser"); + layout = new GridBagLayout(); + mainControlPanel = new Panel(layout); + resultButtonPanel = new Panel(layout); + + GridBagConstraints gbc = new GridBagConstraints(); + String instructions + = "INSTRUCTIONS:" + + "\n 1. Open any browser." + + "\n 2. Select and drag URL from the browser page and " + + "drop it on the panel" + + "\n 3. If test fails, then a popup message will be displayed," + + " click Ok and \n click Fail button." + + "\n 5. Otherwise test passed. Click Pass button."; + + instructionTextArea = new TextArea(); + instructionTextArea.setText(instructions); + instructionTextArea.setEnabled(false); + instructionTextArea.setBackground(Color.white); + + gbc.gridx = 0; + gbc.gridy = 0; + gbc.fill = GridBagConstraints.HORIZONTAL; + mainControlPanel.add(instructionTextArea, gbc); + + passButton = new Button("Pass"); + passButton.setName("Pass"); + passButton.addActionListener(this); + + failButton = new Button("Fail"); + failButton.setName("Fail"); + failButton.addActionListener(this); + + gbc.gridx = 0; + gbc.gridy = 0; + resultButtonPanel.add(passButton, gbc); + gbc.gridx = 1; + gbc.gridy = 0; + resultButtonPanel.add(failButton, gbc); + gbc.gridx = 0; + gbc.gridy = 1; + mainControlPanel.add(resultButtonPanel, gbc); + + mainFrame.add(mainControlPanel); + mainFrame.pack(); + mainFrame.setVisible(true); + } + + @Override + public void actionPerformed(ActionEvent ae) { + if (ae.getSource() instanceof Button) { + Button btn = (Button) ae.getSource(); + switch (btn.getName()) { + case "Pass": + testPassed = true; + isInterrupted = true; + mainThread.interrupt(); + break; + + case "Fail": + testFailed("Dragging link from web browser Failed"); + break; + } + } + } + + public static void cleanUp() { + urlFrame.dispose(); + mainFrame.dispose(); + } + + public static void testFailed(String message) { + testPassed = false; + isInterrupted = true; + failMessage = message; + mainThread.interrupt(); + } + + public static void main(final String[] args) throws Exception { + + DragLinkFromBrowser linkFromBrowser = new DragLinkFromBrowser(); + linkFromBrowser.createInstructionUI(); + linkFromBrowser.dragLinkFromWebBrowser(); + + mainThread = Thread.currentThread(); + try { + mainThread.sleep(testTimeOut); + } catch (InterruptedException ex) { + if (!testPassed) { + throw new RuntimeException(failMessage); + } + } finally { + cleanUp(); + } + + if (!isInterrupted) { + throw new RuntimeException("Test Timed out after " + + testTimeOut / 1000 + " seconds"); + } + } +} + From 5935292ae022e970bd4075de4d704719f3b05575 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Mon, 22 Aug 2016 10:35:16 -0700 Subject: [PATCH 12/87] 8145901: Printed content is overlapping Reviewed-by: serb, psadhukhan --- .../share/native/libfontmanager/HBShaper.c | 14 ++++++++++---- .../share/native/libfontmanager/hb-jdk-font.cc | 6 ++++-- .../share/native/libfontmanager/hb-jdk.h | 1 + 3 files changed, 15 insertions(+), 6 deletions(-) diff --git a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c index 485c42a7b96..d8de3e36d92 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c +++ b/jdk/src/java.desktop/share/native/libfontmanager/HBShaper.c @@ -72,12 +72,13 @@ static int init_JNI_IDs(JNIEnv *env) { int storeGVData(JNIEnv* env, jobject gvdata, jint slot, jint baseIndex, jobject startPt, int glyphCount, hb_glyph_info_t *glyphInfo, - hb_glyph_position_t *glyphPos, hb_direction_t direction) { + hb_glyph_position_t *glyphPos, hb_direction_t direction, + float devScale) { int i; float x=0, y=0; float startX, startY; - float scale = 1.0f/64.0f; + float scale = 1.0f/64.0f/devScale; unsigned int* glyphs; float* positions; int initialCount, glyphArrayLen, posArrayLen, maxGlyphs, storeadv; @@ -216,7 +217,11 @@ JDKFontInfo* fi->ptSize = ptSize; fi->xPtSize = euclidianDistance(fi->matrix[0], fi->matrix[1]); fi->yPtSize = euclidianDistance(fi->matrix[2], fi->matrix[3]); - + if (!aat && (getenv("HB_NODEVTX") != NULL)) { + fi->devScale = fi->xPtSize / fi->ptSize; + } else { + fi->devScale = 1.0f; + } return fi; } @@ -309,7 +314,8 @@ JNIEXPORT jboolean JNICALL Java_sun_font_SunLayoutEngine_shape // by calling code. storeGVData(env, gvdata, slot, baseIndex, startPt, - glyphCount, glyphInfo, glyphPos, direction); + glyphCount, glyphInfo, glyphPos, direction, + jdkFontInfo->devScale); hb_buffer_destroy (buffer); hb_font_destroy(hbfont); diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc index 1727bb80ea3..f7df0f27cbe 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc @@ -52,6 +52,7 @@ hb_jdk_get_glyph (hb_font_t *font HB_UNUSED, *glyph = (hb_codepoint_t) env->CallIntMethod(font2D, sunFontIDs.f2dCharToGlyphMID, u); +printf("unicode=%x glyph=%x\n", unicode, *glyph); return (*glyph != 0); } @@ -81,6 +82,7 @@ hb_jdk_get_glyph_h_advance (hb_font_t *font HB_UNUSED, return 0; } fadv = env->GetFloatField(pt, sunFontIDs.xFID); + fadv *= jdkFontInfo->devScale; env->DeleteLocalRef(pt); return FloatToF26Dot6(fadv); // should this round ? @@ -324,8 +326,8 @@ static hb_font_t* _hb_jdk_font_create(JDKFontInfo *jdkFontInfo, _hb_jdk_get_font_funcs (), jdkFontInfo, (hb_destroy_func_t) _do_nothing); hb_font_set_scale (font, - FloatToF26Dot6(jdkFontInfo->xPtSize), - FloatToF26Dot6(jdkFontInfo->yPtSize)); + FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale), + FloatToF26Dot6(jdkFontInfo->ptSize*jdkFontInfo->devScale)); return font; } diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h index c17ea12ebbc..1cd8d5ba241 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk.h @@ -43,6 +43,7 @@ typedef struct JDKFontInfo_Struct { float ptSize; float xPtSize; float yPtSize; + float devScale; // How much applying the full glyph tx scales x distance. jboolean aat; } JDKFontInfo; From 82a6f087209635f3d01d0afd0f078daaaae98f22 Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Tue, 23 Aug 2016 10:27:47 +0530 Subject: [PATCH 13/87] 8163922: Print-to-file is disabled for SERVICE_FORMATTED docflavor in linux Reviewed-by: prr, jdv --- .../classes/sun/print/ServiceDialog.java | 4 +++ .../attribute/ServiceDialogValidateTest.java | 29 +++++++++++++++---- 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java index 59797508b2e..5dd2b4de046 100644 --- a/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java +++ b/jdk/src/java.desktop/share/classes/sun/print/ServiceDialog.java @@ -944,6 +944,10 @@ public class ServiceDialog extends JDialog implements ActionListener { } catch (MalformedURLException ex) { dstSupported = true; } + } else { + if (psCurrent.isAttributeCategorySupported(dstCategory)) { + dstSupported = true; + } } cbPrintToFile.setEnabled(dstSupported && dstAllowed); cbPrintToFile.setSelected(dstSelected && dstAllowed diff --git a/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java b/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java index 4216da6f015..929f76869cf 100644 --- a/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java +++ b/jdk/test/javax/print/attribute/ServiceDialogValidateTest.java @@ -22,7 +22,7 @@ */ /* * @test - * @bug 5049012 + * @bug 5049012 8163922 * @summary Verify if PrintToFile option is disabled for flavors that do not * support Destination * @requires (os.family == "linux") @@ -30,6 +30,8 @@ */ import java.awt.BorderLayout; import java.awt.FlowLayout; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; import java.io.File; import javax.print.DocFlavor; import javax.print.PrintService; @@ -72,6 +74,9 @@ public class ServiceDialogValidateTest { defService = ServiceUI.printDialog(null, 100, 100, service, defService, flavor, prSet); + ServiceUI.printDialog(null, 100, 100, service, defService, + DocFlavor.SERVICE_FORMATTED.PAGEABLE, + new HashPrintRequestAttributeSet()); } /** @@ -87,7 +92,8 @@ public class ServiceDialogValidateTest { } catch (InterruptedException e) { if (!testPassed && testGeneratedInterrupt) { throw new RuntimeException("PrintToFile option is not disabled " - + "for flavors that do not support destination"); + + "for flavors that do not support destination and/or" + + " disabled for flavors that supports destination"); } } if (!testGeneratedInterrupt) { @@ -110,10 +116,15 @@ public class ServiceDialogValidateTest { private static void doTest(Runnable action) { String description = " Visual inspection of print dialog is required.\n" - + " A print dialog will be shown.\n " - + " Please verify Print-To-File option is disabled.\n" + + " 2 print dialog will be shown.\n " + + " Please verify Print-To-File option is disabled " + + " in the 1st print dialog.\n" + " Press Cancel to close the print dialog.\n" - + " If Print-To-File option is disabled, press PASS else press FAIL"; + + " Please verify Print-To-File option is enabled " + + " in 2nd print dialog\n" + + " Press Cancel to close the print dialog.\n" + + " If the print dialog's Print-to-File behaves as mentioned, " + + " press PASS else press FAIL"; final JDialog dialog = new JDialog(); dialog.setTitle("printSelectionTest"); @@ -148,6 +159,14 @@ public class ServiceDialogValidateTest { dialog.add(mainPanel); dialog.pack(); dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); } } From f423e1290ff0e1b897bfd4f2d8b12e7b25238b6b Mon Sep 17 00:00:00 2001 From: Rachna Goel Date: Tue, 23 Aug 2016 15:35:44 +0900 Subject: [PATCH 14/87] 8163362: Reconsider reflection usage in java.awt.font.JavaAWTFontAccessImpl class Reviewed-by: naoto, okutsu, prr --- .../java/awt/font/JavaAWTFontAccessImpl.java | 25 ++++++++----------- 1 file changed, 11 insertions(+), 14 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java b/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java index cd4c9fdf224..ff2849807ba 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java +++ b/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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,7 +25,6 @@ package java.awt.font; -import java.lang.reflect.Field; import jdk.internal.misc.JavaAWTFontAccess; class JavaAWTFontAccessImpl implements JavaAWTFontAccess { @@ -33,19 +32,17 @@ class JavaAWTFontAccessImpl implements JavaAWTFontAccess { // java.awt.font.TextAttribute constants public Object getTextAttributeConstant(String name) { switch (name) { - case "RUN_DIRECTION": - case "NUMERIC_SHAPING": - case "BIDI_EMBEDDING": - case "RUN_DIRECTION_LTR": - try { - Field f = TextAttribute.class.getField(name); - return f.get(null); - } catch (NoSuchFieldException | IllegalAccessException x) { - throw new AssertionError(x); - } + case "RUN_DIRECTION": + return TextAttribute.RUN_DIRECTION; + case "NUMERIC_SHAPING": + return TextAttribute.NUMERIC_SHAPING; + case "BIDI_EMBEDDING": + return TextAttribute.BIDI_EMBEDDING; + case "RUN_DIRECTION_LTR": + return TextAttribute.RUN_DIRECTION_LTR; + default: + throw new AssertionError("Constant name is not recognized"); } - - throw new AssertionError("Constant name is not recognized"); } // java.awt.font.NumericShaper From 5a41e81056fd71c7ee557080624c3c5ef73f95d6 Mon Sep 17 00:00:00 2001 From: Prahalad Kumar Narayanan Date: Tue, 23 Aug 2016 14:47:53 +0530 Subject: [PATCH 15/87] 8158524: Adding a test case to compare the rendered output of VolatileImage with that of BufferedImage Reviewed-by: serb, psadhukhan --- .../VolatileImage/TransparentVImage.java | 260 ++++++++++++++++++ .../java/awt/image/VolatileImage/duke.gif | Bin 0 -> 1929 bytes 2 files changed, 260 insertions(+) create mode 100644 jdk/test/java/awt/image/VolatileImage/TransparentVImage.java create mode 100644 jdk/test/java/awt/image/VolatileImage/duke.gif diff --git a/jdk/test/java/awt/image/VolatileImage/TransparentVImage.java b/jdk/test/java/awt/image/VolatileImage/TransparentVImage.java new file mode 100644 index 00000000000..525099e24ff --- /dev/null +++ b/jdk/test/java/awt/image/VolatileImage/TransparentVImage.java @@ -0,0 +1,260 @@ +/* + * 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 4881082 4916294 5002129 8158524 + * @summary The test verifies whether the rendering operations on transparent + * and translucent VolatileImage objects generate identical output + * as generated with transparent and translucent BufferedImages. + * @key headful + * @run main/othervm -Dsun.java2d.uiScale=1 TransparentVImage + * @run main/othervm -Dsun.java2d.uiScale=1 -Dsun.java2d.opengl=True -Dsun.java2d.opengl.fbobject=false TransparentVImage + * @run main/othervm -Dsun.java2d.uiScale=1 -Dsun.java2d.opengl=True -Dsun.java2d.opengl.fbobject=true TransparentVImage + */ +import java.awt.GraphicsConfiguration; +import java.awt.Graphics; +import java.awt.Image; +import java.awt.Transparency; +import java.awt.image.BufferedImage; +import java.awt.image.VolatileImage; +import java.awt.Color; +import javax.swing.JFrame; +import javax.swing.JComponent; +import javax.swing.ImageIcon; +import javax.swing.SwingUtilities; + +/* + * This test draws the same contents to 4 images: 2 BufferedImages that are + * transparent and translucent and 2 VolatileImages that are transparent and + * translucent. It compares the results pixel-by-pixel and fails if the + * results are not the same. + */ +public class TransparentVImage + extends JComponent { + + BufferedImage cImgTransparent, cImgTranslucent; + VolatileImage vImgTransparent, vImgTranslucent; + Image sprite; + static final int IMAGE_SIZE = 250; + static final int WINDOW_SIZE = 600; + static boolean doneComparing = false; + static JFrame testFrame = null; + + @Override + public void paint(Graphics g) { + if (cImgTransparent == null) { + GraphicsConfiguration gc = getGraphicsConfiguration(); + // doesn't exist yet: create it (and the other images) + cImgTransparent = (BufferedImage) + gc.createCompatibleImage(IMAGE_SIZE, IMAGE_SIZE, + Transparency.BITMASK); + cImgTranslucent = (BufferedImage) + gc.createCompatibleImage(IMAGE_SIZE, IMAGE_SIZE, + Transparency.TRANSLUCENT); + vImgTransparent = gc.createCompatibleVolatileImage(IMAGE_SIZE, + IMAGE_SIZE, Transparency.BITMASK); + vImgTranslucent = gc.createCompatibleVolatileImage(IMAGE_SIZE, + IMAGE_SIZE, Transparency.TRANSLUCENT); + + String fileName = "duke.gif"; + String separator = System.getProperty("file.separator"); + String dirPath = System.getProperty("test.src", "."); + String filePath = dirPath + separator + fileName; + sprite = new ImageIcon(filePath).getImage(); + + // Now they exist; render to them + Graphics gImg[] = new Graphics[4]; + gImg[0] = cImgTransparent.getGraphics(); + gImg[1] = cImgTranslucent.getGraphics(); + gImg[2] = vImgTransparent.getGraphics(); + gImg[3] = vImgTranslucent.getGraphics(); + + for (int i = 0; i < gImg.length; ++i) { + /* + * VolatileImage utilizes the power of accelerated rendering + * using GPU. The GPU drivers for D3d and OpenGL are supplied + * by OEM vendors and are external to graphics subsystem. Thus + * one cannot guarentee that the drivers will render the + * primitives using exactly the same algorithms as those used + * by BufferedImage. This could result in minor differences in + * pixel values between BufferedImage and VolatileImage. + * + * The pipelines for D3d and OpenGL adjust the rendering with + * fudge factors to align output of GPU rendering with that of + * CPU rendering. Some of the draw calls in this paint method + * are commented indicating a need to fine tune the fudge + * factors in the future. Once they are found to work on all + * hardware, the draw calls will be enabled. + */ + // rectangular fill + gImg[i].setColor(Color.blue); + gImg[i].fillRect(0, 0, IMAGE_SIZE, IMAGE_SIZE); + + /* + * Image copy. Copy it 3 times to get any image management + * acceleration going + */ + int spriteW = sprite.getWidth(null); + gImg[i].drawImage(sprite, 0, 0, null); + gImg[i].drawImage(sprite, spriteW, 0, null); + gImg[i].drawImage(sprite, 2 * spriteW, 0, null); + + // horizontal/vertical/diagonal lines + gImg[i].setColor(Color.red); + gImg[i].drawLine(0, 0, + IMAGE_SIZE - 1, IMAGE_SIZE - 1); + gImg[i].drawLine(IMAGE_SIZE / 2, 0, + IMAGE_SIZE / 2, IMAGE_SIZE - 1); + //gImg[i].drawLine(IMAGE_SIZE, 0, + // 0, IMAGE_SIZE - 1); + gImg[i].drawLine(0, IMAGE_SIZE / 2, + IMAGE_SIZE - 1, IMAGE_SIZE / 2); + + // filled circle + //gImg[i].setColor(Color.yellow); + //gImg[i].fillOval(IMAGE_SIZE / 2 - 20, IMAGE_SIZE / 2 - 20, + // 40, 40); + } + + /* + * Now everything is drawn: let's compare pixels + * First, grab the pixel arrays + */ + int cRgbTransparent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + int cRgbTranslucent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + int vRgbTransparent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + int vRgbTranslucent[] = new int[IMAGE_SIZE * IMAGE_SIZE]; + cImgTransparent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + cRgbTransparent, 0, IMAGE_SIZE); + cImgTranslucent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + cRgbTranslucent, 0, IMAGE_SIZE); + BufferedImage bImgTransparent = vImgTransparent.getSnapshot(); + bImgTransparent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + vRgbTransparent, 0, IMAGE_SIZE); + BufferedImage bImgTranslucent = vImgTranslucent.getSnapshot(); + bImgTranslucent.getRGB(0, 0, IMAGE_SIZE, IMAGE_SIZE, + vRgbTranslucent, 0, IMAGE_SIZE); + + boolean failed = false; + for (int pixel = 0; pixel < cRgbTransparent.length; ++pixel) { + if (cRgbTransparent[pixel] != vRgbTransparent[pixel]) { + failed = true; + System.out.println("Error in transparent image: " + + "BI[" + pixel + "] = " + + Integer.toHexString(cRgbTransparent[pixel]) + + "VI[" + pixel + "] = " + + Integer.toHexString(vRgbTransparent[pixel])); + break; + } + if (cRgbTranslucent[pixel] != vRgbTranslucent[pixel]) { + failed = true; + System.out.println("Error in translucent image: " + + "BI[" + pixel + "] = " + + Integer.toHexString(cRgbTranslucent[pixel]) + + "VI[" + pixel + "] = " + + Integer.toHexString(vRgbTranslucent[pixel])); + break; + } + } + if (failed) { + throw new RuntimeException("Failed: Pixel mis-match observed"); + } + else { + System.out.println("Passed"); + } + doneComparing = true; + } + + g.drawImage(cImgTransparent, 0, 0, null); + g.drawImage(cImgTranslucent, getWidth() - IMAGE_SIZE, 0, null); + g.drawImage(vImgTransparent, 0, getHeight() - IMAGE_SIZE, null); + g.drawImage(vImgTranslucent, getWidth() - IMAGE_SIZE, + getHeight() - IMAGE_SIZE, null); + } + + private static void constructTestUI() { + testFrame = new JFrame(); + testFrame.setSize(600, 600); + testFrame.setResizable(false); + testFrame.getContentPane().add(new TransparentVImage()); + + testFrame.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE); + testFrame.setLocationRelativeTo(null); + testFrame.setVisible(true); + } + + private static void destroyTestUI() { + testFrame.dispose(); + } + + public static void main(String args[]) throws Exception { + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + // Construct the test interface + constructTestUI(); + } catch (Exception ex) { + // Throw an exception indicating error while creating UI + throw new RuntimeException("Test Failed: Error while" + + " creating the test interface."); + } + } + }); + + /* + * Wait until the image comparison between VolatileImage and + * BufferedImage is complete. + */ + while (!doneComparing) { + try { + Thread.sleep(100); + } + catch (Exception e) {} + } + + /* + * Now sleep just a little longer to let the user see the resulting + * images in the frame + */ + try { + Thread.sleep(5000); + } + catch (Exception e) {} + + SwingUtilities.invokeAndWait(new Runnable() { + @Override + public void run() { + try { + // Destroy the test interface + destroyTestUI(); + } catch (Exception ex) { + // Throw an exception indicating error while deleting UI + throw new RuntimeException("Test Failed: Error while" + + " deleting the test interface."); + } + } + }); + } +} diff --git a/jdk/test/java/awt/image/VolatileImage/duke.gif b/jdk/test/java/awt/image/VolatileImage/duke.gif new file mode 100644 index 0000000000000000000000000000000000000000..ed32e0ff79b05c07b82863ce6fb07fa9898adaa2 GIT binary patch literal 1929 zcmWlYe^AtB8pi`HvM4_?{J2I$8$dLc1#@!R2zwgXMWdj^k;9xr+bDW&4{JlE8WpDj z7F-cwwK{H<)?L&#SJz$!;hJ{%BY2FYf)Wp^xl?aq!5Xcdi$c#hV~>m9_n-Hl=Xsy+ z=li^?*Q~;pZ+R1N1J40KRkeWM7ew3~jLM24A{CM-A}~TzqzYpq&od0GC=z71!w_=b z-==B0rt2t*nA}((5YSLs6a*Z@X__WqiSjTW6oLo{5km&|K1mGAimYjhs#wwZtvV8SV~7LCFpgub+-TTAk%UQb0dE_cj+pc?!+0o?qG$?% zVFD)%!w7Z;g)ndE8Uk6Aky=+kLaUQ{UW`XS?Nn*s@SQ{VmFgGdkV{&&98EcEQ5hjc@H$`e)fX zj@&GdchxpMUo|-A^M4iBP3(#Ib53Ap?5{nGT7SBA_V!o!TTzL5R~FUWe)4X?@iTd8 z1;TcF^rQLj?4p0uy?@ikb2eUSXdHVa_jIn=@W%a<6~57D>am6&Z!{lzc=@ZbuGB8` zpU38H8d~@82Da!+qdYG5ls&Cx?~|oPMnbqTHMw%I*KlV~?fc{rSwe29?Om}fsknG# z@n5IwY=4Mx>>0WJLG>=yJX^WbHA30iQ$H!X)3<4K zBe1|sf3NKKTS;)mg{$k(2eDJG^u5=&x{@M!V>EWgzRA((>}?o{WQBehp1mIHU!BGG zYz5_6B(+KIVdCVoum2ItM&gXZd+SB^vQTN=a zeYbbah=i-xCho2{4Pazv_i%2mH`EkM{r8XYDLbdY@(a7Ud}$%!$QrTN_DqwNXA9~g zTGKxKyfto7NDp;5A3O5zgb(hyxjN@OAG!(zy^*Ug4!yjF=Y*8aHA@ovB1({&a4;sR zTf1CVC{>Pgy`m$lG;P1$pC_6F7u%iP+qz0q4{lXT`i9g-ThiYgO^GXC`f?JNo*|@p zr{b%U-tSKw99q0|YJa9{Va?`H{IaNICo>p5lGEY*+IDR4bfIUwq~CTRuC_mGWA%~W zea{@eKJ(Iq^7MvdsPsR%&vt$@4i&s?bPptz#y#!FcRZEaMS0WFTyXMCUEfsNxnJ_9 zPwpt`Er4O>``2G{7=4r1GCSTO8#0xw+{<^L4X(K8y1wKj72KLrYD}Y7SJuY7y==wf z;UkI5?(v?h+4r;vR{P*U`ul~=D@U7K5$eV8c!%rX-38vE>azU80UrhFXCv#d`(ylZS4+i2a^vI91MTIxCx%9gd2&N&D9RC&xcpx8#f=GZv%9;F z#?CEVT%UV$nk;L%RJA+d=f8ZB@U*Xz-TZbG?HKKT(VJZMBH!)$#qRuwbFc%Aljqha zoNBs8od~V$_^vux0ZSk!iP!hI($t35SxY8`FV{pxCjpU}Ova2VIg1&>V)CvvMb_ Date: Tue, 23 Aug 2016 18:15:27 +0300 Subject: [PATCH 16/87] 8162840: Desktop. enableSuddenTermination() has no effect Reviewed-by: serb --- .../macosx/classes/com/apple/eawt/_AppEventHandler.java | 7 ++++++- .../macosx/classes/com/apple/eawt/_AppMiscHandlers.java | 8 ++++++++ 2 files changed, 14 insertions(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java index a417f692ab8..e64e9b158b5 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppEventHandler.java @@ -171,7 +171,8 @@ class _AppEventHandler { currentQuitResponse = null; try { - if (defaultQuitAction == QuitStrategy.NORMAL_EXIT) System.exit(0); + if (defaultQuitAction == QuitStrategy.NORMAL_EXIT + || _AppMiscHandlers.isSuddenTerminationEnbaled()) System.exit(0); if (defaultQuitAction != QuitStrategy.CLOSE_ALL_WINDOWS) { throw new RuntimeException("Unknown quit action"); @@ -422,6 +423,10 @@ class _AppEventHandler { } void performUsing(final QuitHandler handler, final _NativeEvent event) { + if (_AppMiscHandlers.isSuddenTerminationEnbaled()) { + performDefaultAction(event); + return; + } final MacQuitResponse response = obtainQuitResponse(); // obtains the "current" quit response handler.handleQuitRequestWith(new QuitEvent(), response); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java index 6f892caaa91..1851e2aa90c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppMiscHandlers.java @@ -26,6 +26,8 @@ package com.apple.eawt; class _AppMiscHandlers { + private static boolean isSuddenTerminationEnabled; + private static native void nativeOpenHelpViewer(); private static native void nativeRequestActivation(final boolean allWindows); @@ -47,10 +49,16 @@ class _AppMiscHandlers { } static void enableSuddenTermination() { + isSuddenTerminationEnabled = true; nativeEnableSuddenTermination(); } static void disableSuddenTermination() { + isSuddenTerminationEnabled = false; nativeDisableSuddenTermination(); } + + public static boolean isSuddenTerminationEnbaled() { + return isSuddenTerminationEnabled; + } } From 201065a6bad37162b03329a36d2e3b23631a601f Mon Sep 17 00:00:00 2001 From: Sergey Bylokhov Date: Tue, 23 Aug 2016 20:45:35 +0300 Subject: [PATCH 17/87] 8160217: JavaSound should clean up resources better Reviewed-by: prr --- .../com/sun/media/sound/ModelByteBuffer.java | 14 ++++++++------ .../ModelByteBuffer/GetInputStream.java | 18 +++++++++++------- .../midi/Gervill/ModelByteBuffer/GetRoot.java | 12 +++++++----- .../midi/Gervill/ModelByteBuffer/Load.java | 13 +++++++------ .../midi/Gervill/ModelByteBuffer/LoadAll.java | 13 +++++++------ .../NewModelByteBufferByteArray.java | 12 +++++++----- .../NewModelByteBufferByteArrayIntInt.java | 12 +++++++----- .../NewModelByteBufferFile.java | 12 +++++++----- .../NewModelByteBufferFileLongLong.java | 12 +++++++----- .../RandomFileInputStream/Available.java | 13 +++++++------ .../RandomFileInputStream/Close.java | 13 +++++++------ .../RandomFileInputStream/MarkReset.java | 13 +++++++------ .../RandomFileInputStream/MarkSupported.java | 13 +++++++------ .../RandomFileInputStream/Read.java | 13 +++++++------ .../RandomFileInputStream/ReadByte.java | 13 +++++++------ .../RandomFileInputStream/ReadByteIntInt.java | 13 +++++++------ .../RandomFileInputStream/Skip.java | 13 +++++++------ .../Gervill/ModelByteBuffer/SubbufferLong.java | 12 +++++++----- .../ModelByteBuffer/SubbufferLongLong.java | 12 +++++++----- .../SubbufferLongLongBoolean.java | 12 +++++++----- .../midi/Gervill/ModelByteBuffer/Unload.java | 13 +++++++------ .../midi/Gervill/ModelByteBuffer/WriteTo.java | 14 ++++++++------ .../ModelByteBufferWavetable/OpenStream.java | 13 +++++++------ .../FrameLengthAfterConversion.java | 4 +++- .../WriteUnsupportedAudioFormat.java | 4 +++- 25 files changed, 173 insertions(+), 133 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java b/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java index 028efffbd12..ead39be2867 100644 --- a/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java +++ b/jdk/src/java.desktop/share/classes/com/sun/media/sound/ModelByteBuffer.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2013, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -200,11 +200,13 @@ public final class ModelByteBuffer { public void writeTo(OutputStream out) throws IOException { if (root.file != null && root.buffer == null) { - InputStream is = getInputStream(); - byte[] buff = new byte[1024]; - int ret; - while ((ret = is.read(buff)) != -1) - out.write(buff, 0, ret); + try (InputStream is = getInputStream()) { + byte[] buff = new byte[1024]; + int ret; + while ((ret = is.read(buff)) != -1) { + out.write(buff, 0, ret); + } + } } else out.write(array(), (int) arrayOffset(), (int) capacity()); } diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java index e1a39d3c500..72a19c9e80a 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetInputStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,7 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -54,13 +56,13 @@ public class GetInputStream { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { @@ -76,7 +78,9 @@ public class GetInputStream { buff = new ModelByteBuffer(test_byte_array); byte[] b = new byte[test_byte_array.length]; - buff.getInputStream().read(b); + try (InputStream is = buff.getInputStream()) { + is.read(b); + } for (int j = 0; j < b.length; j++) if(b[i] != test_byte_array[i]) throw new RuntimeException("Byte array compare fails!"); diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java index b9928253678..829900f8ba9 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/GetRoot.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class GetRoot { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java index 734ed37b4ac..b589048ff98 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Load.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,7 +28,8 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -54,13 +55,13 @@ public class Load { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java index e912ee98698..5549393fcda 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/LoadAll.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,7 +28,8 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -56,13 +57,13 @@ public class LoadAll { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java index edcef873e0a..801926a5c5e 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArray.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferByteArray { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java index 3d1ad726598..4c193b9e484 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferByteArrayIntInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferByteArrayIntInt { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java index 5a200045671..90b4be57bf2 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFile.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferFile { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java index d55466ae5e8..85f93bd852b 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/NewModelByteBufferFileLongLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class NewModelByteBufferFileLongLong { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java index c4da3ad8183..659f33c66d0 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Available.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Available { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java index 2bfd5891953..4785d4097d0 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Close.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Close { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java index bcd8584834e..f8a3570aef7 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkReset.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class MarkReset { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java index e505d0b9d96..41ed42e08fa 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/MarkSupported.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class MarkSupported { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java index e8fb2818fca..523adf4eaca 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Read.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Read { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java index a847b56783b..ceb33fb25fd 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class ReadByte { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java index c8c0a0fe64d..1570df03fae 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/ReadByteIntInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class ReadByteIntInt { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java index 96ce0fef5e8..d80a1c6ada5 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/RandomFileInputStream/Skip.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 +28,9 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +56,13 @@ public class Skip { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java index 14eba08157e..ad4dc48ea6e 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class SubbufferLong { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java index d6f9cd82521..75b7bbc45c2 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class SubbufferLongLong { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java index d59349ce709..df84eaf6601 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/SubbufferLongLongBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,8 @@ import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -53,13 +55,13 @@ public class SubbufferLongLongBoolean { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java index 1c15fa3a176..8d8895f0266 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/Unload.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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,7 +28,8 @@ import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -54,13 +55,13 @@ public class Unload { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java index 61ebd221659..2f0b1960c90 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBuffer/WriteTo.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2007, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2007, 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 @@ -29,7 +29,9 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; -import java.io.IOException; +import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -55,13 +57,13 @@ public class WriteTo { test_byte_array = new byte[testarray.length*2]; AudioFloatConverter.getConverter(format).toByteArray(testarray, test_byte_array); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(test_byte_array); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(test_byte_array); + } } static void tearDown() throws Exception { - if(!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void main(String[] args) throws Exception { diff --git a/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java b/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java index 01e3b7a26af..7e659d46499 100644 --- a/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java +++ b/jdk/test/javax/sound/midi/Gervill/ModelByteBufferWavetable/OpenStream.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -30,6 +30,8 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.FileOutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import javax.sound.sampled.*; @@ -99,16 +101,15 @@ public class OpenStream { buffer_wave = new ModelByteBuffer(baos.toByteArray()); test_file = File.createTempFile("test", ".raw"); - FileOutputStream fos = new FileOutputStream(test_file); - fos.write(baos.toByteArray()); - fos.close(); + try (FileOutputStream fos = new FileOutputStream(test_file)) { + fos.write(baos.toByteArray()); + } buffer_wave_ondisk = new ModelByteBuffer(test_file); } static void tearDown() throws Exception { - if (!test_file.delete()) - test_file.deleteOnExit(); + Files.delete(Paths.get(test_file.getAbsolutePath())); } public static void testOpenStream(ModelByteBufferWavetable wavetable) diff --git a/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java b/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java index e32e7723db5..f61126bd609 100644 --- a/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java +++ b/jdk/test/javax/sound/sampled/AudioInputStream/FrameLengthAfterConversion.java @@ -26,6 +26,8 @@ import java.io.ByteArrayOutputStream; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -162,7 +164,7 @@ public final class FrameLengthAfterConversion { ais = AudioSystem.getAudioInputStream(temp); final long frameLength = ais.getFrameLength(); ais.close(); - temp.delete(); + Files.delete(Paths.get(temp.getAbsolutePath())); validate(frameLength); } catch (IllegalArgumentException | UnsupportedAudioFileException | IOException ignored) { diff --git a/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java b/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java index 893205944c3..8b0d8993e87 100644 --- a/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java +++ b/jdk/test/javax/sound/sampled/spi/AudioFileWriter/WriteUnsupportedAudioFormat.java @@ -27,6 +27,8 @@ import java.io.File; import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; +import java.nio.file.Paths; import java.util.ArrayList; import java.util.List; @@ -91,7 +93,6 @@ public final class WriteUnsupportedAudioFormat { } catch (final IOException e) { throw new RuntimeException(e); } - FILE.deleteOnExit(); for (final Boolean end : new boolean[]{false, true}) { for (final int sampleSize : sampleBits) { @@ -134,6 +135,7 @@ public final class WriteUnsupportedAudioFormat { } } } + Files.delete(Paths.get(FILE.getAbsolutePath())); } /** From 494e502e0cab046eca312e1c05f844029515c3c5 Mon Sep 17 00:00:00 2001 From: Alexander Scherbatiy Date: Wed, 24 Aug 2016 00:23:49 +0400 Subject: [PATCH 18/87] 8129854: Remove reflection from AWT/Swing classes Reviewed-by: serb --- .../classes/apple/laf/JRSUIConstants.java | 41 ++++++++----- .../com/apple/eawt/_AppDockIconHandler.java | 18 ++---- .../classes/com/apple/laf/AquaIcon.java | 5 +- .../com/apple/laf/AquaImageFactory.java | 4 +- .../classes/com/apple/laf/AquaUtils.java | 39 +------------ .../sun/lwawt/macosx/CAccessibility.java | 24 +------- .../classes/sun/lwawt/macosx/CAccessible.java | 32 +++------- .../classes/sun/lwawt/macosx/CImage.java | 19 ++++++ .../share/classes/java/awt/AWTEvent.java | 58 +++---------------- .../share/classes/java/awt/Component.java | 42 +++----------- .../java/awt/KeyboardFocusManager.java | 31 ++-------- .../classes/java/awt/SequencedEvent.java | 4 ++ .../classes/java/awt/event/InputEvent.java | 6 ++ .../classes/java/awt/event/KeyEvent.java | 5 ++ .../javax/accessibility/AccessibleBundle.java | 12 ++++ .../accessibility/AccessibleContext.java | 10 ++++ .../share/classes/javax/swing/ImageIcon.java | 9 +-- .../share/classes/javax/swing/JComponent.java | 16 +++++ .../classes/javax/swing/text/GlyphView.java | 18 +----- .../javax/swing/text/ParagraphView.java | 16 +---- .../javax/swing/text/html/HTMLEditorKit.java | 7 +-- .../share/classes/sun/applet/AppletPanel.java | 30 +--------- .../share/classes/sun/awt/AWTAccessor.java | 58 +++++++++++++++++-- .../share/classes/sun/awt/SunToolkit.java | 20 ------- .../classes/sun/swing/SwingAccessor.java | 33 +++++++++++ .../classes/sun/awt/X11/XComponentPeer.java | 42 +------------- .../awt/X11/XMouseDragGestureRecognizer.java | 4 -- .../unix/classes/sun/awt/X11/XWindow.java | 3 - 28 files changed, 244 insertions(+), 362 deletions(-) diff --git a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java index 272b1f1f25b..8e105132eaa 100644 --- a/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java +++ b/jdk/src/java.desktop/macosx/classes/apple/laf/JRSUIConstants.java @@ -25,7 +25,6 @@ package apple.laf; -import java.lang.reflect.Field; import java.nio.ByteBuffer; import java.lang.annotation.Native; @@ -70,6 +69,21 @@ public final class JRSUIConstants { throw new RuntimeException("Constant not implemented in native: " + this); } + private String getConstantName(Key hit) { + if (hit == VALUE) { + return "VALUE"; + } else if (hit == THUMB_PROPORTION) { + return "THUMB_PROPORTION"; + } else if (hit == THUMB_START) { + return "THUMB_START"; + } else if (hit == WINDOW_TITLE_BAR_HEIGHT) { + return "WINDOW_TITLE_BAR_HEIGHT"; + } else if (hit == THUMB_START) { + return "ANIMATION_FRAME"; + } + return getClass().getSimpleName(); + } + public String toString() { return getConstantName(this) + (ptr == 0 ? "(unlinked)" : ""); } @@ -138,7 +152,7 @@ public final class JRSUIConstants { } public String toString() { - return getConstantName(this); + return getClass().getSimpleName(); } } @@ -779,6 +793,17 @@ public final class JRSUIConstants { return hit > 0; } + private String getConstantName(Hit hit) { + if (hit == UNKNOWN) { + return "UNKNOWN"; + } else if (hit == NONE) { + return "NONE"; + } else if (hit == HIT) { + return "HIT"; + } + return getClass().getSimpleName(); + } + public String toString() { return getConstantName(this); } @@ -829,16 +854,4 @@ public final class JRSUIConstants { } return Hit.UNKNOWN; } - - static String getConstantName(final Object object) { - final Class clazz = object.getClass(); - try { - for (final Field field : clazz.getFields()) { - if (field.get(null) == object) { - return field.getName(); - } - } - } catch (final Exception e) {} - return clazz.getSimpleName(); - } } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java index eab1efb3447..c9c0c9bcf4d 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/eawt/_AppDockIconHandler.java @@ -72,7 +72,7 @@ class _AppDockIconHandler { public void setDockIconImage(final Image image) { try { - final CImage cImage = getCImageCreator().createFromImage(image); + final CImage cImage = CImage.createFromImage(image); final long nsImagePtr = getNSImagePtrFrom(cImage); nativeSetDockIconImage(nsImagePtr); } catch (final Throwable e) { @@ -84,7 +84,11 @@ class _AppDockIconHandler { try { final long dockNSImage = nativeGetDockIconImage(); if (dockNSImage == 0) return null; - return getCImageCreator().createImageUsingNativeSize(dockNSImage); + final Method getCreatorMethod = CImage.class.getDeclaredMethod( + "getCreator", new Class[]{}); + getCreatorMethod.setAccessible(true); + Creator imageCreator = (Creator) getCreatorMethod.invoke(null, new Object[]{}); + return imageCreator.createImageUsingNativeSize(dockNSImage); } catch (final Throwable e) { throw new RuntimeException(e); } @@ -98,16 +102,6 @@ class _AppDockIconHandler { nativeSetDockIconProgress(value); } - static Creator getCImageCreator() { - try { - final Method getCreatorMethod = CImage.class.getDeclaredMethod("getCreator", new Class[] {}); - getCreatorMethod.setAccessible(true); - return (Creator)getCreatorMethod.invoke(null, new Object[] {}); - } catch (final Throwable e) { - throw new RuntimeException(e); - } - } - static long getNSImagePtrFrom(final CImage cImage) { if (cImage == null) return 0; diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java index b4bc1e69d58..936fe567c66 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaIcon.java @@ -37,6 +37,7 @@ import apple.laf.*; import com.apple.laf.AquaUtilControlSize.*; import com.apple.laf.AquaUtils.RecyclableSingleton; +import sun.lwawt.macosx.CImage; public class AquaIcon { interface InvertableIcon extends Icon { @@ -226,7 +227,7 @@ public class AquaIcon { } Image createImage() { - return AquaUtils.getCImageCreator().createImageOfFile(file.getAbsolutePath(), getIconWidth(), getIconHeight()); + return CImage.createImageOfFile(file.getAbsolutePath(), getIconWidth(), getIconHeight()); } } @@ -299,7 +300,7 @@ public class AquaIcon { } Image createImage() { - return AquaUtils.getCImageCreator().createSystemImageFromSelector( + return CImage.createSystemImageFromSelector( selector, getIconWidth(), getIconHeight()); } } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java index c26bcae3d06..5d43a41e502 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaImageFactory.java @@ -46,8 +46,8 @@ import com.apple.laf.AquaIcon.JRSUIControlSpec; import com.apple.laf.AquaIcon.SystemIcon; import com.apple.laf.AquaUtils.RecyclableObject; import com.apple.laf.AquaUtils.RecyclableSingleton; -import java.awt.image.MultiResolutionImage; import sun.awt.image.MultiResolutionCachedImage; +import sun.lwawt.macosx.CImage; public class AquaImageFactory { public static IconUIResource getConfirmImageIcon() { @@ -73,7 +73,7 @@ public class AquaImageFactory { public static IconUIResource getLockImageIcon() { // public, because UIDefaults.ProxyLazyValue uses reflection to get this value if (JRSUIUtils.Images.shouldUseLegacySecurityUIPath()) { - final Image lockIcon = AquaUtils.getCImageCreator().createImageFromFile("/System/Library/CoreServices/SecurityAgent.app/Contents/Resources/Security.icns", kAlertIconSize, kAlertIconSize); + final Image lockIcon = CImage.createImageFromFile("/System/Library/CoreServices/SecurityAgent.app/Contents/Resources/Security.icns", kAlertIconSize, kAlertIconSize); return getAppIconCompositedOn(lockIcon); } diff --git a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java index 65c38cca879..5e7d160943c 100644 --- a/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java +++ b/jdk/src/java.desktop/macosx/classes/com/apple/laf/AquaUtils.java @@ -41,8 +41,6 @@ import jdk.internal.loader.ClassLoaders; import sun.awt.AppContext; -import sun.lwawt.macosx.CImage; -import sun.lwawt.macosx.CImage.Creator; import sun.lwawt.macosx.CPlatformWindow; import sun.reflect.misc.ReflectUtil; import sun.security.action.GetPropertyAction; @@ -50,6 +48,7 @@ import sun.swing.SwingUtilities2; import com.apple.laf.AquaImageFactory.SlicedImageControl; import sun.awt.image.MultiResolutionCachedImage; +import sun.swing.SwingAccessor; final class AquaUtils { @@ -78,32 +77,6 @@ final class AquaUtils { } } - private static Creator getCImageCreatorInternal() { - return AccessController.doPrivileged(new PrivilegedAction() { - @Override - public Creator run() { - try { - final Method getCreatorMethod = CImage.class.getDeclaredMethod( - "getCreator", new Class[] {}); - getCreatorMethod.setAccessible(true); - return (Creator)getCreatorMethod.invoke(null, new Object[] {}); - } catch (final Exception ignored) { - return null; - } - } - }); - } - - private static final RecyclableSingleton cImageCreator = new RecyclableSingleton() { - @Override - protected Creator getInstance() { - return getCImageCreatorInternal(); - } - }; - static Creator getCImageCreator() { - return cImageCreator.get(); - } - static Image generateSelectedDarkImage(final Image image) { final ImageFilter filter = new IconImageFilter() { @Override @@ -405,15 +378,9 @@ final class AquaUtils { } }; - private static final Integer OPAQUE_SET_FLAG = 24; // private int JComponent.OPAQUE_SET + private static final int OPAQUE_SET_FLAG = 24; // private int JComponent.OPAQUE_SET static boolean hasOpaqueBeenExplicitlySet(final JComponent c) { - final Method method = getJComponentGetFlagMethod.get(); - if (method == null) return false; - try { - return Boolean.TRUE.equals(method.invoke(c, OPAQUE_SET_FLAG)); - } catch (final Throwable ignored) { - return false; - } + return SwingAccessor.getJComponentAccessor().getFlag(c, OPAQUE_SET_FLAG); } private static boolean isWindowTextured(final Component c) { diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java index 00cb5274be2..3307e5b0e86 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessibility.java @@ -37,6 +37,7 @@ import sun.awt.AWTAccessor; import javax.accessibility.*; import javax.swing.*; +import sun.awt.AWTAccessor; class CAccessibility implements PropertyChangeListener { private static Set ignoredRoles; @@ -205,33 +206,12 @@ class CAccessibility implements PropertyChangeListener { }, c); } - static Field getAccessibleBundleKeyFieldWithReflection() { - try { - final Field fieldKey = AccessibleBundle.class.getDeclaredField("key"); - fieldKey.setAccessible(true); - return fieldKey; - } catch (final SecurityException e) { - e.printStackTrace(); - } catch (final NoSuchFieldException e) { - e.printStackTrace(); - } - return null; - } - private static final Field FIELD_KEY = getAccessibleBundleKeyFieldWithReflection(); - static String getAccessibleRoleFor(final Accessible a) { final AccessibleContext ac = a.getAccessibleContext(); if (ac == null) return null; final AccessibleRole role = ac.getAccessibleRole(); - try { - return (String)FIELD_KEY.get(role); - } catch (final IllegalArgumentException e) { - e.printStackTrace(); - } catch (final IllegalAccessException e) { - e.printStackTrace(); - } - return null; + return AWTAccessor.getAccessibleBundleAccessor().getKey(role); } public static String getAccessibleRole(final Accessible a, final Component c) { diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java index 6ac0a07ca0f..d3d3dca9538 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CAccessible.java @@ -28,7 +28,6 @@ package sun.lwawt.macosx; import java.awt.Component; import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; -import java.lang.reflect.Field; import javax.accessibility.Accessible; import javax.accessibility.AccessibleContext; @@ -41,36 +40,23 @@ import static javax.accessibility.AccessibleContext.ACCESSIBLE_ACTIVE_DESCENDANT import static javax.accessibility.AccessibleContext.ACCESSIBLE_CARET_PROPERTY; import static javax.accessibility.AccessibleContext.ACCESSIBLE_SELECTION_PROPERTY; import static javax.accessibility.AccessibleContext.ACCESSIBLE_TEXT_PROPERTY; +import sun.awt.AWTAccessor; class CAccessible extends CFRetainedResource implements Accessible { - static Field getNativeAXResourceField() { - try { - final Field field = AccessibleContext.class.getDeclaredField("nativeAXResource"); - field.setAccessible(true); - return field; - } catch (final Exception e) { - e.printStackTrace(); - return null; - } - } - - private static Field nativeAXResourceField = getNativeAXResourceField(); public static CAccessible getCAccessible(final Accessible a) { if (a == null) return null; AccessibleContext context = a.getAccessibleContext(); - try { - final CAccessible cachedCAX = (CAccessible) nativeAXResourceField.get(context); - if (cachedCAX != null) return cachedCAX; - - final CAccessible newCAX = new CAccessible(a); - nativeAXResourceField.set(context, newCAX); - return newCAX; - } catch (final Exception e) { - e.printStackTrace(); - return null; + AWTAccessor.AccessibleContextAccessor accessor + = AWTAccessor.getAccessibleContextAccessor(); + final CAccessible cachedCAX = (CAccessible) accessor.getNativeAXResource(context); + if (cachedCAX != null) { + return cachedCAX; } + final CAccessible newCAX = new CAccessible(a); + accessor.setNativeAXResource(context, newCAX); + return newCAX; } private static native void unregisterFromCocoaAXSystem(long ptr); diff --git a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java index a5504cbee25..61f41a2c70f 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java +++ b/jdk/src/java.desktop/macosx/classes/sun/lwawt/macosx/CImage.java @@ -56,6 +56,25 @@ public class CImage extends CFRetainedResource { return creator; } + // This is used to create a CImage that represents the icon of the given file. + public static Image createImageOfFile(String file, int width, int height) { + return getCreator().createImageOfFile(file, width, height); + } + + public static Image createSystemImageFromSelector(String iconSelector, + int width, int height) { + return getCreator().createSystemImageFromSelector(iconSelector, width, height); + } + + public static Image createImageFromFile(String file, double width, double height) { + return getCreator().createImageFromFile(file, width, height); + } + + // This is used to create a CImage from a Image + public static CImage createFromImage(final Image image) { + return getCreator().createFromImage(image); + } + public static class Creator { Creator() { } diff --git a/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java b/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java index 1c723aeb133..9250597ac81 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/AWTEvent.java @@ -284,35 +284,6 @@ public abstract class AWTEvent extends EventObject { }); } - private static synchronized Field get_InputEvent_CanAccessSystemClipboard() { - if (inputEvent_CanAccessSystemClipboard_Field == null) { - inputEvent_CanAccessSystemClipboard_Field = - java.security.AccessController.doPrivileged( - new java.security.PrivilegedAction() { - public Field run() { - Field field = null; - try { - field = InputEvent.class. - getDeclaredField("canAccessSystemClipboard"); - field.setAccessible(true); - return field; - } catch (SecurityException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got SecurityException ", e); - } - } catch (NoSuchFieldException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.get_InputEvent_CanAccessSystemClipboard() got NoSuchFieldException ", e); - } - } - return null; - } - }); - } - - return inputEvent_CanAccessSystemClipboard_Field; - } - /** * Initialize JNI field and method IDs for fields that may be * accessed from C. @@ -593,33 +564,20 @@ public abstract class AWTEvent extends EventObject { that.bdata = this.bdata; // Copy canAccessSystemClipboard value from this into that. if (this instanceof InputEvent && that instanceof InputEvent) { - Field field = get_InputEvent_CanAccessSystemClipboard(); - if (field != null) { - try { - boolean b = field.getBoolean(this); - field.setBoolean(that, b); - } catch(IllegalAccessException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.copyPrivateDataInto() got IllegalAccessException ", e); - } - } - } + + AWTAccessor.InputEventAccessor accessor + = AWTAccessor.getInputEventAccessor(); + + boolean b = accessor.canAccessSystemClipboard((InputEvent) this); + accessor.setCanAccessSystemClipboard((InputEvent) that, b); } that.isSystemGenerated = this.isSystemGenerated; } void dispatched() { if (this instanceof InputEvent) { - Field field = get_InputEvent_CanAccessSystemClipboard(); - if (field != null) { - try { - field.setBoolean(this, false); - } catch(IllegalAccessException e) { - if (log.isLoggable(PlatformLogger.Level.FINE)) { - log.fine("AWTEvent.dispatched() got IllegalAccessException ", e); - } - } - } + AWTAccessor.getInputEventAccessor(). + setCanAccessSystemClipboard((InputEvent) this, false); } } } // class AWTEvent diff --git a/jdk/src/java.desktop/share/classes/java/awt/Component.java b/jdk/src/java.desktop/share/classes/java/awt/Component.java index c2a021fd595..25c6ee2b1aa 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/Component.java +++ b/jdk/src/java.desktop/share/classes/java/awt/Component.java @@ -53,13 +53,11 @@ import java.beans.Transient; import java.awt.im.InputContext; import java.awt.im.InputMethodRequests; import java.awt.dnd.DropTarget; -import java.lang.reflect.InvocationTargetException; -import java.lang.reflect.Method; import java.security.AccessController; -import java.security.PrivilegedAction; import java.security.AccessControlContext; import javax.accessibility.*; import java.applet.Applet; +import javax.swing.JComponent; import sun.awt.ComponentFactory; import sun.security.action.GetPropertyAction; @@ -81,6 +79,7 @@ import sun.java2d.pipe.hw.ExtendedBufferCapabilities; import static sun.java2d.pipe.hw.ExtendedBufferCapabilities.VSyncType.*; import sun.awt.RequestFocusController; import sun.java2d.SunGraphicsEnvironment; +import sun.swing.SwingAccessor; import sun.util.logging.PlatformLogger; /** @@ -8695,6 +8694,9 @@ public abstract class Component implements ImageObserver, MenuContainer, * the Swing package private method {@code compWriteObjectNotify}. */ private void doSwingSerialization() { + if (!(this instanceof JComponent)) { + return; + } @SuppressWarnings("deprecation") Package swingPackage = Package.getPackage("javax.swing"); // For Swing serialization to correctly work Swing needs to @@ -8707,36 +8709,10 @@ public abstract class Component implements ImageObserver, MenuContainer, klass = klass.getSuperclass()) { if (klass.getPackage() == swingPackage && klass.getClassLoader() == null) { - final Class swingClass = klass; - // Find the first override of the compWriteObjectNotify method - Method[] methods = AccessController.doPrivileged( - new PrivilegedAction() { - public Method[] run() { - return swingClass.getDeclaredMethods(); - } - }); - for (int counter = methods.length - 1; counter >= 0; - counter--) { - final Method method = methods[counter]; - if (method.getName().equals("compWriteObjectNotify")){ - // We found it, use doPrivileged to make it accessible - // to use. - AccessController.doPrivileged(new PrivilegedAction() { - public Void run() { - method.setAccessible(true); - return null; - } - }); - // Invoke the method - try { - method.invoke(this, (Object[]) null); - } catch (IllegalAccessException iae) { - } catch (InvocationTargetException ite) { - } - // We're done, bail. - return; - } - } + + SwingAccessor.getJComponentAccessor() + .compWriteObjectNotify((JComponent) this); + return; } } } diff --git a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java index aa9d64367a4..1e9e2f4bfd0 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java +++ b/jdk/src/java.desktop/share/classes/java/awt/KeyboardFocusManager.java @@ -40,8 +40,6 @@ import java.beans.VetoableChangeSupport; import java.lang.ref.WeakReference; -import java.lang.reflect.Field; - import java.security.AccessController; import java.security.PrivilegedAction; @@ -140,6 +138,10 @@ public abstract class KeyboardFocusManager public void removeLastFocusRequest(Component heavyweight) { KeyboardFocusManager.removeLastFocusRequest(heavyweight); } + @Override + public Component getMostRecentFocusOwner(Window window) { + return KeyboardFocusManager.getMostRecentFocusOwner(window); + } public void setMostRecentFocusOwner(Window window, Component component) { KeyboardFocusManager.setMostRecentFocusOwner(window, component); } @@ -3053,32 +3055,9 @@ public abstract class KeyboardFocusManager } } - static Field proxyActive; // Accessor to private field isProxyActive of KeyEvent private static boolean isProxyActiveImpl(KeyEvent e) { - if (proxyActive == null) { - proxyActive = AccessController.doPrivileged(new PrivilegedAction() { - public Field run() { - Field field = null; - try { - field = KeyEvent.class.getDeclaredField("isProxyActive"); - if (field != null) { - field.setAccessible(true); - } - } catch (NoSuchFieldException nsf) { - assert(false); - } - return field; - } - }); - } - - try { - return proxyActive.getBoolean(e); - } catch (IllegalAccessException iae) { - assert(false); - } - return false; + return AWTAccessor.getKeyEventAccessor().isProxyActive(e); } // Returns the value of this KeyEvent's field isProxyActive diff --git a/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java b/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java index 678067ab143..394686a7ba3 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/SequencedEvent.java @@ -63,6 +63,10 @@ class SequencedEvent extends AWTEvent implements ActiveEvent { public boolean isSequencedEvent(AWTEvent event) { return event instanceof SequencedEvent; } + + public AWTEvent create(AWTEvent event) { + return new SequencedEvent(event); + } }); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java index d332d2d2735..ec9bd0be0a1 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/event/InputEvent.java @@ -302,6 +302,12 @@ public abstract class InputEvent extends ComponentEvent { public boolean canAccessSystemClipboard(InputEvent event) { return event.canAccessSystemClipboard; } + + @Override + public void setCanAccessSystemClipboard(InputEvent event, + boolean canAccessSystemClipboard) { + event.canAccessSystemClipboard = canAccessSystemClipboard; + } }); } diff --git a/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java b/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java index f103d525271..0ca378d556b 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java +++ b/jdk/src/java.desktop/share/classes/java/awt/event/KeyEvent.java @@ -1091,6 +1091,11 @@ public class KeyEvent extends InputEvent { public Component getOriginalSource( KeyEvent ev ) { return ev.originalSource; } + + @Override + public boolean isProxyActive(KeyEvent ev) { + return ev.isProxyActive; + } }); } diff --git a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java index 936322af467..5e2d97b43e5 100644 --- a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java +++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleBundle.java @@ -31,6 +31,7 @@ import java.util.Vector; import java.util.Locale; import java.util.MissingResourceException; import java.util.ResourceBundle; +import sun.awt.AWTAccessor; /** *

Base class used to maintain a strongly typed enumeration. This is @@ -53,6 +54,17 @@ public abstract class AccessibleBundle { private final String defaultResourceBundleName = "com.sun.accessibility.internal.resources.accessibility"; + static { + AWTAccessor.setAccessibleBundleAccessor( + new AWTAccessor.AccessibleBundleAccessor() { + + @Override + public String getKey(AccessibleBundle accessibleBundle) { + return accessibleBundle.key; + } + }); + } + /** * Construct an {@code AccessibleBundle}. */ diff --git a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java index 65a163fa4ca..c3a30f3a5ae 100644 --- a/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java +++ b/jdk/src/java.desktop/share/classes/javax/accessibility/AccessibleContext.java @@ -99,6 +99,16 @@ public abstract class AccessibleContext { public AppContext getAppContext(AccessibleContext accessibleContext) { return accessibleContext.targetAppContext; } + + @Override + public Object getNativeAXResource(AccessibleContext accessibleContext) { + return accessibleContext.nativeAXResource; + } + + @Override + public void setNativeAXResource(AccessibleContext accessibleContext, Object value) { + accessibleContext.nativeAXResource = value; + } }); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java b/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java index 8a63fe74cab..e12241f5771 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/ImageIcon.java @@ -40,8 +40,8 @@ import java.util.Locale; import javax.accessibility.*; import sun.awt.AppContext; -import java.lang.reflect.Field; import java.security.*; +import sun.awt.AWTAccessor; /** * An implementation of the Icon interface that paints Icons @@ -106,11 +106,8 @@ public class ImageIcon implements Icon, Serializable, Accessible { final Component component = createNoPermsComponent(); // 6482575 - clear the appContext field so as not to leak it - Field appContextField = - - Component.class.getDeclaredField("appContext"); - appContextField.setAccessible(true); - appContextField.set(component, null); + AWTAccessor.getComponentAccessor(). + setAppContext(component, null); return component; } catch (Throwable e) { diff --git a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java index 3d6025407d9..74abca7dc54 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/JComponent.java @@ -55,6 +55,7 @@ import javax.accessibility.*; import sun.awt.AWTAccessor; import sun.awt.SunToolkit; +import sun.swing.SwingAccessor; import sun.swing.SwingUtilities2; /** @@ -376,6 +377,21 @@ public abstract class JComponent extends Container implements Serializable, private transient Object aaHint; private transient Object lcdRenderingHint; + static { + SwingAccessor.setJComponentAccessor(new SwingAccessor.JComponentAccessor() { + + @Override + public boolean getFlag(JComponent comp, int aFlag) { + return comp.getFlag(aFlag); + } + + @Override + public void compWriteObjectNotify(JComponent comp) { + comp.compWriteObjectNotify(); + } + }); + } + static Graphics safelyGetGraphics(Component c) { return safelyGetGraphics(c, SwingUtilities.getRoot(c)); } diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java b/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java index 2698c90bc6e..894f3fabe18 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/GlyphView.java @@ -261,23 +261,7 @@ public class GlyphView extends View implements TabableView, Cloneable { if (painter == null) { if (defaultPainter == null) { // the classname should probably come from a property file. - String classname = "javax.swing.text.GlyphPainter1"; - try { - Class c; - ClassLoader loader = getClass().getClassLoader(); - if (loader != null) { - c = loader.loadClass(classname); - } else { - c = Class.forName(classname); - } - Object o = c.newInstance(); - if (o instanceof GlyphPainter) { - defaultPainter = (GlyphPainter) o; - } - } catch (Throwable e) { - throw new StateInvariantError("GlyphView: Can't load glyph painter: " - + classname); - } + defaultPainter = new GlyphPainter1(); } setGlyphPainter(defaultPainter.getPainter(this, getStartOffset(), getEndOffset())); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java b/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java index 154db5cf7ef..fc96021ccc3 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/ParagraphView.java @@ -61,20 +61,8 @@ public class ParagraphView extends FlowView implements TabExpander { Object i18nFlag = doc.getProperty(AbstractDocument.I18NProperty); if ((i18nFlag != null) && i18nFlag.equals(Boolean.TRUE)) { try { - if (i18nStrategy == null) { - // the classname should probably come from a property file. - String classname = "javax.swing.text.TextLayoutStrategy"; - ClassLoader loader = getClass().getClassLoader(); - if (loader != null) { - i18nStrategy = loader.loadClass(classname); - } else { - i18nStrategy = Class.forName(classname); - } - } - Object o = i18nStrategy.newInstance(); - if (o instanceof FlowStrategy) { - strategy = (FlowStrategy) o; - } + // the classname should probably come from a property file. + strategy = new TextLayoutStrategy(); } catch (Throwable e) { throw new StateInvariantError("ParagraphView: Can't create i18n strategy: " + e.getMessage()); diff --git a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java index 78157460653..57beae1ddb9 100644 --- a/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java +++ b/jdk/src/java.desktop/share/classes/javax/swing/text/html/HTMLEditorKit.java @@ -40,6 +40,7 @@ import javax.accessibility.*; import java.lang.ref.*; import java.security.AccessController; import java.security.PrivilegedAction; +import javax.swing.text.html.parser.ParserDelegator; /** * The Swing JEditorPane text component supports different kinds @@ -610,11 +611,7 @@ public class HTMLEditorKit extends StyledEditorKit implements Accessible { */ protected Parser getParser() { if (defaultParser == null) { - try { - Class c = Class.forName("javax.swing.text.html.parser.ParserDelegator"); - defaultParser = (Parser) c.newInstance(); - } catch (Throwable e) { - } + defaultParser = new ParserDelegator(); } return defaultParser; } diff --git a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java index 404131827fe..d03e5be0527 100644 --- a/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java +++ b/jdk/src/java.desktop/share/classes/sun/applet/AppletPanel.java @@ -616,34 +616,8 @@ abstract class AppletPanel extends Panel implements AppletStub, Runnable { * calls KeyboardFocusManager directly. */ private Component getMostRecentFocusOwnerForWindow(Window w) { - Method meth = AccessController.doPrivileged( - new PrivilegedAction() { - @Override - public Method run() { - Method meth = null; - try { - meth = KeyboardFocusManager.class.getDeclaredMethod( - "getMostRecentFocusOwner", - new Class[]{Window.class}); - meth.setAccessible(true); - } catch (Exception e) { - // Must never happen - e.printStackTrace(); - } - return meth; - } - }); - if (meth != null) { - // Meth refers static method - try { - return (Component)meth.invoke(null, new Object[] {w}); - } catch (Exception e) { - // Must never happen - e.printStackTrace(); - } - } - // Will get here if exception was thrown or meth is null - return w.getMostRecentFocusOwner(); + return AWTAccessor.getKeyboardFocusManagerAccessor() + .getMostRecentFocusOwner(w); } /* diff --git a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java index 796b7ab5d79..f59f064c111 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/AWTAccessor.java @@ -34,6 +34,7 @@ import java.awt.dnd.DragSourceContext; import java.awt.dnd.DropTargetContext; import java.awt.dnd.peer.DragSourceContextPeer; import java.awt.dnd.peer.DropTargetContextPeer; +import java.awt.event.AWTEventListener; import java.awt.event.InputEvent; import java.awt.event.InvocationEvent; import java.awt.event.KeyEvent; @@ -48,6 +49,7 @@ import java.security.AccessControlContext; import java.io.File; import java.util.ResourceBundle; import java.util.Vector; +import javax.accessibility.AccessibleBundle; /** * The AWTAccessor utility class. @@ -406,6 +408,8 @@ public final class AWTAccessor { * Accessor for InputEvent.canAccessSystemClipboard field */ boolean canAccessSystemClipboard(InputEvent event); + void setCanAccessSystemClipboard(InputEvent event, + boolean canAccessSystemClipboard); } /* @@ -454,6 +458,11 @@ public final class AWTAccessor { */ void removeLastFocusRequest(Component heavyweight); + /** + * Gets the most recent focus owner in the window. + */ + Component getMostRecentFocusOwner(Window window); + /** * Sets the most recent focus owner in the window. */ @@ -708,6 +717,11 @@ public final class AWTAccessor { * Gets original source for KeyEvent */ Component getOriginalSource(KeyEvent ev); + + /** + * Gets isProxyActive field for KeyEvent + */ + boolean isProxyActive(KeyEvent ev); } /** @@ -758,6 +772,11 @@ public final class AWTAccessor { * Returns true if the event is an instances of SequencedEvent. */ boolean isSequencedEvent(AWTEvent event); + + /* + * Creates SequencedEvent with the given nested event + */ + AWTEvent create(AWTEvent event); } /* @@ -787,6 +806,15 @@ public final class AWTAccessor { public interface AccessibleContextAccessor { void setAppContext(AccessibleContext accessibleContext, AppContext appContext); AppContext getAppContext(AccessibleContext accessibleContext); + Object getNativeAXResource(AccessibleContext accessibleContext); + void setNativeAXResource(AccessibleContext accessibleContext, Object value); + } + + /* + * An accessor object for the AccessibleContext class + */ + public interface AccessibleBundleAccessor { + String getKey(AccessibleBundle accessibleBundle); } /* @@ -845,6 +873,7 @@ public final class AWTAccessor { private static InvocationEventAccessor invocationEventAccessor; private static SystemColorAccessor systemColorAccessor; private static AccessibleContextAccessor accessibleContextAccessor; + private static AccessibleBundleAccessor accessibleBundleAccessor; private static DragSourceContextAccessor dragSourceContextAccessor; private static DropTargetContextAccessor dropTargetContextAccessor; @@ -1235,9 +1264,13 @@ public final class AWTAccessor { * Get the accessor object for the java.awt.SequencedEvent class. */ public static SequencedEventAccessor getSequencedEventAccessor() { - // The class is not public. So we can't ensure it's initialized. - // Null returned value means it's not initialized - // (so not a single instance of the event has been created). + if (sequencedEventAccessor == null) { + try { + unsafe.ensureClassInitialized( + Class.forName("java.awt.SequencedEvent")); + } catch (ClassNotFoundException ignore) { + } + } return sequencedEventAccessor; } @@ -1301,6 +1334,23 @@ public final class AWTAccessor { return accessibleContextAccessor; } + /* + * Set the accessor object for the javax.accessibility.AccessibleBundle class. + */ + public static void setAccessibleBundleAccessor(AccessibleBundleAccessor accessor) { + AWTAccessor.accessibleBundleAccessor = accessor; + } + + /* + * Get the accessor object for the javax.accessibility.AccessibleBundle class. + */ + public static AccessibleBundleAccessor getAccessibleBundleAccessor() { + if (accessibleBundleAccessor == null) { + unsafe.ensureClassInitialized(AccessibleBundle.class); + } + return accessibleBundleAccessor; + } + /* * Set the accessor object for the javax.accessibility.AccessibleContext class. */ @@ -1342,4 +1392,4 @@ public final class AWTAccessor { AWTAccessor.dropTargetContextAccessor = accessor; } -} +} \ No newline at end of file diff --git a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java index 8461974375f..c017454ec0f 100644 --- a/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java +++ b/jdk/src/java.desktop/share/classes/sun/awt/SunToolkit.java @@ -372,26 +372,6 @@ public abstract class SunToolkit extends Toolkit cont.setFocusTraversalPolicy(defaultPolicy); } - private static FocusTraversalPolicy createLayoutPolicy() { - FocusTraversalPolicy policy = null; - try { - Class layoutPolicyClass = - Class.forName("javax.swing.LayoutFocusTraversalPolicy"); - policy = (FocusTraversalPolicy)layoutPolicyClass.newInstance(); - } - catch (ClassNotFoundException e) { - assert false; - } - catch (InstantiationException e) { - assert false; - } - catch (IllegalAccessException e) { - assert false; - } - - return policy; - } - /* * Insert a mapping from target to AppContext, for later retrieval * via targetToAppContext() above. diff --git a/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java b/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java index 66d20f2458b..76a9f63ec1b 100644 --- a/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java +++ b/jdk/src/java.desktop/share/classes/sun/swing/SwingAccessor.java @@ -50,6 +50,16 @@ public final class SwingAccessor { private SwingAccessor() { } + /** + * An accessor for the JComponent class. + */ + public interface JComponentAccessor { + + boolean getFlag(JComponent comp, int aFlag); + + void compWriteObjectNotify(JComponent comp); + } + /** * An accessor for the JTextComponent class. * Note that we intentionally introduce the JTextComponentAccessor, @@ -105,6 +115,29 @@ public final class SwingAccessor { KeyStroke create(); } + /** + * The javax.swing.JComponent class accessor object. + */ + private static JComponentAccessor jComponentAccessor; + + /** + * Set an accessor object for the javax.swing.JComponent class. + */ + public static void setJComponentAccessor(JComponentAccessor jCompAccessor) { + jComponentAccessor = jCompAccessor; + } + + /** + * Retrieve the accessor object for the javax.swing.JComponent class. + */ + public static JComponentAccessor getJComponentAccessor() { + if (jComponentAccessor == null) { + unsafe.ensureClassInitialized(JComponent.class); + } + + return jComponentAccessor; + } + /** * The javax.swing.text.JTextComponent class accessor object. */ diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java index c65a7c79f96..846e06bb864 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XComponentPeer.java @@ -57,8 +57,6 @@ import java.awt.image.ImageProducer; import java.awt.image.VolatileImage; import java.awt.peer.ComponentPeer; import java.awt.peer.ContainerPeer; -import java.lang.reflect.*; -import java.security.*; import java.util.Collection; import java.util.Objects; import java.util.Set; @@ -241,46 +239,8 @@ public class XComponentPeer extends XWindow implements ComponentPeer, DropTarget return false; } - private static Class seClass; - private static Constructor seCtor; - static final AWTEvent wrapInSequenced(AWTEvent event) { - try { - if (seClass == null) { - seClass = Class.forName("java.awt.SequencedEvent"); - } - - if (seCtor == null) { - seCtor = AccessController.doPrivileged(new - PrivilegedExceptionAction>() { - public Constructor run() throws Exception { - Constructor ctor = seClass.getConstructor( - new Class[] { AWTEvent.class }); - ctor.setAccessible(true); - return ctor; - } - }); - } - - return (AWTEvent) seCtor.newInstance(new Object[] { event }); - } - catch (ClassNotFoundException e) { - throw new NoClassDefFoundError("java.awt.SequencedEvent."); - } - catch (PrivilegedActionException ex) { - throw new NoClassDefFoundError("java.awt.SequencedEvent."); - } - catch (InstantiationException e) { - assert false; - } - catch (IllegalAccessException e) { - assert false; - } - catch (InvocationTargetException e) { - assert false; - } - - return null; + return AWTAccessor.getSequencedEventAccessor().create(event); } // TODO: consider moving it to KeyboardFocusManagerPeerImpl diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java index 4422e7a8b35..e457c43e91e 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XMouseDragGestureRecognizer.java @@ -36,10 +36,6 @@ import java.awt.dnd.DragGestureListener; import java.awt.event.InputEvent; import java.awt.event.MouseEvent; -import java.awt.event.MouseListener; -import java.awt.event.MouseMotionListener; - -import java.lang.reflect.*; import sun.awt.dnd.SunDragSourceContextPeer; diff --git a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java index 907446ad81c..0c5cc361c76 100644 --- a/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java +++ b/jdk/src/java.desktop/unix/classes/sun/awt/X11/XWindow.java @@ -32,8 +32,6 @@ import java.awt.image.ColorModel; import java.lang.ref.WeakReference; -import java.lang.reflect.Method; - import sun.awt.AWTAccessor.ComponentAccessor; import sun.util.logging.PlatformLogger; @@ -395,7 +393,6 @@ class XWindow extends XBaseWindow implements X11ComponentPeer { return false; } - static Method m_sendMessage; static void sendEvent(final AWTEvent e) { // The uses of this method imply that the incoming event is system-generated SunToolkit.setSystemGenerated(e); From 21d1580782cd6091be4467a307082f9406fc8f30 Mon Sep 17 00:00:00 2001 From: Yuka Kamiya Date: Wed, 24 Aug 2016 09:45:20 +0900 Subject: [PATCH 19/87] 8164628: update copyright header in java.awt.font.JavaAWTFontAccessImpl class Reviewed-by: prr, iris --- .../share/classes/java/awt/font/JavaAWTFontAccessImpl.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java b/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java index ff2849807ba..738cd6c9dc9 100644 --- a/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java +++ b/jdk/src/java.desktop/share/classes/java/awt/font/JavaAWTFontAccessImpl.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, 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 From 60eccdede5062e8db3a998114f874f78f54cda98 Mon Sep 17 00:00:00 2001 From: Brian Burkhalter Date: Wed, 24 Aug 2016 10:59:17 -0700 Subject: [PATCH 20/87] 8149562: TIFFField#createFromMetadataNode javadoc should provide information about sibling/child nodes that should be part of parameter node Add a throws clause to the TIFFField.createFromMetadataNode method specification stating that the supplied Node parameter must adhere to the TIFFField element structure defined by the TIFF native image metadata DTD. Reviewed-by: prr, darcy, serb --- .../javax/imageio/plugins/tiff/TIFFField.java | 34 +++++++++++++------ .../imageio/plugins/tiff/TIFFFieldTest.java | 15 ++++++-- 2 files changed, 35 insertions(+), 14 deletions(-) diff --git a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java index edcb086cb45..da9ade0d8f7 100644 --- a/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java +++ b/jdk/src/java.desktop/share/classes/javax/imageio/plugins/tiff/TIFFField.java @@ -412,7 +412,7 @@ public class TIFFField implements Cloneable { /** * Creates a {@code TIFFField} from a TIFF native image - * metadata node. If the value of the "number" attribute + * metadata node. If the value of the {@code "number"} attribute * of the node is not found in {@code tagSet} then a new * {@code TIFFTag} with name {@code TIFFTag.UNKNOWN_TAG_NAME} * will be created and assigned to the field. @@ -420,20 +420,22 @@ public class TIFFField implements Cloneable { * @param tagSet The {@code TIFFTagSet} to which the * {@code TIFFTag} of the field belongs. * @param node A native TIFF image metadata {@code TIFFField} node. - * @throws NullPointerException if {@code node} is - * {@code null}. - * @throws IllegalArgumentException if the name of the node is not - * {@code "TIFFField"}. - * @throws NullPointerException if the node does not contain any data. - * @throws IllegalArgumentException if the combination of node attributes - * and data is not legal per the {@link #TIFFField(TIFFTag,int,int,Object)} - * constructor specification. + * @throws IllegalArgumentException If the {@code Node} parameter content + * does not adhere to the {@code TIFFField} element structure defined by + * the + * TIFF native image metadata format specification, or if the + * combination of node attributes and data is not legal per the + * {@link #TIFFField(TIFFTag,int,int,Object)} constructor specification. + * Note that a cause might be set on such an exception. * @return A new {@code TIFFField}. */ public static TIFFField createFromMetadataNode(TIFFTagSet tagSet, Node node) { if (node == null) { - throw new NullPointerException("node == null!"); + // This method is specified to throw only IllegalArgumentExceptions + // so we create an IAE with a NullPointerException as its cause. + throw new IllegalArgumentException(new NullPointerException + ("node == null!")); } String name = node.getNodeName(); if (!name.equals("TIFFField")) { @@ -487,7 +489,17 @@ public class TIFFField implements Cloneable { tag = new TIFFTag(TIFFTag.UNKNOWN_TAG_NAME, tagNumber, 1 << type); } - return new TIFFField(tag, type, count, data); + TIFFField field; + try { + field = new TIFFField(tag, type, count, data); + } catch (NullPointerException npe) { + // This method is specified to throw only IllegalArgumentExceptions + // so we catch the NullPointerException and set it as the cause of + // the IAE which is thrown. + throw new IllegalArgumentException(npe); + } + + return field; } /** diff --git a/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java b/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java index a50929e8a46..936a5e3af68 100644 --- a/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java +++ b/jdk/test/javax/imageio/plugins/tiff/TIFFFieldTest.java @@ -23,7 +23,7 @@ /** * @test - * @bug 8152183 + * @bug 8152183 8149562 * @author a.stepanov * @summary Some checks for TIFFField methods * @run main TIFFFieldTest @@ -455,8 +455,17 @@ public class TIFFFieldTest { TIFFTagSet ts = new TIFFTagSet(tags); boolean ok = false; - try { TIFFField.createFromMetadataNode(ts, null); } - catch (NullPointerException e) { ok = true; } + try { + TIFFField.createFromMetadataNode(ts, null); + } catch (IllegalArgumentException e) { + // createFromMetadataNode() formerly threw a NullPointerException + // if its Node parameter was null, but the specification has been + // modified to allow only IllegalArgumentExceptions, perhaps with + // a cause set. In the present invocation the cause would be set + // to a NullPointerException but this is not explicitly specified + // hence not verified here. + ok = true; + } check(ok, "can create TIFFField from a null node"); TIFFField f = new TIFFField(tag, v); From 1e96a6f24b4f5fd71b2c4e10b42ec94eee5dd0d0 Mon Sep 17 00:00:00 2001 From: Phil Race Date: Wed, 24 Aug 2016 12:56:51 -0700 Subject: [PATCH 21/87] 8164752: Extraneous debugging printf in hb-jdk-font.cc Reviewed-by: bpb --- jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc index f7df0f27cbe..93ac190b4d1 100644 --- a/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc +++ b/jdk/src/java.desktop/share/native/libfontmanager/hb-jdk-font.cc @@ -52,7 +52,6 @@ hb_jdk_get_glyph (hb_font_t *font HB_UNUSED, *glyph = (hb_codepoint_t) env->CallIntMethod(font2D, sunFontIDs.f2dCharToGlyphMID, u); -printf("unicode=%x glyph=%x\n", unicode, *glyph); return (*glyph != 0); } From b9b87f5a33788b889aeda2ccd1ebabf6a7dd572e Mon Sep 17 00:00:00 2001 From: Phil Race Date: Wed, 24 Aug 2016 13:36:46 -0700 Subject: [PATCH 22/87] 8139176: [macosx] java.awt.TextLayout does not handle correctly the bolded logical fonts Reviewed-by: serb, vadim --- .../macosx/classes/sun/font/CFont.java | 12 ++ .../font/TextLayout/StyledFontLayoutTest.java | 118 ++++++++++++++++++ 2 files changed, 130 insertions(+) create mode 100644 jdk/test/java/awt/font/TextLayout/StyledFontLayoutTest.java diff --git a/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java b/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java index dcc4b5793eb..049dbb58619 100644 --- a/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java +++ b/jdk/src/java.desktop/macosx/classes/sun/font/CFont.java @@ -278,6 +278,18 @@ public final class CFont extends PhysicalFont implements FontSubstitution { return getStrike(font, DEFAULT_FRC); } + public boolean equals(Object o) { + if (!super.equals(o)) { + return false; + } + + return ((Font2D)o).getStyle() == this.getStyle(); + } + + public int hashCode() { + return super.hashCode() ^ this.getStyle(); + } + public String toString() { return "CFont { fullName: " + fullName + ", familyName: " + familyName + ", style: " + style + diff --git a/jdk/test/java/awt/font/TextLayout/StyledFontLayoutTest.java b/jdk/test/java/awt/font/TextLayout/StyledFontLayoutTest.java new file mode 100644 index 00000000000..806381451df --- /dev/null +++ b/jdk/test/java/awt/font/TextLayout/StyledFontLayoutTest.java @@ -0,0 +1,118 @@ +/* + * 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 8139176 + * @summary Test layout uses correct styled font. + * @run main StyledFontLayoutTest + */ + +import java.awt.Color; +import java.awt.Font; +import java.awt.Graphics; +import java.awt.Graphics2D; +import java.awt.RenderingHints; +import java.awt.font.FontRenderContext; +import java.awt.font.GlyphVector; +import java.awt.geom.Rectangle2D; +import java.awt.image.BufferedImage; + +import javax.swing.JFrame; +import javax.swing.JPanel; +import javax.swing.SwingUtilities; +import javax.swing.WindowConstants; + +public class StyledFontLayoutTest extends JPanel { + + static final int W=600, H=400; + static boolean interactive; + static BufferedImage im; + public static void main(String[] args) { + + interactive = args.length > 0; + + runTest(); + + if (!interactive) { + return; + } + SwingUtilities.invokeLater(() -> { + JFrame frame = new JFrame("Styled Font Layout Test"); + frame.add(new StyledFontLayoutTest()); + frame.setDefaultCloseOperation(WindowConstants.EXIT_ON_CLOSE); + frame.setSize(W, H); + frame.setLocationRelativeTo(null); + frame.setVisible(true); + }); + } + + @Override + protected void paintComponent(Graphics g) { + g.drawImage(im, 0, 0, null); + } + + private static void runTest() { + im = new BufferedImage(W, H, BufferedImage.TYPE_INT_RGB); + Graphics2D g2d = im.createGraphics(); + g2d.setColor(Color.white); + g2d.fillRect(0, 0, W, H); + g2d.setColor(Color.black); + g2d.setRenderingHint(RenderingHints.KEY_TEXT_ANTIALIASING, + RenderingHints.VALUE_TEXT_ANTIALIAS_ON); + char[] chs = "Sample Text.".toCharArray(); + int len = chs.length; + + int x = 50, y = 100; + + FontRenderContext frc = g2d.getFontRenderContext(); + Font plain = new Font("Serif", Font.PLAIN, 48); + GlyphVector pgv = plain.layoutGlyphVector(frc, chs, 0, len, 0); + g2d.setFont(plain); + g2d.drawChars(chs, 0, len, x, y); y +=50; + + g2d.drawGlyphVector(pgv, x, y); y += 50; + Rectangle2D plainStrBounds = plain.getStringBounds(chs, 0, len, frc); + Rectangle2D plainGVBounds = pgv.getLogicalBounds(); + Font bold = new Font("Serif", Font.BOLD, 48); + GlyphVector bgv = bold.layoutGlyphVector(frc, chs, 0, len, 0); + Rectangle2D boldStrBounds = bold.getStringBounds(chs, 0, len, frc); + Rectangle2D boldGVBounds = bgv.getLogicalBounds(); + g2d.setFont(bold); + g2d.drawChars(chs, 0, len, x, y); y +=50; + g2d.drawGlyphVector(bgv, x, y); + System.out.println("Plain String Bounds = " + plainStrBounds); + System.out.println("Bold String Bounds = " + boldStrBounds); + System.out.println("Plain GlyphVector Bounds = " + plainGVBounds); + System.out.println("Bold GlyphVector Bounds = " + boldGVBounds); + if (!plainStrBounds.equals(boldStrBounds) && + plainGVBounds.equals(boldGVBounds)) + { + System.out.println("Test failed: Plain GV bounds same as Bold"); + if (!interactive) { + throw new RuntimeException("Plain GV bounds same as Bold"); + } + } + + }; +} From 93fe235cf7b099cc4eaa2f40a61c40ad0ab53ce9 Mon Sep 17 00:00:00 2001 From: Avik Niyogi Date: Thu, 25 Aug 2016 13:46:17 +0530 Subject: [PATCH 23/87] 8163161: [PIT][TEST_BUG] increase timeout in javax/swing/plaf/nimbus/8057791/bug8057791.java Reviewed-by: alexsch, rchamyal --- jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java b/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java index d8146b61b09..3731bed23ea 100644 --- a/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java +++ b/jdk/test/javax/swing/plaf/nimbus/8057791/bug8057791.java @@ -22,9 +22,10 @@ */ /* @test - @bug 8057791 8160438 - @summary Selection in JList is drawn with wrong colors in Nimbus L&F - @run main bug8057791 + @key headful + @bug 8057791 8160438 8163161 + @summary Selection in JList is drawn with wrong colors in Nimbus L&F + @run main/timeout=500 bug8057791 */ import java.awt.Color; import java.awt.Font; From e1726f30e883e6c1d3257dbb8227e38bb0d552c2 Mon Sep 17 00:00:00 2001 From: Ajit Ghaisas Date: Thu, 25 Aug 2016 14:12:13 +0530 Subject: [PATCH 24/87] 8158356: SIGSEGV when attempting to rotate BufferedImage using AffineTransform by NaN degrees Reviewed-by: flar, prr --- .../libawt/awt/medialib/awt_ImagingLib.c | 25 +++- .../native/libmlib_image/mlib_ImageScanPoly.c | 18 ++- .../share/native/libmlib_image/safe_math.h | 7 +- .../InvalidTransformParameterTest.java | 138 ++++++++++++++++++ 4 files changed, 185 insertions(+), 3 deletions(-) create mode 100644 jdk/test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java diff --git a/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c b/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c index 472b5eed491..15c705a5fec 100644 --- a/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c +++ b/jdk/src/java.desktop/share/native/libawt/awt/medialib/awt_ImagingLib.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2014, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 @@ -772,6 +772,7 @@ Java_sun_awt_image_ImagingLib_transformBI(JNIEnv *env, jobject this, mlib_image *src; mlib_image *dst; int i; + int j = 0; int retStatus = 1; mlib_status status; double *matrix; @@ -824,6 +825,15 @@ Java_sun_awt_image_ImagingLib_transformBI(JNIEnv *env, jobject this, return 0; } + /* Check for invalid double value in transformation matrix */ + for (j = 0; j < 6; j++) { + + if (!(IS_FINITE(matrix[j]))) { + (*env)->ReleasePrimitiveArrayCritical(env, jmatrix, matrix, JNI_ABORT); + return 0; + } + } + if (s_printIt) { printf("matrix is %g %g %g %g %g %g\n", matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); @@ -980,6 +990,7 @@ Java_sun_awt_image_ImagingLib_transformRaster(JNIEnv *env, jobject this, mlib_image *src; mlib_image *dst; int i; + int j = 0; int retStatus = 1; mlib_status status; double *matrix; @@ -1044,6 +1055,18 @@ Java_sun_awt_image_ImagingLib_transformRaster(JNIEnv *env, jobject this, return 0; } + /* Check for invalid double value in transformation matrix */ + for (j = 0; j < 6; j++) { + + if (!(IS_FINITE(matrix[j]))) { + (*env)->ReleasePrimitiveArrayCritical(env, jmatrix, matrix, JNI_ABORT); + free(srcRasterP); + free(dstRasterP); + + return 0; + } + } + if (s_printIt) { printf("matrix is %g %g %g %g %g %g\n", matrix[0], matrix[1], matrix[2], matrix[3], matrix[4], matrix[5]); diff --git a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c index 34c2171274e..e151de73cc9 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c +++ b/jdk/src/java.desktop/share/native/libmlib_image/mlib_ImageScanPoly.c @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2003, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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,8 @@ #include "mlib_image.h" #include "mlib_SysMath.h" #include "mlib_ImageAffine.h" +#include "safe_math.h" + /***************************************************************/ mlib_status mlib_AffineEdges(mlib_affine_param *param, @@ -83,6 +85,12 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, dstYStride = mlib_ImageGetStride(dst); paddings = mlib_ImageGetPaddings(src); + /* All the transformation matrix parameters should be finite. if not, return failure */ + if (!(IS_FINITE(a) && IS_FINITE(b) && IS_FINITE(c) && IS_FINITE(d) && + IS_FINITE(tx) && IS_FINITE(ty))) { + return MLIB_FAILURE; + } + if (srcWidth >= (1 << 15) || srcHeight >= (1 << 15)) { return MLIB_FAILURE; } @@ -288,6 +296,10 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, if (dY1 == dY2) continue; + if (!(IS_FINITE(slope))) { + continue; + } + if (dY1 < 0.0) y1 = 0; else { @@ -328,6 +340,10 @@ mlib_status mlib_AffineEdges(mlib_affine_param *param, if (dY1 == dY2) continue; + if (!(IS_FINITE(slope))) { + continue; + } + if (dY1 < 0.0) y1 = 0; else { diff --git a/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h b/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h index 34c1fc56e9a..a87eba11723 100644 --- a/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h +++ b/jdk/src/java.desktop/share/native/libmlib_image/safe_math.h @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -26,10 +26,15 @@ #ifndef __SAFE_MATH_H__ #define __SAFE_MATH_H__ +#include "mlib_types.h" + #define SAFE_TO_MULT(a, b) \ (((a) > 0) && ((b) >= 0) && ((0x7fffffff / (a)) > (b))) #define SAFE_TO_ADD(a, b) \ (((a) >= 0) && ((b) >= 0) && ((0x7fffffff - (a)) > (b))) +#define IS_FINITE(a) \ + (((a) >= MLIB_D64_MIN) && ((a) <= MLIB_D64_MAX)) + #endif // __SAFE_MATH_H__ diff --git a/jdk/test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java b/jdk/test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java new file mode 100644 index 00000000000..f8c36ec21e7 --- /dev/null +++ b/jdk/test/java/awt/geom/AffineTransform/InvalidTransformParameterTest.java @@ -0,0 +1,138 @@ +/* + * 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 8158356 + * @summary Test AffineTransform transformations do not result in SIGSEGV + * if NaN or infinity parameter is passed as argument. + * @run main InvalidTransformParameterTest + */ + +import java.awt.geom.AffineTransform; +import java.awt.image.AffineTransformOp; +import java.awt.image.BufferedImage; +import java.awt.image.ImagingOpException; +import java.awt.Point; +import java.awt.image.DataBuffer; +import java.awt.image.DataBufferByte; +import java.awt.image.PixelInterleavedSampleModel; +import java.awt.image.Raster; +import java.awt.image.WritableRaster; +import java.awt.image.RasterOp; +import java.awt.image.SampleModel; + +public class InvalidTransformParameterTest { + + public static void main(String[] args) { + int count = 0; + final int testScenarios = 12; + double NaNArg = 0.0 / 0.0; + double positiveInfArg = 1.0 / 0.0; + double negativeInfArg = -1.0 / 0.0; + + BufferedImage img = new BufferedImage(5, 5, BufferedImage.TYPE_INT_ARGB); + + AffineTransform[] inputTransforms = new AffineTransform[testScenarios]; + + for (int i = 0; i < inputTransforms.length; i++) { + inputTransforms[i] = new AffineTransform(); + } + + inputTransforms[0].rotate(NaNArg, img.getWidth()/2, img.getHeight()/2); + inputTransforms[1].translate(NaNArg, NaNArg); + inputTransforms[2].scale(NaNArg, NaNArg); + inputTransforms[3].shear(NaNArg, NaNArg); + + inputTransforms[4].rotate(positiveInfArg, img.getWidth()/2, img.getHeight()/2); + inputTransforms[5].translate(positiveInfArg, positiveInfArg); + inputTransforms[6].scale(positiveInfArg, positiveInfArg); + inputTransforms[7].shear(positiveInfArg, positiveInfArg); + + inputTransforms[8].rotate(negativeInfArg, img.getWidth()/2, img.getHeight()/2); + inputTransforms[9].translate(negativeInfArg, negativeInfArg); + inputTransforms[10].scale(negativeInfArg, negativeInfArg); + inputTransforms[11].shear(negativeInfArg, negativeInfArg); + + // Test BufferedImage AffineTransform --------------------------------- + + for (int i = 0; i < inputTransforms.length; i++) { + try { + testImageTransform(img, inputTransforms[i]); + } catch (ImagingOpException ex) { + count++; + } + } + + if (count != testScenarios) { + throw new RuntimeException("Test failed. All test scenarios did not" + + " result in exception as expected."); + } + + // Test Raster AffineTransform --------------------------------- + + count = 0; + int[] bandOffsets = {0}; + Point location = new Point(0, 0); + DataBuffer db = new DataBufferByte(10 * 10); + SampleModel sm = new PixelInterleavedSampleModel(DataBuffer.TYPE_BYTE, + 10, 10, 1, 10, + bandOffsets); + + Raster src = Raster.createRaster(sm, db, location); + WritableRaster dst = Raster.createWritableRaster(sm, db, location); + + for (int i = 0; i < inputTransforms.length; i++) { + try { + testRasterTransform(src, dst, inputTransforms[i]); + } catch (ImagingOpException ex) { + count++; + } + } + + if (count != testScenarios) { + throw new RuntimeException("Test failed. All test scenarios did not" + + " result in exception as expected."); + } + } + + public static BufferedImage testImageTransform(BufferedImage image, + AffineTransform transform) { + AffineTransformOp op = + new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR); + + BufferedImage transformedImage = new BufferedImage(image.getWidth(), + image.getHeight(), + image.getType()); + + return op.filter(image, transformedImage); + } + + public static Raster testRasterTransform(Raster src, WritableRaster dst, + AffineTransform transform) { + AffineTransformOp op = + new AffineTransformOp(transform, AffineTransformOp.TYPE_BILINEAR); + + return op.filter(src, dst); + } +} + From e576ea3b90596a0d5baac1c07ad9cc0feffc2a3a Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Thu, 25 Aug 2016 16:01:44 +0530 Subject: [PATCH 25/87] 8154218: Non-usage of owner Frame when Frame object is passed to getPrintJob() Reviewed-by: prr, jdv --- .../share/classes/javax/print/ServiceUI.java | 6 +- .../TestPrintJobFrameAssociation.java | 170 ++++++++++++++++++ 2 files changed, 173 insertions(+), 3 deletions(-) create mode 100644 jdk/test/java/awt/PrintJob/TestPrintJobFrameAssociation.java diff --git a/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java b/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java index 82566e9f804..615de409bdf 100644 --- a/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java +++ b/jdk/src/java.desktop/share/classes/javax/print/ServiceUI.java @@ -40,6 +40,7 @@ import javax.print.attribute.AttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.Fidelity; +import sun.print.DialogOwner; import sun.print.ServiceDialog; import sun.print.SunAlternateMedia; @@ -187,9 +188,8 @@ public class ServiceUI { defaultIndex = 0; } - // For now we set owner to null. In the future, it may be passed - // as an argument. - Window owner = null; + DialogOwner dlgOwner = (DialogOwner)attributes.get(DialogOwner.class); + Window owner = (dlgOwner != null) ? dlgOwner.getOwner() : null; Rectangle gcBounds = (gc == null) ? GraphicsEnvironment. getLocalGraphicsEnvironment().getDefaultScreenDevice(). diff --git a/jdk/test/java/awt/PrintJob/TestPrintJobFrameAssociation.java b/jdk/test/java/awt/PrintJob/TestPrintJobFrameAssociation.java new file mode 100644 index 00000000000..1dd861cf325 --- /dev/null +++ b/jdk/test/java/awt/PrintJob/TestPrintJobFrameAssociation.java @@ -0,0 +1,170 @@ +/* + * 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 8154218 + * @summary Verifies if owner Frame is associated with print dialog + * @run main/manual TestPrintJobFrameAssociation + */ +import java.awt.BorderLayout; +import java.awt.Button; +import java.awt.FlowLayout; +import java.awt.Frame; +import java.awt.Label; +import java.awt.Panel; +import java.awt.JobAttributes; +import java.awt.PrintJob; +import java.awt.Toolkit; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class TestPrintJobFrameAssociation { + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + private static Button print; + private static Label dialogName; + private static Frame frame; + private static boolean start; + private static Thread t; + + public static void main(String args[]) throws Exception { + SwingUtilities.invokeAndWait(() -> { + doTest(TestPrintJobFrameAssociation::frameTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(60000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Print dialog not disposed." + + " Print dialog is not associated with owner Frame`"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + private static void frameTest() { + Panel panel =new Panel(); + + print = new Button("Print"); + print.setActionCommand("Print"); + print.addActionListener((e) -> { + JobAttributes ja = new JobAttributes(); + ja.setDialog(JobAttributes.DialogType.COMMON); + + t.start(); + start = true; + PrintJob pjob = Toolkit.getDefaultToolkit().getPrintJob(frame, + "Printing Test", + ja,null); + }); + + panel.add(print); + + frame = new Frame("Test Frame"); + frame.setLayout (new BorderLayout ()); + frame.add(panel,"South"); + frame.pack(); + frame.setVisible(true); + + t = new Thread (() -> { + if (start) { + try { + Thread.sleep(5000); + } catch (InterruptedException ex) {} + frame.dispose(); + } + }); + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " A Frame with Print Button is shown. Press Print.\n" + + " A cross-platform print dialog will be shown. After 5 secs\n" + + " the frame along with this print dialog will be disposed.\n" + + " If the print dialog is not disposed, press FAIL else press PASS"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printSelectionTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); + + } +} From 8ae9e471290aeef876e7edbfb66d0d02471b7a08 Mon Sep 17 00:00:00 2001 From: Goetz Lindenmaier Date: Wed, 20 Jul 2016 15:07:48 +0200 Subject: [PATCH 26/87] 8161923: Fix free in awt_PrintControl Reviewed-by: vadim --- .../windows/native/libawt/windows/awt_PrintControl.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp index 6c36d177fb2..6f75291d62f 100644 --- a/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp +++ b/jdk/src/java.desktop/windows/native/libawt/windows/awt_PrintControl.cpp @@ -1132,7 +1132,7 @@ BOOL AwtPrintControl::getDevmode( HANDLE hPrinter, if (dwRet != IDOK) { /* if failure, cleanup and return failure */ - GlobalFree(pDevMode); + GlobalFree(*pDevMode); *pDevMode = NULL; return FALSE; } From 4fc198725593df5b6a1ab6fb912e91364a7eb80b Mon Sep 17 00:00:00 2001 From: Jesper Wilhelmsson Date: Fri, 19 Aug 2016 17:19:47 +0200 Subject: [PATCH 27/87] 8164124: [BACKOUT] G1 does not implement millis_since_last_gc which is needed by RMI GC Reviewed-by: jprovino --- hotspot/src/share/vm/gc/g1/g1Analytics.cpp | 6 +----- hotspot/src/share/vm/gc/g1/g1Analytics.hpp | 1 - hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp | 16 ++-------------- hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp | 2 +- .../src/share/vm/gc/shared/genCollectedHeap.cpp | 14 +++++++------- 5 files changed, 11 insertions(+), 28 deletions(-) diff --git a/hotspot/src/share/vm/gc/g1/g1Analytics.cpp b/hotspot/src/share/vm/gc/g1/g1Analytics.cpp index 8214a4bfa55..c43b4169e49 100644 --- a/hotspot/src/share/vm/gc/g1/g1Analytics.cpp +++ b/hotspot/src/share/vm/gc/g1/g1Analytics.cpp @@ -316,12 +316,8 @@ size_t G1Analytics::predict_pending_cards() const { return get_new_size_prediction(_pending_cards_seq); } -double G1Analytics::oldest_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(); + return _recent_prev_end_times_for_all_gcs_sec->oldest(); } void G1Analytics::update_recent_gc_times(double end_time_sec, diff --git a/hotspot/src/share/vm/gc/g1/g1Analytics.hpp b/hotspot/src/share/vm/gc/g1/g1Analytics.hpp index 3f9a37a98e7..a22d0dd72bd 100644 --- a/hotspot/src/share/vm/gc/g1/g1Analytics.hpp +++ b/hotspot/src/share/vm/gc/g1/g1Analytics.hpp @@ -155,7 +155,6 @@ public: 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; }; diff --git a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp index a267098ed86..d84e1000763 100644 --- a/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/g1/g1CollectedHeap.cpp @@ -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 @@ size_t G1CollectedHeap::max_capacity() const { } 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() { diff --git a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp index dfef9538ba7..454f73bc0c6 100644 --- a/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp +++ b/hotspot/src/share/vm/gc/g1/g1DefaultPolicy.cpp @@ -604,7 +604,7 @@ void G1DefaultPolicy::record_collection_pause_end(double pause_time_ms, size_t c _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); } diff --git a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp index c1a28350047..049b675bd51 100644 --- a/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp +++ b/hotspot/src/share/vm/gc/shared/genCollectedHeap.cpp @@ -1256,21 +1256,21 @@ class GenTimeOfLastGCClosure: public GenCollectedHeap::GenClosure { }; 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; From 20e0d40bc19b90364759f2a471a20e5a5e8c4d40 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Mon, 22 Aug 2016 16:32:40 -0700 Subject: [PATCH 28/87] 8164130: Simplify doclet IOException handling Reviewed-by: bpatel, ksrini --- .../toolkit/builders/AbstractBuilder.java | 4 +- .../formats/html/AbstractIndexWriter.java | 82 ++++---- .../html/AbstractModuleIndexWriter.java | 21 +- .../html/AbstractPackageIndexWriter.java | 9 +- .../formats/html/AbstractTreeWriter.java | 4 - .../formats/html/AllClassesFrameWriter.java | 33 +-- .../html/AnnotationTypeWriterImpl.java | 25 +-- .../doclets/formats/html/ClassUseWriter.java | 46 ++-- .../doclets/formats/html/ClassWriterImpl.java | 25 +-- .../formats/html/ConfigurationImpl.java | 1 - .../html/ConstantsSummaryWriterImpl.java | 4 +- .../formats/html/DeprecatedListWriter.java | 34 ++- .../formats/html/FrameOutputWriter.java | 28 +-- .../doclets/formats/html/HelpWriter.java | 29 +-- .../doclets/formats/html/HtmlDoclet.java | 82 ++++---- .../formats/html/HtmlDocletWriter.java | 14 +- .../formats/html/IndexRedirectWriter.java | 28 +-- .../formats/html/ModuleFrameWriter.java | 54 ++--- .../formats/html/ModuleIndexFrameWriter.java | 22 +- .../formats/html/ModuleIndexWriter.java | 36 ++-- .../html/ModulePackageIndexFrameWriter.java | 23 +- .../formats/html/ModuleWriterImpl.java | 16 +- .../formats/html/PackageFrameWriter.java | 56 +++-- .../formats/html/PackageIndexFrameWriter.java | 29 ++- .../formats/html/PackageIndexWriter.java | 43 ++-- .../formats/html/PackageTreeWriter.java | 35 ++-- .../formats/html/PackageUseWriter.java | 37 ++-- .../formats/html/PackageWriterImpl.java | 18 +- .../html/SerializedFormWriterImpl.java | 11 +- .../formats/html/SingleIndexWriter.java | 29 +-- .../formats/html/SourceToHTMLConverter.java | 44 ++-- .../formats/html/SplitIndexWriter.java | 55 +++-- .../doclets/formats/html/TreeWriter.java | 34 ++- .../formats/html/WriterFactoryImpl.java | 51 ++--- .../doclets/formats/html/markup/Comment.java | 13 +- .../doclets/formats/html/markup/DocType.java | 13 +- .../html/markup/FixedStringContent.java | 13 +- .../formats/html/markup/HtmlDocWriter.java | 16 +- .../formats/html/markup/HtmlDocument.java | 7 +- .../formats/html/markup/HtmlWriter.java | 5 +- .../doclets/formats/html/markup/RawHtml.java | 13 +- .../formats/html/markup/StringContent.java | 9 +- .../html/resources/standard.properties | 1 - .../doclets/toolkit/AbstractDoclet.java | 119 +++++++---- .../doclets/toolkit/AnnotationTypeWriter.java | 7 +- .../internal/doclets/toolkit/ClassWriter.java | 7 +- .../doclets/toolkit/Configuration.java | 94 ++++----- .../toolkit/ConstantsSummaryWriter.java | 6 +- .../internal/doclets/toolkit/Content.java | 5 +- .../doclets/toolkit/DocletException.java | 72 +++++++ .../doclets/toolkit/ModuleSummaryWriter.java | 8 +- .../doclets/toolkit/PackageSummaryWriter.java | 7 +- .../doclets/toolkit/SerializedFormWriter.java | 29 +-- .../doclets/toolkit/WriterFactory.java | 45 ++-- .../toolkit/builders/AbstractBuilder.java | 86 ++++---- .../builders/AbstractMemberBuilder.java | 23 +- .../builders/AnnotationTypeBuilder.java | 77 ++++--- .../builders/AnnotationTypeFieldBuilder.java | 13 +- .../AnnotationTypeOptionalMemberBuilder.java | 6 +- .../AnnotationTypeRequiredMemberBuilder.java | 11 +- .../toolkit/builders/BuilderFactory.java | 44 ++-- .../toolkit/builders/ClassBuilder.java | 47 +++-- .../builders/ConstantsSummaryBuilder.java | 17 +- .../toolkit/builders/ConstructorBuilder.java | 6 +- .../toolkit/builders/EnumConstantBuilder.java | 9 +- .../toolkit/builders/FieldBuilder.java | 9 +- .../toolkit/builders/LayoutParser.java | 46 ++-- .../builders/MemberSummaryBuilder.java | 7 +- .../toolkit/builders/MethodBuilder.java | 4 +- .../builders/ModuleSummaryBuilder.java | 19 +- .../builders/PackageSummaryBuilder.java | 18 +- .../toolkit/builders/PropertyBuilder.java | 9 +- .../builders/SerializedFormBuilder.java | 58 +++-- .../toolkit/resources/doclets.properties | 24 ++- .../doclets/toolkit/util/DocFile.java | 198 ++++++++++++++---- .../doclets/toolkit/util/DocFileFactory.java | 8 +- .../toolkit/util/DocFileIOException.java | 82 ++++++++ .../internal/doclets/toolkit/util/Extern.java | 29 +-- ...tException.java => InternalException.java} | 33 +-- .../toolkit/util/PackageListWriter.java | 48 ++--- .../toolkit/util/ResourceIOException.java | 63 ++++++ .../toolkit/util/SimpleDocletException.java | 62 ++++++ .../toolkit/util/StandardDocFileFactory.java | 113 +++++++--- .../internal/doclets/toolkit/util/Utils.java | 142 +++++++------ .../testIOException/TestIOException.java | 179 ++++++++++++++++ 85 files changed, 1811 insertions(+), 1230 deletions(-) create mode 100644 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/DocletException.java create mode 100644 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFileIOException.java rename langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/{DocletAbortException.java => InternalException.java} (55%) create mode 100644 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ResourceIOException.java create mode 100644 langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/SimpleDocletException.java create mode 100644 langtools/test/jdk/javadoc/doclet/testIOException/TestIOException.java diff --git a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java index e95ac5f7d98..616c968e1bc 100644 --- a/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/com/sun/tools/doclets/internal/toolkit/builders/AbstractBuilder.java @@ -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 @@ public abstract class AbstractBuilder { /** * 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; diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java index 783ef4e1bb6..118dd3c8941 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java @@ -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.*; @@ -46,9 +45,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.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 +92,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { * * @return a content tree for the tree label */ + @Override protected Content getNavLinkIndex() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.indexLabel); return li; @@ -242,6 +242,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { * * @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 +266,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { * * @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 +334,9 @@ public class AbstractIndexWriter extends HtmlDocletWriter { } 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 +432,10 @@ public class AbstractIndexWriter extends HtmlDocletWriter { 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 +450,37 @@ public class AbstractIndexWriter extends HtmlDocletWriter { configuration.tagSearchIndex); } + /** + * @throws DocFileIOException if there is a problem creating the search index file + */ protected void createSearchIndexFile(DocPath searchIndexFile, DocPath searchIndexZip, - List searchIndex) { + List 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); - } - Files.delete(p); - } catch (IOException ie) { - throw new DocletAbortException(ie); } - } - } + searchVar.append("]"); - 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); - } + 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(); } - } finally { - zos.closeEntry(); + } catch (IOException ie) { + throw new DocFileIOException(zipFile, DocFileIOException.Mode.WRITE, ie); } - } catch (IOException e) { - throw new DocletAbortException(e); } } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java index f3b4c897aca..4bdbfd70012 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractModuleIndexWriter.java @@ -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.HtmlTag; 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 @@ public abstract class AbstractModuleIndexWriter extends HtmlDocletWriter { * * @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 @@ public abstract class AbstractModuleIndexWriter extends HtmlDocletWriter { * @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 @@ public abstract class AbstractModuleIndexWriter extends HtmlDocletWriter { * * @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 @@ public abstract class AbstractModuleIndexWriter extends HtmlDocletWriter { * * @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 @@ public abstract class AbstractModuleIndexWriter extends HtmlDocletWriter { * * @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) { } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java index 9066b515da1..5b622355480 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractPackageIndexWriter.java @@ -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.HtmlTag; 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 @@ public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter { * * @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 @@ public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter { * * @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 @@ public abstract class AbstractPackageIndexWriter extends HtmlDocletWriter { * * @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; diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java index b8606b483af..e0274248faf 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractTreeWriter.java @@ -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.formats.html.markup.HtmlTree; 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 @@ public abstract class AbstractTreeWriter extends HtmlDocletWriter { * @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) { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java index c1df8a952ed..51ef581a0fb 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java @@ -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.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; import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; @@ -75,8 +73,6 @@ public class AllClassesFrameWriter extends HtmlDocletWriter { * @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 @@ public class AllClassesFrameWriter extends HtmlDocletWriter { * 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,20 @@ public class AllClassesFrameWriter extends HtmlDocletWriter { } 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); + allclassgen.buildAllClassesFile(false); } /** * 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, diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java index 9ff7d7b8ba6..d0d621df905 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AnnotationTypeWriterImpl.java @@ -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.AnnotationTypeWriter; 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 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter * @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 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter * {@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 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter */ @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 @@ public class AnnotationTypeWriterImpl extends SubWriterHolderWriter * 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); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java index 99155332af3..75e1313106a 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassUseWriter.java @@ -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.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.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 @@ public class ClassUseWriter extends SubWriterHolderWriter { * 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 @@ public class ClassUseWriter extends SubWriterHolderWriter { /** * 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 @@ public class ClassUseWriter extends SubWriterHolderWriter { /** * 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 @@ public class ClassUseWriter extends SubWriterHolderWriter { * * @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 @@ public class ClassUseWriter extends SubWriterHolderWriter { * * @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 @@ public class ClassUseWriter extends SubWriterHolderWriter { * * @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 @@ public class ClassUseWriter extends SubWriterHolderWriter { * * @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 @@ public class ClassUseWriter extends SubWriterHolderWriter { * @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 @@ public class ClassUseWriter extends SubWriterHolderWriter { * @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)); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java index 3bc361efb2d..1e64848771f 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.IOException; import java.util.*; import javax.lang.model.element.AnnotationMirror; @@ -50,9 +49,9 @@ import jdk.javadoc.internal.doclets.toolkit.builders.MemberSummaryBuilder; 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 +90,9 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite * @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 +269,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite * {@inheritDoc} */ @Override - public void printDocument(Content contentTree) throws IOException { + public void printDocument(Content contentTree) throws DocFileIOException { printHtmlDocument(configuration.metakeywords.getMetaKeywords(typeElement), true, contentTree); } @@ -677,14 +674,11 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite * * @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 +686,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite * * @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 +721,8 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite * 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); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java index f51a210c774..c737469218e 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConfigurationImpl.java @@ -50,7 +50,6 @@ import jdk.javadoc.internal.doclets.toolkit.WriterFactory; 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.*; diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java index c4778bc09e5..57ee7012236 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ConstantsSummaryWriterImpl.java @@ -41,6 +41,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; 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 @@ public class ConstantsSummaryWriterImpl extends HtmlDocletWriter implements Cons /** * {@inheritDoc} */ - public void printDocument(Content contentTree) throws IOException { + @Override + public void printDocument(Content contentTree) throws DocFileIOException { printHtmlDocument(null, true, contentTree); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java index 7280544b599..71b7e89e1d4 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/DeprecatedListWriter.java @@ -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.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.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 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { /** * 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 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { * 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 @@ public class DeprecatedListWriter extends SubWriterHolderWriter { * * @return a content tree for the deprecated label */ + @Override protected Content getNavLinkDeprecated() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.deprecatedLabel); return li; diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java index 6093824917e..84cd3ee136e 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/FrameOutputWriter.java @@ -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 @@ public class FrameOutputWriter extends HtmlDocletWriter { * * @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 @@ public class FrameOutputWriter extends HtmlDocletWriter { * 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()"); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java index a65889b64c1..686179c577f 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HelpWriter.java @@ -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 @@ public class HelpWriter extends HtmlDocletWriter { * 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)) diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java index 98397b6de15..3255df12f8e 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDoclet.java @@ -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.Doclet.Option; 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 @@ public class HtmlDoclet extends AbstractDoclet { * 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 @@ public class HtmlDoclet extends AbstractDoclet { } } - protected void copyJqueryFiles() { + protected void copyJqueryFiles() throws DocletException { List files = Arrays.asList( "jquery-1.10.2.js", "jquery-ui.js", @@ -232,7 +233,8 @@ public class HtmlDoclet extends AbstractDoclet { * {@inheritDoc} */ @Override // defined by AbstractDoclet - protected void generateClassFiles(SortedSet arr, ClassTree classtree) { + protected void generateClassFiles(SortedSet arr, ClassTree classtree) + throws DocletException { List list = new ArrayList<>(arr); ListIterator iterator = list.listIterator(); TypeElement klass = null; @@ -241,32 +243,24 @@ public class HtmlDoclet extends AbstractDoclet { 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 @@ public class HtmlDoclet extends AbstractDoclet { * {@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 @@ public class HtmlDoclet extends AbstractDoclet { * {@inheritDoc} */ @Override // defined by AbstractDoclet - protected void generatePackageFiles(ClassTree classtree) throws Exception { + protected void generatePackageFiles(ClassTree classtree) throws DocletException { Set packages = configuration.packages; if (packages.size() > 1 && configuration.frames) { PackageIndexFrameWriter.generate(configuration); @@ -356,24 +350,18 @@ public class HtmlDoclet extends AbstractDoclet { 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); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index a9f3a92fa4f..0945cc80603 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -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,8 +54,8 @@ import com.sun.source.doctree.DocTree.Kind; import com.sun.source.doctree.EndElementTree; import com.sun.source.doctree.EntityTree; import com.sun.source.doctree.ErroneousTree; -import com.sun.source.doctree.InheritDocTree; import com.sun.source.doctree.IndexTree; +import com.sun.source.doctree.InheritDocTree; import com.sun.source.doctree.LinkTree; import com.sun.source.doctree.LiteralTree; import com.sun.source.doctree.SeeTree; @@ -87,14 +86,15 @@ import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter; 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 +439,10 @@ public class HtmlDocletWriter extends HtmlDocWriter { * @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 metakeywords, boolean includeScript, - Content body) throws IOException { + Content body) throws DocFileIOException { Content htmlDocType = configuration.isOutputHtml5() ? DocType.HTML5 : DocType.TRANSITIONAL; @@ -2180,8 +2181,8 @@ public class HtmlDocletWriter extends HtmlDocWriter { 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); @@ -2615,6 +2616,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { * * @return the configuration for this doclet. */ + @Override public Configuration configuration() { return configuration; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java index 6ac58ba2b0f..53a341b6875 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/IndexRedirectWriter.java @@ -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.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; import static jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocWriter.CONTENT_TYPE; @@ -53,28 +50,23 @@ import static jdk.javadoc.internal.doclets.formats.html.markup.HtmlDocWriter.CON */ 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; diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java index e819ad1dba8..ed21cab1a48 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleFrameWriter.java @@ -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.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.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** @@ -76,8 +75,7 @@ public class ModuleFrameWriter extends HtmlDocletWriter { * @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 @@ public class ModuleFrameWriter extends HtmlDocletWriter { * * @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); } /** diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java index 69d8580694c..592c2c496c7 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexFrameWriter.java @@ -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.HtmlTree; 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 @@ public class ModuleIndexFrameWriter extends AbstractModuleIndexWriter { * @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); } /** diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java index 717488ac530..866dc2c4382 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleIndexWriter.java @@ -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.HtmlTree; 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 @@ public class ModuleIndexWriter extends AbstractModuleIndexWriter { /** * 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 @@ public class ModuleIndexWriter extends AbstractModuleIndexWriter { * 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 @@ public class ModuleIndexWriter extends AbstractModuleIndexWriter { * * @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 @@ public class ModuleIndexWriter extends AbstractModuleIndexWriter { * * @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 @@ public class ModuleIndexWriter extends AbstractModuleIndexWriter { * "-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 @@ public class ModuleIndexWriter extends AbstractModuleIndexWriter { * * @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 @@ public class ModuleIndexWriter extends AbstractModuleIndexWriter { * * @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 @@ public class ModuleIndexWriter extends AbstractModuleIndexWriter { } } + @Override protected void addModulePackagesList(Map> modules, String text, String tableSummary, Content body, ModuleElement mdle) { } + @Override protected void addModulesList(Map> modules, String text, String tableSummary, Content body) { } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java index accc9be7930..28275956185 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModulePackageIndexFrameWriter.java @@ -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.HtmlTree; 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 @@ public class ModulePackageIndexFrameWriter extends AbstractModuleIndexWriter { * @param configuration the configuration object * @param filename Name of the package index file to be generated. */ - public ModulePackageIndexFrameWriter(ConfigurationImpl configuration, - DocPath filename) throws IOException { + public ModulePackageIndexFrameWriter(ConfigurationImpl configuration, DocPath filename) { super(configuration, filename); } /** * Generate the module package index file. - * @throws DocletAbortException + * @throws DocFileIOException * @param configuration the configuration object * @param mdle the module being documented */ - public static void generate(ConfigurationImpl configuration, ModuleElement mdle) { - ModulePackageIndexFrameWriter modpackgen; + public static void generate(ConfigurationImpl configuration, ModuleElement mdle) throws DocFileIOException { DocPath filename = DocPaths.moduleFrame(mdle); - try { - modpackgen = new ModulePackageIndexFrameWriter(configuration, filename); - modpackgen.buildModulePackagesIndexFile("doclet.Window_Overview", false, mdle); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), filename); - throw new DocletAbortException(exc); - } + ModulePackageIndexFrameWriter modpackgen = new ModulePackageIndexFrameWriter(configuration, filename); + modpackgen.buildModulePackagesIndexFile("doclet.Window_Overview", false, mdle); } /** diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java index 3c52b31c44f..b79ff717281 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ModuleWriterImpl.java @@ -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; @@ -46,8 +45,8 @@ import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.ModuleSummaryWriter; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** * Class to generate file for each module contents in the right-hand @@ -515,12 +514,8 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW * @param subDiv the content tree to which the summary detail links will be added */ protected void addSummaryDetailLinks(Content subDiv) { - try { - Content div = HtmlTree.DIV(getNavSummaryLinks()); - subDiv.addContent(div); - } catch (Exception e) { - throw new DocletAbortException(e); - } + Content div = HtmlTree.DIV(getNavSummaryLinks()); + subDiv.addContent(div); } /** @@ -528,7 +523,7 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW * * @return the content tree for the navigation summary links */ - protected Content getNavSummaryLinks() throws Exception { + protected Content getNavSummaryLinks() { Content li = HtmlTree.LI(contents.moduleSubNavLabel); li.addContent(Contents.SPACE); Content ulNav = HtmlTree.UL(HtmlStyle.subNavList, li); @@ -591,7 +586,8 @@ public class ModuleWriterImpl extends HtmlDocletWriter implements ModuleSummaryW /** * {@inheritDoc} */ - public void printDocument(Content contentTree) throws IOException { + @Override + public void printDocument(Content contentTree) throws DocFileIOException { printHtmlDocument(configuration.metakeywords.getMetaKeywordsForModule(mdle), true, contentTree); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java index 44590f68b2b..7932cda3b69 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageFrameWriter.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.*; import javax.lang.model.element.PackageElement; @@ -38,10 +37,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.Configuration; 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; /** @@ -62,7 +60,7 @@ public class PackageFrameWriter extends HtmlDocletWriter { /** * The package being documented. */ - private PackageElement packageElement; + private final PackageElement packageElement; /** * The classes to be documented. Use this to filter out classes @@ -96,35 +94,29 @@ public class PackageFrameWriter extends HtmlDocletWriter { * * @param configuration the current configuration of the doclet. * @param packageElement The package for which "pacakge-frame.html" is to be generated. + * @throws DocFileIOException if there is a problem generating the package summary page */ - public static void generate(ConfigurationImpl configuration, PackageElement packageElement) { - PackageFrameWriter packgen; - try { - packgen = new PackageFrameWriter(configuration, packageElement); - String pkgName = configuration.utils.getPackageName(packageElement); - HtmlTree body = packgen.getBody(false, packgen.getWindowTitle(pkgName)); - Content pkgNameContent = new StringContent(pkgName); - HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) - ? HtmlTree.MAIN() - : body; - Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, - packgen.getTargetPackageLink(packageElement, "classFrame", pkgNameContent)); - htmlTree.addContent(heading); - HtmlTree div = new HtmlTree(HtmlTag.DIV); - div.addStyle(HtmlStyle.indexContainer); - packgen.addClassListing(div); - htmlTree.addContent(div); - if (configuration.allowTag(HtmlTag.MAIN)) { - body.addContent(htmlTree); - } - packgen.printHtmlDocument( - configuration.metakeywords.getMetaKeywords(packageElement), false, body); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), DocPaths.PACKAGE_FRAME.getPath()); - throw new DocletAbortException(exc); + public static void generate(ConfigurationImpl configuration, PackageElement packageElement) + throws DocFileIOException { + PackageFrameWriter packgen = new PackageFrameWriter(configuration, packageElement); + String pkgName = configuration.utils.getPackageName(packageElement); + HtmlTree body = packgen.getBody(false, packgen.getWindowTitle(pkgName)); + Content pkgNameContent = new StringContent(pkgName); + HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) + ? HtmlTree.MAIN() + : body; + Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, HtmlStyle.bar, + packgen.getTargetPackageLink(packageElement, "classFrame", pkgNameContent)); + htmlTree.addContent(heading); + HtmlTree div = new HtmlTree(HtmlTag.DIV); + div.addStyle(HtmlStyle.indexContainer); + packgen.addClassListing(div); + htmlTree.addContent(div); + if (configuration.allowTag(HtmlTag.MAIN)) { + body.addContent(htmlTree); } + packgen.printHtmlDocument( + configuration.metakeywords.getMetaKeywords(packageElement), false, body); } /** @@ -168,7 +160,7 @@ public class PackageFrameWriter extends HtmlDocletWriter { /** * Add specific class kind listing. Also add label to the listing. * - * @param arr Array of specific class kinds, namely Class or Interface or Exception or Error + * @param list list of specific class kinds, namely Class or Interface or Exception or Error * @param labelContent content tree of the label to be added * @param contentTree the content tree to which the class kind listing will be added */ diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java index be2b1a9fc4c..8c9087a1c21 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexFrameWriter.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.IOException; import java.util.Collection; import javax.lang.model.element.PackageElement; @@ -37,10 +36,9 @@ import jdk.javadoc.internal.doclets.formats.html.markup.HtmlTree; 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; /** @@ -62,32 +60,24 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { * * @param filename Name of the package index file to be generated. */ - public PackageIndexFrameWriter(ConfigurationImpl configuration, - DocPath filename) throws IOException { + public PackageIndexFrameWriter(ConfigurationImpl configuration, DocPath filename) { super(configuration, filename); } /** * Generate the package index file named "overview-frame.html". - * @throws DocletAbortException + * @throws DocFileIOException */ - public static void generate(ConfigurationImpl configuration) { - PackageIndexFrameWriter packgen; + public static void generate(ConfigurationImpl configuration) throws DocFileIOException { DocPath filename = DocPaths.OVERVIEW_FRAME; - try { - packgen = new PackageIndexFrameWriter(configuration, filename); - packgen.buildPackageIndexFile("doclet.Window_Overview", false); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), filename); - throw new DocletAbortException(exc); - } + PackageIndexFrameWriter packgen = new PackageIndexFrameWriter(configuration, filename); + packgen.buildPackageIndexFile("doclet.Window_Overview", false); } /** * {@inheritDoc} */ + @Override protected void addPackagesList(Collection packages, String text, String tableSummary, Content body) { Content heading = HtmlTree.HEADING(HtmlConstants.PACKAGE_HEADING, true, @@ -135,6 +125,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { /** * {@inheritDoc} */ + @Override protected void addNavigationBarHeader(Content body) { Content headerContent; if (configuration.packagesheader.length() > 0) { @@ -150,6 +141,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { /** * Do nothing as there is no overview information in this page. */ + @Override protected void addOverviewHeader(Content body) { } @@ -159,6 +151,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { * * @param ul the Content object to which the "All Classes" link should be added */ + @Override protected void addAllClassesLink(Content ul) { Content linkContent = getHyperLink(DocPaths.ALLCLASSES_FRAME, contents.allClassesLabel, "", "packageFrame"); @@ -172,6 +165,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { * * @param ul the Content object to which the "All Modules" link should be added */ + @Override protected void addAllModulesLink(Content ul) { Content linkContent = getHyperLink(DocPaths.MODULE_OVERVIEW_FRAME, contents.allModulesLabel, "", "packageListFrame"); @@ -182,6 +176,7 @@ public class PackageIndexFrameWriter extends AbstractPackageIndexWriter { /** * {@inheritDoc} */ + @Override protected void addNavigationBarFooter(Content body) { Content p = HtmlTree.P(Contents.SPACE); body.addContent(p); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java index f40c1e30ba6..f9c0d3b3613 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageIndexWriter.java @@ -25,22 +25,19 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.*; 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; 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.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; /** @@ -58,38 +55,35 @@ import jdk.javadoc.internal.doclets.toolkit.util.Group; */ public class PackageIndexWriter extends AbstractPackageIndexWriter { - /** - * Root of the program structure. Used for "overview" documentation. - */ - private DocletEnvironment docEnv; /** * Map representing the group of packages as specified on the command line. * * @see Group */ - private Map> groupPackageMap; + private final Map> groupPackageMap; /** * List to store the order groups as specified on the command line. */ - private List groupList; + private final List groupList; /** * HTML tree for main tag. */ - private HtmlTree htmlTree = HtmlTree.MAIN(); + private final HtmlTree htmlTree = HtmlTree.MAIN(); /** * Construct the PackageIndexWriter. Also constructs the grouping * information as provided on the command line by "-group" option. Stores * the order of groups specified by the user. * + * @param configuration the configuration for this doclet + * @param filename the path of the page to be generated * @see Group */ - public PackageIndexWriter(ConfigurationImpl configuration, DocPath filename) throws IOException { + public PackageIndexWriter(ConfigurationImpl configuration, DocPath filename) { super(configuration, filename); - this.docEnv = configuration.docEnv; groupPackageMap = configuration.group.groupPackages(packages); groupList = configuration.group.getGroupList(); } @@ -98,19 +92,12 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { * Generate the package index page for the right-hand frame. * * @param configuration the current configuration of the doclet. + * @throws DocFileIOException if there is a problem generating the package index page */ - public static void generate(ConfigurationImpl configuration) { - PackageIndexWriter packgen; + public static void generate(ConfigurationImpl configuration) throws DocFileIOException { DocPath filename = DocPaths.overviewSummary(configuration.frames); - try { - packgen = new PackageIndexWriter(configuration, filename); - packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), filename); - throw new DocletAbortException(exc); - } + PackageIndexWriter packgen = new PackageIndexWriter(configuration, filename); + packgen.buildPackageIndexFile("doclet.Window_Overview_Summary", true); } /** @@ -119,6 +106,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { * * @param body the documentation tree to which the index will be added */ + @Override protected void addIndex(Content body) { for (String groupname : groupList) { SortedSet list = groupPackageMap.get(groupname); @@ -133,6 +121,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { /** * {@inheritDoc} */ + @Override protected void addPackagesList(Collection packages, String text, String tableSummary, Content body) { Content table = (configuration.isOutputHtml5()) @@ -183,6 +172,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { * * @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()) { @@ -227,7 +217,8 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { * * @param body the documentation tree to which the overview will be added */ - 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); @@ -246,6 +237,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { * * @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() @@ -263,6 +255,7 @@ public class PackageIndexWriter extends AbstractPackageIndexWriter { * * @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() diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java index d48e0e17704..f67e906a209 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageTreeWriter.java @@ -25,8 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; - import javax.lang.model.element.PackageElement; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlConstants; @@ -34,11 +32,10 @@ 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.ClassTree; +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; /** @@ -77,14 +74,11 @@ public class PackageTreeWriter extends AbstractTreeWriter { * @param packageElement the current package * @param prev the previous package * @param next the next package - * @throws IOException - * @throws DocletAbortException */ public PackageTreeWriter(ConfigurationImpl configuration, DocPath path, PackageElement packageElement, - PackageElement prev, PackageElement next) - throws IOException { + PackageElement prev, PackageElement next) { super(configuration, path, new ClassTree(configuration.typeElementCatalog.allClasses(packageElement), configuration)); this.packageElement = packageElement; @@ -102,30 +96,22 @@ public class PackageTreeWriter extends AbstractTreeWriter { * @param next Next package in the alpha-ordered list. * @param noDeprecated If true, do not generate any information for * deprecated classe or interfaces. - * @throws DocletAbortException + * @throws DocFileIOException if there is a problem generating the package tree page */ public static void generate(ConfigurationImpl configuration, PackageElement pkg, PackageElement prev, - PackageElement next, boolean noDeprecated) { - PackageTreeWriter packgen; + PackageElement next, boolean noDeprecated) + throws DocFileIOException { DocPath path = DocPath.forPackage(pkg).resolve(DocPaths.PACKAGE_TREE); - try { - packgen = new PackageTreeWriter(configuration, path, pkg, - prev, next); - packgen.generatePackageTreeFile(); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), path.getPath()); - throw new DocletAbortException(exc); - } + PackageTreeWriter packgen = new PackageTreeWriter(configuration, path, pkg, prev, next); + packgen.generatePackageTreeFile(); } /** * Generate a separate tree file for each package. - * @throws java.io.IOException + * @throws DocFileIOException if there is a problem generating the package tree file */ - protected void generatePackageTreeFile() throws IOException { + protected void generatePackageTreeFile() throws DocFileIOException { HtmlTree body = getPackageTreeHeader(); HtmlTree htmlTree = (configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN() @@ -200,6 +186,7 @@ public class PackageTreeWriter extends AbstractTreeWriter { * * @return a content tree for the link */ + @Override protected Content getNavLinkPrevious() { if (prev == null) { return getNavLinkPrevious(null); @@ -214,6 +201,7 @@ public class PackageTreeWriter extends AbstractTreeWriter { * * @return a content tree for the link */ + @Override protected Content getNavLinkNext() { if (next == null) { return getNavLinkNext(null); @@ -241,6 +229,7 @@ public class PackageTreeWriter extends AbstractTreeWriter { * * @return a content tree for the package link */ + @Override protected Content getNavLinkPackage() { Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, contents.packageLabel); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java index b653aedf77a..05b966ec318 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageUseWriter.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.*; import javax.lang.model.element.PackageElement; @@ -38,11 +37,10 @@ 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.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 package usage information. @@ -65,12 +63,10 @@ public class PackageUseWriter extends SubWriterHolderWriter { * Constructor. * * @param filename the file to be generated. - * @throws IOException - * @throws DocletAbortException */ public PackageUseWriter(ConfigurationImpl configuration, ClassUseMapper mapper, DocPath filename, - PackageElement pkgElement) throws IOException { + PackageElement pkgElement) { super(configuration, DocPath.forPackage(pkgElement).resolve(filename)); this.packageElement = pkgElement; @@ -101,25 +97,21 @@ public class PackageUseWriter extends SubWriterHolderWriter { * @param configuration the current configuration of the doclet. * @param mapper the mapping of the class usage. * @param pkgElement the package being documented. + * @throws DocFileIOException if there is a problem generating the package use page */ public static void generate(ConfigurationImpl configuration, - ClassUseMapper mapper, PackageElement pkgElement) { - PackageUseWriter pkgusegen; + ClassUseMapper mapper, PackageElement pkgElement) + throws DocFileIOException { DocPath filename = DocPaths.PACKAGE_USE; - try { - pkgusegen = new PackageUseWriter(configuration, mapper, filename, pkgElement); - pkgusegen.generatePackageUseFile(); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error(exc.toString(), filename); - throw new DocletAbortException(exc); - } + PackageUseWriter pkgusegen = new PackageUseWriter(configuration, mapper, filename, pkgElement); + pkgusegen.generatePackageUseFile(); } /** * Generate the package use list. + * @throws DocFileIOException if there is a problem generating the package use page */ - protected void generatePackageUseFile() throws IOException { + protected void generatePackageUseFile() throws DocFileIOException { HtmlTree body = getPackageUseHeader(); HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.contentContainer); @@ -150,7 +142,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { * * @param contentTree the content tree to which the package use information will be added */ - protected void addPackageUse(Content contentTree) throws IOException { + protected void addPackageUse(Content contentTree) { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.blockList); if (configuration.packages.size() > 1) { @@ -165,7 +157,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { * * @param contentTree the content tree to which the package list 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", getPackageLink(packageElement, utils.getPackageName(packageElement)))); @@ -193,7 +185,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { * * @param contentTree the content tree to which the class list will be added */ - protected void addClassList(Content contentTree) throws IOException { + protected void addClassList(Content contentTree) { List classTableHeader = Arrays.asList( configuration.getText("doclet.0_and_1", configuration.getText("doclet.Class"), @@ -254,7 +246,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { * @param pkg the package that used the given package * @param contentTree the content tree to which the 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(utils.getPackageName(pkg), new StringContent(utils.getPackageName(pkg)))); @@ -320,6 +312,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { * * @return a content tree for the package link */ + @Override protected Content getNavLinkPackage() { Content linkContent = getHyperLink(DocPaths.PACKAGE_SUMMARY, contents.packageLabel); @@ -332,6 +325,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { * * @return a content tree for the use link */ + @Override protected Content getNavLinkClassUse() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.useLabel); return li; @@ -342,6 +336,7 @@ public class PackageUseWriter extends SubWriterHolderWriter { * * @return a content tree for the tree link */ + @Override protected Content getNavLinkTree() { Content linkContent = getHyperLink(DocPaths.PACKAGE_TREE, contents.treeLabel); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java index 7e8c76aa3f2..f6c2eaba492 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/PackageWriterImpl.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.*; import javax.lang.model.element.ModuleElement; @@ -42,6 +41,7 @@ import jdk.javadoc.internal.doclets.formats.html.markup.StringContent; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter; 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; @@ -112,6 +112,7 @@ public class PackageWriterImpl extends HtmlDocletWriter /** * {@inheritDoc} */ + @Override public Content getPackageHeader(String heading) { HtmlTree bodyTree = getBody(true, getWindowTitle(utils.getPackageName(packageElement))); HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER)) @@ -166,6 +167,7 @@ public class PackageWriterImpl extends HtmlDocletWriter /** * {@inheritDoc} */ + @Override public Content getContentHeader() { HtmlTree div = new HtmlTree(HtmlTag.DIV); div.addStyle(HtmlStyle.contentContainer); @@ -198,6 +200,7 @@ public class PackageWriterImpl extends HtmlDocletWriter /** * {@inheritDoc} */ + @Override public Content getSummaryHeader() { HtmlTree ul = new HtmlTree(HtmlTag.UL); ul.addStyle(HtmlStyle.blockList); @@ -207,6 +210,7 @@ public class PackageWriterImpl extends HtmlDocletWriter /** * {@inheritDoc} */ + @Override public void addClassesSummary(SortedSet classes, String label, String tableSummary, List tableHeader, Content summaryContentTree) { if(!classes.isEmpty()) { @@ -252,6 +256,7 @@ public class PackageWriterImpl extends HtmlDocletWriter /** * {@inheritDoc} */ + @Override public void addPackageDescription(Content packageContentTree) { if (!utils.getBody(packageElement).isEmpty()) { packageContentTree.addContent( @@ -273,6 +278,7 @@ public class PackageWriterImpl extends HtmlDocletWriter /** * {@inheritDoc} */ + @Override public void addPackageTags(Content packageContentTree) { Content htmlTree = (configuration.allowTag(HtmlTag.SECTION)) ? sectionTree @@ -283,6 +289,7 @@ public class PackageWriterImpl extends HtmlDocletWriter /** * {@inheritDoc} */ + @Override public void addPackageContent(Content contentTree, Content packageContentTree) { if (configuration.allowTag(HtmlTag.MAIN)) { packageContentTree.addContent(sectionTree); @@ -296,6 +303,7 @@ public class PackageWriterImpl extends HtmlDocletWriter /** * {@inheritDoc} */ + @Override public void addPackageFooter(Content contentTree) { Content htmlTree = (configuration.allowTag(HtmlTag.FOOTER)) ? HtmlTree.FOOTER() @@ -310,7 +318,8 @@ public class PackageWriterImpl extends HtmlDocletWriter /** * {@inheritDoc} */ - public void printDocument(Content contentTree) throws IOException { + @Override + public void printDocument(Content contentTree) throws DocFileIOException { printHtmlDocument(configuration.metakeywords.getMetaKeywords(packageElement), true, contentTree); } @@ -320,6 +329,7 @@ public class PackageWriterImpl extends HtmlDocletWriter * * @return a content tree for the class use link */ + @Override protected Content getNavLinkClassUse() { Content useLink = getHyperLink(DocPaths.PACKAGE_USE, contents.useLabel, "", ""); @@ -332,6 +342,7 @@ public class PackageWriterImpl extends HtmlDocletWriter * * @return a content tree for the previous link */ + @Override public Content getNavLinkPrevious() { Content li; if (prev == null) { @@ -349,6 +360,7 @@ public class PackageWriterImpl extends HtmlDocletWriter * * @return a content tree for the next link */ + @Override public Content getNavLinkNext() { Content li; if (next == null) { @@ -367,6 +379,7 @@ public class PackageWriterImpl extends HtmlDocletWriter * * @return a content tree for the tree link */ + @Override protected Content getNavLinkTree() { Content useLink = getHyperLink(DocPaths.PACKAGE_TREE, contents.treeLabel, "", ""); @@ -392,6 +405,7 @@ public class PackageWriterImpl extends HtmlDocletWriter * * @return a content tree for the package link */ + @Override protected Content getNavLinkPackage() { Content li = HtmlTree.LI(HtmlStyle.navBarCell1Rev, contents.packageLabel); return li; diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java index e23cd8bb206..98b47053cbd 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SerializedFormWriterImpl.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.*; import javax.lang.model.element.TypeElement; @@ -39,8 +38,8 @@ import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter; import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter.SerialFieldWriter; import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter.SerialMethodWriter; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** * Generate the Serialized Form Information Page. @@ -64,11 +63,8 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter /** * @param configuration the configuration data for the doclet - * @throws IOException - * @throws DocletAbortException */ - public SerializedFormWriterImpl(ConfigurationImpl configuration) - throws IOException { + public SerializedFormWriterImpl(ConfigurationImpl configuration) { super(configuration, DocPaths.SERIALIZED_FORM); visibleClasses = configuration.docEnv.getIncludedTypeElements(); } @@ -277,7 +273,8 @@ public class SerializedFormWriterImpl extends SubWriterHolderWriter /** * {@inheritDoc} */ - public void printDocument(Content serializedTree) throws IOException { + @Override + public void printDocument(Content serializedTree) throws DocFileIOException { printHtmlDocument(null, true, serializedTree); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java index 42a09f8aa85..d5735fffe19 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SingleIndexWriter.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.*; import jdk.javadoc.internal.doclets.formats.html.markup.HtmlStyle; @@ -33,10 +32,9 @@ 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; import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; @@ -62,42 +60,37 @@ public class SingleIndexWriter extends AbstractIndexWriter { * Construct the SingleIndexWriter with filename "index-all.html" and the * {@link IndexBuilder} * + * @param configuration the configuration for this doclet * @param filename Name of the index file to be generated. * @param indexbuilder Unicode based Index from {@link IndexBuilder} */ public SingleIndexWriter(ConfigurationImpl configuration, DocPath filename, - IndexBuilder indexbuilder) throws IOException { + IndexBuilder indexbuilder) { super(configuration, filename, indexbuilder); } /** * Generate single index file, for all Unicode characters. * + * @param configuration the configuration for this doclet * @param indexbuilder IndexBuilder built by {@link IndexBuilder} - * @throws DocletAbortException + * @throws DocFileIOException if there is a problem generating the index */ public static void generate(ConfigurationImpl configuration, - IndexBuilder indexbuilder) { - SingleIndexWriter indexgen; + IndexBuilder indexbuilder) throws DocFileIOException { DocPath filename = DocPaths.INDEX_ALL; - try { - indexgen = new SingleIndexWriter(configuration, - filename, indexbuilder); - indexgen.generateIndexFile(); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), filename); - throw new DocletAbortException(exc); - } + SingleIndexWriter indexgen = new SingleIndexWriter(configuration, + filename, indexbuilder); + indexgen.generateIndexFile(); } /** * Generate the contents of each index file, with Header, Footer, * Member Field, Method and Constructor Description. + * @throws DocFileIOException if there is a problem generating the index */ - protected void generateIndexFile() throws IOException { + protected void generateIndexFile() throws DocFileIOException { String title = configuration.getText("doclet.Window_Single_Index"); HtmlTree body = getBody(true, getWindowTitle(title)); HtmlTree htmlTree = (configuration.allowTag(HtmlTag.HEADER)) diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java index 417c930decc..c54eebe8e58 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SourceToHTMLConverter.java @@ -42,10 +42,11 @@ 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.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.DocletConstants; +import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException; import jdk.javadoc.internal.doclets.toolkit.util.Utils; /** @@ -79,7 +80,7 @@ public class SourceToHTMLConverter { private final DocletEnvironment docEnv; - private DocPath outputdir; + private final DocPath outputdir; /** * Relative path from the documentation root to the file that is being @@ -102,13 +103,15 @@ public class SourceToHTMLConverter { * @param configuration the configuration. * @param docEnv the DocletEnvironment to convert. * @param outputdir the name of the directory to output to. + * @throws DocFileIOException if there is a problem generating an output file + * @throws SimpleDocletException if there is a problem reading a source file */ public static void convertRoot(ConfigurationImpl configuration, DocletEnvironment docEnv, - DocPath outputdir) { + DocPath outputdir) throws DocFileIOException, SimpleDocletException { new SourceToHTMLConverter(configuration, docEnv, outputdir).generate(); } - void generate() { + void generate() throws DocFileIOException, SimpleDocletException { if (docEnv == null || outputdir == null) { return; } @@ -129,12 +132,15 @@ public class SourceToHTMLConverter { } /** - * Convert the Classes in the given Package to an HTML. + * Convert the Classes in the given Package to an HTML file. * * @param pkg the Package to convert. * @param outputdir the name of the directory to output to. + * @throws DocFileIOException if there is a problem generating an output file + * @throws SimpleDocletException if there is a problem reading a source file */ - public void convertPackage(PackageElement pkg, DocPath outputdir) { + public void convertPackage(PackageElement pkg, DocPath outputdir) + throws DocFileIOException, SimpleDocletException { if (pkg == null) { return; } @@ -152,16 +158,20 @@ public class SourceToHTMLConverter { * Convert the given Class to an HTML. * * @param te the class to convert. - * @param outputdir the name of the directory to output to. + * @param outputdir the name of the directory to output to + * @throws DocFileIOException if there is a problem generating the output file + * @throws SimpleDocletException if there is a problem reading the source file */ - public void convertClass(TypeElement te, DocPath outputdir) { + public void convertClass(TypeElement te, DocPath outputdir) + throws DocFileIOException, SimpleDocletException { if (te == null) { return; } + FileObject fo = utils.getFileObject(te); + if (fo == null) + return; + try { - FileObject fo = utils.getFileObject(te); - if (fo == null) - return; Reader r = fo.openReader(true); int lineno = 1; String line; @@ -182,7 +192,8 @@ public class SourceToHTMLConverter { body.addContent((configuration.allowTag(HtmlTag.MAIN)) ? HtmlTree.MAIN(div) : div); writeToFile(body, outputdir.resolve(DocPath.forClass(utils, te))); } catch (IOException e) { - throw new DocletAbortException(e); + String message = configuration.resources.getText("doclet.exception.read.file", fo.getName()); + throw new SimpleDocletException(message, e); } } @@ -192,7 +203,7 @@ public class SourceToHTMLConverter { * @param body the documentation content to be written to the file. * @param path the path for the file. */ - private void writeToFile(Content body, DocPath path) throws IOException { + private void writeToFile(Content body, DocPath path) throws DocFileIOException { Content htmlDocType = configuration.isOutputHtml5() ? DocType.HTML5 : DocType.TRANSITIONAL; @@ -207,6 +218,8 @@ public class SourceToHTMLConverter { DocFile df = DocFile.createFileForOutput(configuration, path); try (Writer w = df.openWriter()) { htmlDocument.write(w, true); + } catch (IOException e) { + throw new DocFileIOException(df, DocFileIOException.Mode.WRITE, e); } } @@ -287,9 +300,10 @@ public class SourceToHTMLConverter { } /** - * Given a Doc, return an anchor name for it. + * Given an element, return an anchor name for it. * - * @param d the Doc to check. + * @param utils the utility class, used to get the line number of the element + * @param e the element to check. * @return the name of the anchor. */ public static String getAnchorName(Utils utils, Element e) { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java index 8b7bbc9eca1..364d283b113 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/SplitIndexWriter.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.*; import java.util.ArrayList; import java.util.Collection; import java.util.List; @@ -38,10 +37,9 @@ 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; import jdk.javadoc.internal.doclets.toolkit.util.IndexBuilder; @@ -71,20 +69,24 @@ public class SplitIndexWriter extends AbstractIndexWriter { */ protected int next; - private List indexElements; + private final List indexElements; /** * Construct the SplitIndexWriter. Uses path to this file and relative path * from this file. * + * @param configuration the configuration for this doclet * @param path Path to the file which is getting generated. * @param indexbuilder Unicode based Index from {@link IndexBuilder} + * @param elements the collection of characters for which to generate index files + * @param prev the previous character that was indexed + * @param next the next character to be indexed */ public SplitIndexWriter(ConfigurationImpl configuration, DocPath path, IndexBuilder indexbuilder, Collection elements, - int prev, int next) throws IOException { + int prev, int next) { super(configuration, path, indexbuilder); this.indexElements = new ArrayList<>(elements); this.prev = prev; @@ -95,34 +97,26 @@ public class SplitIndexWriter extends AbstractIndexWriter { * Generate separate index files, for each Unicode character, listing all * the members starting with the particular unicode character. * + * @param configuration the configuration for this doclet * @param indexbuilder IndexBuilder built by {@link IndexBuilder} - * @throws DocletAbortException + * @throws DocFileIOException if there is a problem generating the index files */ public static void generate(ConfigurationImpl configuration, - IndexBuilder indexbuilder) { - SplitIndexWriter indexgen; - DocPath filename = DocPath.empty; + IndexBuilder indexbuilder) throws DocFileIOException { DocPath path = DocPaths.INDEX_FILES; - try { - Set keys = new TreeSet<>(indexbuilder.getIndexMap().keySet()); - keys.addAll(configuration.tagSearchIndexKeys); - ListIterator li = new ArrayList<>(keys).listIterator(); - while (li.hasNext()) { - Object ch = li.next(); - filename = DocPaths.indexN(li.nextIndex()); - indexgen = new SplitIndexWriter(configuration, - path.resolve(filename), - indexbuilder, keys, li.previousIndex(), li.nextIndex()); - indexgen.generateIndexFile((Character) ch); - if (!li.hasNext()) { - indexgen.createSearchIndexFiles(); - } + Set keys = new TreeSet<>(indexbuilder.getIndexMap().keySet()); + keys.addAll(configuration.tagSearchIndexKeys); + ListIterator li = new ArrayList<>(keys).listIterator(); + while (li.hasNext()) { + Object ch = li.next(); + DocPath filename = DocPaths.indexN(li.nextIndex()); + SplitIndexWriter indexgen = new SplitIndexWriter(configuration, + path.resolve(filename), + indexbuilder, keys, li.previousIndex(), li.nextIndex()); + indexgen.generateIndexFile((Character) ch); + if (!li.hasNext()) { + indexgen.createSearchIndexFiles(); } - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), filename.getPath()); - throw new DocletAbortException(exc); } } @@ -132,8 +126,9 @@ public class SplitIndexWriter extends AbstractIndexWriter { * * @param unicode Unicode character referring to the character for the * index. + * @throws DocFileIOException if there is a problem generating an index file */ - protected void generateIndexFile(Character unicode) throws IOException { + protected void generateIndexFile(Character unicode) throws DocFileIOException { String title = configuration.getText("doclet.Window_Split_Index", unicode.toString()); HtmlTree body = getBody(true, getWindowTitle(title)); @@ -188,6 +183,7 @@ public class SplitIndexWriter extends AbstractIndexWriter { * * @return a content tree for the link */ + @Override public Content getNavLinkPrevious() { Content prevletterLabel = contents.prevLetter; if (prev == -1) { @@ -205,6 +201,7 @@ public class SplitIndexWriter extends AbstractIndexWriter { * * @return a content tree for the link */ + @Override public Content getNavLinkNext() { Content nextletterLabel = contents.nextLetter; if (next == -1) { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java index 3a6f31b1ce2..cade70f9622 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TreeWriter.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.IOException; import java.util.SortedSet; import javax.lang.model.element.PackageElement; @@ -36,11 +35,10 @@ 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.ClassTree; +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 Hierarchy page for all the Classes in this run. Use @@ -67,7 +65,7 @@ public class TreeWriter extends AbstractTreeWriter { * True if there are no packages specified on the command line, * False otherwise. */ - private boolean classesonly; + private final boolean classesOnly; /** * Constructor to construct TreeWriter object. @@ -76,39 +74,33 @@ public class TreeWriter extends AbstractTreeWriter { * @param filename String filename * @param classtree the tree being built. */ - public TreeWriter(ConfigurationImpl configuration, - DocPath filename, ClassTree classtree) throws IOException { + public TreeWriter(ConfigurationImpl configuration, DocPath filename, ClassTree classtree) { super(configuration, filename, classtree); packages = configuration.packages; - classesonly = packages.isEmpty(); + classesOnly = packages.isEmpty(); } /** * Create a TreeWriter object and use it to generate the * "overview-tree.html" file. * + * @param configuration the configuration for this doclet * @param classtree the class tree being documented. - * @throws DocletAbortException + * @throws DocFileIOException if there is a problem generating the overview tree page */ public static void generate(ConfigurationImpl configuration, - ClassTree classtree) { - TreeWriter treegen; + ClassTree classtree) throws DocFileIOException { DocPath filename = DocPaths.OVERVIEW_TREE; - try { - treegen = new TreeWriter(configuration, filename, classtree); - treegen.generateTreeFile(); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), filename); - throw new DocletAbortException(exc); - } + TreeWriter treegen = new TreeWriter(configuration, filename, classtree); + treegen.generateTreeFile(); } /** * Generate the interface hierarchy and class hierarchy. + * + * @throws DocFileIOException if there is a problem generating the overview tree page */ - public void generateTreeFile() throws IOException { + public void generateTreeFile() throws DocFileIOException { HtmlTree body = getTreeHeader(); Content headContent = contents.hierarchyForAllPackages; Content heading = HtmlTree.HEADING(HtmlConstants.TITLE_HEADING, false, @@ -152,7 +144,7 @@ public class TreeWriter extends AbstractTreeWriter { if (isUnnamedPackage()) { return; } - if (!classesonly) { + if (!classesOnly) { Content span = HtmlTree.SPAN(HtmlStyle.packageHierarchyLabel, contents.packageHierarchies); contentTree.addContent(span); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/WriterFactoryImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/WriterFactoryImpl.java index 7e67fa7ac66..55742f604af 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/WriterFactoryImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/WriterFactoryImpl.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html; -import java.io.IOException; import javax.lang.model.element.ModuleElement; import javax.lang.model.element.PackageElement; @@ -69,7 +68,7 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public ConstantsSummaryWriter getConstantsSummaryWriter() throws Exception { + public ConstantsSummaryWriter getConstantsSummaryWriter() { return new ConstantsSummaryWriterImpl(configuration); } @@ -78,7 +77,7 @@ public class WriterFactoryImpl implements WriterFactory { */ @Override public PackageSummaryWriter getPackageSummaryWriter(PackageElement packageElement, - PackageElement prevPkg, PackageElement nextPkg) throws Exception { + PackageElement prevPkg, PackageElement nextPkg) { return new PackageWriterImpl(configuration, packageElement, prevPkg, nextPkg); } @@ -86,7 +85,7 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ public ModuleSummaryWriter getModuleSummaryWriter(ModuleElement mdle, - ModuleElement prevModule, ModuleElement nextModule) throws Exception { + ModuleElement prevModule, ModuleElement nextModule) { return new ModuleWriterImpl(configuration, mdle, prevModule, nextModule); } @@ -96,7 +95,7 @@ public class WriterFactoryImpl implements WriterFactory { */ @Override public ClassWriter getClassWriter(TypeElement typeElement, TypeElement prevClass, - TypeElement nextClass, ClassTree classTree) throws IOException { + TypeElement nextClass, ClassTree classTree) { return new ClassWriterImpl(configuration, typeElement, prevClass, nextClass, classTree); } @@ -105,7 +104,7 @@ public class WriterFactoryImpl implements WriterFactory { */ @Override public AnnotationTypeWriter getAnnotationTypeWriter(TypeElement annotationType, - TypeMirror prevType, TypeMirror nextType) throws Exception { + TypeMirror prevType, TypeMirror nextType) { return new AnnotationTypeWriterImpl(configuration, annotationType, prevType, nextType); } @@ -113,8 +112,8 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public AnnotationTypeFieldWriter - getAnnotationTypeFieldWriter(AnnotationTypeWriter annotationTypeWriter) throws Exception { + public AnnotationTypeFieldWriter getAnnotationTypeFieldWriter( + AnnotationTypeWriter annotationTypeWriter) { TypeElement te = annotationTypeWriter.getAnnotationTypeElement(); return new AnnotationTypeFieldWriterImpl( (SubWriterHolderWriter) annotationTypeWriter, te); @@ -124,9 +123,8 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public AnnotationTypeOptionalMemberWriter - getAnnotationTypeOptionalMemberWriter( - AnnotationTypeWriter annotationTypeWriter) throws Exception { + public AnnotationTypeOptionalMemberWriter getAnnotationTypeOptionalMemberWriter( + AnnotationTypeWriter annotationTypeWriter) { TypeElement te = annotationTypeWriter.getAnnotationTypeElement(); return new AnnotationTypeOptionalMemberWriterImpl( (SubWriterHolderWriter) annotationTypeWriter, te); @@ -136,8 +134,8 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public AnnotationTypeRequiredMemberWriter - getAnnotationTypeRequiredMemberWriter(AnnotationTypeWriter annotationTypeWriter) throws Exception { + public AnnotationTypeRequiredMemberWriter getAnnotationTypeRequiredMemberWriter( + AnnotationTypeWriter annotationTypeWriter) { TypeElement te = annotationTypeWriter.getAnnotationTypeElement(); return new AnnotationTypeRequiredMemberWriterImpl( (SubWriterHolderWriter) annotationTypeWriter, te); @@ -147,8 +145,7 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public EnumConstantWriterImpl getEnumConstantWriter(ClassWriter classWriter) - throws Exception { + public EnumConstantWriterImpl getEnumConstantWriter(ClassWriter classWriter) { return new EnumConstantWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getTypeElement()); } @@ -157,8 +154,7 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public FieldWriterImpl getFieldWriter(ClassWriter classWriter) - throws Exception { + public FieldWriterImpl getFieldWriter(ClassWriter classWriter) { return new FieldWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getTypeElement()); } @@ -166,8 +162,7 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public PropertyWriterImpl getPropertyWriter(ClassWriter classWriter) - throws Exception { + public PropertyWriterImpl getPropertyWriter(ClassWriter classWriter) { return new PropertyWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getTypeElement()); } @@ -176,8 +171,7 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public MethodWriterImpl getMethodWriter(ClassWriter classWriter) - throws Exception { + public MethodWriterImpl getMethodWriter(ClassWriter classWriter) { return new MethodWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getTypeElement()); } @@ -185,8 +179,7 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public ConstructorWriterImpl getConstructorWriter(ClassWriter classWriter) - throws Exception { + public ConstructorWriterImpl getConstructorWriter(ClassWriter classWriter) { return new ConstructorWriterImpl((SubWriterHolderWriter) classWriter, classWriter.getTypeElement()); } @@ -195,9 +188,8 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public MemberSummaryWriter getMemberSummaryWriter( - ClassWriter classWriter, VisibleMemberMap.Kind memberType) - throws Exception { + public MemberSummaryWriter getMemberSummaryWriter(ClassWriter classWriter, + VisibleMemberMap.Kind memberType) { switch (memberType) { case CONSTRUCTORS: return getConstructorWriter(classWriter); @@ -221,9 +213,8 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public MemberSummaryWriter getMemberSummaryWriter( - AnnotationTypeWriter annotationTypeWriter, VisibleMemberMap.Kind memberType) - throws Exception { + public MemberSummaryWriter getMemberSummaryWriter(AnnotationTypeWriter annotationTypeWriter, + VisibleMemberMap.Kind memberType) { switch (memberType) { case ANNOTATION_TYPE_FIELDS: return (AnnotationTypeFieldWriterImpl) @@ -243,7 +234,7 @@ public class WriterFactoryImpl implements WriterFactory { * {@inheritDoc} */ @Override - public SerializedFormWriter getSerializedFormWriter() throws Exception { + public SerializedFormWriter getSerializedFormWriter() { return new SerializedFormWriterImpl(configuration); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java index 32c5cc6c5b3..b2f134b0686 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/Comment.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.io.Writer; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; /** @@ -59,25 +58,21 @@ public class Comment extends Content { * This method is not supported by the class. * * @param content content that needs to be added - * @throws DocletAbortException this method will always throw a - * DocletAbortException because it - * is not supported. + * @throws UnsupportedOperationException always */ public void addContent(Content content) { - throw new DocletAbortException("not supported"); + throw new UnsupportedOperationException(); } /** * This method is not supported by the class. * * @param stringContent string content that needs to be added - * @throws DocletAbortException this method will always throw a - * DocletAbortException because it - * is not supported. + * @throws UnsupportedOperationException always */ @Override public void addContent(CharSequence stringContent) { - throw new DocletAbortException("not supported"); + throw new UnsupportedOperationException(); } /** diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/DocType.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/DocType.java index cd6739d3f1f..86da64d69e9 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/DocType.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/DocType.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.io.Writer; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; /** @@ -73,25 +72,21 @@ public class DocType extends Content { * This method is not supported by the class. * * @param content content that needs to be added - * @throws DocletAbortException this method will always throw a - * DocletAbortException because it - * is not supported. + * @throws UnsupportedOperationException always */ public void addContent(Content content) { - throw new DocletAbortException("not supported"); + throw new UnsupportedOperationException(); } /** * This method is not supported by the class. * * @param stringContent string content that needs to be added - * @throws DocletAbortException this method will always throw a - * DocletAbortException because it - * is not supported. + * @throws UnsupportedOperationException always */ @Override public void addContent(CharSequence stringContent) { - throw new DocletAbortException("not supported"); + throw new UnsupportedOperationException(); } /** diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java index 78b27a58c21..358b0d40023 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/FixedStringContent.java @@ -28,7 +28,6 @@ import java.io.IOException; import java.io.Writer; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; /** @@ -57,13 +56,11 @@ public class FixedStringContent extends Content { * This method is not supported by the class. * * @param content content that needs to be added - * @throws DocletAbortException this method will always throw a - * DocletAbortException because it - * is not supported. + * @throws UnsupportedOperationException always */ @Override public void addContent(Content content) { - throw new DocletAbortException("not supported"); + throw new UnsupportedOperationException(); } /** @@ -71,13 +68,11 @@ public class FixedStringContent extends Content { * HTML characters for the string content that is added. * * @param strContent string content to be added - * @throws DocletAbortException this method will always throw a - * DocletAbortException because it - * is not supported. + * @throws UnsupportedOperationException always */ @Override public void addContent(CharSequence strContent) { - throw new DocletAbortException("not supported"); + throw new UnsupportedOperationException(); } /** diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java index e15c2ada422..de06d5253a8 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocWriter.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.formats.html.markup; -import java.io.*; import java.util.*; import javax.lang.model.element.ModuleElement; @@ -38,6 +37,7 @@ import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Messages; 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; @@ -66,6 +66,7 @@ public abstract class HtmlDocWriter extends HtmlWriter { * Constructor. Initializes the destination file name through the super * class HtmlWriter. * + * @param configuration the configuration for this doclet * @param filename String file name. */ public HtmlDocWriter(Configuration configuration, DocPath filename) { @@ -78,6 +79,7 @@ public abstract class HtmlDocWriter extends HtmlWriter { /** * Accessor for configuration. + * @return the configuration for this doclet */ public abstract Configuration configuration(); @@ -289,13 +291,9 @@ public abstract class HtmlDocWriter extends HtmlWriter { DocLink mtFrameLink = new DocLink(DocPaths.moduleTypeFrame(mdle)); DocLink cFrameLink = new DocLink(DocPaths.moduleSummary(mdle)); HtmlTree anchor = HtmlTree.A(mdlLink.toString(), label); - StringBuilder onclickStr = new StringBuilder("updateModuleFrame('") - .append(mtFrameLink.toString()) - .append("','") - .append(cFrameLink.toString()) - .append("');"); + String onclickStr = "updateModuleFrame('" + mtFrameLink + "','" + cFrameLink + "');"; anchor.addAttr(HtmlAttr.TARGET, target); - anchor.addAttr(HtmlAttr.ONCLICK, onclickStr.toString()); + anchor.addAttr(HtmlAttr.ONCLICK, onclickStr); return anchor; } @@ -318,9 +316,10 @@ public abstract class HtmlDocWriter extends HtmlWriter { * @param title Title of this HTML document * @param configuration the configuration object * @param body the body content tree to be added to the HTML document + * @throws DocFileIOException if there is an error writing the frames document */ public void printFramesDocument(String title, ConfigurationImpl configuration, - HtmlTree body) throws IOException { + HtmlTree body) throws DocFileIOException { Content htmlDocType = configuration.isOutputHtml5() ? DocType.HTML5 : DocType.TRANSITIONAL; @@ -345,6 +344,7 @@ public abstract class HtmlDocWriter extends HtmlWriter { /** * Returns a link to the stylesheet file. * + * @param configuration the configuration for this doclet * @return an HtmlTree for the lINK tag which provides the stylesheet location */ public HtmlTree getStyleSheetProperties(ConfigurationImpl configuration) { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocument.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocument.java index 73da0086ab1..0c2bb460a82 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocument.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlDocument.java @@ -30,7 +30,6 @@ import java.io.Writer; import java.util.*; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; /** * Class for generating an HTML document for javadoc output. @@ -86,13 +85,11 @@ public class HtmlDocument extends Content { * This method is not supported by the class. * * @param stringContent string content that needs to be added - * @throws DocletAbortException this method will always throw a - * DocletAbortException because it - * is not supported. + * @throws UnsupportedOperationException always */ @Override public void addContent(CharSequence stringContent) { - throw new DocletAbortException("not supported"); + throw new UnsupportedOperationException(); } /** diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java index b69f8546253..2e90af8eba9 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/HtmlWriter.java @@ -32,6 +32,7 @@ import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.Resources; 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.DocletConstants; import jdk.javadoc.internal.doclets.toolkit.util.MethodTypes; @@ -147,9 +148,11 @@ public class HtmlWriter { resources.getText("doclet.Type")); } - public void write(Content c) throws IOException { + public void write(Content c) throws DocFileIOException { try (Writer writer = docFile.openWriter()) { c.write(writer, true); + } catch (IOException e) { + throw new DocFileIOException(docFile, DocFileIOException.Mode.WRITE, e); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java index 599e01dca92..0a2c3609a12 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/RawHtml.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.io.Writer; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; /** @@ -61,25 +60,21 @@ public class RawHtml extends Content { * This method is not supported by the class. * * @param content content that needs to be added - * @throws DocletAbortException this method will always throw a - * DocletAbortException because it - * is not supported. + * @throws UnsupportedOperationException always */ public void addContent(Content content) { - throw new DocletAbortException("not supported"); + throw new UnsupportedOperationException(); } /** * This method is not supported by the class. * * @param stringContent string content that needs to be added - * @throws DocletAbortException this method will always throw a - * DocletAbortException because it - * is not supported. + * @throws UnsupportedOperationException always */ @Override public void addContent(CharSequence stringContent) { - throw new DocletAbortException("not supported"); + throw new UnsupportedOperationException(); } /** diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java index cececf6b991..912e876bc13 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/markup/StringContent.java @@ -29,7 +29,6 @@ import java.io.IOException; import java.io.Writer; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; /** @@ -44,7 +43,7 @@ import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; */ public class StringContent extends Content { - private StringBuilder stringContent; + private final StringBuilder stringContent; /** * Constructor to construct StringContent object. @@ -67,13 +66,11 @@ public class StringContent extends Content { * This method is not supported by the class. * * @param content content that needs to be added - * @throws DocletAbortException this method will always throw a - * DocletAbortException because it - * is not supported. + * @throws UnsupportedOperationException always */ @Override public void addContent(Content content) { - throw new DocletAbortException("not supported"); + throw new UnsupportedOperationException(); } /** diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties index 38a3cc084c4..4f7018178f7 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/resources/standard.properties @@ -189,7 +189,6 @@ doclet.navClassUse=Use doclet.Error_in_packagelist=Error in using -group option: {0} {1} doclet.Groupname_already_used=In -group option, groupname already used: {0} doclet.Same_package_name_used=Package name format used twice: {0} -doclet.exception_encountered=Exception encountered while processing {1}\n{0} # option specifiers doclet.usage.d.parameters= diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java index e14f6c89d42..abeebe6b14c 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AbstractDoclet.java @@ -34,12 +34,17 @@ import javax.lang.model.element.TypeElement; import jdk.javadoc.doclet.Doclet; import jdk.javadoc.doclet.DocletEnvironment; +import jdk.javadoc.doclets.StandardDoclet; +import jdk.javadoc.internal.doclets.formats.html.HtmlDoclet; import jdk.javadoc.internal.doclets.toolkit.builders.AbstractBuilder; import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory; import jdk.javadoc.internal.doclets.toolkit.util.ClassTree; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; +import jdk.javadoc.internal.doclets.toolkit.util.InternalException; import jdk.javadoc.internal.doclets.toolkit.util.PackageListWriter; +import jdk.javadoc.internal.doclets.toolkit.util.ResourceIOException; +import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException; import jdk.javadoc.internal.doclets.toolkit.util.Utils; import static javax.tools.Diagnostic.Kind.*; @@ -107,30 +112,61 @@ public abstract class AbstractDoclet implements Doclet { return false; } + boolean dumpOnError = false; // set true to always show stack traces + try { startGeneration(docEnv); - } catch (Configuration.Fault f) { - configuration.reporter.print(ERROR, f.getMessage()); - return false; - } catch (DocletAbortException e) { - Throwable cause = e.getCause(); - if (cause != null) { - if (cause.getLocalizedMessage() != null) { - configuration.reporter.print(ERROR, cause.getLocalizedMessage()); - } else { - configuration.reporter.print(ERROR, cause.toString()); - } + return true; + + } catch (DocFileIOException e) { + switch (e.mode) { + case READ: + messages.error("doclet.exception.read.file", + e.fileName.getPath(), e.getCause()); + break; + case WRITE: + messages.error("doclet.exception.write.file", + e.fileName.getPath(), e.getCause()); } - return false; - } catch (Exception exc) { - exc.printStackTrace(System.err); - return false; + dumpStack(dumpOnError, e); + + } catch (ResourceIOException e) { + messages.error("doclet.exception.read.resource", + e.resource.getPath(), e.getCause()); + dumpStack(dumpOnError, e); + + } catch (SimpleDocletException e) { + configuration.reporter.print(ERROR, e.getMessage()); + dumpStack(dumpOnError, e); + + } catch (InternalException e) { + configuration.reporter.print(ERROR, e.getMessage()); + reportInternalError(e.getCause()); + + } catch (DocletException | RuntimeException | Error e) { + messages.error("doclet.internal.exception", e); + reportInternalError(e); + } + + return false; + } + + private void reportInternalError(Throwable t) { + if (getClass().equals(StandardDoclet.class) || getClass().equals(HtmlDoclet.class)) { + System.err.println(configuration.getResources().getText("doclet.internal.report.bug")); + } + dumpStack(true, t); + } + + private void dumpStack(boolean enabled, Throwable t) { + if (enabled && t != null) { + t.printStackTrace(System.err); } - return true; } /** * Returns the SourceVersion indicating the features supported by this doclet. + * * @return SourceVersion */ @Override @@ -141,6 +177,7 @@ public abstract class AbstractDoclet implements Doclet { /** * Create the configuration instance and returns it. + * * @return the configuration of the doclet. */ public abstract Configuration configuration(); @@ -152,8 +189,9 @@ public abstract class AbstractDoclet implements Doclet { * first and then can be used in the later generation. * * @see jdk.doclet.DocletEnvironment + * @throws DocletException if there is a problem while generating the documentation */ - private void startGeneration(DocletEnvironment docEnv) throws Configuration.Fault, Exception { + private void startGeneration(DocletEnvironment docEnv) throws DocletException { if (docEnv.getIncludedTypeElements().isEmpty()) { messages.error("doclet.No_Public_Classes_To_Document"); return; @@ -179,10 +217,12 @@ public abstract class AbstractDoclet implements Doclet { /** * Generate additional documentation that is added to the API documentation. * - * @param docEnv the DocletEnvironment. - * @param classtree the data structure representing the class tree. + * @param docEnv the DocletEnvironment + * @param classtree the data structure representing the class tree + * @throws DocletException if there is a problem while generating the documentation */ - protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree) throws Exception { + protected void generateOtherFiles(DocletEnvironment docEnv, ClassTree classtree) + throws DocletException { BuilderFactory builderFactory = configuration.getBuilderFactory(); AbstractBuilder constantsSummaryBuilder = builderFactory.getConstantsSummaryBuilder(); constantsSummaryBuilder.build(); @@ -193,50 +233,59 @@ public abstract class AbstractDoclet implements Doclet { /** * Generate the module documentation. * + * @throws DocletException if there is a problem while generating the documentation + * */ - protected abstract void generateModuleFiles() throws Exception; + protected abstract void generateModuleFiles() throws DocletException; /** * Generate the package documentation. * - * @param classtree the data structure representing the class tree. + * @param classtree the data structure representing the class tree + * @throws DocletException if there is a problem while generating the documentation */ - protected abstract void generatePackageFiles(ClassTree classtree) throws Exception; + protected abstract void generatePackageFiles(ClassTree classtree) throws DocletException; /** * Generate the class documentation. * - * @param classtree the data structure representing the class tree. + * @param arr the set of types to be documented + * @param classtree the data structure representing the class tree + * @throws DocletException if there is a problem while generating the documentation */ - protected abstract void generateClassFiles(SortedSet arr, ClassTree classtree); + protected abstract void generateClassFiles(SortedSet arr, ClassTree classtree) + throws DocletException; /** * Iterate through all classes and construct documentation for them. * - * @param docEnv the DocletEnvironment. - * @param classtree the data structure representing the class tree. + * @param docEnv the DocletEnvironment + * @param classtree the data structure representing the class tree + * @throws DocletException if there is a problem while generating the documentation */ - protected void generateClassFiles(DocletEnvironment docEnv, ClassTree classtree) { + protected void generateClassFiles(DocletEnvironment docEnv, ClassTree classtree) + throws DocletException { generateClassFiles(classtree); SortedSet packages = new TreeSet<>(utils.makePackageComparator()); packages.addAll(configuration.getSpecifiedPackages()); configuration.modulePackages.values().stream().forEach(pset -> { packages.addAll(pset); }); - packages.stream().forEach((pkg) -> { + for (PackageElement pkg : packages) { generateClassFiles(utils.getAllClasses(pkg), classtree); - }); + } } /** * Generate the class files for single classes specified on the command line. * - * @param classtree the data structure representing the class tree. + * @param classtree the data structure representing the class tree + * @throws DocletException if there is a problem while generating the documentation */ - private void generateClassFiles(ClassTree classtree) { + private void generateClassFiles(ClassTree classtree) throws DocletException { SortedSet packages = configuration.typeElementCatalog.packages(); - packages.stream().forEach((pkg) -> { + for (PackageElement pkg : packages) { generateClassFiles(configuration.typeElementCatalog.allClasses(pkg), classtree); - }); + } } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java index 7b23954346d..a218f2ae0e8 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/AnnotationTypeWriter.java @@ -25,10 +25,10 @@ package jdk.javadoc.internal.doclets.toolkit; -import java.io.*; - import javax.lang.model.element.TypeElement; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; + /** * The interface for writing annotation type output. * @@ -152,8 +152,9 @@ public interface AnnotationTypeWriter { * Print the document. * * @param contentTree content tree that will be printed as a document + * @throws DocFileIOException if there is a problem while writing the document */ - public void printDocument(Content contentTree) throws IOException; + public void printDocument(Content contentTree) throws DocFileIOException; /** * Return the {@link TypeElement} being documented. diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java index 33169d216fa..660547cde5e 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ClassWriter.java @@ -25,10 +25,10 @@ package jdk.javadoc.internal.doclets.toolkit; -import java.io.*; - import javax.lang.model.element.TypeElement; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; + /** * The interface for writing class output. * @@ -193,8 +193,9 @@ public interface ClassWriter { * Print the document. * * @param contentTree content tree that will be printed as a document + * @throws DocFileIOException if there is a problem while writing the document */ - public void printDocument(Content contentTree) throws IOException; + public void printDocument(Content contentTree) throws DocFileIOException; /** * Return the TypeElement being documented. diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java index be8e63db8c0..393f261c607 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Configuration.java @@ -44,11 +44,12 @@ import jdk.javadoc.internal.doclets.toolkit.builders.BuilderFactory; import jdk.javadoc.internal.doclets.toolkit.taglets.TagletManager; import jdk.javadoc.internal.doclets.toolkit.util.DocFile; import jdk.javadoc.internal.doclets.toolkit.util.DocFileFactory; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.DocletConstants; import jdk.javadoc.internal.doclets.toolkit.util.Extern; import jdk.javadoc.internal.doclets.toolkit.util.Group; import jdk.javadoc.internal.doclets.toolkit.util.MetaKeywords; +import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException; import jdk.javadoc.internal.doclets.toolkit.util.TypeElementCatalog; import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap.GetterSetter; @@ -72,21 +73,6 @@ import static javax.tools.Diagnostic.Kind.*; */ public abstract class Configuration { - /** - * Exception used to report a problem during setOptions. - */ - public static class Fault extends Exception { - private static final long serialVersionUID = 0; - - Fault(String msg) { - super(msg); - } - - Fault(String msg, Exception cause) { - super(msg, cause); - } - } - /** * The factory for builders. */ @@ -105,7 +91,7 @@ public abstract class Configuration { /** * The default path to the builder XML. */ - private static final String DEFAULT_BUILDER_XML = "resources/doclet.xml"; + public static final String DEFAULT_BUILDER_XML = "resources/doclet.xml"; /** * The path to Taglets @@ -302,13 +288,17 @@ public abstract class Configuration { /** * Return the build date for the doclet. + * + * @return the build date */ public abstract String getDocletSpecificBuildDate(); /** - * This method should be defined in all those doclets(configurations), + * This method should be defined in all those doclets (configurations), * which want to derive themselves from this Configuration. This method * can be used to finish up the options setup. + * + * @return true if successful and false otherwise */ public abstract boolean finishOptionSettings(); @@ -638,8 +628,8 @@ public abstract class Configuration { * when this is called all the option have been set, this method, * initializes certain components before anything else is started. */ - private void finishOptionSettings0() throws Fault { - ensureOutputDirExists(); + private void finishOptionSettings0() throws DocletException { + initDestDirectory(); if (urlForLink != null && pkglistUrlForLink != null) extern.link(urlForLink, pkglistUrlForLink, reporter, false); if (urlForLinkOffline != null && pkglistUrlForLinkOffline != null) @@ -658,43 +648,42 @@ public abstract class Configuration { * Set the command line options supported by this configuration. * * @return true if the options are set successfully - * @throws DocletAbortException + * @throws DocletException if there is a problem while setting the options */ - public boolean setOptions() throws Fault { - try { - initPackages(); - initModules(); - finishOptionSettings0(); - if (!finishOptionSettings()) - return false; + public boolean setOptions() throws DocletException { + initPackages(); + initModules(); + finishOptionSettings0(); + if (!finishOptionSettings()) + return false; - } catch (Fault f) { - throw new DocletAbortException(f.getMessage()); - } return true; } - private void ensureOutputDirExists() throws Fault { - DocFile destDir = DocFile.createFileForDirectory(this, destDirName); - if (!destDir.exists()) { - //Create the output directory (in case it doesn't exist yet) - if (!destDirName.isEmpty()) + private void initDestDirectory() throws DocletException { + if (!destDirName.isEmpty()) { + DocFile destDir = DocFile.createFileForDirectory(this, destDirName); + if (!destDir.exists()) { + //Create the output directory (in case it doesn't exist yet) reporter.print(NOTE, getText("doclet.dest_dir_create", destDirName)); - destDir.mkdirs(); - } else if (!destDir.isDirectory()) { - throw new Fault(getText( - "doclet.destination_directory_not_directory_0", - destDir.getPath())); - } else if (!destDir.canWrite()) { - throw new Fault(getText( - "doclet.destination_directory_not_writable_0", - destDir.getPath())); + destDir.mkdirs(); + } else if (!destDir.isDirectory()) { + throw new SimpleDocletException(getText( + "doclet.destination_directory_not_directory_0", + destDir.getPath())); + } else if (!destDir.canWrite()) { + throw new SimpleDocletException(getText( + "doclet.destination_directory_not_writable_0", + destDir.getPath())); + } } + DocFileFactory.getFactory(this).setDestDir(destDirName); } /** * Initialize the taglet manager. The strings to initialize the simple custom tags should * be in the following format: "[tag name]:[location str]:[heading]". + * * @param customTagStrs the set two dimensional arrays of strings. These arrays contain * either -tag or -taglet arguments. */ @@ -819,7 +808,7 @@ public abstract class Configuration { if (!checkOutputFileEncoding(docencoding)) { return false; } - }; + } } if (!docencodingfound && (encoding != null && !encoding.isEmpty())) { if (!checkOutputFileEncoding(encoding)) { @@ -858,6 +847,7 @@ public abstract class Configuration { /** * Return true if the given doc-file subdirectory should be excluded and * false otherwise. + * * @param docfilesubdir the doc-files subdirectory to check. * @return true if the directory is excluded. */ @@ -867,7 +857,9 @@ public abstract class Configuration { /** * Return true if the given qualifier should be excluded and false otherwise. + * * @param qualifier the qualifier to check. + * @return true if the qualifier should be excluded */ public boolean shouldExcludeQualifier(String qualifier){ if (excludedQualifiers.contains("all") || @@ -888,6 +880,7 @@ public abstract class Configuration { /** * Return the qualified name of the Element if its qualifier is not excluded. * Otherwise return the unqualified Element name. + * * @param te the TypeElement to check. * @return the class name */ @@ -931,6 +924,7 @@ public abstract class Configuration { * Convenience method to obtain a resource from the doclet's * {@link Resources resources}. * Equivalent to getResources.getText(key);. + * * @param key the key for the desired string * @return the string for the given key * @throws MissingResourceException if the key is not found in either @@ -942,6 +936,7 @@ public abstract class Configuration { * Convenience method to obtain a resource from the doclet's * {@link Resources resources}. * Equivalent to getResources.getText(key, args);. + * * @param key the key for the desired string * @param args values to be substituted into the resulting string * @return the string for the given key @@ -1009,6 +1004,7 @@ public abstract class Configuration { /** * Return the doclet specific instance of a writer factory. + * * @return the {@link WriterFactory} for the doclet. */ public abstract WriterFactory getWriterFactory(); @@ -1017,9 +1013,9 @@ public abstract class Configuration { * Return the input stream to the builder XML. * * @return the input steam to the builder XML. - * @throws FileNotFoundException when the given XML file cannot be found. + * @throws DocFileIOException when the given XML file cannot be found or opened. */ - public InputStream getBuilderXML() throws IOException { + public InputStream getBuilderXML() throws DocFileIOException { return builderXMLPath == null ? Configuration.class.getResourceAsStream(DEFAULT_BUILDER_XML) : DocFile.createFileForInput(this, builderXMLPath).openInputStream(); @@ -1027,6 +1023,7 @@ public abstract class Configuration { /** * Return the Locale for this document. + * * @return the current locale */ public abstract Locale getLocale(); @@ -1040,6 +1037,7 @@ public abstract class Configuration { /** * Return the current file manager. + * * @return JavaFileManager */ public abstract JavaFileManager getFileManager(); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java index 536b9791e12..9afe3757501 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ConstantsSummaryWriter.java @@ -25,13 +25,14 @@ package jdk.javadoc.internal.doclets.toolkit; -import java.io.*; import java.util.*; import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; + /** * The interface for writing constants summary output. * @@ -144,7 +145,8 @@ public interface ConstantsSummaryWriter { * Print the constants summary document. * * @param contentTree content tree which should be printed + * @throws DocFileIOException if there is a problem while writing the document */ - public abstract void printDocument(Content contentTree) throws IOException; + public abstract void printDocument(Content contentTree) throws DocFileIOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java index 7efd4250504..a053e3d5663 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/Content.java @@ -30,9 +30,6 @@ import java.io.StringWriter; import java.io.Writer; import java.util.Objects; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; - - /** * A class to create content for javadoc output pages. * @@ -57,7 +54,7 @@ public abstract class Content { write(out, true); } catch (IOException e) { // cannot happen from StringWriter - throw new DocletAbortException(e); + throw new AssertionError(e); } return out.toString(); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/DocletException.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/DocletException.java new file mode 100644 index 00000000000..15bb25553cb --- /dev/null +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/DocletException.java @@ -0,0 +1,72 @@ +/* + * 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. + */ + +package jdk.javadoc.internal.doclets.toolkit; + + +/** + * Supertype for all checked doclet exceptions. + * + *

This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + * + * @apiNote This is primarily intended for the benefit of the builder API + * in {@code jdk.javadoc.internal.doclets.toolkit.builders}. + */ +public class DocletException extends Exception { + + private static final long serialVersionUID = 1L; + + /** + * Creates a DocletException with a given detail message. + * + * The message may or may not be intended for presentation to the end user. + * + * @param message the detail message. + */ + protected DocletException(String message) { + super(message); + if (message == null || message.isEmpty()) { + throw new IllegalArgumentException(); + } + } + + /** + * Creates a DocletException with a given detail message and underlying cause. + * + * The message may or may not be intended for presentation to the end user. + * + * @param message the detail message. + * @param cause the underlying cause + */ + protected DocletException(String message, Throwable cause) { + super(message, cause); + if (message == null || message.isEmpty()) { + throw new IllegalArgumentException(); + } + } +} diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java index a49bf26d0b2..c62f676468a 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/ModuleSummaryWriter.java @@ -25,10 +25,7 @@ package jdk.javadoc.internal.doclets.toolkit; -import java.io.*; -import java.util.Set; - -import javax.lang.model.element.PackageElement; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; /** * The interface for writing module summary output. @@ -130,6 +127,7 @@ public interface ModuleSummaryWriter { * Print the module summary document. * * @param contentTree the content tree that will be printed + * @throws DocFileIOException if there is a problem while writing the document */ - public abstract void printDocument(Content contentTree) throws IOException; + public abstract void printDocument(Content contentTree) throws DocFileIOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java index 8e24984486b..889f9cde63f 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/PackageSummaryWriter.java @@ -25,13 +25,13 @@ package jdk.javadoc.internal.doclets.toolkit; -import java.io.*; - import java.util.List; import java.util.SortedSet; import javax.lang.model.element.TypeElement; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; + /** * The interface for writing package summary output. * @@ -118,7 +118,8 @@ public interface PackageSummaryWriter { * Print the package summary document. * * @param contentTree the content tree that will be printed + * @throws DocFileIOException if there is a problem while writing the document */ - public abstract void printDocument(Content contentTree) throws IOException; + public abstract void printDocument(Content contentTree) throws DocFileIOException; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java index a72c51c76e0..7fd1c581186 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/SerializedFormWriter.java @@ -25,13 +25,12 @@ package jdk.javadoc.internal.doclets.toolkit; -import java.io.*; - import javax.lang.model.element.ExecutableElement; import javax.lang.model.element.TypeElement; import javax.lang.model.element.VariableElement; import com.sun.source.doctree.DocTree; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; /** * The interface for writing serialized form output. @@ -124,15 +123,17 @@ public interface SerializedFormWriter { public Content getClassContentHeader(); /** - * Return an instance of a SerialFieldWriter. + * Return an instance of a SerialFieldWriter for a class. * + * @param typeElement the class * @return an instance of a SerialFieldWriter. */ public SerialFieldWriter getSerialFieldWriter(TypeElement typeElement); /** - * Return an instance of a SerialMethodWriter. + * Return an instance of a SerialMethodWriter for a class. * + * @param typeElement the class * @return an instance of a SerialMethodWriter. */ public SerialMethodWriter getSerialMethodWriter(TypeElement typeElement); @@ -156,8 +157,9 @@ public interface SerializedFormWriter { * Print the serialized form document. * * @param serializedTree the content tree that will be printed + * @throws DocFileIOException if there is a problem while writing the document */ - public abstract void printDocument(Content serializedTree) throws IOException; + public abstract void printDocument(Content serializedTree) throws DocFileIOException; /** * Write the serialized form for a given field. @@ -199,7 +201,7 @@ public interface SerializedFormWriter { /** * Adds the description text for this member. * - * @param field the field to document. + * @param field the field to document * @param contentTree content tree to which the member description will be added */ public void addMemberDescription(VariableElement field, Content contentTree); @@ -207,7 +209,8 @@ public interface SerializedFormWriter { /** * Adds the description text for this member represented by the tag. * - * @param serialFieldTag the field to document (represented by tag). + * @param field the field to document + * @param serialFieldTag the field to document (represented by tag) * @param contentTree content tree to which the member description will be added */ public void addMemberDescription(VariableElement field, DocTree serialFieldTag, Content contentTree); @@ -215,7 +218,7 @@ public interface SerializedFormWriter { /** * Adds the tag information for this member. * - * @param field the field to document. + * @param field the field to document * @param contentTree content tree to which the member tags will be added */ public void addMemberTags(VariableElement field, Content contentTree); @@ -223,11 +226,11 @@ public interface SerializedFormWriter { /** * Adds the member header. * - * @param fieldType the type of the field. + * @param fieldType the type of the field * @param fieldTypeStr the type of the field in string format. We will - * print this out if we can't link to the type. - * @param fieldDimensions the dimensions of the field. - * @param fieldName the name of the field. + * print this out if we can't link to the type + * @param fieldDimensions the dimensions of the field + * @param fieldName the name of the field * @param contentTree content tree to which the member header will be added */ public void addMemberHeader(TypeElement fieldType, String fieldTypeStr, @@ -239,7 +242,7 @@ public interface SerializedFormWriter { * for deprecation info, inline comment or tags, * do not print overview details. * - * @param field the field to check overview details for. + * @param field the field to check overview details for * @return true if overview details need to be printed */ public boolean shouldPrintOverview(VariableElement field); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WriterFactory.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WriterFactory.java index a9f400e0463..5477ff7da39 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WriterFactory.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/WriterFactory.java @@ -52,8 +52,7 @@ public interface WriterFactory { * @return the writer for the constant summary. Return null if this * writer is not supported by the doclet. */ - public abstract ConstantsSummaryWriter getConstantsSummaryWriter() - throws Exception; + public abstract ConstantsSummaryWriter getConstantsSummaryWriter(); /** * Return the writer for the package summary. @@ -65,8 +64,7 @@ public interface WriterFactory { * writer is not supported by the doclet. */ public abstract PackageSummaryWriter getPackageSummaryWriter(PackageElement - packageElement, PackageElement prevPkg, PackageElement nextPkg) - throws Exception; + packageElement, PackageElement prevPkg, PackageElement nextPkg); /** * Return the writer for the module summary. @@ -78,8 +76,7 @@ public interface WriterFactory { * writer is not supported by the doclet. */ public abstract ModuleSummaryWriter getModuleSummaryWriter( - ModuleElement mdle, ModuleElement prevModule, ModuleElement nextModule) - throws Exception; + ModuleElement mdle, ModuleElement prevModule, ModuleElement nextModule); /** * Return the writer for a class. @@ -92,8 +89,7 @@ public interface WriterFactory { * writer is not supported by the doclet. */ public abstract ClassWriter getClassWriter(TypeElement typeElement, - TypeElement prevClass, TypeElement nextClass, ClassTree classTree) - throws Exception; + TypeElement prevClass, TypeElement nextClass, ClassTree classTree); /** * Return the writer for an annotation type. @@ -105,8 +101,7 @@ public interface WriterFactory { * writer is not supported by the doclet. */ public abstract AnnotationTypeWriter getAnnotationTypeWriter( - TypeElement annotationType, TypeMirror prevType, TypeMirror nextType) - throws Exception; + TypeElement annotationType, TypeMirror prevType, TypeMirror nextType); /** * Return the method writer for a given class. @@ -115,8 +110,7 @@ public interface WriterFactory { * @return the method writer for the give class. Return null if this * writer is not supported by the doclet. */ - public abstract MethodWriter getMethodWriter(ClassWriter classWriter) - throws Exception; + public abstract MethodWriter getMethodWriter(ClassWriter classWriter); /** * Return the annotation type field writer for a given annotation type. @@ -128,7 +122,7 @@ public interface WriterFactory { */ public abstract AnnotationTypeFieldWriter getAnnotationTypeFieldWriter( - AnnotationTypeWriter annotationTypeWriter) throws Exception; + AnnotationTypeWriter annotationTypeWriter); /** * Return the annotation type optional member writer for a given annotation @@ -141,7 +135,7 @@ public interface WriterFactory { */ public abstract AnnotationTypeOptionalMemberWriter getAnnotationTypeOptionalMemberWriter( - AnnotationTypeWriter annotationTypeWriter) throws Exception; + AnnotationTypeWriter annotationTypeWriter); /** * Return the annotation type required member writer for a given annotation type. @@ -153,7 +147,7 @@ public interface WriterFactory { */ public abstract AnnotationTypeRequiredMemberWriter getAnnotationTypeRequiredMemberWriter( - AnnotationTypeWriter annotationTypeWriter) throws Exception; + AnnotationTypeWriter annotationTypeWriter); /** * Return the enum constant writer for a given class. @@ -163,7 +157,7 @@ public interface WriterFactory { * writer is not supported by the doclet. */ public abstract EnumConstantWriter getEnumConstantWriter( - ClassWriter classWriter) throws Exception; + ClassWriter classWriter); /** * Return the field writer for a given class. @@ -172,8 +166,7 @@ public interface WriterFactory { * @return the field writer for the give class. Return null if this * writer is not supported by the doclet. */ - public abstract FieldWriter getFieldWriter(ClassWriter classWriter) - throws Exception; + public abstract FieldWriter getFieldWriter(ClassWriter classWriter); /** * Return the property writer for a given class. @@ -182,8 +175,7 @@ public interface WriterFactory { * @return the property writer for the give class. Return null if this * writer is not supported by the doclet. */ - public abstract PropertyWriter getPropertyWriter(ClassWriter classWriter) - throws Exception; + public abstract PropertyWriter getPropertyWriter(ClassWriter classWriter); /** * Return the constructor writer for a given class. @@ -193,8 +185,7 @@ public interface WriterFactory { * writer is not supported by the doclet. */ public abstract ConstructorWriter getConstructorWriter( - ClassWriter classWriter) - throws Exception; + ClassWriter classWriter); /** * Return the specified member summary writer for a given class. @@ -206,11 +197,9 @@ public interface WriterFactory { * writer is not supported by the doclet. * * @see VisibleMemberMap - * @throws IllegalArgumentException if memberType is unknown. */ public abstract MemberSummaryWriter getMemberSummaryWriter( - ClassWriter classWriter, VisibleMemberMap.Kind memberType) - throws Exception; + ClassWriter classWriter, VisibleMemberMap.Kind memberType); /** * Return the specified member summary writer for a given annotation type. @@ -223,16 +212,14 @@ public interface WriterFactory { * writer is not supported by the doclet. * * @see VisibleMemberMap - * @throws IllegalArgumentException if memberType is unknown. */ public abstract MemberSummaryWriter getMemberSummaryWriter( - AnnotationTypeWriter annotationTypeWriter, VisibleMemberMap.Kind memberType) - throws Exception; + AnnotationTypeWriter annotationTypeWriter, VisibleMemberMap.Kind memberType); /** * Return the writer for the serialized form. * * @return the writer for the serialized form. */ - public SerializedFormWriter getSerializedFormWriter() throws Exception; + public SerializedFormWriter getSerializedFormWriter(); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java index 777d1d25ef6..a2296e30abe 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractBuilder.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.toolkit.builders; -import java.io.*; import java.lang.reflect.*; import java.util.*; @@ -33,8 +32,11 @@ import javax.lang.model.element.PackageElement; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.Messages; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; +import jdk.javadoc.internal.doclets.toolkit.Resources; +import jdk.javadoc.internal.doclets.toolkit.util.InternalException; +import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException; import jdk.javadoc.internal.doclets.toolkit.util.Utils; import static javax.tools.Diagnostic.Kind.*; @@ -91,6 +93,7 @@ public abstract class AbstractBuilder { protected final Configuration configuration; protected final Messages messages; + protected final Resources resources; protected final Utils utils; /** @@ -109,12 +112,12 @@ public abstract class AbstractBuilder { /** * Construct a Builder. - * @param configuration the configuration used in this run - * of the doclet. + * @param c a context providing information used in this run of the doclet */ public AbstractBuilder(Context c) { this.configuration = c.configuration; this.messages = configuration.getMessages(); + this.resources = configuration.getResources(); this.utils = configuration.utils; this.containingPackagesSeen = c.containingPackagesSeen; this.layoutParser = c.layoutParser; @@ -130,39 +133,55 @@ public abstract class AbstractBuilder { /** * Build the documentation. * - * @throws IOException there was a problem writing the output. + * @throws DocletException if there is a problem building the documentation */ - public abstract void build() throws IOException; + public abstract void build() throws DocletException; /** * Build the documentation, as specified by the given XML element. * * @param node the XML element that specifies which component to document. * @param contentTree content tree to which the documentation will be added + * @throws DocletException if there is a problem building the documentation */ - protected void build(XMLNode node, Content contentTree) { + protected void build(XMLNode node, Content contentTree) throws DocletException { String component = node.name; try { - invokeMethod("build" + component, - new Class[]{XMLNode.class, Content.class}, - new Object[]{node, contentTree}); + String methodName = "build" + component; + if (DEBUG) { + configuration.reporter.print(ERROR, + "DEBUG: " + getClass().getName() + "." + methodName); + } + Method method = getClass().getMethod(methodName, XMLNode.class, Content.class); + method.invoke(this, node, contentTree); + } catch (NoSuchMethodException e) { - e.printStackTrace(System.err); - configuration.reporter.print(ERROR, "Unknown element: " + component); - throw new DocletAbortException(e); + // Use SimpleDocletException instead of InternalException because there is nothing + // informative about about the place the exception occurred, here in this method. + // The problem is either a misconfigured doclet.xml file or a missing method in the + // user-supplied(?) doclet + String message = resources.getText("doclet.builder.unknown.component", component); + throw new SimpleDocletException(message, e); + } catch (InvocationTargetException e) { Throwable cause = e.getCause(); - if (cause instanceof DocletAbortException) { - throw (DocletAbortException) cause; + if (cause instanceof DocletException) { + throw (DocletException) cause; } else { - throw new DocletAbortException(e.getCause()); + // use InternalException, so that a stacktrace showing the position of + // the internal exception is generated + String message = resources.getText("doclet.builder.exception.in.component", component, + e.getCause()); + throw new InternalException(message, e.getCause()); } - } catch (Exception e) { - e.printStackTrace(System.err); - configuration.reporter.print(ERROR, "Exception " + - e.getClass().getName() + - " thrown while processing element: " + component); - throw new DocletAbortException(e); + + } catch (ReflectiveOperationException e) { + // Use SimpleDocletException instead of InternalException because there is nothing + // informative about about the place the exception occurred, here in this method. + // The problem is specific to the method being invoked, such as illegal access + // or illegal argument. + String message = resources.getText("doclet.builder.exception.in.component", component, e); + throw new SimpleDocletException(message, e.getCause()); } } @@ -171,29 +190,10 @@ public abstract class AbstractBuilder { * * @param node the XML element that specifies which components to document. * @param contentTree content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the children */ - protected void buildChildren(XMLNode node, Content contentTree) { + protected void buildChildren(XMLNode node, Content contentTree) throws DocletException { for (XMLNode child : node.children) build(child, contentTree); } - - /** - * Given the name and parameters, invoke the method in the builder. This - * method is required to invoke the appropriate build method as instructed - * by the builder XML file. - * - * @param methodName the name of the method that we would like to invoke. - * @param paramClasses the types for each parameter. - * @param params the parameters of the method. - */ - protected void invokeMethod(String methodName, Class[] paramClasses, - Object[] params) - throws Exception { - if (DEBUG) { - configuration.reporter.print(ERROR, "DEBUG: " + - this.getClass().getName() + "." + methodName); - } - Method method = this.getClass().getMethod(methodName, paramClasses); - method.invoke(this, params); - } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractMemberBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractMemberBuilder.java index 58c5b6bf67c..ee0dba08fee 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractMemberBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AbstractMemberBuilder.java @@ -26,7 +26,7 @@ package jdk.javadoc.internal.doclets.toolkit.builders; import jdk.javadoc.internal.doclets.toolkit.Content; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; +import jdk.javadoc.internal.doclets.toolkit.DocletException; /** * The superclass for all member builders. Member builders are only executed @@ -44,7 +44,7 @@ public abstract class AbstractMemberBuilder extends AbstractBuilder { /** * Construct a SubBuilder. - * @param configuration the configuration used in this run + * @param context a context object, providing information used in this run * of the doclet. */ public AbstractMemberBuilder(Context context) { @@ -54,32 +54,33 @@ public abstract class AbstractMemberBuilder extends AbstractBuilder { /** * This method is not supported by sub-builders. * - * @throws DocletAbortException this method will always throw a - * DocletAbortException because it is not supported. + * @throws AssertionError always */ - public void build() throws DocletAbortException { - //You may not call the build method in a subbuilder. - throw new DocletAbortException("not supported"); + @Override + public void build() { + // You may not call the build method in a subbuilder. + throw new AssertionError(); } /** - * Build the sub component if there is anything to document. + * Builds the sub component if there is anything to document. * * @param node the XML element that specifies which components to document. * @param contentTree content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ @Override - public void build(XMLNode node, Content contentTree) { + public void build(XMLNode node, Content contentTree) throws DocletException { if (hasMembersToDocument()) { super.build(node, contentTree); } } /** - * Return true if this subbuilder has anything to document. + * Returns true if this subbuilder has anything to document. * - * @return true if this subbuilder has anything to document. + * @return true if this subbuilder has anything to document */ public abstract boolean hasMembersToDocument(); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java index bec5010b927..065a0da840c 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeBuilder.java @@ -25,13 +25,12 @@ package jdk.javadoc.internal.doclets.toolkit.builders; -import java.io.*; - import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeWriter; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; /** @@ -83,54 +82,59 @@ public class AnnotationTypeBuilder extends AbstractBuilder { } /** - * Construct a new ClassBuilder. + * Construct a new AnnotationTypeBuilder. * * @param context the build context. * @param annotationTypeDoc the class being documented. * @param writer the doclet specific writer. + * @return an AnnotationTypeBuilder */ public static AnnotationTypeBuilder getInstance(Context context, TypeElement annotationTypeDoc, - AnnotationTypeWriter writer) - throws Exception { + AnnotationTypeWriter writer) { return new AnnotationTypeBuilder(context, annotationTypeDoc, writer); } /** * {@inheritDoc} */ - public void build() throws IOException { + @Override + public void build() throws DocletException { build(layoutParser.parseXML(ROOT), contentTree); } /** * {@inheritDoc} */ + @Override public String getName() { return ROOT; } /** - * Build the annotation type documentation. - * - * @param node the XML element that specifies which components to document - * @param contentTree the content tree to which the documentation will be added - */ - public void buildAnnotationTypeDoc(XMLNode node, Content contentTree) throws Exception { - contentTree = writer.getHeader(configuration.getText("doclet.AnnotationType") + - " " + utils.getSimpleName(annotationType)); - Content annotationContentTree = writer.getAnnotationContentHeader(); - buildChildren(node, annotationContentTree); - writer.addAnnotationContentTree(contentTree, annotationContentTree); - writer.addFooter(contentTree); - writer.printDocument(contentTree); - copyDocFiles(); - } + * Build the annotation type documentation. + * + * @param node the XML element that specifies which components to document + * @param contentTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem building the documentation + */ + public void buildAnnotationTypeDoc(XMLNode node, Content contentTree) throws DocletException { + contentTree = writer.getHeader(configuration.getText("doclet.AnnotationType") + + " " + utils.getSimpleName(annotationType)); + Content annotationContentTree = writer.getAnnotationContentHeader(); + buildChildren(node, annotationContentTree); + writer.addAnnotationContentTree(contentTree, annotationContentTree); + writer.addFooter(contentTree); + writer.printDocument(contentTree); + copyDocFiles(); + } - /** - * Copy the doc files for the current TypeElement if necessary. - */ - private void copyDocFiles() { + /** + * Copy the doc files for the current TypeElement if necessary. + * + * @throws DocletException if there is a problem building the documentation + */ + private void copyDocFiles() throws DocletException { PackageElement containingPackage = utils.containingPackage(annotationType); if((configuration.packages == null || !configuration.packages.contains(containingPackage) && @@ -141,15 +145,17 @@ public class AnnotationTypeBuilder extends AbstractBuilder { utils.copyDocFiles(containingPackage); containingPackagesSeen.add(containingPackage); } - } + } /** * Build the annotation information tree documentation. * * @param node the XML element that specifies which components to document * @param annotationContentTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem building the documentation */ - public void buildAnnotationTypeInfo(XMLNode node, Content annotationContentTree) { + public void buildAnnotationTypeInfo(XMLNode node, Content annotationContentTree) + throws DocletException { Content annotationInfoTree = writer.getAnnotationInfoTreeHeader(); buildChildren(node, annotationInfoTree); annotationContentTree.addContent(writer.getAnnotationInfo(annotationInfoTree)); @@ -201,9 +207,9 @@ public class AnnotationTypeBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param annotationContentTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem building the documentation */ - public void buildMemberSummary(XMLNode node, Content annotationContentTree) - throws Exception { + public void buildMemberSummary(XMLNode node, Content annotationContentTree) throws DocletException { Content memberSummaryTree = writer.getMemberTreeHeader(); configuration.getBuilderFactory(). getMemberSummaryBuilder(writer).buildChildren(node, memberSummaryTree); @@ -215,8 +221,10 @@ public class AnnotationTypeBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param annotationContentTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem building the documentation */ - public void buildAnnotationTypeMemberDetails(XMLNode node, Content annotationContentTree) { + public void buildAnnotationTypeMemberDetails(XMLNode node, Content annotationContentTree) + throws DocletException { Content memberDetailsTree = writer.getMemberTreeHeader(); buildChildren(node, memberDetailsTree); if (memberDetailsTree.isValid()) { @@ -229,9 +237,10 @@ public class AnnotationTypeBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem building the documentation */ public void buildAnnotationTypeFieldDetails(XMLNode node, Content memberDetailsTree) - throws Exception { + throws DocletException { configuration.getBuilderFactory(). getAnnotationTypeFieldsBuilder(writer).buildChildren(node, memberDetailsTree); } @@ -241,9 +250,10 @@ public class AnnotationTypeBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem building the documentation */ public void buildAnnotationTypeOptionalMemberDetails(XMLNode node, Content memberDetailsTree) - throws Exception { + throws DocletException { configuration.getBuilderFactory(). getAnnotationTypeOptionalMemberBuilder(writer).buildChildren(node, memberDetailsTree); } @@ -253,9 +263,10 @@ public class AnnotationTypeBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem building the documentation */ public void buildAnnotationTypeRequiredMemberDetails(XMLNode node, Content memberDetailsTree) - throws Exception { + throws DocletException { configuration.getBuilderFactory(). getAnnotationTypeRequiredMemberBuilder(writer).buildChildren(node, memberDetailsTree); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java index c62fe2a5d13..f8d020ab904 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeFieldBuilder.java @@ -33,6 +33,7 @@ import javax.lang.model.element.TypeElement; import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeFieldWriter; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; @@ -100,6 +101,7 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder { * @param context the build context. * @param typeElement the class whose members are being documented. * @param writer the doclet specific writer. + * @return the new AnnotationTypeFieldBuilder */ public static AnnotationTypeFieldBuilder getInstance( Context context, TypeElement typeElement, @@ -138,7 +140,8 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder { } /** - * summaryOrder.size() + * Returns whether or not there are members to document. + * @return whether or not there are members to document */ @Override public boolean hasMembersToDocument() { @@ -150,8 +153,10 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildAnnotationTypeField(XMLNode node, Content memberDetailsTree) { + public void buildAnnotationTypeField(XMLNode node, Content memberDetailsTree) + throws DocletException { buildAnnotationTypeMember(node, memberDetailsTree); } @@ -160,8 +165,10 @@ public class AnnotationTypeFieldBuilder extends AbstractMemberBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree) { + public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree) + throws DocletException { if (writer == null) { return; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java index a794a52b038..d004dbb76a7 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeOptionalMemberBuilder.java @@ -30,6 +30,7 @@ import javax.lang.model.element.TypeElement; import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeOptionalMemberWriter; import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; @@ -67,6 +68,7 @@ public class AnnotationTypeOptionalMemberBuilder extends AnnotationTypeRequiredM * @param context the build context. * @param typeElement the class whose members are being documented. * @param writer the doclet specific writer. + * @return the new AnnotationTypeMemberBuilder */ public static AnnotationTypeOptionalMemberBuilder getInstance( Context context, TypeElement typeElement, @@ -88,8 +90,10 @@ public class AnnotationTypeOptionalMemberBuilder extends AnnotationTypeRequiredM * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildAnnotationTypeOptionalMember(XMLNode node, Content memberDetailsTree) { + public void buildAnnotationTypeOptionalMember(XMLNode node, Content memberDetailsTree) + throws DocletException { buildAnnotationTypeMember(node, memberDetailsTree); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java index b8a98409e35..8f4a678c585 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/AnnotationTypeRequiredMemberBuilder.java @@ -33,6 +33,7 @@ import javax.lang.model.element.TypeElement; import jdk.javadoc.internal.doclets.toolkit.AnnotationTypeRequiredMemberWriter; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; @@ -139,7 +140,8 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { } /** - * summaryOrder.size() + * Returns whether or not there are members to document. + * @return whether or not there are members to document */ @Override public boolean hasMembersToDocument() { @@ -151,8 +153,10 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildAnnotationTypeRequiredMember(XMLNode node, Content memberDetailsTree) { + public void buildAnnotationTypeRequiredMember(XMLNode node, Content memberDetailsTree) + throws DocletException { buildAnnotationTypeMember(node, memberDetailsTree); } @@ -162,7 +166,8 @@ public class AnnotationTypeRequiredMemberBuilder extends AbstractMemberBuilder { * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added */ - public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree) { + public void buildAnnotationTypeMember(XMLNode node, Content memberDetailsTree) + throws DocletException { if (writer == null) { return; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/BuilderFactory.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/BuilderFactory.java index 2b8ccd4769f..2ca7ac25a0b 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/BuilderFactory.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/BuilderFactory.java @@ -83,7 +83,7 @@ public class BuilderFactory { * Return the builder that builds the constant summary. * @return the builder that builds the constant summary. */ - public AbstractBuilder getConstantsSummaryBuilder() throws Exception { + public AbstractBuilder getConstantsSummaryBuilder() { return ConstantsSummaryBuilder.getInstance(context, writerFactory.getConstantsSummaryWriter()); } @@ -97,7 +97,7 @@ public class BuilderFactory { * @return the builder that builds the constant summary. */ public AbstractBuilder getPackageSummaryBuilder(PackageElement pkg, PackageElement prevPkg, - PackageElement nextPkg) throws Exception { + PackageElement nextPkg) { return PackageSummaryBuilder.getInstance(context, pkg, writerFactory.getPackageSummaryWriter(pkg, prevPkg, nextPkg)); } @@ -111,7 +111,7 @@ public class BuilderFactory { * @return the builder that builds the module summary. */ public AbstractBuilder getModuleSummaryBuilder(ModuleElement mdle, ModuleElement prevModule, - ModuleElement nextModule) throws Exception { + ModuleElement nextModule) { return ModuleSummaryBuilder.getInstance(context, mdle, writerFactory.getModuleSummaryWriter(mdle, prevModule, nextModule)); } @@ -127,8 +127,7 @@ public class BuilderFactory { * writer is not supported by the doclet. */ public AbstractBuilder getClassBuilder(TypeElement typeElement, - TypeElement prevClass, TypeElement nextClass, ClassTree classTree) - throws Exception { + TypeElement prevClass, TypeElement nextClass, ClassTree classTree) { return ClassBuilder.getInstance(context, typeElement, writerFactory.getClassWriter(typeElement, prevClass, nextClass, classTree)); } @@ -143,8 +142,7 @@ public class BuilderFactory { * writer is not supported by the doclet. */ public AbstractBuilder getAnnotationTypeBuilder( - TypeElement annotationType, TypeMirror prevType, TypeMirror nextType) - throws Exception { + TypeElement annotationType, TypeMirror prevType, TypeMirror nextType) { return AnnotationTypeBuilder.getInstance(context, annotationType, writerFactory.getAnnotationTypeWriter(annotationType, prevType, nextType)); } @@ -154,8 +152,7 @@ public class BuilderFactory { * * @return an instance of the method builder for the given class. */ - public AbstractBuilder getMethodBuilder(ClassWriter classWriter) - throws Exception { + public AbstractBuilder getMethodBuilder(ClassWriter classWriter) { return MethodBuilder.getInstance(context, classWriter.getTypeElement(), writerFactory.getMethodWriter(classWriter)); } @@ -168,8 +165,7 @@ public class BuilderFactory { * annotation type. */ public AbstractBuilder getAnnotationTypeFieldsBuilder( - AnnotationTypeWriter annotationTypeWriter) - throws Exception { + AnnotationTypeWriter annotationTypeWriter) { return AnnotationTypeFieldBuilder.getInstance(context, annotationTypeWriter.getAnnotationTypeElement(), writerFactory.getAnnotationTypeFieldWriter(annotationTypeWriter)); @@ -183,8 +179,7 @@ public class BuilderFactory { * annotation type. */ public AbstractBuilder getAnnotationTypeOptionalMemberBuilder( - AnnotationTypeWriter annotationTypeWriter) - throws Exception { + AnnotationTypeWriter annotationTypeWriter) { return AnnotationTypeOptionalMemberBuilder.getInstance(context, annotationTypeWriter.getAnnotationTypeElement(), writerFactory.getAnnotationTypeOptionalMemberWriter(annotationTypeWriter)); @@ -198,8 +193,7 @@ public class BuilderFactory { * annotation type. */ public AbstractBuilder getAnnotationTypeRequiredMemberBuilder( - AnnotationTypeWriter annotationTypeWriter) - throws Exception { + AnnotationTypeWriter annotationTypeWriter) { return AnnotationTypeRequiredMemberBuilder.getInstance(context, annotationTypeWriter.getAnnotationTypeElement(), writerFactory.getAnnotationTypeRequiredMemberWriter(annotationTypeWriter)); @@ -210,8 +204,7 @@ public class BuilderFactory { * * @return an instance of the enum constants builder for the given class. */ - public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter) - throws Exception { + public AbstractBuilder getEnumConstantsBuilder(ClassWriter classWriter) { return EnumConstantBuilder.getInstance(context, classWriter.getTypeElement(), writerFactory.getEnumConstantWriter(classWriter)); } @@ -221,7 +214,7 @@ public class BuilderFactory { * * @return an instance of the field builder for the given class. */ - public AbstractBuilder getFieldBuilder(ClassWriter classWriter) throws Exception { + public AbstractBuilder getFieldBuilder(ClassWriter classWriter) { return FieldBuilder.getInstance(context, classWriter.getTypeElement(), writerFactory.getFieldWriter(classWriter)); } @@ -231,7 +224,7 @@ public class BuilderFactory { * * @return an instance of the field builder for the given class. */ - public AbstractBuilder getPropertyBuilder(ClassWriter classWriter) throws Exception { + public AbstractBuilder getPropertyBuilder(ClassWriter classWriter) { final PropertyWriter propertyWriter = writerFactory.getPropertyWriter(classWriter); return PropertyBuilder.getInstance(context, @@ -244,8 +237,7 @@ public class BuilderFactory { * * @return an instance of the constructor builder for the given class. */ - public AbstractBuilder getConstructorBuilder(ClassWriter classWriter) - throws Exception { + public AbstractBuilder getConstructorBuilder(ClassWriter classWriter) { return ConstructorBuilder.getInstance(context, classWriter.getTypeElement(), writerFactory.getConstructorWriter(classWriter)); } @@ -255,8 +247,7 @@ public class BuilderFactory { * * @return an instance of the member summary builder for the given class. */ - public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter) - throws Exception { + public AbstractBuilder getMemberSummaryBuilder(ClassWriter classWriter) { return MemberSummaryBuilder.getInstance(classWriter, context); } @@ -267,9 +258,7 @@ public class BuilderFactory { * @return an instance of the member summary builder for the given * annotation type. */ - public AbstractBuilder getMemberSummaryBuilder( - AnnotationTypeWriter annotationTypeWriter) - throws Exception { + public AbstractBuilder getMemberSummaryBuilder(AnnotationTypeWriter annotationTypeWriter) { return MemberSummaryBuilder.getInstance(annotationTypeWriter, context); } @@ -278,8 +267,7 @@ public class BuilderFactory { * * @return the builder that builds the serialized form. */ - public AbstractBuilder getSerializedFormBuilder() - throws Exception { + public AbstractBuilder getSerializedFormBuilder() { return SerializedFormBuilder.getInstance(context); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java index 5ad0b019848..436fcb143f6 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ClassBuilder.java @@ -25,13 +25,13 @@ package jdk.javadoc.internal.doclets.toolkit.builders; -import java.io.*; - import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import jdk.javadoc.internal.doclets.toolkit.ClassWriter; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; import jdk.javadoc.internal.doclets.toolkit.util.Utils; /** @@ -105,11 +105,12 @@ public class ClassBuilder extends AbstractBuilder { } /** - * Construct a new ClassBuilder. + * Constructs a new ClassBuilder. * * @param context the build context * @param typeElement the class being documented. * @param writer the doclet specific writer. + * @return the new ClassBuilder */ public static ClassBuilder getInstance(Context context, TypeElement typeElement, ClassWriter writer) { @@ -119,13 +120,15 @@ public class ClassBuilder extends AbstractBuilder { /** * {@inheritDoc} */ - public void build() throws IOException { + @Override + public void build() throws DocletException { build(layoutParser.parseXML(ROOT), contentTree); } /** * {@inheritDoc} */ + @Override public String getName() { return ROOT; } @@ -135,8 +138,9 @@ public class ClassBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param contentTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildClassDoc(XMLNode node, Content contentTree) throws Exception { + public void buildClassDoc(XMLNode node, Content contentTree) throws DocletException { String key; if (isInterface) { key = "doclet.Interface"; @@ -170,15 +174,16 @@ public class ClassBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param classContentTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildClassInfo(XMLNode node, Content classContentTree) { + public void buildClassInfo(XMLNode node, Content classContentTree) throws DocletException { Content classInfoTree = writer.getClassInfoTreeHeader(); buildChildren(node, classInfoTree); classContentTree.addContent(writer.getClassInfo(classInfoTree)); } /** - * Build the typeparameters of this class. + * Build the type parameters of this class. * * @param node the XML element that specifies which components to document * @param classInfoTree the content tree to which the documentation will be added @@ -269,8 +274,10 @@ public class ClassBuilder extends AbstractBuilder { /** * Copy the doc files. + * + * @throws DocFileIOException if there is a problem while copying the files */ - private void copyDocFiles() { + private void copyDocFiles() throws DocFileIOException { PackageElement containingPackage = utils.containingPackage(typeElement); if((configuration.packages == null || !configuration.packages.contains(containingPackage)) && @@ -318,8 +325,9 @@ public class ClassBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param classContentTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildMemberSummary(XMLNode node, Content classContentTree) throws Exception { + public void buildMemberSummary(XMLNode node, Content classContentTree) throws DocletException { Content memberSummaryTree = writer.getMemberTreeHeader(); configuration.getBuilderFactory(). getMemberSummaryBuilder(writer).buildChildren(node, memberSummaryTree); @@ -331,8 +339,9 @@ public class ClassBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param classContentTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildMemberDetails(XMLNode node, Content classContentTree) { + public void buildMemberDetails(XMLNode node, Content classContentTree) throws DocletException { Content memberDetailsTree = writer.getMemberTreeHeader(); buildChildren(node, memberDetailsTree); classContentTree.addContent(writer.getMemberDetailsTree(memberDetailsTree)); @@ -343,9 +352,10 @@ public class ClassBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ public void buildEnumConstantsDetails(XMLNode node, - Content memberDetailsTree) throws Exception { + Content memberDetailsTree) throws DocletException { configuration.getBuilderFactory(). getEnumConstantsBuilder(writer).buildChildren(node, memberDetailsTree); } @@ -355,9 +365,10 @@ public class ClassBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ public void buildFieldDetails(XMLNode node, - Content memberDetailsTree) throws Exception { + Content memberDetailsTree) throws DocletException { configuration.getBuilderFactory(). getFieldBuilder(writer).buildChildren(node, memberDetailsTree); } @@ -365,10 +376,12 @@ public class ClassBuilder extends AbstractBuilder { /** * Build the property documentation. * - * @param elements the XML elements that specify how a field is documented. + * @param node the XML element that specifies which components to document + * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ public void buildPropertyDetails(XMLNode node, - Content memberDetailsTree) throws Exception { + Content memberDetailsTree) throws DocletException { configuration.getBuilderFactory(). getPropertyBuilder(writer).buildChildren(node, memberDetailsTree); } @@ -378,9 +391,10 @@ public class ClassBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ public void buildConstructorDetails(XMLNode node, - Content memberDetailsTree) throws Exception { + Content memberDetailsTree) throws DocletException { configuration.getBuilderFactory(). getConstructorBuilder(writer).buildChildren(node, memberDetailsTree); } @@ -390,9 +404,10 @@ public class ClassBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ public void buildMethodDetails(XMLNode node, - Content memberDetailsTree) throws Exception { + Content memberDetailsTree) throws DocletException { configuration.getBuilderFactory(). getMethodBuilder(writer).buildChildren(node, memberDetailsTree); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java index 704cb55efe8..45eea2bc5b9 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstantsSummaryBuilder.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.toolkit.builders; -import java.io.*; import java.util.*; import javax.lang.model.element.Element; @@ -35,6 +34,7 @@ import javax.lang.model.element.VariableElement; import jdk.javadoc.internal.doclets.toolkit.ConstantsSummaryWriter; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; @@ -116,6 +116,7 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * * @param context the build context. * @param writer the writer for the summary. + * @return the new ConstantsSummaryBuilder */ public static ConstantsSummaryBuilder getInstance(Context context, ConstantsSummaryWriter writer) { @@ -124,9 +125,10 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { /** * {@inheritDoc} + * @throws DocletException if there is a problem while building the documentation */ @Override - public void build() throws IOException { + public void build() throws DocletException { if (writer == null) { //Doclet does not support this output. return; @@ -147,8 +149,9 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param contentTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildConstantSummary(XMLNode node, Content contentTree) throws Exception { + public void buildConstantSummary(XMLNode node, Content contentTree) throws DocletException { contentTree = writer.getHeader(); buildChildren(node, contentTree); writer.addFooter(contentTree); @@ -177,8 +180,9 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param contentTree the tree to which the summaries will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildConstantSummaries(XMLNode node, Content contentTree) { + public void buildConstantSummaries(XMLNode node, Content contentTree) throws DocletException { printedPackageHeaders.clear(); Content summariesTree = writer.getConstantSummaries(); for (PackageElement aPackage : configuration.packages) { @@ -211,8 +215,11 @@ public class ConstantsSummaryBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param summariesTree the tree to which the class constant summary will be added + * @throws DocletException if there is a problem while building the documentation + * */ - public void buildClassConstantSummary(XMLNode node, Content summariesTree) { + public void buildClassConstantSummary(XMLNode node, Content summariesTree) + throws DocletException { SortedSet classes = !currentPackage.isUnnamed() ? utils.getAllClasses(currentPackage) : configuration.typeElementCatalog.allUnnamedClasses(); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java index 888d1de87e8..787ba257eb7 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ConstructorBuilder.java @@ -34,6 +34,7 @@ import javax.lang.model.element.TypeElement; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.ConstructorWriter; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; @@ -112,6 +113,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder { * @param context the build context. * @param typeElement the class whoses members are being documented. * @param writer the doclet specific writer. + * @return the new ConstructorBuilder */ public static ConstructorBuilder getInstance(Context context, TypeElement typeElement, ConstructorWriter writer) { @@ -139,6 +141,7 @@ public class ConstructorBuilder extends AbstractMemberBuilder { * This information can be used for doclet specific documentation * generation. * + * @param typeElement the class * @return a list of constructors that will be documented. */ public SortedSet members(TypeElement typeElement) { @@ -159,8 +162,9 @@ public class ConstructorBuilder extends AbstractMemberBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException is there is a problem while building the documentation */ - public void buildConstructorDoc(XMLNode node, Content memberDetailsTree) { + public void buildConstructorDoc(XMLNode node, Content memberDetailsTree) throws DocletException { if (writer == null) { return; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java index 93428d70517..47ac296c5e9 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/EnumConstantBuilder.java @@ -33,6 +33,7 @@ import javax.lang.model.element.VariableElement; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.EnumConstantWriter; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; @@ -102,6 +103,7 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { * @param context the build context. * @param typeElement the class whoses members are being documented. * @param writer the doclet specific writer. + * @return the new EnumConstantsBuilder */ public static EnumConstantBuilder getInstance(Context context, TypeElement typeElement, EnumConstantWriter writer) { @@ -138,7 +140,9 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { } /** - * summaryOrder.size() + * Returns whether or not there are members to document. + * + * @return whether or not there are members to document */ @Override public boolean hasMembersToDocument() { @@ -150,8 +154,9 @@ public class EnumConstantBuilder extends AbstractMemberBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException is there is a problem while building the documentation */ - public void buildEnumConstant(XMLNode node, Content memberDetailsTree) { + public void buildEnumConstant(XMLNode node, Content memberDetailsTree) throws DocletException { if (writer == null) { return; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java index 30de2dc9312..09f6965f07f 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/FieldBuilder.java @@ -33,6 +33,7 @@ import javax.lang.model.element.VariableElement; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.FieldWriter; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; @@ -103,6 +104,7 @@ public class FieldBuilder extends AbstractMemberBuilder { * @param context the build context. * @param typeElement the class whoses members are being documented. * @param writer the doclet specific writer. + * @return the new FieldBuilder */ public static FieldBuilder getInstance(Context context, TypeElement typeElement, @@ -140,7 +142,9 @@ public class FieldBuilder extends AbstractMemberBuilder { } /** - * summaryOrder.size() + * Returns whether or not there are members to document. + * + * @return whether or not there are members to document */ @Override public boolean hasMembersToDocument() { @@ -152,8 +156,9 @@ public class FieldBuilder extends AbstractMemberBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildFieldDoc(XMLNode node, Content memberDetailsTree) { + public void buildFieldDoc(XMLNode node, Content memberDetailsTree) throws DocletException { if (writer == null) { return; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/LayoutParser.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/LayoutParser.java index 18406b9aebf..f74751cb51b 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/LayoutParser.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/LayoutParser.java @@ -31,7 +31,8 @@ import java.util.*; import javax.xml.parsers.*; import jdk.javadoc.internal.doclets.toolkit.Configuration; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; +import jdk.javadoc.internal.doclets.toolkit.util.DocFileIOException; +import jdk.javadoc.internal.doclets.toolkit.util.SimpleDocletException; import org.xml.sax.*; import org.xml.sax.helpers.DefaultHandler; @@ -53,7 +54,7 @@ public class LayoutParser extends DefaultHandler { /** * The map of XML elements that have been parsed. */ - private Map xmlElementsMap; + private final Map xmlElementsMap; private XMLNode currentNode; private final Configuration configuration; private String currentRoot; @@ -77,33 +78,38 @@ public class LayoutParser extends DefaultHandler { /** * Parse the XML specifying the layout of the documentation. * + * @param root the name of the desired node * @return the list of XML elements parsed. + * @throws DocFileIOException if there is a problem reading a user-supplied build file + * @throws SimpleDocletException if there is a problem reading the system build file */ - public XMLNode parseXML(String root) { - if (xmlElementsMap.containsKey(root)) { - return xmlElementsMap.get(root); - } - try { - currentRoot = root; - isParsing = false; - SAXParserFactory factory = SAXParserFactory.newInstance(); - SAXParser saxParser = factory.newSAXParser(); - InputStream in = configuration.getBuilderXML(); - saxParser.parse(in, this); - return xmlElementsMap.get(root); - } catch (Throwable t) { - t.printStackTrace(); - throw new DocletAbortException(t); + public XMLNode parseXML(String root) throws DocFileIOException, SimpleDocletException { + if (!xmlElementsMap.containsKey(root)) { + try { + currentRoot = root; + isParsing = false; + SAXParserFactory factory = SAXParserFactory.newInstance(); + SAXParser saxParser = factory.newSAXParser(); + InputStream in = configuration.getBuilderXML(); + saxParser.parse(in, this); + } catch (IOException | ParserConfigurationException | SAXException e) { + String message = (configuration.builderXMLPath == null) + ? configuration.getResources().getText("doclet.exception.read.resource", + Configuration.DEFAULT_BUILDER_XML, e) + : configuration.getResources().getText("doclet.exception.read.file", + configuration.builderXMLPath, e); + throw new SimpleDocletException(message, e); + } } + return xmlElementsMap.get(root); } /** * {@inheritDoc} */ @Override - public void startElement(String namespaceURI, String sName, String qName, - Attributes attrs) - throws SAXException { + public void startElement(String namespaceURI, String sName, String qName, Attributes attrs) + throws SAXException { if (isParsing || qName.equals(currentRoot)) { isParsing = true; currentNode = new XMLNode(currentNode, qName); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java index 28d4c1966fc..36b8d909295 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MemberSummaryBuilder.java @@ -42,7 +42,6 @@ import jdk.javadoc.internal.doclets.toolkit.MemberSummaryWriter; import jdk.javadoc.internal.doclets.toolkit.WriterFactory; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; -import jdk.javadoc.internal.doclets.toolkit.util.Utils; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; import jdk.javadoc.internal.doclets.toolkit.CommentUtils; @@ -107,8 +106,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { * @param context the build context. */ public static MemberSummaryBuilder getInstance( - ClassWriter classWriter, Context context) - throws Exception { + ClassWriter classWriter, Context context) { MemberSummaryBuilder builder = new MemberSummaryBuilder(context, classWriter.getTypeElement()); WriterFactory wf = context.configuration.getWriterFactory(); @@ -129,8 +127,7 @@ public class MemberSummaryBuilder extends AbstractMemberBuilder { * @param configuration the current configuration of the doclet. */ public static MemberSummaryBuilder getInstance( - AnnotationTypeWriter annotationTypeWriter, Context context) - throws Exception { + AnnotationTypeWriter annotationTypeWriter, Context context) { MemberSummaryBuilder builder = new MemberSummaryBuilder(context, annotationTypeWriter.getAnnotationTypeElement()); WriterFactory wf = context.configuration.getWriterFactory(); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java index 5180f07d366..d31909d95b9 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/MethodBuilder.java @@ -35,6 +35,7 @@ import javax.lang.model.type.TypeMirror; import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.MethodWriter; import jdk.javadoc.internal.doclets.toolkit.util.DocFinder; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; @@ -156,8 +157,9 @@ public class MethodBuilder extends AbstractMemberBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildMethodDoc(XMLNode node, Content memberDetailsTree) { + public void buildMethodDoc(XMLNode node, Content memberDetailsTree) throws DocletException { if (writer == null) { return; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java index 0b6d48c1ca8..02246a3a96d 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/ModuleSummaryBuilder.java @@ -25,14 +25,12 @@ package jdk.javadoc.internal.doclets.toolkit.builders; -import java.io.IOException; -import java.util.Set; - import javax.lang.model.element.ModuleElement; import javax.lang.model.element.PackageElement; import javax.tools.StandardLocation; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.ModuleSummaryWriter; import jdk.javadoc.internal.doclets.toolkit.util.DocPaths; @@ -105,8 +103,11 @@ public class ModuleSummaryBuilder extends AbstractBuilder { /** * Build the module summary. + * + * @throws DocletException if there is a problem while building the documentation */ - public void build() throws IOException { + @Override + public void build() throws DocletException { if (moduleWriter == null) { //Doclet does not support this output. return; @@ -117,6 +118,7 @@ public class ModuleSummaryBuilder extends AbstractBuilder { /** * {@inheritDoc} */ + @Override public String getName() { return ROOT; } @@ -126,8 +128,9 @@ public class ModuleSummaryBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param contentTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildModuleDoc(XMLNode node, Content contentTree) throws Exception { + public void buildModuleDoc(XMLNode node, Content contentTree) throws DocletException { contentTree = moduleWriter.getModuleHeader(mdle.getSimpleName().toString()); buildChildren(node, contentTree); moduleWriter.addModuleFooter(contentTree); @@ -145,8 +148,9 @@ public class ModuleSummaryBuilder extends AbstractBuilder { * @param node the XML element that specifies which components to document * @param contentTree the content tree to which the module contents * will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildContent(XMLNode node, Content contentTree) { + public void buildContent(XMLNode node, Content contentTree) throws DocletException { Content moduleContentTree = moduleWriter.getContentHeader(); buildChildren(node, moduleContentTree); moduleWriter.addModuleContent(contentTree, moduleContentTree); @@ -158,8 +162,9 @@ public class ModuleSummaryBuilder extends AbstractBuilder { * @param node the XML element that specifies which components to document * @param moduleContentTree the module content tree to which the summaries will * be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildSummary(XMLNode node, Content moduleContentTree) { + public void buildSummary(XMLNode node, Content moduleContentTree) throws DocletException { Content summaryContentTree = moduleWriter.getSummaryHeader(); buildChildren(node, summaryContentTree); moduleContentTree.addContent(moduleWriter.getSummaryTree(summaryContentTree)); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java index d70d05c7ea2..554588f339c 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PackageSummaryBuilder.java @@ -25,8 +25,6 @@ package jdk.javadoc.internal.doclets.toolkit.builders; -import java.io.*; - import java.util.Arrays; import java.util.List; import java.util.Set; @@ -36,6 +34,7 @@ import javax.lang.model.element.PackageElement; import javax.lang.model.element.TypeElement; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.PackageSummaryWriter; @@ -104,8 +103,11 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * Build the package summary. + * + * @throws DocletException if there is a problem while building the documentation */ - public void build() throws IOException { + @Override + public void build() throws DocletException { if (packageWriter == null) { //Doclet does not support this output. return; @@ -116,6 +118,7 @@ public class PackageSummaryBuilder extends AbstractBuilder { /** * {@inheritDoc} */ + @Override public String getName() { return ROOT; } @@ -125,8 +128,9 @@ public class PackageSummaryBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param contentTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildPackageDoc(XMLNode node, Content contentTree) throws Exception { + public void buildPackageDoc(XMLNode node, Content contentTree) throws DocletException { contentTree = packageWriter.getPackageHeader(utils.getPackageName(packageElement)); buildChildren(node, contentTree); packageWriter.addPackageFooter(contentTree); @@ -140,8 +144,9 @@ public class PackageSummaryBuilder extends AbstractBuilder { * @param node the XML element that specifies which components to document * @param contentTree the content tree to which the package contents * will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildContent(XMLNode node, Content contentTree) { + public void buildContent(XMLNode node, Content contentTree) throws DocletException { Content packageContentTree = packageWriter.getContentHeader(); buildChildren(node, packageContentTree); packageWriter.addPackageContent(contentTree, packageContentTree); @@ -153,8 +158,9 @@ public class PackageSummaryBuilder extends AbstractBuilder { * @param node the XML element that specifies which components to document * @param packageContentTree the package content tree to which the summaries will * be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildSummary(XMLNode node, Content packageContentTree) { + public void buildSummary(XMLNode node, Content packageContentTree) throws DocletException { Content summaryContentTree = packageWriter.getSummaryHeader(); buildChildren(node, summaryContentTree); packageContentTree.addContent(summaryContentTree); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java index 5ec27163607..68af2e3447b 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/PropertyBuilder.java @@ -33,6 +33,7 @@ import javax.lang.model.element.TypeElement; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.PropertyWriter; import jdk.javadoc.internal.doclets.toolkit.util.VisibleMemberMap; @@ -103,6 +104,7 @@ public class PropertyBuilder extends AbstractMemberBuilder { * @param context the build context. * @param typeElement the class whoses members are being documented. * @param writer the doclet specific writer. + * @return the new PropertyBuilder */ public static PropertyBuilder getInstance(Context context, TypeElement typeElement, @@ -140,7 +142,9 @@ public class PropertyBuilder extends AbstractMemberBuilder { } /** - * summaryOrder.size() + * Returns whether or not there are members to document. + * + * @return whether or not there are members to document */ @Override public boolean hasMembersToDocument() { @@ -152,8 +156,9 @@ public class PropertyBuilder extends AbstractMemberBuilder { * * @param node the XML element that specifies which components to document * @param memberDetailsTree the content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildPropertyDoc(XMLNode node, Content memberDetailsTree) { + public void buildPropertyDoc(XMLNode node, Content memberDetailsTree) throws DocletException { if (writer == null) { return; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java index fcbbda4ad7d..ef401f1c5d6 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/builders/SerializedFormBuilder.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.toolkit.builders; -import java.io.*; import java.util.*; import javax.lang.model.element.Element; @@ -37,9 +36,9 @@ import javax.lang.model.element.VariableElement; import com.sun.source.doctree.DocTree; import com.sun.source.doctree.SerialFieldTree; import jdk.javadoc.internal.doclets.toolkit.Content; +import jdk.javadoc.internal.doclets.toolkit.DocletException; import jdk.javadoc.internal.doclets.toolkit.SerializedFormWriter; import jdk.javadoc.internal.doclets.toolkit.util.CommentHelper; -import jdk.javadoc.internal.doclets.toolkit.util.DocletAbortException; import jdk.javadoc.internal.doclets.toolkit.util.Utils; /** @@ -114,7 +113,9 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * Construct a new SerializedFormBuilder. + * * @param context the build context. + * @return the new SerializedFormBuilder */ public static SerializedFormBuilder getInstance(Context context) { return new SerializedFormBuilder(context); @@ -122,22 +123,21 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * Build the serialized form. + * + * @throws DocletException if there is a problem while building the documentation */ - public void build() throws IOException { + @Override + public void build() throws DocletException { SortedSet rootclasses = new TreeSet<>(utils.makeGeneralPurposeComparator()); rootclasses.addAll(configuration.docEnv.getIncludedTypeElements()); if (!serialClassFoundToDocument(rootclasses)) { //Nothing to document. return; } - try { - writer = configuration.getWriterFactory().getSerializedFormWriter(); - if (writer == null) { - //Doclet does not support this output. - return; - } - } catch (Exception e) { - throw new DocletAbortException(e); + writer = configuration.getWriterFactory().getSerializedFormWriter(); + if (writer == null) { + //Doclet does not support this output. + return; } build(layoutParser.parseXML(NAME), contentTree); } @@ -145,6 +145,7 @@ public class SerializedFormBuilder extends AbstractBuilder { /** * {@inheritDoc} */ + @Override public String getName() { return NAME; } @@ -154,8 +155,9 @@ public class SerializedFormBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param serializedTree content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildSerializedForm(XMLNode node, Content serializedTree) throws Exception { + public void buildSerializedForm(XMLNode node, Content serializedTree) throws DocletException { serializedTree = writer.getHeader(configuration.getText( "doclet.Serialized_Form")); buildChildren(node, serializedTree); @@ -168,8 +170,10 @@ public class SerializedFormBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param serializedTree content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildSerializedFormSummaries(XMLNode node, Content serializedTree) { + public void buildSerializedFormSummaries(XMLNode node, Content serializedTree) + throws DocletException { Content serializedSummariesTree = writer.getSerializedSummariesHeader(); for (PackageElement pkg : configuration.packages) { currentPackage = pkg; @@ -184,8 +188,9 @@ public class SerializedFormBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param serializedSummariesTree content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildPackageSerializedForm(XMLNode node, Content serializedSummariesTree) { + public void buildPackageSerializedForm(XMLNode node, Content serializedSummariesTree) throws DocletException { Content packageSerializedTree = writer.getPackageSerializedHeader(); SortedSet classes = utils.getAllClassesUnfiltered(currentPackage); if (classes.isEmpty()) { @@ -217,8 +222,10 @@ public class SerializedFormBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param packageSerializedTree content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildClassSerializedForm(XMLNode node, Content packageSerializedTree) { + public void buildClassSerializedForm(XMLNode node, Content packageSerializedTree) + throws DocletException { Content classSerializedTree = writer.getClassSerializedHeader(); SortedSet typeElements = utils.getAllClassesUnfiltered(currentPackage); for (TypeElement typeElement : typeElements) { @@ -262,8 +269,9 @@ public class SerializedFormBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param classTree content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildClassContent(XMLNode node, Content classTree) { + public void buildClassContent(XMLNode node, Content classTree) throws DocletException { Content classContentTree = writer.getClassContentHeader(); buildChildren(node, classContentTree); classTree.addContent(classContentTree); @@ -275,8 +283,9 @@ public class SerializedFormBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param classContentTree content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildSerializableMethods(XMLNode node, Content classContentTree) { + public void buildSerializableMethods(XMLNode node, Content classContentTree) throws DocletException { Content serializableMethodTree = methodWriter.getSerializableMethodsHeader(); SortedSet members = utils.serializationMethods(currentTypeElement); if (!members.isEmpty()) { @@ -329,8 +338,9 @@ public class SerializedFormBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param methodsContentTree content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildMethodInfo(XMLNode node, Content methodsContentTree) { + public void buildMethodInfo(XMLNode node, Content methodsContentTree) throws DocletException { if(configuration.nocomment){ return; } @@ -411,8 +421,10 @@ public class SerializedFormBuilder extends AbstractBuilder { * * @param node the XML element that specifies which components to document * @param classContentTree content tree to which the documentation will be added + * @throws DocletException if there is a problem while building the documentation */ - public void buildSerializableFields(XMLNode node, Content classContentTree) { + public void buildSerializableFields(XMLNode node, Content classContentTree) + throws DocletException { SortedSet members = utils.serializableFields(currentTypeElement); if (!members.isEmpty()) { Content serializableFieldsTree = fieldWriter.getSerializableFieldsHeader(); @@ -533,10 +545,12 @@ public class SerializedFormBuilder extends AbstractBuilder { } /** - * Return true if the given Element should be included + * Returns true if the given Element should be included * in the serialized form. * - * @param element the Element object to check for serializability. + * @param utils the utils object + * @param element the Element object to check for serializability + * @return true if the element should be included in the serial form */ public static boolean serialInclude(Utils utils, Element element) { if (element == null) { @@ -548,7 +562,7 @@ public class SerializedFormBuilder extends AbstractBuilder { } /** - * Return true if the given TypeElement should be included + * Returns true if the given TypeElement should be included * in the serialized form. * * @param te the TypeElement object to check for serializability. diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties index 8471fd9e6a3..aaf2392279a 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/resources/doclets.properties @@ -14,17 +14,29 @@ doclet.Option_reuse=Option reused: {0} doclet.Option_doclint_no_qualifiers=Access qualifiers not permitted for -Xdoclint arguments doclet.Option_doclint_invalid_arg=Invalid argument for -Xdoclint option doclet.Option_doclint_package_invalid_arg=Invalid argument for -Xdoclint/package option -doclet.exception_encountered= {0} encountered \n\ -\twhile attempting to create file: {1} -doclet.perform_copy_exception_encountered= {0} encountered while \n\ -performing copy. +doclet.builder.exception.in.component=An exception occurred while building a component: {0}\n\ +\t({1}) +doclet.builder.unknown.component=Unknown component referenced in doclet build file: {0} +doclet.error.initializing.dest.dir=Error initializing destination directory: {0} +doclet.exception.read.file=Error reading file: {0}\n\ +\t({1}) +doclet.exception.write.file=Error writing file: {0}\n\ +\t({1}) +doclet.exception.read.resource=Error reading system resource: {0}\n\ +\t({1}) +doclet.internal.exception=An internal exception has occurred. \n\ +\t({0}) +doclet.internal.report.bug=\ +Please file a bug against the javadoc tool via the Java bug reporting page\n\ +(http://bugreport.java.com) after checking the Bug Database (http://bugs.java.com)\n\ +for duplicates. Include error messages and the following diagnostic in your report. Thank you. doclet.File_not_found=File not found: {0} doclet.Copy_Overwrite_warning=File {0} not copied to {1} due to existing file with same name... doclet.Copying_File_0_To_Dir_1=Copying file {0} to directory {1}... doclet.Copying_File_0_To_File_1=Copying file {0} to file {1}... doclet.No_Public_Classes_To_Document=No public or protected classes found to document. -doclet.destination_directory_not_directory_0=Destination directory is not a directory {0} -doclet.destination_directory_not_writable_0=Destination directory not writable {0} +doclet.destination_directory_not_directory_0=Destination directory is not a directory: {0} +doclet.destination_directory_not_writable_0=Destination directory not writable: {0} doclet.Encoding_not_supported=Encoding not supported: {0} doclet.Building_Tree=Building tree for all the packages and classes... doclet.Building_Index=Building index for all the packages and classes... diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFile.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFile.java index d3be58c0f2d..88da82d3da7 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFile.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFile.java @@ -26,13 +26,10 @@ package jdk.javadoc.internal.doclets.toolkit.util; import java.io.BufferedReader; -import java.io.BufferedWriter; -import java.io.FileNotFoundException; import java.io.IOException; import java.io.InputStream; import java.io.InputStreamReader; import java.io.OutputStream; -import java.io.OutputStreamWriter; import java.io.UnsupportedEncodingException; import java.io.Writer; @@ -68,8 +65,6 @@ public abstract class DocFile { return DocFileFactory.getFactory(configuration).createFileForOutput(path); } - private final Configuration configuration; - /** * The location for this file. Maybe null if the file was created without * a location or path. @@ -95,63 +90,85 @@ public abstract class DocFile { } /** Create a DocFile without a location or path */ - protected DocFile(Configuration configuration) { - this.configuration = configuration; + protected DocFile() { this.location = null; this.path = null; } /** Create a DocFile for a given location and relative path. */ - protected DocFile(Configuration configuration, Location location, DocPath path) { - this.configuration = configuration; + protected DocFile(Location location, DocPath path) { this.location = location; this.path = path; } - /** Open an input stream for the file. */ - public abstract InputStream openInputStream() throws IOException; + /** + * Open an input stream for the file. + * + * @return an open input stream for the file + * @throws DocFileIOException if there is a problem opening the stream + */ + public abstract InputStream openInputStream() throws DocFileIOException; /** * Open an output stream for the file. * The file must have been created with a location of * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} * and a corresponding relative path. + * + * @return an open output stream for the file + * @throws DocFileIOException if there is a problem opening the stream + * @throws UnsupportedEncodingException if the configured encoding is not supported */ - public abstract OutputStream openOutputStream() throws IOException, UnsupportedEncodingException; + public abstract OutputStream openOutputStream() throws DocFileIOException, UnsupportedEncodingException; /** * Open an writer for the file, using the encoding (if any) given in the * doclet configuration. * The file must have been created with a location of * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. + * + * @return an open output stream for the file + * @throws DocFileIOException if there is a problem opening the stream + * @throws UnsupportedEncodingException if the configured encoding is not supported */ - public abstract Writer openWriter() throws IOException, UnsupportedEncodingException; + public abstract Writer openWriter() throws DocFileIOException, UnsupportedEncodingException; /** * Copy the contents of another file directly to this file. + * + * @param fromFile the file to be copied + * @throws DocFileIOException if there is a problem file copying the file */ - public void copyFile(DocFile fromFile) throws IOException { - try (OutputStream output = openOutputStream(); - InputStream input = fromFile.openInputStream()) { - byte[] bytearr = new byte[1024]; - int len; - while ((len = input.read(bytearr)) != -1) { - output.write(bytearr, 0, len); + public void copyFile(DocFile fromFile) throws DocFileIOException { + try (OutputStream output = openOutputStream()) { + try (InputStream input = fromFile.openInputStream()) { + byte[] bytearr = new byte[1024]; + int len; + while ((len = read(fromFile, input, bytearr)) != -1) { + write(this, output, bytearr, len); + } + } catch (IOException e) { + throw new DocFileIOException(fromFile, DocFileIOException.Mode.READ, e); } - } - catch (FileNotFoundException | SecurityException exc) { + } catch (IOException e) { + throw new DocFileIOException(this, DocFileIOException.Mode.WRITE, e); } } /** * Copy the contents of a resource file to this file. + * * @param resource the path of the resource, relative to the package of this class * @param overwrite whether or not to overwrite the file if it already exists * @param replaceNewLine if false, the file is copied as a binary file; * if true, the file is written line by line, using the platform line * separator + * + * @throws DocFileIOException if there is a problem while writing the copy + * @throws ResourceIOException if there is a problem while reading the resource */ - public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine) { + public void copyResource(DocPath resource, boolean overwrite, boolean replaceNewLine) + throws DocFileIOException, ResourceIOException { if (exists() && !overwrite) return; @@ -160,30 +177,35 @@ public abstract class DocFile { if (in == null) return; - try (OutputStream out = openOutputStream()) { - if (!replaceNewLine) { - byte[] buf = new byte[2048]; - int n; - while ((n = in.read(buf)) > 0) - out.write(buf, 0, n); - } else { - try (BufferedReader reader = new BufferedReader(new InputStreamReader(in)); - BufferedWriter writer = new BufferedWriter(configuration.docencoding == null - ? new OutputStreamWriter(out) - : new OutputStreamWriter(out, configuration.docencoding))) { - String line; - while ((line = reader.readLine()) != null) { - writer.write(line); - writer.write(DocletConstants.NL); + try { + if (replaceNewLine) { + try (BufferedReader reader = new BufferedReader(new InputStreamReader(in))) { + try (Writer writer = openWriter()) { + String line; + while ((line = readResourceLine(resource, reader)) != null) { + write(this, writer, line); + write(this, writer, DocletConstants.NL); + } + } catch (IOException e) { + throw new DocFileIOException(this, DocFileIOException.Mode.WRITE, e); } } + } else { + try (OutputStream out = openOutputStream()) { + byte[] buf = new byte[2048]; + int n; + while ((n = readResource(resource, in, buf)) > 0) { + write(this, out, buf, n); + } + } catch (IOException e) { + throw new DocFileIOException(this, DocFileIOException.Mode.WRITE, e); + } } } finally { in.close(); } } catch (IOException e) { - e.printStackTrace(System.err); - throw new DocletAbortException(e); + throw new ResourceIOException(resource, e); } } @@ -214,8 +236,12 @@ public abstract class DocFile { /** Return true if this file is the same as another. */ public abstract boolean isSameFile(DocFile other); - /** If the file is a directory, list its contents. */ - public abstract Iterable list() throws IOException; + /** If the file is a directory, list its contents. + * + * @return the contents of the directory + * @throws DocFileIOException if there is a problem while listing the directory + */ + public abstract Iterable list() throws DocFileIOException; /** Create the file as a directory, including any parent directories. */ public abstract boolean mkdirs(); @@ -242,4 +268,92 @@ public abstract class DocFile { * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} is supported. */ public abstract DocFile resolveAgainst(Location locn); + + + /** + * Reads from an input stream opened from a given file into a given buffer. + * If an IOException occurs, it is wrapped in a DocFileIOException. + * + * @param inFile the file for the stream + * @param input the stream + * @param buf the buffer + * @return the number of bytes read, or -1 if at end of file + * @throws DocFileIOException if an exception occurred while reading the stream + */ + private static int read(DocFile inFile, InputStream input, byte[] buf) throws DocFileIOException { + try { + return input.read(buf); + } catch (IOException e) { + throw new DocFileIOException(inFile, DocFileIOException.Mode.READ, e); + } + } + + /** + * Writes to an output stream for a given file from a given buffer. + * If an IOException occurs, it is wrapped in a DocFileIOException. + * + * @param outFile the file for the stream + * @param out the stream + * @param buf the buffer + * @throws DocFileIOException if an exception occurred while writing the stream + */ + private static void write(DocFile outFile, OutputStream out, byte[] buf, int len) throws DocFileIOException { + try { + out.write(buf, 0, len); + } catch (IOException e) { + throw new DocFileIOException(outFile, DocFileIOException.Mode.WRITE, e); + } + } + + /** + * Writes text to an output stream for a given file from a given buffer. + * If an IOException occurs, it is wrapped in a DocFileIOException. + * + * @param outFile the file for the stream + * @param out the stream + * @param text the text to be written + * @throws DocFileIOException if an exception occurred while writing the stream + */ + private static void write(DocFile outFile, Writer out, String text) throws DocFileIOException { + try { + out.write(text); + } catch (IOException e) { + throw new DocFileIOException(outFile, DocFileIOException.Mode.WRITE, e); + } + } + + /** + * Reads from an input stream opened from a given resource into a given buffer. + * If an IOException occurs, it is wrapped in a ResourceIOException. + * + * @param resource the resource for the stream + * @param in the stream + * @param buf the buffer + * @return the number of bytes read, or -1 if at end of file + * @throws ResourceIOException if an exception occurred while reading the stream + */ + private static int readResource(DocPath resource, InputStream in, byte[] buf) throws ResourceIOException { + try { + return in.read(buf); + } catch (IOException e) { + throw new ResourceIOException(resource, e); + } + } + + /** + * Reads a line of characters from an input stream opened from a given resource. + * If an IOException occurs, it is wrapped in a ResourceIOException. + * + * @param resource the resource for the stream + * @param in the stream + * @return the line of text, or {@code null} if at end of stream + * @throws ResourceIOException if an exception occurred while reading the stream + */ + private static String readResourceLine(DocPath docPath, BufferedReader in) throws ResourceIOException { + try { + return in.readLine(); + } catch (IOException e) { + throw new ResourceIOException(docPath, e); + } + } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFileFactory.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFileFactory.java index 557f84c361a..3df700faa84 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFileFactory.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFileFactory.java @@ -31,6 +31,7 @@ import javax.tools.StandardJavaFileManager; import javax.tools.StandardLocation; import jdk.javadoc.internal.doclets.toolkit.Configuration; +import jdk.javadoc.internal.doclets.toolkit.DocletException; /** * Factory for DocFile objects. @@ -45,8 +46,11 @@ public abstract class DocFileFactory { /** * Get the appropriate factory, based on the file manager given in the * configuration. + * + * @param configuration the configuration for this doclet + * @return the factory associated with this configuration */ - static synchronized DocFileFactory getFactory(Configuration configuration) { + public static synchronized DocFileFactory getFactory(Configuration configuration) { DocFileFactory f = configuration.docFileFactory; if (f == null) { JavaFileManager fm = configuration.getFileManager(); @@ -66,6 +70,8 @@ public abstract class DocFileFactory { this.configuration = configuration; } + public abstract void setDestDir(String dir) throws DocletException; + /** Create a DocFile for a directory. */ abstract DocFile createFileForDirectory(String file); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFileIOException.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFileIOException.java new file mode 100644 index 00000000000..705cb88a80a --- /dev/null +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocFileIOException.java @@ -0,0 +1,82 @@ +/* + * 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. + */ + +package jdk.javadoc.internal.doclets.toolkit.util; + +import java.io.IOException; + +import jdk.javadoc.internal.doclets.toolkit.DocletException; + + +/** + * Wraps an IOException and the filename to which it applies. + * + *

This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + * + * @apiNote This exception should be thrown by a doclet when an IO exception occurs + * and the file is known that was in use when the exception occurred. + */ +public class DocFileIOException extends DocletException { + /** + * A hint for the type of operation being performed when the exception occurred. + * + * @apiNote This may be used as a hint when reporting a message to the end user. + */ + public enum Mode { + /** The file was being opened for reading, or being read when the exception occurred. */ + READ, + /** The file was being opened for writing, or being written when the exception occurred. */ + WRITE + }; + + /** + * The file that was in use when the exception occurred. + */ + public final DocFile fileName; + + /** + * The mode in which the file was being used when the exception occurred. + */ + public final Mode mode; + + private static final long serialVersionUID = 1L; + + /** + * Creates an exception to wrap an IO exception, the file which caused it, and the manner + * in which the file was being used. + * + * @param fileName the file in use when the exception occurred + * @param mode the manner in which the file was being used + * @param cause the underlying exception + */ + public DocFileIOException(DocFile fileName, Mode mode, IOException cause) { + super(mode + ":" + fileName.getPath(), cause); + this.fileName = fileName; + this.mode = mode; + } +} diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java index eebcc5e6686..5db358f7c3b 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Extern.java @@ -117,6 +117,7 @@ public class Extern { /** * String representation of "this" with packagename and the path. */ + @Override public String toString() { return packageName + (relative? " -> " : " => ") + path; } @@ -130,6 +131,7 @@ public class Extern { * Determine if a element item is externally documented. * * @param element an Element. + * @return true if the element is externally documented */ public boolean isExternal(Element element) { if (packageToItemMap == null) { @@ -176,8 +178,11 @@ public class Extern { * file. * @param reporter The DocErrorReporter used to report errors. * @param linkoffline True if -linkoffline is used and false if -link is used. + * @return true if successful, false otherwise + * @throws DocFileIOException if there is a problem reading a package list file */ - public boolean link(String url, String pkglisturl, Reporter reporter, boolean linkoffline) { + public boolean link(String url, String pkglisturl, Reporter reporter, boolean linkoffline) + throws DocFileIOException { this.linkoffline = linkoffline; try { url = adjustEndFileSeparator(url); @@ -251,9 +256,11 @@ public class Extern { * * @param path URL or directory path to the packages. * @param pkgListPath Path to the local "package-list" file. + * @throws Fault if an error occurs that can be treated as a warning + * @throws DocFileIOException if there is a problem opening the package list file */ private void readPackageListFromFile(String path, DocFile pkgListPath) - throws Fault { + throws Fault, DocFileIOException { DocFile file = pkgListPath.resolve(DocPaths.PACKAGE_LIST); if (! (file.isAbsolute() || linkoffline)){ file = file.resolveAgainst(DocumentationTool.Location.DOCUMENTATION_OUTPUT); @@ -279,35 +286,33 @@ public class Extern { * @param input InputStream from the "package-list" file. * @param path URL or the directory path to the packages. * @param relative Is path relative? + * @throws IOException if there is a problem reading or closing the stream */ private void readPackageList(InputStream input, String path, boolean relative) throws IOException { - BufferedReader in = new BufferedReader(new InputStreamReader(input)); - StringBuilder strbuf = new StringBuilder(); - try { + try (BufferedReader in = new BufferedReader(new InputStreamReader(input))) { + StringBuilder strbuf = new StringBuilder(); int c; while ((c = in.read()) >= 0) { - char ch = (char)c; + char ch = (char) c; if (ch == '\n' || ch == '\r') { if (strbuf.length() > 0) { String packname = strbuf.toString(); - String packpath = path + - packname.replace('.', '/') + '/'; - new Item(packname, packpath, relative); + String packpath = path + + packname.replace('.', '/') + '/'; + Item ignore = new Item(packname, packpath, relative); strbuf.setLength(0); } } else { strbuf.append(ch); } } - } finally { - input.close(); } } public boolean isUrl (String urlCandidate) { try { - new URL(urlCandidate); + URL ignore = new URL(urlCandidate); //No exception was thrown, so this must really be a URL. return true; } catch (MalformedURLException e) { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocletAbortException.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/InternalException.java similarity index 55% rename from langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocletAbortException.java rename to langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/InternalException.java index 7cf32a85d6b..9f48678fabc 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/DocletAbortException.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/InternalException.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015, Oracle and/or its affiliates. All rights reserved. + * 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 @@ -25,20 +25,29 @@ package jdk.javadoc.internal.doclets.toolkit.util; +import jdk.javadoc.internal.doclets.toolkit.DocletException; + + /** - *

This is NOT part of any supported API. - * If you write code that depends on this, you do so at your own risk. - * This code and its internal interfaces are subject to change or - * deletion without notice. + * An exception with a user-friendly detail message for an unexpected/internal exception. + * + *

This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. */ -public class DocletAbortException extends RuntimeException { - private static final long serialVersionUID = -9131058909576418984L; +public class InternalException extends DocletException { - public DocletAbortException(String message) { - super(message); - } + private static final long serialVersionUID = 1L; - public DocletAbortException(Throwable cause) { - super(cause); + /** + * Creates an exception with a user-friendly detail message, and underlying cause. + * A stacktrace for the cause may be presented to the user. + * + * @param message a localized detail message, suitable for direct presentation to the end user + * @param cause the underlying cause for the exception + */ + public InternalException(String message, Throwable cause) { + super(message, cause); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java index 10938419501..7152c2437d0 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/PackageListWriter.java @@ -26,13 +26,11 @@ package jdk.javadoc.internal.doclets.toolkit.util; import java.io.*; -import java.util.*; import javax.lang.model.element.PackageElement; import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.internal.doclets.toolkit.Configuration; -import jdk.javadoc.internal.doclets.toolkit.Messages; /** @@ -45,18 +43,19 @@ import jdk.javadoc.internal.doclets.toolkit.Messages; * * @author Atul M Dambalkar */ -public class PackageListWriter extends PrintWriter { +public class PackageListWriter { private final Configuration configuration; private final Utils utils; + private final DocFile file; /** * Constructor. * * @param configuration the current configuration of the doclet. */ - public PackageListWriter(Configuration configuration) throws IOException { - super(DocFile.createFileForOutput(configuration, DocPaths.PACKAGE_LIST).openWriter()); + public PackageListWriter(Configuration configuration) { + file = DocFile.createFileForOutput(configuration, DocPaths.PACKAGE_LIST); this.configuration = configuration; this.utils = configuration.utils; } @@ -65,32 +64,25 @@ public class PackageListWriter extends PrintWriter { * Generate the package index. * * @param configuration the current configuration of the doclet. - * @throws DocletAbortException + * @throws DocFileIOException if there is a problem writing the output */ - public static void generate(Configuration configuration) { - PackageListWriter packgen; - try { - packgen = new PackageListWriter(configuration); - packgen.generatePackageListFile(configuration.docEnv); - packgen.close(); - } catch (IOException exc) { - Messages messages = configuration.getMessages(); - messages.error("doclet.exception_encountered", - exc.toString(), DocPaths.PACKAGE_LIST); - throw new DocletAbortException(exc); - } + public static void generate(Configuration configuration) throws DocFileIOException { + PackageListWriter packgen = new PackageListWriter(configuration); + packgen.generatePackageListFile(configuration.docEnv); } - protected void generatePackageListFile(DocletEnvironment docEnv) { - ArrayList names = new ArrayList<>(); - for (PackageElement pkg : configuration.packages) { - // if the -nodeprecated option is set and the package is marked as - // deprecated, do not include it in the packages list. - if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) - names.add(pkg); + protected void generatePackageListFile(DocletEnvironment docEnv) throws DocFileIOException { + try (BufferedWriter out = new BufferedWriter(file.openWriter())) { + for (PackageElement pkg : configuration.packages) { + // if the -nodeprecated option is set and the package is marked as + // deprecated, do not include it in the packages list. + if (!(configuration.nodeprecated && utils.isDeprecated(pkg))) { + out.write(pkg.toString()); + out.newLine(); + } + } + } catch (IOException e) { + throw new DocFileIOException(file, DocFileIOException.Mode.WRITE, e); } - names.stream().forEach((name) -> { - println(name); - }); } } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ResourceIOException.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ResourceIOException.java new file mode 100644 index 00000000000..402850a2133 --- /dev/null +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ResourceIOException.java @@ -0,0 +1,63 @@ +/* + * 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. + */ + +package jdk.javadoc.internal.doclets.toolkit.util; + +import java.io.IOException; + +import jdk.javadoc.internal.doclets.toolkit.DocletException; + + +/** + * Wraps an IOException and the path for the resource to which it applies. + * + *

This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + * + * @apiNote This exception should be thrown by a doclet when an IO exception occurs + * and the file is known that was in use when the exception occurred. + */ +public class ResourceIOException extends DocletException { + + /** + * The resource that was in use when the exception occurred. + */ + public final DocPath resource; + + private static final long serialVersionUID = 1L; + + /** + * Creates an exception to wrap an IO exception, the resource which caused it. + * + * @param resource the resource in use when the exception occurred + * @param cause the underlying exception + */ + public ResourceIOException(DocPath resource, IOException cause) { + super(resource.getPath(), cause); + this.resource = resource; + } +} diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/SimpleDocletException.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/SimpleDocletException.java new file mode 100644 index 00000000000..11f138f2f35 --- /dev/null +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/SimpleDocletException.java @@ -0,0 +1,62 @@ +/* + * 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. + */ + +package jdk.javadoc.internal.doclets.toolkit.util; + +import jdk.javadoc.internal.doclets.toolkit.DocletException; + + +/** + * An exception with a user-friendly detail message. + * + *

This is NOT part of any supported API. + * If you write code that depends on this, you do so at your own risk. + * This code and its internal interfaces are subject to change or + * deletion without notice. + */ +public class SimpleDocletException extends DocletException { + + private static final long serialVersionUID = 1L; + + /** + * Creates an exception with a user-friendly detail message. + * + * @param message a localized detail message, suitable for direct presentation to the end user + */ + public SimpleDocletException(String message) { + super(message); + } + + /** + * Creates an exception with a user-friendly detail message, and underlying cause. + * The cause may be used for debugging but in normal use, should not be presented to the user. + * + * @param message a localized detail message, suitable for direct presentation to the end user + * @param cause the underlying cause for the exception + */ + public SimpleDocletException(String message, Throwable cause) { + super(message, cause); + } +} diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/StandardDocFileFactory.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/StandardDocFileFactory.java index 6cf91e53390..d230809da5e 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/StandardDocFileFactory.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/StandardDocFileFactory.java @@ -42,6 +42,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.LinkedHashSet; import java.util.List; +import java.util.Objects; import java.util.Set; import javax.tools.DocumentationTool; @@ -72,32 +73,43 @@ class StandardDocFileFactory extends DocFileFactory { fileManager = (StandardJavaFileManager) configuration.getFileManager(); } - private Path getDestDir() { - if (destDir == null) { - if (!configuration.destDirName.isEmpty() - || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) { - try { - String dirName = configuration.destDirName.isEmpty() ? "." : configuration.destDirName; - Path dir = Paths.get(dirName); - fileManager.setLocationFromPaths(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir)); - } catch (IOException e) { - throw new DocletAbortException(e); - } - } + @Override + public void setDestDir(String destDirName) throws SimpleDocletException { + if (destDir != null) + throw new AssertionError("destDir already initialized: " + destDir); - destDir = fileManager.getLocationAsPaths(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next(); + if (!destDirName.isEmpty() + || !fileManager.hasLocation(DocumentationTool.Location.DOCUMENTATION_OUTPUT)) { + try { + String dirName = destDirName.isEmpty() ? "." : destDirName; + Path dir = Paths.get(dirName); + fileManager.setLocationFromPaths(DocumentationTool.Location.DOCUMENTATION_OUTPUT, Arrays.asList(dir)); + } catch (IOException e) { + // generic IOException from file manager, setting location, e.g. file not a directory + String message = configuration.getResources().getText("doclet.error.initializing.dest.dir", e); + throw new SimpleDocletException(message, e); + } } + + destDir = fileManager.getLocationAsPaths(DocumentationTool.Location.DOCUMENTATION_OUTPUT).iterator().next(); + } + + private Path getDestDir() { + Objects.requireNonNull(destDir, "destDir not initialized"); return destDir; } + @Override public DocFile createFileForDirectory(String file) { return new StandardDocFile(Paths.get(file)); } + @Override public DocFile createFileForInput(String file) { return new StandardDocFile(Paths.get(file)); } + @Override public DocFile createFileForOutput(DocPath path) { return new StandardDocFile(DocumentationTool.Location.DOCUMENTATION_OUTPUT, path); } @@ -125,38 +137,53 @@ class StandardDocFileFactory extends DocFileFactory { } class StandardDocFile extends DocFile { - private Path file; + private final Path file; /** Create a StandardDocFile for a given file. */ private StandardDocFile(Path file) { - super(configuration); this.file = file; } /** Create a StandardDocFile for a given location and relative path. */ private StandardDocFile(Location location, DocPath path) { - super(configuration, location, path); + super(location, path); Assert.check(location == DocumentationTool.Location.DOCUMENTATION_OUTPUT); this.file = newFile(getDestDir(), path.getPath()); } - /** Open an input stream for the file. */ - public InputStream openInputStream() throws IOException { - JavaFileObject fo = getJavaFileObjectForInput(file); - return new BufferedInputStream(fo.openInputStream()); + /** + * Open an input stream for the file. + * + * @throws DocFileIOException if there is a problem while opening stream + */ + @Override + public InputStream openInputStream() throws DocFileIOException { + try { + JavaFileObject fo = getJavaFileObjectForInput(file); + return new BufferedInputStream(fo.openInputStream()); + } catch (IOException e) { + throw new DocFileIOException(this, DocFileIOException.Mode.READ, e); + } } /** * Open an output stream for the file. * The file must have been created with a location of * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. + * + * @throws DocFileIOException if there is a problem while opening stream */ - public OutputStream openOutputStream() throws IOException, UnsupportedEncodingException { + @Override + public OutputStream openOutputStream() throws DocFileIOException { if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalStateException(); - OutputStream out = getFileObjectForOutput(path).openOutputStream(); - return new BufferedOutputStream(out); + try { + OutputStream out = getFileObjectForOutput(path).openOutputStream(); + return new BufferedOutputStream(out); + } catch (IOException e) { + throw new DocFileIOException(this, DocFileIOException.Mode.WRITE, e); + } } /** @@ -164,60 +191,77 @@ class StandardDocFileFactory extends DocFileFactory { * doclet configuration. * The file must have been created with a location of * {@link DocumentationTool.Location#DOCUMENTATION_OUTPUT} and a corresponding relative path. + * + * @throws DocFileIOException if there is a problem while opening stream + * @throws UnsupportedEncodingException if the configured encoding is not supported */ - public Writer openWriter() throws IOException, UnsupportedEncodingException { + @Override + public Writer openWriter() throws DocFileIOException, UnsupportedEncodingException { if (location != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalStateException(); - OutputStream out = getFileObjectForOutput(path).openOutputStream(); - if (configuration.docencoding == null) { - return new BufferedWriter(new OutputStreamWriter(out)); - } else { - return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding)); + try { + OutputStream out = getFileObjectForOutput(path).openOutputStream(); + if (configuration.docencoding == null) { + return new BufferedWriter(new OutputStreamWriter(out)); + } else { + return new BufferedWriter(new OutputStreamWriter(out, configuration.docencoding)); + } + } catch (IOException e) { + throw new DocFileIOException(this, DocFileIOException.Mode.WRITE, e); } } /** Return true if the file can be read. */ + @Override public boolean canRead() { return Files.isReadable(file); } /** Return true if the file can be written. */ + @Override public boolean canWrite() { return Files.isWritable(file); } /** Return true if the file exists. */ + @Override public boolean exists() { return Files.exists(file); } /** Return the base name (last component) of the file name. */ + @Override public String getName() { return file.getFileName().toString(); } /** Return the file system path for this file. */ + @Override public String getPath() { return file.toString(); } /** Return true is file has an absolute path name. */ + @Override public boolean isAbsolute() { return file.isAbsolute(); } /** Return true is file identifies a directory. */ + @Override public boolean isDirectory() { return Files.isDirectory(file); } /** Return true is file identifies a file. */ + @Override public boolean isFile() { return Files.isRegularFile(file); } /** Return true if this file is the same as another. */ + @Override public boolean isSameFile(DocFile other) { if (!(other instanceof StandardDocFile)) return false; @@ -230,17 +274,21 @@ class StandardDocFileFactory extends DocFileFactory { } /** If the file is a directory, list its contents. */ - public Iterable list() throws IOException { - List files = new ArrayList(); + @Override + public Iterable list() throws DocFileIOException { + List files = new ArrayList<>(); try (DirectoryStream ds = Files.newDirectoryStream(file)) { for (Path f: ds) { files.add(new StandardDocFile(f)); } + } catch (IOException e) { + throw new DocFileIOException(this, DocFileIOException.Mode.READ, e); } return files; } /** Create the file as a directory, including any parent directories. */ + @Override public boolean mkdirs() { try { Files.createDirectories(file); @@ -256,6 +304,7 @@ class StandardDocFileFactory extends DocFileFactory { * If this file has a path set, the new file will have a corresponding * new path. */ + @Override public DocFile resolve(DocPath p) { return resolve(p.getPath()); } @@ -266,6 +315,7 @@ class StandardDocFileFactory extends DocFileFactory { * If this file has a path set, the new file will have a corresponding * new path. */ + @Override public DocFile resolve(String p) { if (location == null && path == null) { return new StandardDocFile(file.resolve(p)); @@ -279,6 +329,7 @@ class StandardDocFileFactory extends DocFileFactory { * @param locn Currently, only * {@link DocumentationTool.Location.DOCUMENTATION_OUTPUT} is supported. */ + @Override public DocFile resolveAgainst(Location locn) { if (locn != DocumentationTool.Location.DOCUMENTATION_OUTPUT) throw new IllegalArgumentException(); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java index fbbe30259ac..8b093d64f4e 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java @@ -25,7 +25,6 @@ package jdk.javadoc.internal.doclets.toolkit.util; -import java.io.*; import java.lang.annotation.Documented; import java.lang.ref.SoftReference; import java.text.CollationKey; @@ -78,6 +77,7 @@ import com.sun.tools.javac.util.DefinedBy; import com.sun.tools.javac.util.DefinedBy.Api; import jdk.javadoc.internal.doclets.toolkit.CommentUtils.DocCommentDuo; import jdk.javadoc.internal.doclets.toolkit.Configuration; +import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.WorkArounds; import static javax.lang.model.element.ElementKind.*; @@ -85,9 +85,6 @@ import static javax.lang.model.element.Modifier.*; import static javax.lang.model.type.TypeKind.*; import static com.sun.source.doctree.DocTree.Kind.*; - -import jdk.javadoc.internal.doclets.toolkit.Messages; - import static jdk.javadoc.internal.doclets.toolkit.builders.ConstantsSummaryBuilder.MAX_CONSTANT_VALUE_INDEX_LENGTH; @@ -274,48 +271,52 @@ public class Utils { * {@link SourcePath} and if given directory is found in the source * directory structure, copy the entire directory, to the generated * documentation hierarchy. - * @param pe + * + * @param pe the package containing the doc files to be copied + * @throws DocFileIOException if there is a problem while copying the documentation files */ - public void copyDocFiles(PackageElement pe) { + public void copyDocFiles(PackageElement pe) throws DocFileIOException { copyDocFiles(DocPath.forPackage(pe).resolve(DocPaths.DOC_FILES)); } - public void copyDocFiles(DocPath dir) { - try { - boolean first = true; - for (DocFile f : DocFile.list(configuration, StandardLocation.SOURCE_PATH, dir)) { - if (!f.isDirectory()) { - continue; - } - DocFile srcdir = f; - DocFile destdir = DocFile.createFileForOutput(configuration, dir); - if (srcdir.isSameFile(destdir)) { - continue; - } + /** + * This method is obsolete, should not be used, and should be deleted. + * It does not take module locations into account! + * + * @throws DocFileIOException if there is a problem while copying the documentation files + */ + public void copyDocFiles(DocPath dir) throws DocFileIOException { + boolean first = true; + for (DocFile f : DocFile.list(configuration, StandardLocation.SOURCE_PATH, dir)) { + if (!f.isDirectory()) { + continue; + } + DocFile srcdir = f; + DocFile destdir = DocFile.createFileForOutput(configuration, dir); + if (srcdir.isSameFile(destdir)) { + continue; + } for (DocFile srcfile: srcdir.list()) { - DocFile destfile = destdir.resolve(srcfile.getName()); - if (srcfile.isFile()) { - if (destfile.exists() && !first) { - messages.warning("doclet.Copy_Overwrite_warning", - srcfile.getPath(), destdir.getPath()); - } else { - messages.notice("doclet.Copying_File_0_To_Dir_1", - srcfile.getPath(), destdir.getPath()); - destfile.copyFile(srcfile); - } - } else if (srcfile.isDirectory()) { - if (configuration.copydocfilesubdirs - && !configuration.shouldExcludeDocFileDir(srcfile.getName())) { - copyDocFiles(dir.resolve(srcfile.getName())); - } + DocFile destfile = destdir.resolve(srcfile.getName()); + if (srcfile.isFile()) { + if (destfile.exists() && !first) { + messages.warning("doclet.Copy_Overwrite_warning", + srcfile.getPath(), destdir.getPath()); + } else { + messages.notice("doclet.Copying_File_0_To_Dir_1", + srcfile.getPath(), destdir.getPath()); + destfile.copyFile(srcfile); + } + } else if (srcfile.isDirectory()) { + if (configuration.copydocfilesubdirs + && !configuration.shouldExcludeDocFileDir(srcfile.getName())) { + copyDocFiles(dir.resolve(srcfile.getName())); } } - - first = false; } - } catch (SecurityException | IOException exc) { - throw new DocletAbortException(exc); + + first = false; } } @@ -1567,42 +1568,45 @@ public class Utils { return secondaryCollator.compare(s1, s2); } - public void copyDocFiles(Configuration configuration, Location locn, DocPath dir) { - try { - boolean first = true; - for (DocFile f : DocFile.list(configuration, locn, dir)) { - if (!f.isDirectory()) { - continue; - } - DocFile srcdir = f; - DocFile destdir = DocFile.createFileForOutput(configuration, dir); - if (srcdir.isSameFile(destdir)) { - continue; - } + /** + * @param configuration the configuration for this doclet + * @param locn the location from which to read files + * @param dir the path for the files to be copied + * @throws DocFileIOException if there is a problem copying the files + */ + public void copyDocFiles(Configuration configuration, Location locn, DocPath dir) + throws DocFileIOException { + boolean first = true; + for (DocFile f : DocFile.list(configuration, locn, dir)) { + if (!f.isDirectory()) { + continue; + } + DocFile srcdir = f; + DocFile destdir = DocFile.createFileForOutput(configuration, dir); + if (srcdir.isSameFile(destdir)) { + continue; + } - for (DocFile srcfile: srcdir.list()) { - DocFile destfile = destdir.resolve(srcfile.getName()); - if (srcfile.isFile()) { - if (destfile.exists() && !first) { - messages.warning("doclet.Copy_Overwrite_warning", - srcfile.getPath(), destdir.getPath()); - } else { - messages.notice("doclet.Copying_File_0_To_Dir_1", - srcfile.getPath(), destdir.getPath()); - destfile.copyFile(srcfile); - } - } else if (srcfile.isDirectory()) { - if (configuration.copydocfilesubdirs - && !configuration.shouldExcludeDocFileDir(srcfile.getName())) { - copyDocFiles(configuration, locn, dir.resolve(srcfile.getName())); - } + for (DocFile srcfile: srcdir.list()) { + DocFile destfile = destdir.resolve(srcfile.getName()); + if (srcfile.isFile()) { + if (destfile.exists() && !first) { + messages.warning("doclet.Copy_Overwrite_warning", + srcfile.getPath(), destdir.getPath()); + } else { + messages.notice("doclet.Copying_File_0_To_Dir_1", + srcfile.getPath(), destdir.getPath()); + destfile.copyFile(srcfile); + } + } else if (srcfile.isDirectory()) { + if (configuration.copydocfilesubdirs + && !configuration.shouldExcludeDocFileDir(srcfile.getName())) { + copyDocFiles(configuration, locn, dir.resolve(srcfile.getName())); } } - - first = false; } - } catch (SecurityException | IOException exc) { - throw new DocletAbortException(exc); + + first = false; } } diff --git a/langtools/test/jdk/javadoc/doclet/testIOException/TestIOException.java b/langtools/test/jdk/javadoc/doclet/testIOException/TestIOException.java new file mode 100644 index 00000000000..792baa0627c --- /dev/null +++ b/langtools/test/jdk/javadoc/doclet/testIOException/TestIOException.java @@ -0,0 +1,179 @@ +/* + * 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 8164130 + * @summary test IOException handling + * @library ../lib + * @modules jdk.javadoc/jdk.javadoc.internal.tool + * @build JavadocTester + * @run main TestIOException + */ + +import java.io.File; +import java.io.FileWriter; + +public class TestIOException extends JavadocTester { + + public static void main(String... args) throws Exception { + TestIOException tester = new TestIOException(); + tester.runTests(); + } + + @Test + void testReadOnlyDirectory() { + File outDir = new File("out1"); + if (!outDir.mkdir()) { + throw new Error("Cannot create directory"); + } + if (!outDir.setReadOnly()) { + throw new Error("could not set directory read-only"); + } + if (outDir.canWrite()) { + throw new Error("directory is writable"); + } + + try { + javadoc("-d", outDir.toString(), + new File(testSrc, "TestIOException.java").getPath()); + checkExit(Exit.FAILED); + checkOutput(Output.OUT, true, + "Destination directory not writable: " + outDir); + } finally { + outDir.setWritable(true); + } + } + + @Test + void testReadOnlyFile() throws Exception { + File outDir = new File("out2"); + if (!outDir.mkdir()) { + throw new Error("Cannot create directory"); + } + File index = new File(outDir, "index.html"); + try (FileWriter fw = new FileWriter(index)) { } + if (!index.setReadOnly()) { + throw new Error("could not set index read-only"); + } + if (index.canWrite()) { + throw new Error("index is writable"); + } + + try { + setOutputDirectoryCheck(DirectoryCheck.NONE); + javadoc("-d", outDir.toString(), + new File(testSrc, "TestIOException.java").getPath()); + + checkExit(Exit.FAILED); + checkOutput(Output.OUT, true, + "Error writing file: " + index); + } finally { + setOutputDirectoryCheck(DirectoryCheck.EMPTY); + index.setWritable(true); + } + } + + @Test + void testReadOnlySubdirectory() throws Exception { + // init source file + File srcDir = new File("src4"); + File src_p = new File(srcDir, "p"); + src_p.mkdirs(); + File src_p_C = new File(src_p, "C.java"); + try (FileWriter fw = new FileWriter(src_p_C)) { + fw.write("package p; public class C { }"); + } + + // create an unwritable package output directory + File outDir = new File("out3"); + File pkgOutDir = new File(outDir, "p"); + if (!pkgOutDir.mkdirs()) { + throw new Error("Cannot create directory"); + } + if (!pkgOutDir.setReadOnly()) { + throw new Error("could not set directory read-only"); + } + if (pkgOutDir.canWrite()) { + throw new Error("directory is writable"); + } + + // run javadoc and check results + try { + setOutputDirectoryCheck(DirectoryCheck.NONE); + javadoc("-d", outDir.toString(), + src_p_C.getPath()); + checkExit(Exit.FAILED); + checkOutput(Output.OUT, true, + "Error writing file: " + new File(pkgOutDir, "C.html")); + } finally { + setOutputDirectoryCheck(DirectoryCheck.EMPTY); + pkgOutDir.setWritable(true); + } + } + + @Test + void testReadOnlyDocFilesDir() throws Exception { + // init source files + File srcDir = new File("src4"); + File src_p = new File(srcDir, "p"); + src_p.mkdirs(); + File src_p_C = new File(src_p, "C.java"); + try (FileWriter fw = new FileWriter(src_p_C)) { + fw.write("package p; public class C { }"); + } + File src_p_docfiles = new File(src_p, "doc-files"); + src_p_docfiles.mkdir(); + try (FileWriter fw = new FileWriter(new File(src_p_docfiles, "info.txt"))) { + fw.write("info"); + } + + // create an unwritable doc-files output directory + File outDir = new File("out4"); + File pkgOutDir = new File(outDir, "p"); + File docFilesOutDir = new File(pkgOutDir, "doc-files"); + if (!docFilesOutDir.mkdirs()) { + throw new Error("Cannot create directory"); + } + if (!docFilesOutDir.setReadOnly()) { + throw new Error("could not set directory read-only"); + } + if (docFilesOutDir.canWrite()) { + throw new Error("directory is writable"); + } + + try { + setOutputDirectoryCheck(DirectoryCheck.NONE); + javadoc("-d", outDir.toString(), + "-sourcepath", srcDir.getPath(), + "p"); + checkExit(Exit.FAILED); + checkOutput(Output.OUT, true, + "Error writing file: " + new File(docFilesOutDir, "info.txt")); + } finally { + setOutputDirectoryCheck(DirectoryCheck.EMPTY); + docFilesOutDir.setWritable(true); + } + } +} + From f39e9128570bb8c9f9ed6e9f8835d48e0e5a50c8 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Mon, 22 Aug 2016 19:31:37 -0700 Subject: [PATCH 29/87] 8160089: jshell tool: use new double-dash long-form command-line options Reviewed-by: jlahoda --- .../jdk/internal/jshell/tool/JShellTool.java | 161 ++++++++++-------- .../jshell/tool/resources/l10n.properties | 40 ++--- .../jdk.jshell/share/classes/module-info.java | 1 + .../jdk/jshell/CommandCompletionTest.java | 6 +- langtools/test/jdk/jshell/EditorTestBase.java | 4 +- .../test/jdk/jshell/ExternalEditorTest.java | 2 +- .../test/jdk/jshell/StartOptionTest.java | 59 ++++--- langtools/test/jdk/jshell/ToolBasicTest.java | 26 ++- .../jdk/jshell/ToolCommandOptionTest.java | 2 +- .../jdk/jshell/ToolLocaleMessageTest.java | 2 +- langtools/test/jdk/jshell/ToolReloadTest.java | 12 +- langtools/test/jdk/jshell/ToolSimpleTest.java | 42 +++-- 12 files changed, 201 insertions(+), 156 deletions(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index 0d65fef1455..f2d0b13feae 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -94,12 +94,16 @@ import java.util.ResourceBundle; import java.util.Spliterators; import java.util.function.Function; import java.util.function.Supplier; +import jdk.internal.joptsimple.*; import jdk.internal.jshell.tool.Feedback.FormatAction; import jdk.internal.jshell.tool.Feedback.FormatCase; import jdk.internal.jshell.tool.Feedback.FormatErrors; import jdk.internal.jshell.tool.Feedback.FormatResolve; import jdk.internal.jshell.tool.Feedback.FormatUnresolved; import jdk.internal.jshell.tool.Feedback.FormatWhen; +import static java.util.Arrays.asList; +import static java.util.Arrays.stream; +import static java.util.stream.Collectors.joining; import static java.util.stream.Collectors.toList; import static jdk.jshell.Snippet.SubKind.VAR_VALUE_SUBKIND; import static java.util.stream.Collectors.toMap; @@ -515,82 +519,91 @@ public class JShellTool implements MessageHandler { * @return the list of files to be loaded */ private List processCommandArgs(String[] args) { - List loadList = new ArrayList<>(); - Iterator ai = Arrays.asList(args).iterator(); - while (ai.hasNext()) { - String arg = ai.next(); - if (arg.startsWith("-")) { - switch (arg) { - case "-classpath": - case "-cp": - if (cmdlineClasspath != null) { - startmsg("jshell.err.opt.classpath.conflict"); - return null; - } - if (ai.hasNext()) { - cmdlineClasspath = ai.next(); - } else { - startmsg("jshell.err.opt.classpath.arg"); - return null; - } - break; - case "-help": - printUsage(); - return null; - case "-version": - cmdout.printf("jshell %s\n", version()); - return null; - case "-fullversion": - cmdout.printf("jshell %s\n", fullVersion()); - return null; - case "-feedback": - if (ai.hasNext()) { - commandLineFeedbackMode = ai.next(); - } else { - startmsg("jshell.err.opt.feedback.arg"); - return null; - } - break; - case "-q": - commandLineFeedbackMode = "concise"; - break; - case "-qq": - commandLineFeedbackMode = "silent"; - break; - case "-v": - commandLineFeedbackMode = "verbose"; - break; - case "-startup": - if (startup != null) { - startmsg("jshell.err.opt.startup.one"); - return null; - } - startup = readFile(ai.hasNext()? ai.next() : null, "-startup"); - if (startup == null) { - return null; - } - break; - case "-nostartup": - if (startup != null) { - startmsg("jshell.err.opt.startup.one"); - return null; - } - startup = ""; - break; - default: - if (arg.startsWith("-R")) { - remoteVMOptions.add(arg.substring(2)); - break; - } - startmsg("jshell.err.opt.unknown", arg); - printUsage(); - return null; - } + OptionParser parser = new OptionParser(); + OptionSpec cp = parser.accepts("class-path").withRequiredArg(); + OptionSpec st = parser.accepts("startup").withRequiredArg(); + parser.acceptsAll(asList("n", "no-startup")); + OptionSpec fb = parser.accepts("feedback").withRequiredArg(); + parser.accepts("q"); + parser.accepts("s"); + parser.accepts("v"); + OptionSpec r = parser.accepts("R").withRequiredArg(); + parser.acceptsAll(asList("h", "help")); + parser.accepts("version"); + parser.accepts("full-version"); + NonOptionArgumentSpec loadFileSpec = parser.nonOptions(); + + OptionSet options; + try { + options = parser.parse(args); + } catch (OptionException ex) { + if (ex.options().isEmpty()) { + startmsg("jshell.err.opt.invalid", stream(args).collect(joining(", "))); } else { - loadList.add(arg); + boolean isKnown = parser.recognizedOptions().containsKey(ex.options().iterator().next()); + startmsg(isKnown + ? "jshell.err.opt.arg" + : "jshell.err.opt.unknown", + ex.options() + .stream() + .collect(joining(", "))); } + return null; } - return loadList; + + if (options.has("help")) { + printUsage(); + return null; + } + if (options.has("version")) { + cmdout.printf("jshell %s\n", version()); + return null; + } + if (options.has("full-version")) { + cmdout.printf("jshell %s\n", fullVersion()); + return null; + } + if (options.has(cp)) { + List cps = options.valuesOf(cp); + if (cps.size() > 1) { + startmsg("jshell.err.opt.one", "--class-path"); + return null; + } + cmdlineClasspath = cps.get(0); + } + if (options.has(st)) { + List sts = options.valuesOf(st); + if (sts.size() != 1 || options.has("no-startup")) { + startmsg("jshell.err.opt.startup.one"); + return null; + } + startup = readFile(sts.get(0), "--startup"); + if (startup == null) { + return null; + } + } else if (options.has("no-startup")) { + startup = ""; + } + if ((options.valuesOf(fb).size() + + (options.has("q") ? 1 : 0) + + (options.has("s") ? 1 : 0) + + (options.has("v") ? 1 : 0)) > 1) { + startmsg("jshell.err.opt.feedback.one"); + return null; + } else if (options.has(fb)) { + commandLineFeedbackMode = options.valueOf(fb); + } else if (options.has("q")) { + commandLineFeedbackMode = "concise"; + } else if (options.has("s")) { + commandLineFeedbackMode = "silent"; + } else if (options.has("v")) { + commandLineFeedbackMode = "verbose"; + } + if (options.has(r)) { + remoteVMOptions = options.valuesOf(r); + } + + return options.valuesOf(loadFileSpec); } private void printUsage() { @@ -686,7 +699,7 @@ public class JShellTool implements MessageHandler { } if (commandLineFeedbackMode != null) { // The feedback mode to use was specified on the command line, use it - if (!feedback.setFeedback(initmh, new ArgTokenizer("-feedback", commandLineFeedbackMode))) { + if (!feedback.setFeedback(initmh, new ArgTokenizer("--feedback", commandLineFeedbackMode))) { regenerateOnDeath = false; } commandLineFeedbackMode = null; diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties index da44d078219..5d7a1a111ea 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties @@ -26,10 +26,11 @@ jshell.msg.welcome =\ Welcome to JShell -- Version {0}\n\ For an introduction type: /help intro\n -jshell.err.opt.classpath.conflict = Conflicting -classpath option. -jshell.err.opt.classpath.arg = Argument to -classpath missing. -jshell.err.opt.feedback.arg = Argument to -feedback missing. Mode required. -jshell.err.opt.startup.one = Only one -startup or -nostartup option may be used. +jshell.err.opt.arg = Argument to {0} missing. +jshell.err.opt.invalid = Invalid options: {0}. +jshell.err.opt.one = Only one {0} option may be used. +jshell.err.opt.startup.one = Only one --startup or --no-startup option may be used. +jshell.err.opt.feedback.one = Only one feedback option (--feedback, -q, -s, or -v) may be used. jshell.err.opt.unknown = Unknown option: {0} jshell.msg.terminated =\ @@ -148,22 +149,21 @@ jshell.console.incomplete = \nResults may be incomplete; try again later for com help.usage = \ Usage: jshell \n\ where possible options include:\n\ -\ -classpath Specify where to find user class files\n\ -\ -cp Specify where to find user class files\n\ -\ -startup One run replacement for the start-up definitions\n\ -\ -nostartup Do not run the start-up definitions\n\ -\ -feedback Specify the initial feedback mode. The mode may be\n\ -\ predefined (silent, concise, normal, or verbose) or\n\ -\ previously user-defined\n\ -\ -q Quiet feedback. Same as: -feedback concise\n\ -\ -qq Really quiet feedback. Same as: -feedback silent\n\ -\ -v Verbose feedback. Same as: -feedback verbose\n\ -\ -J Pass directly to the runtime system.\n\ -\ Use one -J for each runtime flag or flag argument\n\ -\ -R Pass to the remote runtime system.\n\ -\ Use one -R for each remote flag or flag argument\n\ -\ -help Print this synopsis of standard options\n\ -\ -version Version information\n +\ --class-path Specify where to find user class files\n\ +\ --startup One run replacement for the start-up definitions\n\ +\ --no-startup Do not run the start-up definitions\n\ +\ --feedback Specify the initial feedback mode. The mode may be\n\ +\ predefined (silent, concise, normal, or verbose) or\n\ +\ previously user-defined\n\ +\ -q Quiet feedback. Same as: --feedback concise\n\ +\ -s Really quiet feedback. Same as: --feedback silent\n\ +\ -v Verbose feedback. Same as: --feedback verbose\n\ +\ -J Pass directly to the runtime system.\n\ +\ Use one -J for each runtime flag or flag argument\n\ +\ -R Pass to the remote runtime system.\n\ +\ Use one -R for each remote flag or flag argument\n\ +\ --help Print this synopsis of standard options\n\ +\ --version Version information\n help.list.summary = list the source you have typed help.list.args = [|-all|-start] diff --git a/langtools/src/jdk.jshell/share/classes/module-info.java b/langtools/src/jdk.jshell/share/classes/module-info.java index b6c1b522bbc..b9c6e5e2b26 100644 --- a/langtools/src/jdk.jshell/share/classes/module-info.java +++ b/langtools/src/jdk.jshell/share/classes/module-info.java @@ -34,6 +34,7 @@ module jdk.jshell { requires java.prefs; requires jdk.compiler; requires jdk.internal.le; + requires jdk.internal.opt; requires jdk.jdi; exports jdk.jshell; diff --git a/langtools/test/jdk/jshell/CommandCompletionTest.java b/langtools/test/jdk/jshell/CommandCompletionTest.java index 0a986a621c1..6544084a133 100644 --- a/langtools/test/jdk/jshell/CommandCompletionTest.java +++ b/langtools/test/jdk/jshell/CommandCompletionTest.java @@ -58,7 +58,7 @@ public class CommandCompletionTest extends ReplToolTesting { } public void testList() { - test(false, new String[] {"-nostartup"}, + test(false, new String[] {"--no-startup"}, a -> assertCompletion(a, "/l|", false, "/list "), a -> assertCompletion(a, "/list |", false, "-all ", "-history ", "-start "), a -> assertCompletion(a, "/list -h|", false, "-history "), @@ -70,7 +70,7 @@ public class CommandCompletionTest extends ReplToolTesting { } public void testDrop() { - test(false, new String[] {"-nostartup"}, + test(false, new String[] {"--no-startup"}, a -> assertCompletion(a, "/d|", false, "/drop "), a -> assertClass(a, "class cTest {}", "class", "cTest"), a -> assertMethod(a, "int mTest() { return 0; }", "()I", "mTest"), @@ -81,7 +81,7 @@ public class CommandCompletionTest extends ReplToolTesting { } public void testEdit() { - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, a -> assertCompletion(a, "/e|", false, "/edit ", "/exit "), a -> assertCompletion(a, "/ed|", false, "/edit "), a -> assertClass(a, "class cTest {}", "class", "cTest"), diff --git a/langtools/test/jdk/jshell/EditorTestBase.java b/langtools/test/jdk/jshell/EditorTestBase.java index 067bbb9da99..18b6dae4557 100644 --- a/langtools/test/jdk/jshell/EditorTestBase.java +++ b/langtools/test/jdk/jshell/EditorTestBase.java @@ -42,7 +42,7 @@ public abstract class EditorTestBase extends ReplToolTesting { public abstract void shutdownEditor(); public void testEditor(ReplTest... tests) { - testEditor(false, new String[]{"-nostartup"}, tests); + testEditor(false, new String[]{"--no-startup"}, tests); } public void testEditor(boolean defaultStartup, String[] args, ReplTest... tests) { @@ -71,7 +71,7 @@ public abstract class EditorTestBase extends ReplToolTesting { @Test public void testEditNegative() { for (String edit : new String[] {"/ed", "/edit"}) { - test(new String[]{"-nostartup"}, + test(new String[]{"--no-startup"}, a -> assertCommandOutputStartsWith(a, edit + " 1", "| No such snippet: 1"), a -> assertCommandOutputStartsWith(a, edit + " unknown", diff --git a/langtools/test/jdk/jshell/ExternalEditorTest.java b/langtools/test/jdk/jshell/ExternalEditorTest.java index cd3d70f442b..21c731866e5 100644 --- a/langtools/test/jdk/jshell/ExternalEditorTest.java +++ b/langtools/test/jdk/jshell/ExternalEditorTest.java @@ -203,7 +203,7 @@ public class ExternalEditorTest extends EditorTestBase { @Test(enabled = false) // TODO 8159229 public void testRemoveTempFile() { - test(new String[]{"-nostartup"}, + test(new String[]{"--no-startup"}, a -> assertCommandCheckOutput(a, "/set editor " + executionScript, assertStartsWith("| Editor set to: " + executionScript)), a -> assertVariable(a, "int", "a", "0", "0"), diff --git a/langtools/test/jdk/jshell/StartOptionTest.java b/langtools/test/jdk/jshell/StartOptionTest.java index e3326597934..5ca48854341 100644 --- a/langtools/test/jdk/jshell/StartOptionTest.java +++ b/langtools/test/jdk/jshell/StartOptionTest.java @@ -22,7 +22,7 @@ */ /* - * @test 8151754 8080883 + * @test 8151754 8080883 8160089 * @summary Testing start-up options. * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -106,53 +106,68 @@ public class StartOptionTest { @Test public void testUsage() throws Exception { - start(s -> { - assertTrue(s.split("\n").length >= 7, "Not enough usage lines: " + s); - assertTrue(s.startsWith("Usage: jshell "), "Unexpect usage start: " + s); - }, null, "-help"); + for (String opt : new String[]{"-h", "--help"}) { + start(s -> { + assertTrue(s.split("\n").length >= 7, "Not enough usage lines: " + s); + assertTrue(s.startsWith("Usage: jshell "), "Unexpect usage start: " + s); + }, null, opt); + } } @Test public void testUnknown() throws Exception { - start(s -> { - assertTrue(s.split("\n").length >= 7, "Not enough usage lines (unknown): " + s); - assertTrue(s.startsWith("Usage: jshell "), "Unexpect usage start (unknown): " + s); - }, s -> assertEquals(s.trim(), "Unknown option: -unknown"), "-unknown"); + start(s -> { }, + s -> assertEquals(s.trim(), "Unknown option: u"), "-unknown"); + start(s -> { }, + s -> assertEquals(s.trim(), "Unknown option: unknown"), "--unknown"); } public void testStartup() throws Exception { Compiler compiler = new Compiler(); Path p = compiler.getPath("file.txt"); compiler.writeToFile(p); - start("", "'-startup' requires a filename argument.", "-startup"); - start("", "Only one -startup or -nostartup option may be used.", "-startup", p.toString(), "-startup", p.toString()); - start("", "Only one -startup or -nostartup option may be used.", "-nostartup", "-startup", p.toString()); - start("", "Only one -startup or -nostartup option may be used.", "-startup", p.toString(), "-nostartup"); - start("", "Only one -startup or -nostartup option may be used.", "-nostartup", "-nostartup"); - start("", "Only one -startup or -nostartup option may be used.", "-nostartup", "-startup"); + start("", "Argument to startup missing.", "--startup"); + start("", "Only one --startup or --no-startup option may be used.", "--startup", p.toString(), "--startup", p.toString()); + start("", "Only one --startup or --no-startup option may be used.", "--no-startup", "--startup", p.toString()); + start("", "Only one --startup or --no-startup option may be used.", "--startup", p.toString(), "--no-startup"); + start("", "Argument to startup missing.", "--no-startup", "--startup"); } public void testStartupUnknown() throws Exception { - start("", "File 'UNKNOWN' for '-startup' is not found.", "-startup", "UNKNOWN"); + start("", "File 'UNKNOWN' for '--startup' is not found.", "--startup", "UNKNOWN"); } @Test public void testClasspath() throws Exception { - for (String cp : new String[] {"-cp", "-classpath"}) { - start("", "Conflicting -classpath option.", cp, ".", "-classpath", "."); - start("", "Argument to -classpath missing.", cp); + for (String cp : new String[] {"--class-path"}) { + start("", "Only one --class-path option may be used.", cp, ".", "--class-path", "."); + start("", "Argument to class-path missing.", cp); } } + @Test + public void testFeedbackOptionConflict() throws Exception { + start("", "Only one feedback option (--feedback, -q, -s, or -v) may be used.", + "--feedback", "concise", "--feedback", "verbose"); + start("", "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "--feedback", "concise", "-s"); + start("", "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "--feedback", "verbose", "-q"); + start("", "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "--feedback", "concise", "-v"); + start("", "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "-v", "--feedback", "concise"); + start("", "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "-q", "-v"); + start("", "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "-s", "-v"); + start("", "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "-v", "-q"); + start("", "Only one feedback option (--feedback, -q, -s, or -v) may be used.", "-q", "-s"); + } + @Test public void testNegFeedbackOption() throws Exception { - start("", "Argument to -feedback missing. Mode required.", "-feedback"); - start("", "Does not match any current feedback mode: blorp -- -feedback blorp", "-feedback", "blorp"); + start("", "Argument to feedback missing.", "--feedback"); + start("", "Does not match any current feedback mode: blorp -- --feedback blorp", "--feedback", "blorp"); } @Test public void testVersion() throws Exception { - start(s -> assertTrue(s.startsWith("jshell"), "unexpected version: " + s), null, "-version"); + start(s -> assertTrue(s.startsWith("jshell"), "unexpected version: " + s), null, "--version"); } @AfterMethod diff --git a/langtools/test/jdk/jshell/ToolBasicTest.java b/langtools/test/jdk/jshell/ToolBasicTest.java index 0c5bf1dfab9..7ccf529fb2d 100644 --- a/langtools/test/jdk/jshell/ToolBasicTest.java +++ b/langtools/test/jdk/jshell/ToolBasicTest.java @@ -97,7 +97,7 @@ public class ToolBasicTest extends ReplToolTesting { public void testInterrupt() { ReplTest interrupt = (a) -> assertCommand(a, "\u0003", ""); for (String s : new String[] { "", "\u0003" }) { - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, (a) -> assertCommand(a, "int a = 2 +" + s, ""), interrupt, (a) -> assertCommand(a, "int a\u0003", ""), @@ -190,7 +190,7 @@ public class ToolBasicTest extends ReplToolTesting { } public void testRerun() { - test(false, new String[] {"-nostartup"}, + test(false, new String[] {"--no-startup"}, (a) -> assertCommand(a, "/0", "| No such command or snippet id: /0\n| Type /help for help."), (a) -> assertCommand(a, "/5", "| No such command or snippet id: /5\n| Type /help for help.") ); @@ -226,7 +226,7 @@ public class ToolBasicTest extends ReplToolTesting { tests.add((a) -> assertCommandCheckOutput(a, "/-" + (2 * finalI + 1), check)); } tests.add((a) -> assertCommandCheckOutput(a, "/!", assertStartsWith("int a = 0;"))); - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, tests.toArray(new ReplTest[tests.size()])); } @@ -243,7 +243,7 @@ public class ToolBasicTest extends ReplToolTesting { Path startup = compiler.getPath("StartupFileOption/startup.txt"); compiler.writeToFile(startup, "int assertionCount = 0;\n" + // id: s1 "void add(int n) { assertionCount += n; }"); - test(new String[]{"-startup", startup.toString()}, + test(new String[]{"--startup", startup.toString()}, (a) -> assertCommand(a, "add(1)", ""), // id: 1 (a) -> assertCommandCheckOutput(a, "add(ONE)", s -> assertEquals(s.split("\n")[0], "| Error:")), // id: e1 (a) -> assertVariable(a, "int", "ONE", "1", "1"), @@ -252,7 +252,7 @@ public class ToolBasicTest extends ReplToolTesting { assertRerun.apply("/s1").apply("int assertionCount = 0;", 0), assertVariables ); - test(false, new String[] {"-nostartup"}, + test(false, new String[] {"--no-startup"}, (a) -> assertCommand(a, "/s1", "| No such command or snippet id: /s1\n| Type /help for help."), (a) -> assertCommand(a, "/1", "| No such command or snippet id: /1\n| Type /help for help."), (a) -> assertCommand(a, "/e1", "| No such command or snippet id: /e1\n| Type /help for help.") @@ -268,10 +268,7 @@ public class ToolBasicTest extends ReplToolTesting { (a) -> assertCommand(a, "/classpath " + classpath, String.format("| Path '%s' added to classpath", classpath)), (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A") ); - test(new String[] { "-cp", classpath.toString() }, - (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A") - ); - test(new String[] { "-classpath", classpath.toString() }, + test(new String[] { "--class-path", classpath.toString() }, (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A") ); } @@ -287,10 +284,7 @@ public class ToolBasicTest extends ReplToolTesting { (a) -> assertCommand(a, "/classpath " + jarPath, String.format("| Path '%s' added to classpath", jarPath)), (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A") ); - test(new String[] { "-cp", jarPath.toString() }, - (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A") - ); - test(new String[] { "-classpath", jarPath.toString() }, + test(new String[] { "--class-path", jarPath.toString() }, (a) -> evaluateExpression(a, "pkg.A", "new pkg.A();", "A") ); } @@ -300,10 +294,10 @@ public class ToolBasicTest extends ReplToolTesting { Compiler compiler = new Compiler(); Path startup = compiler.getPath("StartupFileOption/startup.txt"); compiler.writeToFile(startup, "class A { public String toString() { return \"A\"; } }"); - test(new String[]{"-startup", startup.toString()}, + test(new String[]{"--startup", startup.toString()}, (a) -> evaluateExpression(a, "A", "new A()", "A") ); - test(new String[]{"-nostartup"}, + test(new String[]{"--no-startup"}, (a) -> assertCommandCheckOutput(a, "printf(\"\")", assertStartsWith("| Error:\n| cannot find symbol")) ); test( @@ -550,7 +544,7 @@ public class ToolBasicTest extends ReplToolTesting { } public void testHistoryReference() { - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, a -> assertCommand(a, "System.err.println(1)", "", "", null, "", "1\n"), a -> assertCommand(a, "System.err.println(2)", "", "", null, "", "2\n"), a -> assertCommand(a, "/-2", "System.err.println(1)", "", null, "", "1\n"), diff --git a/langtools/test/jdk/jshell/ToolCommandOptionTest.java b/langtools/test/jdk/jshell/ToolCommandOptionTest.java index 030d016a89e..940bd350096 100644 --- a/langtools/test/jdk/jshell/ToolCommandOptionTest.java +++ b/langtools/test/jdk/jshell/ToolCommandOptionTest.java @@ -88,7 +88,7 @@ public class ToolCommandOptionTest extends ReplToolTesting { } public void dropTest() { - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, (a) -> assertCommand(a, "int x = 5;", "x ==> 5"), (a) -> assertCommand(a, "x", diff --git a/langtools/test/jdk/jshell/ToolLocaleMessageTest.java b/langtools/test/jdk/jshell/ToolLocaleMessageTest.java index b2125d7c3dc..d52c4ed9633 100644 --- a/langtools/test/jdk/jshell/ToolLocaleMessageTest.java +++ b/langtools/test/jdk/jshell/ToolLocaleMessageTest.java @@ -44,7 +44,7 @@ import static org.testng.Assert.assertTrue; public class ToolLocaleMessageTest extends ReplToolTesting { void testLocale(ReplTest... tests) { - test(Locale.getDefault(), false, new String[]{"-nostartup"}, "", tests); + test(Locale.getDefault(), false, new String[]{"--no-startup"}, "", tests); } void assertCommandOK(boolean after, String cmd, String... contains) { diff --git a/langtools/test/jdk/jshell/ToolReloadTest.java b/langtools/test/jdk/jshell/ToolReloadTest.java index 0faf3e668dc..ed4c15b013b 100644 --- a/langtools/test/jdk/jshell/ToolReloadTest.java +++ b/langtools/test/jdk/jshell/ToolReloadTest.java @@ -90,7 +90,7 @@ public class ToolReloadTest extends ReplToolTesting { } public void testReloadDrop() { - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, a -> assertVariable(a, "int", "a"), a -> dropVariable(a, "/dr 1", "int a = 0", "| dropped variable a"), a -> assertMethod(a, "int b() { return 0; }", "()I", "b"), @@ -113,7 +113,7 @@ public class ToolReloadTest extends ReplToolTesting { } public void testReloadQuiet() { - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, a -> assertVariable(a, "int", "a"), a -> dropVariable(a, "/dr 1", "int a = 0", "| dropped variable a"), a -> assertMethod(a, "int b() { return 0; }", "()I", "b"), @@ -130,7 +130,7 @@ public class ToolReloadTest extends ReplToolTesting { } public void testReloadRepeat() { - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, (a) -> assertVariable(a, "int", "c", "7", "7"), (a) -> assertCommand(a, "++c", null), (a) -> assertCommand(a, "/!", null), @@ -150,7 +150,7 @@ public class ToolReloadTest extends ReplToolTesting { } public void testReloadIgnore() { - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, (a) -> assertCommand(a, "(-)", null), (a) -> assertCommand(a, "/list", null), (a) -> assertCommand(a, "/history", null), @@ -201,13 +201,13 @@ public class ToolReloadTest extends ReplToolTesting { } public void testReloadExitRestore() { - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, (a) -> assertVariable(a, "int", "x", "5", "5"), (a) -> assertMethod(a, "int m(int z) { return z * z; }", "(int)int", "m"), (a) -> evaluateExpression(a, "int", "m(x)", "25") ); - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, (a) -> assertCommand(a, "/reload -restore", "| Restarting and restoring from previous state.\n" + "-: int x = 5;\n" + diff --git a/langtools/test/jdk/jshell/ToolSimpleTest.java b/langtools/test/jdk/jshell/ToolSimpleTest.java index 96f9e69eef8..9e82c24273b 100644 --- a/langtools/test/jdk/jshell/ToolSimpleTest.java +++ b/langtools/test/jdk/jshell/ToolSimpleTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 + * @bug 8153716 8143955 8151754 8150382 8153920 8156910 8131024 8160089 * @summary Simple jshell tool tests * @modules jdk.compiler/com.sun.tools.javac.api * jdk.compiler/com.sun.tools.javac.main @@ -209,7 +209,7 @@ public class ToolSimpleTest extends ReplToolTesting { } public void testDrop() { - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, a -> assertVariable(a, "int", "a"), a -> dropVariable(a, "/drop 1", "int a = 0", "| dropped variable a"), a -> assertMethod(a, "int b() { return 0; }", "()I", "b"), @@ -223,7 +223,7 @@ public class ToolSimpleTest extends ReplToolTesting { a -> assertCommandCheckOutput(a, "/types", assertClasses()), a -> assertCommandCheckOutput(a, "/imports", assertImports()) ); - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, a -> assertVariable(a, "int", "a"), a -> dropVariable(a, "/drop a", "int a = 0", "| dropped variable a"), a -> assertMethod(a, "int b() { return 0; }", "()I", "b"), @@ -238,7 +238,7 @@ public class ToolSimpleTest extends ReplToolTesting { } public void testDropNegative() { - test(false, new String[]{"-nostartup"}, + test(false, new String[]{"--no-startup"}, a -> assertCommandOutputStartsWith(a, "/drop 0", "| No such snippet: 0"), a -> assertCommandOutputStartsWith(a, "/drop a", "| No such snippet: a"), a -> assertCommandCheckOutput(a, "/drop", @@ -462,20 +462,20 @@ public class ToolSimpleTest extends ReplToolTesting { } public void testOptionQ() { - test(new String[]{"-q", "-nostartup"}, + test(new String[]{"-q", "--no-startup"}, (a) -> assertCommand(a, "1+1", "$1 ==> 2"), (a) -> assertCommand(a, "int x = 5", "") ); } - public void testOptionQq() { - test(new String[]{"-qq", "-nostartup"}, + public void testOptionS() { + test(new String[]{"-s", "--no-startup"}, (a) -> assertCommand(a, "1+1", "") ); } public void testOptionV() { - test(new String[]{"-v", "-nostartup"}, + test(new String[]{"-v", "--no-startup"}, (a) -> assertCommand(a, "1+1", "$1 ==> 2\n" + "| created scratch variable $1 : int") @@ -483,14 +483,36 @@ public class ToolSimpleTest extends ReplToolTesting { } public void testOptionFeedback() { - test(new String[]{"-feedback", "concise", "-nostartup"}, + test(new String[]{"--feedback", "concise", "--no-startup"}, (a) -> assertCommand(a, "1+1", "$1 ==> 2"), (a) -> assertCommand(a, "int x = 5", "") ); } + public void testCompoundOptions() { + Consumer confirmNoStartup = s -> { + assertEquals(0, Stream.of(s.split("\n")) + .filter(l -> !l.isEmpty()) + .count(), "Expected no lines: " + s); + }; + test(new String[]{"-nq"}, + (a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup), + (a) -> assertCommand(a, "1+1", "$1 ==> 2"), + (a) -> assertCommand(a, "int x = 5", "") + ); + test(new String[]{"-qn"}, + (a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup), + (a) -> assertCommand(a, "1+1", "$1 ==> 2"), + (a) -> assertCommand(a, "int x = 5", "") + ); + test(new String[]{"-ns"}, + (a) -> assertCommandCheckOutput(a, "/list -all", confirmNoStartup), + (a) -> assertCommand(a, "1+1", "") + ); + } + public void testOptionR() { - test(new String[]{"-R-Dthe.sound=blorp", "-nostartup"}, + test(new String[]{"-R-Dthe.sound=blorp", "--no-startup"}, (a) -> assertCommand(a, "System.getProperty(\"the.sound\")", "$1 ==> \"blorp\"") ); From 4f7021e5a3b8f75004f6bd1432388623935860ef Mon Sep 17 00:00:00 2001 From: Joe Darcy Date: Mon, 22 Aug 2016 19:33:00 -0700 Subject: [PATCH 30/87] 8164598: Problem list TestIOException.java Reviewed-by: jjg --- langtools/test/ProblemList.txt | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/test/ProblemList.txt b/langtools/test/ProblemList.txt index 9a85f8b3d9e..6d80c431a08 100644 --- a/langtools/test/ProblemList.txt +++ b/langtools/test/ProblemList.txt @@ -30,6 +30,7 @@ jdk/javadoc/tool/VerifyLocale.java jdk/javadoc/tool/enum/docComments/Main.java 8152313 generic-all convert to doclet test framework jdk/javadoc/tool/enum/enumType/Main.java 8152313 generic-all convert to doclet test framework jdk/javadoc/tool/varArgs/Main.java 8152313 generic-all convert to doclet test framework +jdk/javadoc/doclet/testIOException/TestIOException.java 8164597 windows-all ########################################################################### # From 865b439a6952994a90dee57f2b1fcb9dc55f0581 Mon Sep 17 00:00:00 2001 From: Sandeep Konchady Date: Tue, 23 Aug 2016 10:19:49 +0100 Subject: [PATCH 31/87] 8163991: Fix license and copyright headers under test/jdk/javadoc/ and test/tools/javac/ Reviewed-by: anazarov, iris, jjg, shurailine --- .../testTypeAnnotations/typeannos/RepeatedAnnotations.java | 2 +- langtools/test/tools/javac/InnerClassesAttribute/Test.java | 2 +- langtools/test/tools/javac/modules/SingleModuleModeTest.java | 2 +- langtools/test/tools/javac/redefineObject/Object1-test.java | 2 +- langtools/test/tools/javac/redefineObject/Object2-test.java | 2 +- 5 files changed, 5 insertions(+), 5 deletions(-) diff --git a/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/RepeatedAnnotations.java b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/RepeatedAnnotations.java index 75bedba621e..b7c432ee3ac 100644 --- a/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/RepeatedAnnotations.java +++ b/langtools/test/jdk/javadoc/doclet/testTypeAnnotations/typeannos/RepeatedAnnotations.java @@ -8,7 +8,7 @@ * * 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 RepeatingA PARTICULAR PURPOSE. See the GNU General Public License + * 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). * diff --git a/langtools/test/tools/javac/InnerClassesAttribute/Test.java b/langtools/test/tools/javac/InnerClassesAttribute/Test.java index f2357ada27c..69bbaa35d50 100644 --- a/langtools/test/tools/javac/InnerClassesAttribute/Test.java +++ b/langtools/test/tools/javac/InnerClassesAttribute/Test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997, 2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/langtools/test/tools/javac/modules/SingleModuleModeTest.java b/langtools/test/tools/javac/modules/SingleModuleModeTest.java index e453d3bf8e4..17aa42c93f1 100644 --- a/langtools/test/tools/javac/modules/SingleModuleModeTest.java +++ b/langtools/test/tools/javac/modules/SingleModuleModeTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015-2016, 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 diff --git a/langtools/test/tools/javac/redefineObject/Object1-test.java b/langtools/test/tools/javac/redefineObject/Object1-test.java index 86827f5ddae..a654ecee5d5 100644 --- a/langtools/test/tools/javac/redefineObject/Object1-test.java +++ b/langtools/test/tools/javac/redefineObject/Object1-test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997,2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 diff --git a/langtools/test/tools/javac/redefineObject/Object2-test.java b/langtools/test/tools/javac/redefineObject/Object2-test.java index 34a40554c35..59eb4b670df 100644 --- a/langtools/test/tools/javac/redefineObject/Object2-test.java +++ b/langtools/test/tools/javac/redefineObject/Object2-test.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 1997,2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 1997, 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 From 5576d5da30eecb45eaedcfe9677abe8466b87f4f Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Tue, 23 Aug 2016 13:33:03 -0700 Subject: [PATCH 32/87] 8157797: SAX Parser throws incorrect error on invalid xml Reviewed-by: lancea --- .../impl/XMLDocumentFragmentScannerImpl.java | 3 +- .../jaxp/unittest/parsers/HandleError.java | 98 +++++++++++++++++++ 2 files changed, 100 insertions(+), 1 deletion(-) create mode 100644 jaxp/test/javax/xml/jaxp/unittest/parsers/HandleError.java diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java index bf1b53b1b32..6cd1fd0435c 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLDocumentFragmentScannerImpl.java @@ -511,7 +511,8 @@ public class XMLDocumentFragmentScannerImpl //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"); diff --git a/jaxp/test/javax/xml/jaxp/unittest/parsers/HandleError.java b/jaxp/test/javax/xml/jaxp/unittest/parsers/HandleError.java new file mode 100644 index 00000000000..0a3e35c5dd3 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/parsers/HandleError.java @@ -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 = ""; + 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 = ""; + 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}, + }; + } +} From 200608b4c00688d7bccdcb6328a627e258b8cd17 Mon Sep 17 00:00:00 2001 From: Srinivas Dama Date: Wed, 24 Aug 2016 14:02:41 +0530 Subject: [PATCH 33/87] 8164618: add documentation for NativeNumber and NativeBoolean Reviewed-by: sundar --- .../codegen/OptimisticTypesCalculator.java | 2 +- .../runtime/resources/Functions.properties | 17 +++++++++++++++++ 2 files changed, 18 insertions(+), 1 deletion(-) diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesCalculator.java b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesCalculator.java index ac05a5f77ca..a026f2d2c57 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesCalculator.java +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/codegen/OptimisticTypesCalculator.java @@ -79,7 +79,7 @@ final class OptimisticTypesCalculator extends SimpleNodeVisitor { @Override public boolean enterPropertyNode(final PropertyNode propertyNode) { - if(propertyNode.getKeyName().equals(ScriptObject.PROTO_PROPERTY_NAME)) { + if(ScriptObject.PROTO_PROPERTY_NAME.equals(propertyNode.getKeyName())) { tagNeverOptimistic(propertyNode.getValue()); } return super.enterPropertyNode(propertyNode); diff --git a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties index 718f6cb07ef..d259e7528b5 100644 --- a/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties +++ b/nashorn/src/jdk.scripting.nashorn/share/classes/jdk/nashorn/internal/runtime/resources/Functions.properties @@ -173,3 +173,20 @@ String.prototype.toUpperCase=returns a new string representing the calling strin String.prototype.toLocaleUpperCase=returns a new string representing the calling string value converted to upper case according to any locale specific case mappings String.prototype.trim=returns a new string representing the calling string with white space removed from both ends + +Boolean.prototype.toString=returns string representation of specified Boolean object + +Boolean.prototype.valueOf=returns the primitive value of the specified Boolean object + +Number.prototype.toString=returns string representation of specified object in the specified radix + +Number.prototype.toLocaleString=returns a string with a language sensitive representation of this number + +Number.prototype.valueOf=returns the primitive value of the specified object + +Number.prototype.toFixed=returns a string representing the number in decimal fixed-point notation + +Number.prototype.toExponential=returns a string representing the number in decimal exponential notation + +Number.prototype.toPrecision=returns a string representing the number to a specified precision in fixed-point or exponential notation + From ddbef393bc87048ee8a5a0f0cf22228799b1e444 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Wed, 24 Aug 2016 12:23:10 -0700 Subject: [PATCH 34/87] 8047338: javac is not correctly filtering non-members methods to obtain the function descriptor Reviewed-by: mcimadamore --- .../com/sun/tools/javac/code/Types.java | 11 +++- ...MembersToObtainFunctionDescriptorTest.java | 55 +++++++++++++++++++ 2 files changed, 63 insertions(+), 3 deletions(-) create mode 100644 langtools/test/tools/javac/T8047338/FilterNonMembersToObtainFunctionDescriptorTest.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java index 1d303030829..d8f6cf527af 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Types.java @@ -418,10 +418,15 @@ public class Types { final ListBuffer 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 && - overrideEquivalent(mtype, memberType(origin.type, abstracts.first())))) { + if (abstracts.isEmpty()) { abstracts.append(sym); + } else if ((sym.name == abstracts.first().name && + overrideEquivalent(mtype, memberType(origin.type, abstracts.first())))) { + 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, diff --git a/langtools/test/tools/javac/T8047338/FilterNonMembersToObtainFunctionDescriptorTest.java b/langtools/test/tools/javac/T8047338/FilterNonMembersToObtainFunctionDescriptorTest.java new file mode 100644 index 00000000000..501d01b4561 --- /dev/null +++ b/langtools/test/tools/javac/T8047338/FilterNonMembersToObtainFunctionDescriptorTest.java @@ -0,0 +1,55 @@ +/* + * 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 8047338 + * @summary javac is not correctly filtering non-members methods to obtain the function descriptor + * @compile FilterNonMembersToObtainFunctionDescriptorTest.java + */ + +public class FilterNonMembersToObtainFunctionDescriptorTest { + V fails(CallableFail callable) throws E { + return null; + } + + V failsSub(CallableFailSub callable) throws E { + return null; + } + + void m() throws Exception { + fails((String s) -> 2); + failsSub((String s) -> 2); + } + + interface Callable { + V callFail(String s) throws Exception; + } + + interface CallableFail extends Callable { + @Override + V callFail(String s) throws E; + } + + interface CallableFailSub extends CallableFail {} +} From 486c59283bedfcb64a56925d4654e634f525f0a1 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Wed, 24 Aug 2016 15:40:35 -0700 Subject: [PATCH 35/87] 8164747: allclasses-frame broken after JDK-8162353 Reviewed-by: bpatel --- .../formats/html/AllClassesFrameWriter.java | 1 - .../TestFramesNoFrames.java | 20 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java index 51ef581a0fb..47351de8004 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AllClassesFrameWriter.java @@ -105,7 +105,6 @@ public class AllClassesFrameWriter extends HtmlDocletWriter { allclassgen.buildAllClassesFile(wantFrames); allclassgen = new AllClassesFrameWriter(configuration, fileName, indexBuilder); - allclassgen.buildAllClassesFile(false); } /** diff --git a/langtools/test/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java b/langtools/test/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java index c9a6f1aa5b2..bc7d8e676b7 100644 --- a/langtools/test/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java +++ b/langtools/test/jdk/javadoc/doclet/testFramesNoFrames/TestFramesNoFrames.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8162353 + * @bug 8162353 8164747 * @summary javadoc should provide a way to disable use of frames * @library /tools/lib ../lib * @modules @@ -283,6 +283,19 @@ public class TestFramesNoFrames extends JavadocTester { // this file is only generated when not in frames mode checkFiles(!frames, "allclasses.html"); + + if (frames) { + checkOutput("allclasses-frame.html", true, + classes.stream() + .map(c -> "title=\"class in " + packagePart(c) + "\" target=\"classFrame\">" + classPart(c) + "") + .toArray(String[]::new)); + checkOutput("allclasses-noframe.html", false, + "target=\"classFrame\">"); + } else { + checkOutput("allclasses.html", false, + "target=\"classFrame\">"); + + } } private void checkFrameFiles() { @@ -367,6 +380,11 @@ public class TestFramesNoFrames extends JavadocTester { .count(); } + private String classPart(String className) { + int lastDot = className.lastIndexOf("."); + return className.substring(lastDot + 1); + } + private String packagePart(String className) { int slash = className.indexOf("/"); int lastDot = className.lastIndexOf("."); From 7328ed21cbe077694f5835d2b6149b190d2b89c3 Mon Sep 17 00:00:00 2001 From: Vicente Romero Date: Wed, 24 Aug 2016 17:41:52 -0700 Subject: [PATCH 36/87] 8161501: JSR269 jigsaw update: javax.lang.model.element.ModuleElement.getEnclosedElements() on unnamed module with unnamed package Reviewed-by: jjg --- .../com/sun/tools/javac/code/Symtab.java | 1 + .../javac/modules/T8161501/EmptyClass.java | 26 +++++++ .../UnnamedModuleUnnamedPackageTest.java | 70 +++++++++++++++++++ 3 files changed, 97 insertions(+) create mode 100644 langtools/test/tools/javac/modules/T8161501/EmptyClass.java create mode 100644 langtools/test/tools/javac/modules/T8161501/UnnamedModuleUnnamedPackageTest.java diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java index 2d1c87d3272..034ffda0ad0 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/code/Symtab.java @@ -369,6 +369,7 @@ public class Symtab { } }; addRootPackageFor(unnamedModule); + unnamedModule.enclosedPackages = unnamedModule.enclosedPackages.prepend(unnamedModule.unnamedPackage); errModule = new ModuleSymbol(names.empty, null) { }; addRootPackageFor(errModule); diff --git a/langtools/test/tools/javac/modules/T8161501/EmptyClass.java b/langtools/test/tools/javac/modules/T8161501/EmptyClass.java new file mode 100644 index 00000000000..3d9a88eff43 --- /dev/null +++ b/langtools/test/tools/javac/modules/T8161501/EmptyClass.java @@ -0,0 +1,26 @@ +/* + * 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 pkg1; + +class EmptyClass {} diff --git a/langtools/test/tools/javac/modules/T8161501/UnnamedModuleUnnamedPackageTest.java b/langtools/test/tools/javac/modules/T8161501/UnnamedModuleUnnamedPackageTest.java new file mode 100644 index 00000000000..a8533698249 --- /dev/null +++ b/langtools/test/tools/javac/modules/T8161501/UnnamedModuleUnnamedPackageTest.java @@ -0,0 +1,70 @@ +/* + * 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 8161501 + * @summary JSR269 jigsaw update: javax.lang.model.element.ModuleElement.getEnclosedElements() on unnamed module with unnamed package + * @compile UnnamedModuleUnnamedPackageTest.java + * @compile -processor UnnamedModuleUnnamedPackageTest UnnamedModuleUnnamedPackageTest.java EmptyClass.java + */ + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.lang.model.SourceVersion; +import javax.lang.model.element.*; + +import java.util.*; +import java.util.stream.Collectors; + +@SupportedAnnotationTypes("*") +public class UnnamedModuleUnnamedPackageTest extends AbstractProcessor { + static final Set expected = new HashSet<>(Arrays.asList("unnamed package", "pkg1")); + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + for (Element e: roundEnv.getRootElements()) { + Element m = e.getEnclosingElement(); + while (!(m instanceof ModuleElement)) { + m = m.getEnclosingElement(); + } + Set found = m.getEnclosedElements().stream() + .map(p -> ((PackageElement)p).isUnnamed() ? + "unnamed package" : + ((PackageElement)p).getQualifiedName().toString()) + .collect(Collectors.toSet()); + if (!Objects.equals(expected, found)) { + System.err.println("expected: " + expected); + System.err.println("found: " + found); + throw new AssertionError("unexpected packages found"); + } + } + return false; + } + + @Override + public SourceVersion getSupportedSourceVersion() { + return SourceVersion.latest(); + } +} From 2c2d5c49175c1826a27c3ae07371f79770450215 Mon Sep 17 00:00:00 2001 From: Maurizio Cimadamore Date: Thu, 25 Aug 2016 11:51:19 +0100 Subject: [PATCH 37/87] 8164399: inference of thrown variable does not work correctly Logic for inferring thrown variables should exclude non proper bounds as per JLS 18.1 Reviewed-by: vromero, dlsmith --- .../com/sun/tools/javac/comp/Infer.java | 16 +++--- .../generics/inference/8164399/T8164399.java | 49 +++++++++++++++++++ .../generics/inference/8164399/T8164399b.java | 21 ++++++++ .../generics/inference/8164399/T8164399b.out | 2 + 4 files changed, 78 insertions(+), 10 deletions(-) create mode 100644 langtools/test/tools/javac/generics/inference/8164399/T8164399.java create mode 100644 langtools/test/tools/javac/generics/inference/8164399/T8164399b.java create mode 100644 langtools/test/tools/javac/generics/inference/8164399/T8164399b.out diff --git a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java index 4bb5b7e1f69..d2ca305072a 100644 --- a/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java +++ b/langtools/src/jdk.compiler/share/classes/com/sun/tools/javac/comp/Infer.java @@ -61,6 +61,7 @@ import java.util.Properties; 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 @@ public class Infer { //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 diff --git a/langtools/test/tools/javac/generics/inference/8164399/T8164399.java b/langtools/test/tools/javac/generics/inference/8164399/T8164399.java new file mode 100644 index 00000000000..a069edc2516 --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/8164399/T8164399.java @@ -0,0 +1,49 @@ +/* + * 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 8164399 + * @summary inference of thrown variable does not work correctly + * @compile T8164399.java + */ + +abstract class T8164399 { + + interface ThrowableRunnable { + void compute() throws E; + } + + public abstract < E extends Exception> void computeException(ThrowableRunnable process) throws E; + + + public static T compute(ThrowableRunnable action) throws E { + return null; + } + + { + computeException(() -> compute(() -> {})); + } +} diff --git a/langtools/test/tools/javac/generics/inference/8164399/T8164399b.java b/langtools/test/tools/javac/generics/inference/8164399/T8164399b.java new file mode 100644 index 00000000000..ea2a8d1fb00 --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/8164399/T8164399b.java @@ -0,0 +1,21 @@ +/* + * @test /nodynamiccopyright/ + * @bug 8164399 + * @summary inference of thrown variable does not work correctly + * @compile/fail/ref=T8164399b.out -XDrawDiagnostics T8164399b.java + */ +class T8164399b { + void m(Class arg) throws T {} + void g() throws T {} + + void test() { + m(RuntimeException.class); // ok + m(Exception.class); // error + m(Throwable.class); // ok + m(java.io.Serializable.class); // error + m(Object.class); // error + m(Runnable.class); // error + T8164399b x = null; + x.g(); // expected: ok; actual: error + } +} diff --git a/langtools/test/tools/javac/generics/inference/8164399/T8164399b.out b/langtools/test/tools/javac/generics/inference/8164399/T8164399b.out new file mode 100644 index 00000000000..6091fbb27f6 --- /dev/null +++ b/langtools/test/tools/javac/generics/inference/8164399/T8164399b.out @@ -0,0 +1,2 @@ +T8164399b.java:17:10: compiler.err.unreported.exception.need.to.catch.or.throw: java.lang.Throwable&java.lang.Runnable +1 error From 87f1cd1d737d4b027d4a9ac777c901aab953cd73 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Thu, 25 Aug 2016 22:23:59 +0530 Subject: [PATCH 38/87] 8164748: Edit pad crashes when calling function Reviewed-by: jlaskey --- .../share/classes/jdk/nashorn/tools/jjs/Main.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Main.java b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Main.java index 418bce95c85..d792738cfa4 100644 --- a/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Main.java +++ b/nashorn/src/jdk.scripting.nashorn.shell/share/classes/jdk/nashorn/tools/jjs/Main.java @@ -172,7 +172,7 @@ public final class Main extends Shell { final Consumer evaluator = str -> { // could be called from different thread (GUI), we need to handle Context set/reset final Global _oldGlobal = Context.getGlobal(); - final boolean _globalChanged = (oldGlobal != global); + final boolean _globalChanged = (_oldGlobal != global); if (_globalChanged) { Context.setGlobal(global); } From 1a404080eee49fa16c61ba9e7ac6e521779999e1 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Fri, 26 Aug 2016 16:16:09 +0200 Subject: [PATCH 39/87] 8163371: Enable tracing which JLI classes can be pre-generated Reviewed-by: vlivanov --- .../java/lang/invoke/BoundMethodHandle.java | 4 + .../lang/invoke/InvokerBytecodeGenerator.java | 5 +- .../java/lang/invoke/MethodHandleStatics.java | 3 + .../plugins/GenerateJLIClassesPlugin.java | 209 ++++++++++-------- .../tools/jlink/resources/plugins.properties | 6 +- 5 files changed, 127 insertions(+), 100 deletions(-) diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java index 91071a2b3b4..461dd3967cb 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/BoundMethodHandle.java @@ -497,6 +497,10 @@ import static jdk.internal.org.objectweb.asm.Opcodes.*; 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 { diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java index b71bd527608..afb04b6efa4 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/InvokerBytecodeGenerator.java @@ -607,7 +607,10 @@ class InvokerBytecodeGenerator { 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; } diff --git a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java index 4f5f1f4dc0d..22408f1b55a 100644 --- a/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java +++ b/jdk/src/java.base/share/classes/java/lang/invoke/MethodHandleStatics.java @@ -46,6 +46,7 @@ import java.util.Properties; 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 @@ import java.util.Properties; 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( diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java index 514d1b7528e..42fe47c97f1 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java @@ -24,7 +24,11 @@ */ package jdk.tools.jlink.internal.plugins; +import java.io.File; +import java.io.IOException; import java.lang.invoke.MethodType; +import java.nio.file.Files; +import java.util.ArrayList; import java.util.Arrays; import java.util.EnumSet; import java.util.HashMap; @@ -32,6 +36,7 @@ import java.util.List; import java.util.Map; import java.util.Set; 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 @@ public final class GenerateJLIClassesPlugin implements Plugin { 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 @@ public final class GenerateJLIClassesPlugin implements Plugin { 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"; @@ -76,7 +75,6 @@ public final class GenerateJLIClassesPlugin implements Plugin { Map> dmhMethods; - public GenerateJLIClassesPlugin() { } @@ -112,7 +110,7 @@ public final class GenerateJLIClassesPlugin implements Plugin { * 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 defaultSpecies() { + private static List defaultSpecies() { return List.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", @@ -122,26 +120,27 @@ public final class GenerateJLIClassesPlugin implements Plugin { /** * @return the default invoker forms to generate. */ - public static List defaultInvokers() { - return List.of("_L", "_I", "I_I", "LI_I", "ILL_I", "LIL_I", "L_L", "LL_V", "LLLL_L"); + private static List defaultInvokers() { + return List.of("LL_L", "LL_I", "LILL_I", "L6_L"); } /** * @return the list of default DirectMethodHandle methods to generate. */ - public static Map> defaultDMHMethods() { + private static Map> 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, List.of("L_L", "LL_L", "LLI_I", "L3_V"), + DMH_INVOKE_SPECIAL, List.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, List.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,92 +159,89 @@ public final class GenerateJLIClassesPlugin implements Plugin { public void configure(Map config) { String mainArgument = config.get(NAME); - // Enable by default - boolean bmhEnabled = true; - boolean dmhEnabled = true; - boolean invokersEnabled = true; - if (mainArgument != null) { - List 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 (mainArgument != null && mainArgument.startsWith("@")) { + File file = new File(mainArgument.substring(1)); + if (file.exists()) { + speciesTypes = new ArrayList<>(); + invokerTypes = new ArrayList<>(); + dmhMethods = new HashMap<>(); + Stream lines = fileLines(file); - if (!bmhEnabled) { - speciesTypes = List.of(); + lines.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 + } + }); + } } else { - String args = config.get(BMH_SPECIES_PARAM); - List bmhSpecies; - if (args != null && !args.isEmpty()) { - bmhSpecies = Arrays.stream(args.split(",")) - .map(String::trim) - .filter(s -> !s.isEmpty()) - .collect(Collectors.toList()); - } else { - bmhSpecies = defaultSpecies(); - } - + List bmhSpecies = defaultSpecies(); // Expand BMH species signatures speciesTypes = bmhSpecies.stream() .map(type -> expandSignature(type)) .collect(Collectors.toList()); - } - if (!invokersEnabled) { - invokerTypes = List.of(); - } 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(); - } + invokerTypes = defaultInvokers(); + validateMethodTypes(invokerTypes); - } - // 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 dmhMethodTypes = Arrays.stream(args.split(",")) - .map(String::trim) - .filter(s -> !s.isEmpty()) - .collect(Collectors.toList()); - dmhMethods.put(dmhParam, dmhMethodTypes); - validateMethodTypes(dmhMethodTypes); - } - } - if (dmhMethods.isEmpty()) { - dmhMethods = defaultDMHMethods(); + dmhMethods = defaultDMHMethods(); + for (List dmhMethodTypes : dmhMethods.values()) { + validateMethodTypes(dmhMethodTypes); } } } - void validateMethodTypes(List 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]); + private void addDMHMethodType(String dmh, String methodType) { + validateMethodType(methodType); + List methodTypes = dmhMethods.get(dmh); + if (methodTypes == null) { + methodTypes = new ArrayList<>(); + dmhMethods.put(dmh, methodTypes); } + methodTypes.add(methodType); + } + + private Stream fileLines(File file) { + try { + return Files.lines(file.toPath()); + } catch (IOException io) { + throw new PluginException("Couldn't read file"); + } + } + + private void validateMethodTypes(List dmhMethodTypes) { + for (String type : dmhMethodTypes) { + 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) { @@ -304,14 +300,33 @@ public final class GenerateJLIClassesPlugin implements Plugin { for (Map.Entry> 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)); + // 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(invokerTypes.get(i)); + 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); } try { byte[] bytes = JLIA.generateDirectMethodHandleHolderClassBytes( diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties index 6fa0248531f..67c40903eb9 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties @@ -68,10 +68,12 @@ exclude-resources.argument= resources to exclude exclude-resources.description=\ Specify resources to exclude. e.g.: **.jcov,glob:**/META-INF/** -generate-jli-classes.argument= +generate-jli-classes.argument=<@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, so to \n\ +disable pre-generation supply the name of an empty or non-existing file installed-modules.description=Fast loading of module descriptors (always enabled) From 616336b6c23d4364c4d30e7095ceae6b56d3886b Mon Sep 17 00:00:00 2001 From: Felix Yang Date: Fri, 26 Aug 2016 08:33:28 -0700 Subject: [PATCH 40/87] 8163561: Add a test for Proxy Authentication in HTTP/2 Client API Reviewed-by: chegar --- .../java/net/httpclient/ProxyAuthTest.java | 174 ++++++++++++++++++ 1 file changed, 174 insertions(+) create mode 100644 jdk/test/java/net/httpclient/ProxyAuthTest.java diff --git a/jdk/test/java/net/httpclient/ProxyAuthTest.java b/jdk/test/java/net/httpclient/ProxyAuthTest.java new file mode 100644 index 00000000000..42bc0c709db --- /dev/null +++ b/jdk/test/java/net/httpclient/ProxyAuthTest.java @@ -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); + } + } + } + +} + From e079e3b069be94b3ca3614c292e6ddbde09f62ac Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Fri, 26 Aug 2016 21:31:47 +0530 Subject: [PATCH 41/87] 8164800: Cross targeting Windows Reviewed-by: jlaskey, alanb, mchung --- .../jlink/builder/DefaultImageBuilder.java | 44 ++++++++++--------- 1 file changed, 24 insertions(+), 20 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java index 1b37140ed55..6f4c7e59041 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java @@ -78,28 +78,23 @@ public final class DefaultImageBuilder implements ImageBuilder { private final List args; private final Set modules; - public DefaultExecutableImage(Path home, Set modules) { - this(home, modules, createArgs(home)); - } - - private DefaultExecutableImage(Path home, Set modules, - List args) { + DefaultExecutableImage(Path home, Set 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 createArgs(Path home) { Objects.requireNonNull(home); List 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"; + javaArgs.add(binDir.resolve(java).toString()); + return Collections.unmodifiableList(javaArgs); } @Override @@ -130,6 +125,7 @@ public final class DefaultImageBuilder implements ImageBuilder { private final Path root; private final Path mdir; private final Set modules = new HashSet<>(); + private String targetOsName; /** * Default image builder constructor. @@ -171,6 +167,10 @@ public final class DefaultImageBuilder implements ImageBuilder { @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); + files.entries().forEach(f -> { if (!f.type().equals(ResourcePoolEntry.Type.CLASS_OR_RESOURCE)) { try { @@ -186,7 +186,8 @@ public final class DefaultImageBuilder implements ImageBuilder { 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 @@ -226,6 +227,11 @@ public final class DefaultImageBuilder implements ImageBuilder { props.setProperty("JAVA_VERSION", System.getProperty("java.version")); }); + this.targetOsName = props.getProperty("OS_NAME"); + if (this.targetOsName == null) { + throw new RuntimeException("can't determine target OS from java.base descriptor"); + } + Optional release = pool.findEntry("/java.base/release"); if (release.isPresent()) { try (InputStream is = release.get().content()) { @@ -373,7 +379,7 @@ public final class DefaultImageBuilder implements ImageBuilder { 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 +392,8 @@ public final class DefaultImageBuilder implements ImageBuilder { } } - private static boolean isWindows() { - return System.getProperty("os.name").startsWith("Windows"); + private boolean isWindows() { + return targetOsName.startsWith("Windows"); } /** @@ -452,12 +458,10 @@ public final class DefaultImageBuilder implements ImageBuilder { } } - 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; From 2d02799b3b3b907cc00b2607c7a5347c5bfb49b9 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Fri, 26 Aug 2016 18:10:12 +0200 Subject: [PATCH 42/87] 8164866: tools/jlink/plugins/GenerateJLIClassesPluginTest.java can't compile after JDK-8163371 Reviewed-by: sundar, vlivanov --- .../plugins/GenerateJLIClassesPlugin.java | 2 +- .../plugins/GenerateJLIClassesPluginTest.java | 41 ------------------- 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java index 42fe47c97f1..a60a1e934b5 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java @@ -110,7 +110,7 @@ public final class GenerateJLIClassesPlugin implements Plugin { * 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. */ - private static List defaultSpecies() { + public static List defaultSpecies() { return List.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", diff --git a/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java b/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java index 53010cfa217..ae2d3ec5945 100644 --- a/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java +++ b/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java @@ -73,47 +73,6 @@ public class GenerateJLIClassesPluginTest { 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 classFilesForSpecies(List species) { From 0edc4fa72dcf4a1844e14e301c27a75f47e7a798 Mon Sep 17 00:00:00 2001 From: Anthony Scarpino Date: Fri, 26 Aug 2016 09:57:36 -0700 Subject: [PATCH 43/87] 8074838: Resolve disabled warnings for libj2pkcs11 Reviewed-by: wetmore, erikj --- jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk | 4 +--- .../jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_util.c | 2 +- .../unix/native/libj2pkcs11/j2secmod_md.c | 7 ++++--- .../windows/native/libj2pkcs11/j2secmod_md.c | 3 +++ 4 files changed, 9 insertions(+), 7 deletions(-) diff --git a/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk b/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk index c74f77960bb..82618b11fb5 100644 --- a/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk +++ b/jdk/make/lib/Lib-jdk.crypto.pkcs11.gmk @@ -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 @@ $(eval $(call SetupNativeCompilation,BUILD_LIBJ2PKCS11, \ 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), \ diff --git a/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_util.c b/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_util.c index f102baa64bf..87d34543731 100644 --- a/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_util.c +++ b/jdk/src/jdk.crypto.pkcs11/share/native/libj2pkcs11/p11_util.c @@ -558,7 +558,7 @@ void jStringToCKUTF8CharArray(JNIEnv *env, const jstring jArray, CK_UTF8CHAR_PTR 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); diff --git a/jdk/src/jdk.crypto.pkcs11/unix/native/libj2pkcs11/j2secmod_md.c b/jdk/src/jdk.crypto.pkcs11/unix/native/libj2pkcs11/j2secmod_md.c index 225263247db..d5154eff606 100644 --- a/jdk/src/jdk.crypto.pkcs11/unix/native/libj2pkcs11/j2secmod_md.c +++ b/jdk/src/jdk.crypto.pkcs11/unix/native/libj2pkcs11/j2secmod_md.c @@ -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 @@ void *findFunction(JNIEnv *env, jlong jHandle, const char *functionName) { 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 @@ JNIEXPORT jlong JNICALL Java_sun_security_pkcs11_Secmod_nssGetLibraryHandle // 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); diff --git a/jdk/src/jdk.crypto.pkcs11/windows/native/libj2pkcs11/j2secmod_md.c b/jdk/src/jdk.crypto.pkcs11/windows/native/libj2pkcs11/j2secmod_md.c index 33b11bfd07e..6e983ce158f 100644 --- a/jdk/src/jdk.crypto.pkcs11/windows/native/libj2pkcs11/j2secmod_md.c +++ b/jdk/src/jdk.crypto.pkcs11/windows/native/libj2pkcs11/j2secmod_md.c @@ -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); From f894a28859acab03ac210eb40246752b8ae28be3 Mon Sep 17 00:00:00 2001 From: Svetlana Nikandrova Date: Thu, 25 Aug 2016 20:53:40 +0300 Subject: [PATCH 44/87] 8005068: HttpCookie does not correctly handle negative maxAge values Reviewed-by: chegar --- .../share/classes/java/net/HttpCookie.java | 7 ++- .../net/HttpCookie/CookieNegativeMaxAge.java | 56 +++++++++++++++++++ 2 files changed, 60 insertions(+), 3 deletions(-) create mode 100644 jdk/test/java/net/HttpCookie/CookieNegativeMaxAge.java diff --git a/jdk/src/java.base/share/classes/java/net/HttpCookie.java b/jdk/src/java.base/share/classes/java/net/HttpCookie.java index c8d127837ca..7cc7d6e8ebc 100644 --- a/jdk/src/java.base/share/classes/java/net/HttpCookie.java +++ b/jdk/src/java.base/share/classes/java/net/HttpCookie.java @@ -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 @@ public final class HttpCookie implements Cloneable { // 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 @@ public final class HttpCookie implements Cloneable { 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); } } }); diff --git a/jdk/test/java/net/HttpCookie/CookieNegativeMaxAge.java b/jdk/test/java/net/HttpCookie/CookieNegativeMaxAge.java new file mode 100644 index 00000000000..aae65f4f625 --- /dev/null +++ b/jdk/test/java/net/HttpCookie/CookieNegativeMaxAge.java @@ -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 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"); + } + } +} From ff0876af590b5be055f94392f7d5e86180f22524 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 25 Aug 2016 21:18:44 +0000 Subject: [PATCH 45/87] Added tag jdk-9+133 for changeset cf75dd18b3cd --- hotspot/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/hotspot/.hgtags b/hotspot/.hgtags index dd85a0e3b2b..8d8a2e6cf99 100644 --- a/hotspot/.hgtags +++ b/hotspot/.hgtags @@ -535,3 +535,4 @@ e96b34b76d863ed1fa04e0eeb3f297ac17b490fd jdk-9+129 7d54c7056328b6a2bf4877458b8f4d8cd870f93b jdk-9+130 943bf73b49c33c2d7cbd796f6a4ae3c7a00ae932 jdk-9+131 713951c08aa26813375175c2ab6cc99ff2a56903 jdk-9+132 +a25e0fb6033245ab075136e744d362ce765464cd jdk-9+133 From 8925d80b0f1e0dca1b9c6d98eae8d3928aea9593 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 25 Aug 2016 21:18:44 +0000 Subject: [PATCH 46/87] Added tag jdk-9+133 for changeset 3d8b2db865d7 --- .hgtags-top-repo | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags-top-repo b/.hgtags-top-repo index 2ab754ea198..9b00c6661fd 100644 --- a/.hgtags-top-repo +++ b/.hgtags-top-repo @@ -375,3 +375,4 @@ f5902d3841b82cac6e7716a20c24e8e916fb14a8 jdk-9+129 d94d54a3192fea79234c3ac55cd0b4052d45e954 jdk-9+130 8728756c2f70a79a90188f4019cfd6b9a275765c jdk-9+131 a24702d4d5ab0015a5c553ed57f66fce7d85155e jdk-9+132 +be1218f792a450dfb5d4b1f82616b9d95a6a732e jdk-9+133 From f4b607169835dff2a1991b023d01cc0fcd369cb7 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 25 Aug 2016 21:18:44 +0000 Subject: [PATCH 47/87] Added tag jdk-9+133 for changeset 93cc31534cc4 --- corba/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/corba/.hgtags b/corba/.hgtags index 2ba88ee0421..a959d0d2240 100644 --- a/corba/.hgtags +++ b/corba/.hgtags @@ -375,3 +375,4 @@ c3e83ccab3bb1733ae903d681879a33f85ed465c jdk-9+129 77f9692d5976ae155773dd3e07533616bb95bae1 jdk-9+130 f7e1d5337c2e550fe553df7a3886bbed80292ecd jdk-9+131 1ab4b9399c4cba584f66c1c088188f2f565fbf9c jdk-9+132 +2021bfedf1c478a4808a7711a6090682a12f4c0e jdk-9+133 From 008dd9bd6c908d1ce5cbc86588c4205681d97508 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 25 Aug 2016 21:18:45 +0000 Subject: [PATCH 48/87] Added tag jdk-9+133 for changeset 0aa2e371af02 --- jaxp/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxp/.hgtags b/jaxp/.hgtags index 380d39ea6ab..e81f2084cef 100644 --- a/jaxp/.hgtags +++ b/jaxp/.hgtags @@ -375,3 +375,4 @@ bdc3c0b737efbf899709eb3121ce760dcfb51151 jdk-9+127 e66cdc2de6b02443911d386fc9217b0d824d0686 jdk-9+130 874082a9b565a7092a40bfa934a6e3e3c3455a60 jdk-9+131 907445d85e680ea410fe2c83c0ec64b5508e4f3e jdk-9+132 +9490ba2e5e41685c858a0ca2a6ec87611eb011c6 jdk-9+133 From 3f2860e14d630660219907f4c6af9175f1f9a2f5 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 25 Aug 2016 21:18:46 +0000 Subject: [PATCH 49/87] Added tag jdk-9+133 for changeset a6f581ca1fc4 --- jaxws/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/jaxws/.hgtags b/jaxws/.hgtags index 36eb74d3bb0..136f72fe00d 100644 --- a/jaxws/.hgtags +++ b/jaxws/.hgtags @@ -378,3 +378,4 @@ fe4e11bd2423635dc0f5f5cb9a64eb2f2cce7f4c jdk-9+128 39c6293131d91aec7f2f5120395e070a937b8858 jdk-9+130 783e7e2c587f2c7e1b9998a46d90ec196ab2a195 jdk-9+131 9fff2477a4cadf2a9618a76f1f4fe0f20bb5ff3b jdk-9+132 +05e99eefda2b58d1ed176e411302d9d6b35dca16 jdk-9+133 From 233fae72ed048059abf2e04ac3f39139cf0a2e5f Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 25 Aug 2016 21:18:47 +0000 Subject: [PATCH 50/87] Added tag jdk-9+133 for changeset 611ca58fca75 --- langtools/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/langtools/.hgtags b/langtools/.hgtags index 06cc131cdbd..4fdf92ea61c 100644 --- a/langtools/.hgtags +++ b/langtools/.hgtags @@ -375,3 +375,4 @@ e181909291981038b041ed4d22714c4760e049cd jdk-9+129 3665ebc22a42c8f33777ee025ba0e300e6086a8c jdk-9+130 aebfafc43714d5a27d5064d8a0011eaccde633cf jdk-9+131 2c17b65a37a8d7afdb9f96d5f11b28a3f21c78f2 jdk-9+132 +7efa4b3477b2b93edbdb4abf827b74c6391f056e jdk-9+133 From 4af40de9e799e96d28bdff96398e2cd882af5893 Mon Sep 17 00:00:00 2001 From: Lana Steuck Date: Thu, 25 Aug 2016 21:18:47 +0000 Subject: [PATCH 51/87] Added tag jdk-9+133 for changeset a3fdd74e324a --- nashorn/.hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/nashorn/.hgtags b/nashorn/.hgtags index aa139484a6f..f68987a568a 100644 --- a/nashorn/.hgtags +++ b/nashorn/.hgtags @@ -366,3 +366,4 @@ ff07be6106fa56b72c163244f45a3ecb4c995564 jdk-9+127 0de67a63e2c73781ecf5979a2f3aa9619a445c37 jdk-9+130 ee77c6b3713ab293e027ac3ea1cc16f86dac535f jdk-9+131 55a75af751dfe44039baef2b762ee7347021025b jdk-9+132 +3a924b820d02b108cf57b51e145b5150d1eedcca jdk-9+133 From 1673e17518536d880fbea4fb52ffd9f1abe5b3f6 Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Thu, 25 Aug 2016 17:58:39 -0700 Subject: [PATCH 52/87] 8145464: implement deprecation static analysis tool Reviewed-by: psandoz, darcy --- langtools/make/CompileInterim.gmk | 5 +- .../classes/com/sun/tools/jdeprscan/CSV.java | 147 ++++ .../tools/jdeprscan/CSVParseException.java | 55 ++ .../com/sun/tools/jdeprscan/DeprDB.java | 178 +++++ .../com/sun/tools/jdeprscan/DeprData.java | 62 ++ .../com/sun/tools/jdeprscan/LoadProc.java | 206 +++++ .../classes/com/sun/tools/jdeprscan/Main.java | 717 ++++++++++++++++++ .../com/sun/tools/jdeprscan/Messages.java | 55 ++ .../com/sun/tools/jdeprscan/Pretty.java | 274 +++++++ .../com/sun/tools/jdeprscan/TraverseProc.java | 172 +++++ .../com/sun/tools/jdeprscan/internals.md | 215 ++++++ .../classes/com/sun/tools/jdeprscan/readme.md | 180 +++++ .../jdeprscan/resources/jdeprscan.properties | 96 +++ .../sun/tools/jdeprscan/scan/CPEntries.java | 76 ++ .../sun/tools/jdeprscan/scan/CPSelector.java | 108 +++ .../sun/tools/jdeprscan/scan/ClassFinder.java | 211 ++++++ .../sun/tools/jdeprscan/scan/MethodSig.java | 167 ++++ .../com/sun/tools/jdeprscan/scan/Scan.java | 614 +++++++++++++++ .../deprcases/members/ExampleAnnotation.java | 34 + .../jdk/deprcases/members/ExampleClass.java | 49 ++ .../deprcases/members/ExampleElements.java | 44 ++ .../jdk/deprcases/members/ExampleEnum.java | 42 + .../deprcases/members/ExampleInterface.java | 44 ++ .../deprcases/members/ExampleSubclass.java | 39 + .../deprcases/types/DeprecatedAnnotation.java | 35 + .../jdk/deprcases/types/DeprecatedClass.java | 28 + .../jdk/deprcases/types/DeprecatedEnum.java | 31 + .../deprcases/types/DeprecatedException.java | 29 + .../deprcases/types/DeprecatedInterface.java | 28 + .../tests/jdk/jdeprscan/TestCSV.java | 144 ++++ .../tests/jdk/jdeprscan/TestLoad.java | 120 +++ .../tests/jdk/jdeprscan/TestLoadExpected.csv | 30 + .../tests/jdk/jdeprscan/TestMethodSig.java | 61 ++ .../tests/jdk/jdeprscan/TestScan.java | 110 +++ .../tests/jdk/jdeprscan/TestScanExpected.txt | 47 ++ .../usage/jdk/deprusage/UseAnnotation.java | 41 + .../usage/jdk/deprusage/UseClass.java | 107 +++ .../usage/jdk/deprusage/UseEnum.java | 62 ++ .../usage/jdk/deprusage/UseEnumMembers.java | 74 ++ .../usage/jdk/deprusage/UseException.java | 40 + .../usage/jdk/deprusage/UseField.java | 72 ++ .../usage/jdk/deprusage/UseInterface.java | 36 + .../usage/jdk/deprusage/UseMethod.java | 123 +++ 43 files changed, 5006 insertions(+), 2 deletions(-) create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/CSV.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/CSVParseException.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/DeprDB.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/DeprData.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Messages.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Pretty.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/internals.md create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/CPEntries.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/CPSelector.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/ClassFinder.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/MethodSig.java create mode 100644 langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/Scan.java create mode 100644 langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleAnnotation.java create mode 100644 langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleClass.java create mode 100644 langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleElements.java create mode 100644 langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleEnum.java create mode 100644 langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleInterface.java create mode 100644 langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleSubclass.java create mode 100644 langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedAnnotation.java create mode 100644 langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedClass.java create mode 100644 langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedEnum.java create mode 100644 langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedException.java create mode 100644 langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedInterface.java create mode 100644 langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestCSV.java create mode 100644 langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestLoad.java create mode 100644 langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestLoadExpected.csv create mode 100644 langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestMethodSig.java create mode 100644 langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java create mode 100644 langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScanExpected.txt create mode 100644 langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseAnnotation.java create mode 100644 langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseClass.java create mode 100644 langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseEnum.java create mode 100644 langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseEnumMembers.java create mode 100644 langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseException.java create mode 100644 langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseField.java create mode 100644 langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseInterface.java create mode 100644 langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseMethod.java diff --git a/langtools/make/CompileInterim.gmk b/langtools/make/CompileInterim.gmk index 06a13d92ba8..171c830fb1a 100644 --- a/langtools/make/CompileInterim.gmk +++ b/langtools/make/CompileInterim.gmk @@ -32,7 +32,7 @@ include JavaCompilation.gmk 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 @@ define SetupInterimModule 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), \ diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/CSV.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/CSV.java new file mode 100644 index 00000000000..8e710484455 --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/CSV.java @@ -0,0 +1,147 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan; + +import java.io.PrintStream; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.stream.Collectors; + +/** + * Utility class for manipulating comma-separated-value (CSV) data. + */ +public class CSV { + static String quote(String input) { + String result; + boolean needQuote = input.contains(","); + + if (input.contains("\"")) { + needQuote = true; + result = input.replace("\"", "\"\""); + } else { + result = input; + } + + if (needQuote) { + return "\"" + result + "\""; + } else { + return result; + } + } + + /** + * Writes the objects' string representations to the output as a line of CSV. + * The objects are converted to String, quoted if necessary, joined with commas, + * and are written to the output followed by the line separator string. + * + * @param out the output destination + * @param objs the objects to write + */ + public static void write(PrintStream out, Object... objs) { + out.println(Arrays.stream(objs) + .map(Object::toString) + .map(CSV::quote) + .collect(Collectors.joining(","))); + } + + /** + * The CSV parser state. + */ + enum State { + START_FIELD, // the start of a field + IN_FIELD, // within an unquoted field + IN_QFIELD, // within a quoted field + END_QFIELD // after the end of a quoted field + } + + /** + * Splits an input line into a list of strings, handling quoting. + * + * @param input the input line + * @return the resulting list of strings + */ + public static List split(String input) { + List result = new ArrayList<>(); + StringBuilder cur = new StringBuilder(); + State state = State.START_FIELD; + + for (int i = 0; i < input.length(); i++) { + char ch = input.charAt(i); + switch (ch) { + case ',': + switch (state) { + case IN_QFIELD: + cur.append(','); + break; + default: + result.add(cur.toString()); + cur.setLength(0); + state = State.START_FIELD; + break; + } + break; + case '"': + switch (state) { + case START_FIELD: + state = State.IN_QFIELD; + break; + case IN_QFIELD: + state = State.END_QFIELD; + break; + case IN_FIELD: + throw new CSVParseException("unexpected quote", input, i); + case END_QFIELD: + cur.append('"'); + state = State.IN_QFIELD; + break; + } + break; + default: + switch (state) { + case START_FIELD: + state = State.IN_FIELD; + break; + case IN_FIELD: + case IN_QFIELD: + break; + case END_QFIELD: + throw new CSVParseException("extra character after quoted string", + input, i); + } + cur.append(ch); + break; + } + } + + if (state == State.IN_QFIELD) { + throw new CSVParseException("unclosed quote", input, input.length()); + } + + result.add(cur.toString()); + return result; + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/CSVParseException.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/CSVParseException.java new file mode 100644 index 00000000000..79347123b3d --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/CSVParseException.java @@ -0,0 +1,55 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan; + +/** + * Exception representing an error encountered during CSV parsing. + */ +public class CSVParseException extends IllegalArgumentException { + private static final long serialVersionUID = 6822670269555409371L; + final String input; + final int index; + + public CSVParseException(String msg, String input, int index) { + super(msg); + this.input = input; + this.index = index; + } + + public String getInput() { return input; } + + public int getIndex() { return index; } + + /** + * Returns a string describing the parse error. + * + * @return a string describing the parse error + */ + @Override + public String getMessage() { + return super.getMessage() + " at index " + index + ": " + input; + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/DeprDB.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/DeprDB.java new file mode 100644 index 00000000000..f25eea9bb75 --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/DeprDB.java @@ -0,0 +1,178 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan; + +import java.io.BufferedReader; +import java.io.IOException; +import java.nio.file.Files; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Formatter; +import java.util.HashMap; +import java.util.List; +import java.util.Locale; +import java.util.Map; +import java.util.Set; + +import javax.lang.model.element.ElementKind; + +/** + * A database of deprecations (APIs declared to be deprecated), + * loaded from a JDK or from a class library. + */ +public class DeprDB { + /** + * Deprecated types. + * A map from deprecated type names to DeprData values. + * Types include classes, interfaces, enums, and annotation types. + */ + final Map types = new HashMap<>(); + + /** + * Deprecated methods. Key is type name, value is map from method + * signatures in the form "methodname(parms)ret" to DeprData value. + */ + final Map> methods = new HashMap<>(); + + /** + * Deprecated fields. Key is type name, value is map from field name + * to forRemoval value. + */ + final Map> fields = new HashMap<>(); + + /** + * Set of valid ElementKind strings. + */ + static final Set validElementKinds = + Set.of(Arrays.stream(ElementKind.values()) + .map(ElementKind::toString) + .toArray(String[]::new)); + + + private DeprDB() { } + + public static List loadFromFile(String filename) throws IOException { + List list = new ArrayList<>(); + + exit: + try (final BufferedReader br = Files.newBufferedReader(Paths.get(filename))) { + String line = br.readLine(); + if (line == null || !line.equals("#jdepr1")) { + System.out.printf("ERROR: invalid first line %s%n", line); + break exit; + } + while ((line = br.readLine()) != null) { + if (line.startsWith("#")) { + continue; + } + List tokens = CSV.split(line); + if (tokens.size() != 5) { + System.out.printf("ERROR: %s%n", line); + continue; + } + // kind,typeName,descOrName,since,forRemoval + String kindStr = tokens.get(0); + String type = tokens.get(1); + String detail = tokens.get(2); + String since = tokens.get(3); + boolean forRemoval = Boolean.parseBoolean(tokens.get(4)); + ElementKind kind; + + if (validElementKinds.contains(kindStr)) { + kind = ElementKind.valueOf(kindStr); + } else { + System.out.printf("ERROR: invalid element kind %s%n", kindStr); + continue; + } + + DeprData data = new DeprData(kind, /*TypeElement*/null, type, detail, since, forRemoval); + list.add(data); + } + } + return list; + } + + public static DeprDB loadFromList(List deprList) { + DeprDB db = new DeprDB(); + + for (DeprData dd : deprList) { + switch (dd.kind) { + case CLASS: + case INTERFACE: + case ENUM: + case ANNOTATION_TYPE: + db.types.put(dd.typeName, dd); + break; + case METHOD: + case CONSTRUCTOR: + db.methods.computeIfAbsent(dd.typeName, k -> new HashMap<>()) + .put(dd.nameSig, dd); + break; + case ENUM_CONSTANT: + case FIELD: + db.fields.computeIfAbsent(dd.typeName, k -> new HashMap<>()) + .put(dd.nameSig, dd); + break; + } + } + + return db; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + Formatter f = new Formatter(sb, Locale.US); + f.format("=== Types ===%n"); + f.format("%s%n", types.toString()); + f.format("=== Methods ===%n"); + f.format("%s%n", methods.toString()); + f.format("=== Fields ===%n"); + f.format("%s%n", fields.toString()); + return sb.toString(); + } + + public DeprData getTypeDeprecated(String typeName) { + return types.get(typeName); + } + + public DeprData getMethodDeprecated(String typeName, String methodName, String type) { + Map m = methods.get(typeName); + if (m == null) { + return null; + } + return m.get(methodName + type); + } + + public DeprData getFieldDeprecated(String typeName, String fieldName) { + Map f = fields.get(typeName); + if (f == null) { + return null; + } + return f.get(fieldName); + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/DeprData.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/DeprData.java new file mode 100644 index 00000000000..7729c03d56d --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/DeprData.java @@ -0,0 +1,62 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan; + +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.TypeElement; + +/** + * A simple data class that contains language model data (TypeElement, etc.) + * about a deprecated API. + */ +public class DeprData { + final ElementKind kind; + final TypeElement type; // null if data loaded from file + final String typeName; + final String nameSig; + final String since; + final boolean forRemoval; + + public DeprData(ElementKind kind, TypeElement type, String typeName, String nameSig, + String since, boolean forRemoval) { + this.kind = kind; + this.type = type; + this.typeName = typeName; + this.nameSig = nameSig; + this.since = since; + this.forRemoval = forRemoval; + } + + public boolean isForRemoval() { + return forRemoval; + } + + @Override + public String toString() { + return String.format("DeprData(%s,%s,%s,%s,%s,%s)", + kind, type, typeName, nameSig, since, forRemoval); + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java new file mode 100644 index 00000000000..11978a22389 --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/LoadProc.java @@ -0,0 +1,206 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan; + +import java.lang.annotation.IncompleteAnnotationException; +import java.util.ArrayList; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.Messager; +import javax.annotation.processing.ProcessingEnvironment; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.annotation.processing.SupportedSourceVersion; + +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.ExecutableElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.type.ArrayType; +import javax.lang.model.type.DeclaredType; +import javax.lang.model.type.ExecutableType; +import javax.lang.model.type.TypeMirror; +import javax.lang.model.util.Elements; + +import javax.tools.Diagnostic; + +import static javax.lang.model.SourceVersion.RELEASE_9; + +/** + * Annotation processor for the Deprecation Scanner tool. + * Examines APIs for deprecated elements and records information + * + */ +@SupportedAnnotationTypes("java.lang.Deprecated") +@SupportedSourceVersion(RELEASE_9) +public class LoadProc extends AbstractProcessor { + Elements elements; + Messager messager; + final List deprList = new ArrayList<>(); + + public LoadProc() { + } + + @Override + public void init(ProcessingEnvironment pe) { + super.init(pe); + elements = pe.getElementUtils(); + messager = pe.getMessager(); + } + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) { + return false; + } + + // Assume annotations contains only @Deprecated. + // Note: no way to get deprecated packages, since + // @Deprecated is ignored in package-info.java files. + + Set set = roundEnv.getElementsAnnotatedWith(Deprecated.class); + for (Element e : set) { + ElementKind kind = e.getKind(); + Deprecated depr = e.getAnnotation(Deprecated.class); + switch (kind) { + case CLASS: + case INTERFACE: + case ENUM: + case ANNOTATION_TYPE: + addType(kind, (TypeElement)e, depr); + break; + case CONSTRUCTOR: + case ENUM_CONSTANT: + case FIELD: + case METHOD: + Element encl = e.getEnclosingElement(); + ElementKind enclKind = encl.getKind(); + switch (enclKind) { + case CLASS: + case INTERFACE: + case ENUM: + case ANNOTATION_TYPE: + String detail = getDetail(e); + addMember(kind, (TypeElement)encl, detail, depr); + break; + default: + messager.printMessage(Diagnostic.Kind.WARNING, + "element " + e + + " within unknown enclosing element " + encl + + " of kind " + enclKind, e); + break; + } + break; + default: + messager.printMessage(Diagnostic.Kind.WARNING, + "unknown element " + e + + " of kind " + kind + + " within " + e.getEnclosingElement(), e); + break; + } + } + return true; + } + + public List getDeprecations() { + return deprList; + } + + String getDetail(Element e) { + if (e.getKind().isField()) { + return e.getSimpleName().toString(); + } else { + // method or constructor + ExecutableElement ee = (ExecutableElement) e; + String ret; + ret = desc(ee.getReturnType()); + List parameterTypes = ((ExecutableType)ee.asType()).getParameterTypes(); + String parms = parameterTypes.stream() + .map(this::desc) + .collect(Collectors.joining()); + return ee.getSimpleName().toString() + "(" + parms + ")" + ret; + } + } + + String desc(TypeMirror tm) { + switch (tm.getKind()) { + case BOOLEAN: + return "Z"; + case BYTE: + return "B"; + case SHORT: + return "S"; + case CHAR: + return "C"; + case INT: + return "I"; + case LONG: + return "J"; + case FLOAT: + return "F"; + case DOUBLE: + return "D"; + case VOID: + return "V"; + case DECLARED: + String s = + ((TypeElement)((DeclaredType)tm).asElement()).getQualifiedName().toString(); + s = s.replace('.', '/'); + return "L" + s + ";"; + case ARRAY: + return "[" + desc(((ArrayType)tm).getComponentType()); + default: + return tm.getKind().toString(); + } + } + + void addType(ElementKind kind, TypeElement type, Deprecated dep) { + addData(kind, type, "", dep); + } + + void addMember(ElementKind kind, TypeElement type, String nameSig, Deprecated dep) { + addData(kind, type, nameSig, dep); + } + + void addData(ElementKind kind, TypeElement type, String nameSig, Deprecated dep) { + String typeName = elements.getBinaryName(type).toString().replace('.', '/'); + + String since = ""; + try { + since = dep.since(); + } catch (IncompleteAnnotationException ignore) { } + + boolean forRemoval = false; + try { + forRemoval = dep.forRemoval(); + } catch (IncompleteAnnotationException ignore) { } + + deprList.add(new DeprData(kind, type, typeName, nameSig, since, forRemoval)); + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java new file mode 100644 index 00000000000..28d4b33e886 --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Main.java @@ -0,0 +1,717 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan; + +import java.io.File; +import java.io.IOException; +import java.io.PrintStream; +import java.net.URI; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.FileSystems; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayDeque; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.Collection; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.NoSuchElementException; +import java.util.Set; +import java.util.Queue; +import java.util.stream.Stream; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; + +import javax.tools.Diagnostic; +import javax.tools.DiagnosticListener; +import javax.tools.JavaCompiler; +import javax.tools.JavaFileObject; +import javax.tools.StandardJavaFileManager; +import javax.tools.StandardLocation; +import javax.tools.ToolProvider; + +import com.sun.tools.javac.file.JavacFileManager; + +import com.sun.tools.jdeprscan.scan.Scan; + +import static java.util.stream.Collectors.*; + +import javax.lang.model.element.PackageElement; +import javax.lang.model.element.TypeElement; + +/** + * Deprecation Scanner tool. Loads API deprecation information from the + * JDK image, or optionally, from a jar file or class hierarchy. Then scans + * a class library for usages of those APIs. + * + * TODO: + * - audit error handling throughout, but mainly in scan package + * - handling of covariant overrides + * - handling of override of method found in multiple superinterfaces + * - convert type/method/field output to Java source like syntax, e.g. + * instead of java/lang/Runtime.runFinalizersOnExit(Z)V + * print void java.lang.Runtime.runFinalizersOnExit(boolean) + * - more example output in man page + * - more rigorous GNU style option parsing; use joptsimple? + * + * FUTURES: + * - add module support: -addmods, -modulepath, module arg + * - load deprecation declarations from a designated class library instead + * of the JDK + * - load deprecation declarations from a module + * - scan a module (but a modular jar can be treated just a like an ordinary jar) + * - multi-version jar + */ +public class Main implements DiagnosticListener { + public static Main instance; + + final PrintStream out; + final PrintStream err; + final List bootClassPath = new ArrayList<>(); + final List classPath = new ArrayList<>(); + final List systemModules = new ArrayList<>(); + final List options = new ArrayList<>(); + final List comments = new ArrayList<>(); + + // Valid releases need to match what the compiler supports. + // Keep these updated manually until there's a compiler API + // that allows querying of supported releases. + final Set releasesWithoutForRemoval = Set.of("6", "7", "8"); + final Set releasesWithForRemoval = Set.of("9"); + + final Set validReleases; + { + Set temp = new HashSet<>(releasesWithoutForRemoval); + temp.addAll(releasesWithForRemoval); + validReleases = Set.of(temp.toArray(new String[0])); + } + + boolean verbose = false; + boolean forRemoval = false; + + final JavaCompiler compiler; + final StandardJavaFileManager fm; + + List deprList; // non-null after successful load phase + + /** + * Processes a collection of class names. Names should fully qualified + * names in the form "pkg.pkg.pkg.classname". + * + * @param classNames collection of fully qualified classnames to process + * @return true for success, false for failure + * @throws IOException if an I/O error occurs + */ + boolean doClassNames(Collection classNames) throws IOException { + if (verbose) { + out.println("List of classes to process:"); + classNames.forEach(out::println); + out.println("End of class list."); + } + + // TODO: not sure this is necessary... + if (fm instanceof JavacFileManager) { + ((JavacFileManager)fm).setSymbolFileEnabled(false); + } + + fm.setLocation(StandardLocation.CLASS_PATH, classPath); + if (!bootClassPath.isEmpty()) { + fm.setLocation(StandardLocation.PLATFORM_CLASS_PATH, bootClassPath); + } + + if (!systemModules.isEmpty()) { + fm.setLocation(StandardLocation.SYSTEM_MODULES, systemModules); + } + + LoadProc proc = new LoadProc(); + JavaCompiler.CompilationTask task = + compiler.getTask(null, fm, this, options, classNames, null); + task.setProcessors(List.of(proc)); + boolean r = task.call(); + if (r) { + if (forRemoval) { + deprList = proc.getDeprecations().stream() + .filter(DeprData::isForRemoval) + .collect(toList()); + } else { + deprList = proc.getDeprecations(); + } + } + return r; + } + + /** + * Processes a stream of filenames (strings). The strings are in the + * form pkg/pkg/pkg/classname.class relative to the root of a package + * hierarchy. + * + * @param filenames a Stream of filenames to process + * @return true for success, false for failure + * @throws IOException if an I/O error occurs + */ + boolean doFileNames(Stream filenames) throws IOException { + return doClassNames( + filenames.filter(name -> name.endsWith(".class")) + .filter(name -> !name.endsWith("package-info.class")) + .filter(name -> !name.endsWith("module-info.class")) + .map(s -> s.replaceAll("\\.class$", "")) + .map(s -> s.replace('/', '.')) + .collect(toList())); + } + + /** + * Replaces all but the first occurrence of '/' with '.'. Assumes + * that the name is in the format module/pkg/pkg/classname.class. + * That is, the name should contain at least one '/' character + * separating the module name from the package-class name. + * + * @param filename the input filename + * @return the modular classname + */ + String convertModularFileName(String filename) { + int slash = filename.indexOf('/'); + return filename.substring(0, slash) + + "/" + + filename.substring(slash+1).replace('/', '.'); + } + + /** + * Processes a stream of filenames (strings) including a module prefix. + * The strings are in the form module/pkg/pkg/pkg/classname.class relative + * to the root of a directory containing modules. The strings are processed + * into module-qualified class names of the form + * "module/pkg.pkg.pkg.classname". + * + * @param filenames a Stream of filenames to process + * @return true for success, false for failure + * @throws IOException if an I/O error occurs + */ + boolean doModularFileNames(Stream filenames) throws IOException { + return doClassNames( + filenames.filter(name -> name.endsWith(".class")) + .filter(name -> !name.endsWith("package-info.class")) + .filter(name -> !name.endsWith("module-info.class")) + .map(s -> s.replaceAll("\\.class$", "")) + .map(this::convertModularFileName) + .collect(toList())); + } + + /** + * Processes named class files in the given directory. The directory + * should be the root of a package hierarchy. If classNames is + * empty, walks the directory hierarchy to find all classes. + * + * @param dirname the name of the directory to process + * @param classNames the names of classes to process + * @return true for success, false for failure + * @throws IOException if an I/O error occurs + */ + boolean processDirectory(String dirname, Collection classNames) throws IOException { + if (!Files.isDirectory(Paths.get(dirname))) { + err.printf("%s: not a directory%n", dirname); + return false; + } + + classPath.add(0, new File(dirname)); + + if (classNames.isEmpty()) { + Path base = Paths.get(dirname); + int baseCount = base.getNameCount(); + try (Stream paths = Files.walk(base)) { + Stream files = + paths.filter(p -> p.getNameCount() > baseCount) + .map(p -> p.subpath(baseCount, p.getNameCount())) + .map(Path::toString); + return doFileNames(files); + } + } else { + return doClassNames(classNames); + } + } + + /** + * Processes all class files in the given jar file. + * + * @param jarname the name of the jar file to process + * @return true for success, false for failure + * @throws IOException if an I/O error occurs + */ + boolean doJarFile(String jarname) throws IOException { + try (JarFile jf = new JarFile(jarname)) { + Stream files = + jf.stream() + .map(JarEntry::getName); + return doFileNames(files); + } + } + + /** + * Processes named class files from the given jar file, + * or all classes if classNames is empty. + * + * @param jarname the name of the jar file to process + * @param classNames the names of classes to process + * @return true for success, false for failure + * @throws IOException if an I/O error occurs + */ + boolean processJarFile(String jarname, Collection classNames) throws IOException { + classPath.add(0, new File(jarname)); + + if (classNames.isEmpty()) { + return doJarFile(jarname); + } else { + return doClassNames(classNames); + } + } + + /** + * Processes named class files from rt.jar of a JDK version 7 or 8. + * If classNames is empty, processes all classes. + * + * @param jdkHome the path to the "home" of the JDK to process + * @param classNames the names of classes to process + * @return true for success, false for failure + * @throws IOException if an I/O error occurs + */ + boolean processOldJdk(String jdkHome, Collection classNames) throws IOException { + String RTJAR = jdkHome + "/jre/lib/rt.jar"; + String CSJAR = jdkHome + "/jre/lib/charsets.jar"; + + bootClassPath.add(0, new File(RTJAR)); + bootClassPath.add(1, new File(CSJAR)); + options.add("-source"); + options.add("8"); + + if (classNames.isEmpty()) { + return doJarFile(RTJAR); + } else { + return doClassNames(classNames); + } + } + + /** + * Processes listed classes given a JDK 9 home. + */ + boolean processJdk9(String jdkHome, Collection classes) throws IOException { + systemModules.add(new File(jdkHome)); + return doClassNames(classes); + } + + /** + * Processes the class files from the currently running JDK, + * using the jrt: filesystem. + * + * @return true for success, false for failure + * @throws IOException if an I/O error occurs + */ + boolean processSelf(Collection classes) throws IOException { + options.add("-addmods"); + options.add("java.se.ee,jdk.xml.bind"); // TODO why jdk.xml.bind? + + if (classes.isEmpty()) { + Path modules = FileSystems.getFileSystem(URI.create("jrt:/")) + .getPath("/modules"); + + // names are /modules//pkg/.../Classname.class + try (Stream paths = Files.walk(modules)) { + Stream files = + paths.filter(p -> p.getNameCount() > 2) + .map(p -> p.subpath(1, p.getNameCount())) + .map(Path::toString); + return doModularFileNames(files); + } + } else { + return doClassNames(classes); + } + } + + /** + * Process classes from a particular JDK release, using only information + * in this JDK. + * + * @param release "6", "7", "8", or "9" + * @param classes collection of classes to process, may be empty + * @return success value + */ + boolean processRelease(String release, Collection classes) throws IOException { + options.addAll(List.of("-release", release)); + + if (release.equals("9")) { + List rootMods = List.of("java.se", "java.se.ee"); + TraverseProc proc = new TraverseProc(rootMods); + JavaCompiler.CompilationTask task = + compiler.getTask(null, fm, this, + // options + List.of("-addmods", String.join(",", rootMods)), + // classes + List.of("java.lang.Object"), + null); + task.setProcessors(List.of(proc)); + if (!task.call()) { + return false; + } + Map> types = proc.getPublicTypes(); + options.add("-addmods"); + options.add(String.join(",", rootMods)); + return doClassNames( + types.values().stream() + .flatMap(List::stream) + .map(TypeElement::toString) + .collect(toList())); + } else { + // TODO: kind of a hack... + // Create a throwaway compilation task with options "-release N" + // which has the side effect of setting the file manager's + // PLATFORM_CLASS_PATH to the right value. + JavaCompiler compiler = ToolProvider.getSystemJavaCompiler(); + StandardJavaFileManager fm = + compiler.getStandardFileManager(this, null, StandardCharsets.UTF_8); + JavaCompiler.CompilationTask task = + compiler.getTask(null, fm, this, List.of("-release", release), null, null); + List paths = new ArrayList<>(); + for (Path p : fm.getLocationAsPaths(StandardLocation.PLATFORM_CLASS_PATH)) { + try (Stream str = Files.walk(p)) { + str.forEachOrdered(paths::add); + } + } + + options.add("-Xlint:-options"); + + return doClassNames( + paths.stream() + .filter(path -> path.toString().endsWith(".sig")) + .map(path -> path.subpath(1, path.getNameCount())) + .map(Path::toString) + .map(s -> s.replaceAll("\\.sig$", "")) + .map(s -> s.replace('/', '.')) + .collect(toList())); + } + } + + /** + * Prints a usage message to the err stream. + */ + void usage() { + + } + + /** + * An enum denoting the mode in which the tool is running. + * Different modes correspond to the different process* methods. + * The exception is UNKNOWN, which indicates that a mode wasn't + * specified on the command line, which is an error. + */ + static enum LoadMode { + CLASSES, DIR, JAR, OLD_JDK, JDK9, SELF, RELEASE, LOAD_CSV + } + + static enum ScanMode { + ARGS, LIST, PRINT_CSV + } + + /** + * A checked exception that's thrown if a command-line syntax error + * is detected. + */ + static class UsageException extends Exception { + private static final long serialVersionUID = 3611828659572908743L; + } + + /** + * Convenience method to throw UsageException if a condition is false. + * + * @param cond the condition that's required to be true + * @throws UsageException + */ + void require(boolean cond) throws UsageException { + if (!cond) { + throw new UsageException(); + } + } + + /** + * Constructs an instance of the finder tool. + * + * @param out the stream to which the tool's output is sent + * @param err the stream to which error messages are sent + */ + Main(PrintStream out, PrintStream err) { + this.out = out; + this.err = err; + compiler = ToolProvider.getSystemJavaCompiler(); + fm = compiler.getStandardFileManager(this, null, StandardCharsets.UTF_8); + } + + /** + * Prints the diagnostic to the err stream. + * + * Specified by the DiagnosticListener interface. + * + * @param diagnostic the tool diagnostic to print + */ + @Override + public void report(Diagnostic diagnostic) { + err.println(diagnostic); + } + + /** + * Parses arguments and performs the requested processing. + * + * @param argArray command-line arguments + * @return true on success, false on error + */ + boolean run(String... argArray) { + Queue args = new ArrayDeque<>(Arrays.asList(argArray)); + LoadMode loadMode = LoadMode.RELEASE; + ScanMode scanMode = ScanMode.ARGS; + String dir = null; + String jar = null; + String jdkHome = null; + String release = "9"; + List loadClasses = new ArrayList<>(); + String csvFile = null; + + try { + while (!args.isEmpty()) { + String a = args.element(); + if (a.startsWith("-")) { + args.remove(); + switch (a) { + case "--class-path": + case "-cp": + classPath.clear(); + Arrays.stream(args.remove().split(File.pathSeparator)) + .map(File::new) + .forEachOrdered(classPath::add); + break; + case "--for-removal": + forRemoval = true; + break; + case "--full-version": + out.println(System.getProperty("java.vm.version")); + return false; + case "--help": + case "-h": + out.println(Messages.get("main.usage")); + out.println(); + out.println(Messages.get("main.help")); + return false; + case "-l": + case "--list": + require(scanMode == ScanMode.ARGS); + scanMode = ScanMode.LIST; + break; + case "--release": + loadMode = LoadMode.RELEASE; + release = args.remove(); + if (!validReleases.contains(release)) { + throw new UsageException(); + } + break; + case "-v": + case "--verbose": + verbose = true; + break; + case "--version": + out.println(System.getProperty("java.version")); + return false; + case "--Xcompiler-arg": + options.add(args.remove()); + break; + case "--Xcsv-comment": + comments.add(args.remove()); + break; + case "--Xhelp": + out.println(Messages.get("main.xhelp")); + return false; + case "--Xload-class": + loadMode = LoadMode.CLASSES; + loadClasses.add(args.remove()); + break; + case "--Xload-csv": + loadMode = LoadMode.LOAD_CSV; + csvFile = args.remove(); + break; + case "--Xload-dir": + loadMode = LoadMode.DIR; + dir = args.remove(); + break; + case "--Xload-jar": + loadMode = LoadMode.JAR; + jar = args.remove(); + break; + case "--Xload-jdk9": + loadMode = LoadMode.JDK9; + jdkHome = args.remove(); + break; + case "--Xload-old-jdk": + loadMode = LoadMode.OLD_JDK; + jdkHome = args.remove(); + break; + case "--Xload-self": + loadMode = LoadMode.SELF; + break; + case "--Xprint-csv": + require(scanMode == ScanMode.ARGS); + scanMode = ScanMode.PRINT_CSV; + break; + default: + throw new UsageException(); + } + } else { + break; + } + } + + if ((scanMode == ScanMode.ARGS) == args.isEmpty()) { + throw new UsageException(); + } + + if ( forRemoval && loadMode == LoadMode.RELEASE && + releasesWithoutForRemoval.contains(release)) { + throw new UsageException(); + } + + boolean success = false; + + switch (loadMode) { + case CLASSES: + success = doClassNames(loadClasses); + break; + case DIR: + success = processDirectory(dir, loadClasses); + break; + case JAR: + success = processJarFile(jar, loadClasses); + break; + case JDK9: + require(!args.isEmpty()); + success = processJdk9(jdkHome, loadClasses); + break; + case LOAD_CSV: + deprList = DeprDB.loadFromFile(csvFile); + success = true; + break; + case OLD_JDK: + success = processOldJdk(jdkHome, loadClasses); + break; + case RELEASE: + success = processRelease(release, loadClasses); + break; + case SELF: + success = processSelf(loadClasses); + break; + default: + throw new UsageException(); + } + + if (!success) { + return false; + } + } catch (NoSuchElementException | UsageException ex) { + err.println(Messages.get("main.usage")); + return false; + } catch (IOException ioe) { + if (verbose) { + ioe.printStackTrace(err); + } else { + err.println(ioe); + } + return false; + } + + // now the scanning phase + + switch (scanMode) { + case LIST: + for (DeprData dd : deprList) { + if (!forRemoval || dd.isForRemoval()) { + out.println(Pretty.print(dd)); + } + } + break; + case PRINT_CSV: + out.println("#jdepr1"); + comments.forEach(s -> out.println("# " + s)); + for (DeprData dd : deprList) { + CSV.write(out, dd.kind, dd.typeName, dd.nameSig, dd.since, dd.forRemoval); + } + break; + case ARGS: + DeprDB db = DeprDB.loadFromList(deprList); + List cp = classPath.stream() + .map(File::toString) + .collect(toList()); + Scan scan = new Scan(out, err, cp, db, verbose); + + for (String a : args) { + boolean success; + + if (a.endsWith(".jar")) { + success = scan.scanJar(a); + } else if (Files.isDirectory(Paths.get(a))) { + success = scan.scanDir(a); + } else { + success = scan.processClassName(a.replace('.', '/')); + } + + if (!success) { + return false; + } + } + break; + } + + return true; + } + + /** + * Programmatic main entry point: initializes the tool instance to + * use stdout and stderr; runs the tool, passing command-line args; + * returns an exit status. + * + * @return true on success, false otherwise + */ + public static boolean call(PrintStream out, PrintStream err, String... args) { + try { + instance = new Main(out, err); + return instance.run(args); + } finally { + instance = null; + } + } + + /** + * Calls the main entry point and exits the JVM with an exit + * status determined by the return status. + */ + public static void main(String[] args) { + System.exit(call(System.out, System.err, args) ? 0 : 1); + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Messages.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Messages.java new file mode 100644 index 00000000000..bd904b053e2 --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Messages.java @@ -0,0 +1,55 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan; + +import java.text.MessageFormat; +import java.util.Locale; +import java.util.MissingResourceException; +import java.util.ResourceBundle; + +/** + * Message handling class for localization. + */ +public class Messages { + static final ResourceBundle bundle; + + static { + Locale locale = Locale.getDefault(); + try { + bundle = ResourceBundle.getBundle("com.sun.tools.jdeprscan.resources.jdeprscan", locale); + } catch (MissingResourceException e) { + throw new InternalError("Cannot find jdeps resource bundle for locale " + locale, e); + } + } + + public static String get(String key, Object... args) { + try { + return MessageFormat.format(bundle.getString(key), args); + } catch (MissingResourceException e) { + throw new InternalError("Missing message: " + key, e); + } + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Pretty.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Pretty.java new file mode 100644 index 00000000000..7258449f41f --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/Pretty.java @@ -0,0 +1,274 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan; + +import java.util.regex.Matcher; +import java.util.regex.Pattern; + +/** + * Utility class for pretty-printing various bits of API syntax. + */ +public class Pretty { + /** + * Converts deprecation information into an {@code @Deprecated} annotation. + * The output is minimized: an empty since string is omitted, a forRemoval + * value of false is omitted; and if both are omitted, the trailing parentheses + * are also omitted. + * + * @param since the since value + * @param forRemoval the forRemoval value + * @return string containing an annotation + */ + static String depr(String since, boolean forRemoval) { + String d = "@Deprecated"; + + if (since.isEmpty() && !forRemoval) { + return d; + } + + StringBuilder sb = new StringBuilder(d).append('('); + + if (!since.isEmpty()) { + sb.append("since=\"") + .append(since.replace("\"", "\\\"")) + .append('"'); + } + + if (forRemoval) { + if (!since.isEmpty()) { + sb.append(", "); + } + sb.append("forRemoval=true"); + } + + sb.append(')'); + + return sb.toString(); + } + + /** + * Converts a slash-$ style name into a dot-separated name. + * + * @param n the input name + * @return the result name + */ + static String unslashify(String n) { + return n.replace("/", ".") + .replace("$", "."); + } + + /** + * Converts a type descriptor to a readable string. + * + * @param desc the input descriptor + * @return the result string + */ + static String desc(String desc) { + return desc(desc, new int[] { 0 }); + } + + /** + * Converts one type descriptor to a readable string, starting + * from position {@code pos_inout[0]}, and updating it to the + * location following the descriptor just parsed. A type descriptor + * mostly corresponds to a FieldType in JVMS 4.3.2. It can be one of a + * BaseType (a single character denoting a primitive, plus void), + * an object type ("Lname;"), or an array type (one more more '[' followed + * by a base or object type). + * + * @param desc a string possibly containing several descriptors + * @param pos_inout on input, the start position; on return, the position + * following the just-parsed descriptor + * @return the result string + */ + static String desc(String desc, int[] pos_inout) { + int dims = 0; + int pos = pos_inout[0]; + final int len = desc.length(); + + while (pos < len && desc.charAt(pos) == '[') { + pos++; + dims++; + } + + String name; + + if (pos >= len) { + return null; + } + + char c = desc.charAt(pos++); + switch (c) { + case 'Z': + name = "boolean"; + break; + case 'B': + name = "byte"; + break; + case 'S': + name = "short"; + break; + case 'C': + name = "char"; + break; + case 'I': + name = "int"; + break; + case 'J': + name = "long"; + break; + case 'F': + name = "float"; + break; + case 'D': + name = "double"; + break; + case 'V': + name = "void"; + break; + case 'L': + int semi = desc.indexOf(';', pos); + if (semi == -1) { + return null; + } + name = unslashify(desc.substring(pos, semi)); + pos = semi + 1; + break; + default: + return null; + } + + StringBuilder sb = new StringBuilder(name); + for (int i = 0; i < dims; i++) { + sb.append("[]"); + } + pos_inout[0] = pos; + return sb.toString(); + } + + /** + * Converts a series of type descriptors into a comma-separated, + * readable string. This is used for the parameter types of a + * method descriptor. + * + * @param types the parameter types + * @return the readable string + */ + static String parms(String types) { + int[] pos = new int[] { 0 }; + StringBuilder sb = new StringBuilder(); + + boolean first = true; + + String t; + + while ((t = desc(types, pos)) != null) { + if (first) { + first = false; + } else { + sb.append(','); + } + sb.append(t); + } + + return sb.toString(); + } + + /** + * Pattern for matching a method descriptor. Match results can + * be retrieved from named capture groups as follows: "name(params)return". + */ + static final Pattern DESC_PAT = Pattern.compile("(?.*)\\((?.*)\\)(?.*)"); + + /** + * Pretty-prints the data contained in the given DeprData object. + * + * @param dd the deprecation data object + * @return the formatted string + */ + public static String print(DeprData dd) { + StringBuilder sb = new StringBuilder(); + sb.append(depr(dd.since, dd.forRemoval)) + .append(' '); + + switch (dd.kind) { + case ANNOTATION_TYPE: + sb.append("@interface "); + sb.append(unslashify(dd.typeName)); + break; + case CLASS: + sb.append("class "); + sb.append(unslashify(dd.typeName)); + break; + case ENUM: + sb.append("enum "); + sb.append(unslashify(dd.typeName)); + break; + case INTERFACE: + sb.append("interface "); + sb.append(unslashify(dd.typeName)); + break; + + case ENUM_CONSTANT: + case FIELD: + sb.append(unslashify(dd.typeName)) + .append('.') + .append(dd.nameSig); + break; + case CONSTRUCTOR: + Matcher cons = DESC_PAT.matcher(dd.nameSig); + sb.append(unslashify(dd.typeName)); + if (cons.matches()) { + sb.append('(') + .append(parms(cons.group("args"))) + .append(')'); + } else { + sb.append('.') + .append(dd.nameSig); + } + break; + case METHOD: + Matcher meth = DESC_PAT.matcher(dd.nameSig); + if (meth.matches()) { + sb.append(desc(meth.group("return"))) + .append(' ') + .append(unslashify(dd.typeName)) + .append('.') + .append(meth.group("name")) + .append('(') + .append(parms(meth.group("args"))) + .append(')'); + } else { + sb.append(unslashify(dd.typeName)) + .append('.') + .append(dd.nameSig); + } + break; + } + + return sb.toString(); + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java new file mode 100644 index 00000000000..0b65d9f8762 --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/TraverseProc.java @@ -0,0 +1,172 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan; + +import java.util.ArrayList; +import java.util.Collection; +import java.util.Comparator; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; + +import javax.annotation.processing.AbstractProcessor; +import javax.annotation.processing.Messager; +import javax.annotation.processing.ProcessingEnvironment; +import javax.annotation.processing.RoundEnvironment; +import javax.annotation.processing.SupportedAnnotationTypes; +import javax.annotation.processing.SupportedSourceVersion; + +import javax.lang.model.element.ModuleElement; +import javax.lang.model.element.TypeElement; +import javax.lang.model.util.Elements; + +import static javax.lang.model.SourceVersion.RELEASE_9; +import javax.lang.model.element.Element; +import javax.lang.model.element.ElementKind; +import javax.lang.model.element.Modifier; +import javax.lang.model.element.PackageElement; +import javax.tools.Diagnostic; + +@SupportedSourceVersion(RELEASE_9) +@SupportedAnnotationTypes("*") +public class TraverseProc extends AbstractProcessor { + Elements elements; + Messager messager; + final List moduleRoots; + Map> publicTypes; + + TraverseProc(List roots) { + moduleRoots = roots; + } + + @Override + public void init(ProcessingEnvironment pe) { + super.init(pe); + elements = pe.getElementUtils(); + messager = pe.getMessager(); + } + + @Override + public boolean process(Set annotations, RoundEnvironment roundEnv) { + if (roundEnv.processingOver()) { + return false; + } + + Set modules = new HashSet<>(); + for (String mname : moduleRoots) { + ModuleElement me = elements.getModuleElement(mname); + if (me == null) { + messager.printMessage(Diagnostic.Kind.ERROR, + String.format("module %s not found%n", mname)); + } else { + modules.addAll(findModules(me)); + } + } + + Set packages = findPackages(modules); + + publicTypes = findPublicTypes(packages); + + return true; + } + + void printPublicTypes() { + printPublicTypes(publicTypes); + } + + public Map> getPublicTypes() { + return publicTypes; + } + + void printPublicTypes(Map> types) { + System.out.println("All public types:"); + types.entrySet().stream() + .sorted(Comparator.comparing(e -> e.getKey().toString())) + .forEach(e -> { + System.out.println(" " + e.getKey()); + e.getValue().stream() + .sorted(Comparator.comparing(TypeElement::toString)) + .forEach(t -> System.out.println(" " + t)); + }); + System.out.println(); + System.out.flush(); + } + + Set findModules(ModuleElement root) { + return findModules0(root, new HashSet<>(), 0); + } + + Set findModules0(ModuleElement m, Set set, int nesting) { + set.add(m); + for (ModuleElement.Directive dir : m.getDirectives()) { + if (dir.getKind() == ModuleElement.DirectiveKind.REQUIRES) { + ModuleElement.RequiresDirective req = (ModuleElement.RequiresDirective)dir; + findModules0(req.getDependency(), set, nesting + 1); + } + } + return set; + } + + Set findPackages(Collection mods) { + Set set = new HashSet<>(); + for (ModuleElement m : mods) { + for (ModuleElement.Directive dir : m.getDirectives()) { + if (dir.getKind() == ModuleElement.DirectiveKind.EXPORTS) { + ModuleElement.ExportsDirective exp = (ModuleElement.ExportsDirective)dir; + if (exp.getTargetModules() == null) { + set.add(exp.getPackage()); + } + } + } + } + return set; + } + + Map> findPublicTypes(Collection pkgs) { + Map> map = new HashMap<>(); + for (PackageElement pkg : pkgs) { + List enclosed = new ArrayList<>(); + for (Element e : pkg.getEnclosedElements()) { + addPublicTypes(enclosed, e); + } + map.put(pkg, enclosed); + } + return map; + } + + void addPublicTypes(List list, Element e) { + ElementKind kind = e.getKind(); + if ((kind.isClass() || kind.isInterface()) + && e.getModifiers().contains(Modifier.PUBLIC)) { + list.add((TypeElement)e); + for (Element enc : e.getEnclosedElements()) { + addPublicTypes(list, enc); + } + } + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/internals.md b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/internals.md new file mode 100644 index 00000000000..7e5fc529686 --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/internals.md @@ -0,0 +1,215 @@ + + + +JDeprScan Internals +----- + +**EXPERIMENTAL OPTIONS** + + --Xload-class CLASSNAME + + Loads deprecation data from the class named CLASSNAME instead of from + the JDK image. + + --Xload-csv CVSFILE + + Loads deprecation data from file CSVFILE. + + --Xload-dir DIR + + Loads deprecation data from the class hierarchy rooted + at the directory named DIR. + + --Xload-jar JARFILE + + Loads deprecation data from the classes contained in the + jar file named JARFILE. + + --Xload-jdk9 JAVA_HOME + + Loads deprecation data from a modular JDK whose home + directory is at JAVA_HOME. This essentially adds the given + path to the system-modules location. + + --Xload-old-jdk JAVA_HOME + + Loads deprecation data from an old (non-modular) JDK whose + home directory is at JAVA_HOME. This essentially scans the + rt.jar file from that JDK. + + --Xload-self + + Loads deprecation data from the running JDK image by + traversing the entire jrt: filesystem. This differs from + -release 9, which traverses modules, packages, and classes by + starting from a set of root modules and using javax.lang.model + mechanisms (as opposed to filesystem mechanisms) for + traversing contained elements recursively. + + --Xcompiler-arg ARG + + Adds ARG to the list of arguments passed to the compiler. + + --Xcsv-comment COMMENT + + Adds a comment line containing COMMENT to the top of the CSV + that is emitted. Valid only when --Xprint-csv is + specified. More than one --Xcsv-comment option is permitted, + which will cause a corresponding number of comment lines to be + emitted to the CSV file. + + --Xprint-csv + + Prints out the loaded deprecation information in CSV format + to standard output. In this mode, no scanning is done, so + there must not be any additional directory, jar, or classname + arguments. + +**CSV FILE SYNTAX** + +The `-Xprint-csv` option causes **jdeprscan** to emit the loaded +deprecation data in CSV (comma-separated value) format. The general +syntax of CSV is documented in [RFC 4180][RFC] with supplemental +information in a [Wikipedia article][wiki]. + +The file is encoded in UTF-8. + +The file consists of a series of lines. Any of the standard line +separators CR (U+000D), LF (U+000A), or a CR immediately followed by +LF, are supported. Newlines are only supported between records and +are not supported within field values. + +Comment lines start with a `#` (U+0023) character in the first +column. The entire line is ignored up until the next line separator +sequence. + +Each line is divided into fields separated by the comma `,` (U+002C) +character. Horizontal whitespace is not treated specially; that is, +it is considered part of a field's value. An empty line is considered +to have one field which is the empty string. + +A field value that contains a comma or a quote quotation mark `"` +(U+0022) must be surrounded by quotation marks. The surrounding +quotation marks are not considered part of the field value. Any +quotation marks that are part of a field value must be repeated in +addition to being surrounded by quotation marks. + +It is a syntax error if a quotation mark appears within an unquoted field; +if a quoted field isn't immediately followed by a comma or line +separator; or if a quoted field is left unclosed at the end of the line. + +For example, a record with the following four fields: + +1. abcd +2. ef,gh +3. ij"kl +4. mnop + +would be encoded as follows: + + abcd,"ef,gh","ij""kl",mnop + +**CSV FILE DATA** + +The first line of output must be the following: + + #jdepr1 + +This is strictly a comment line, but it serves as a file +identifier. The "1" indicates version 1 of this file. + +Zero or more comment lines follow, containing text that is specified +by the `-Xcsv-comment` options. + +Subsequent non-comment lines must have the following five fields: + + kind,typeName,descOrName,since,forRemoval + +Fields are defined as follows: + + * _kind_ - one of CONSTRUCTOR, FIELD, METHOD, ENUM\_CONSTANT, + CLASS, INTERFACE, ENUM, or ANNOTATION\_TYPE. These correspond to + enumeration constants from the `javax.lang.model.element.ElementKind` + enum. + + * _typeName_ - the fully qualified name of the type (if *kind* is + CLASS, INTERFACE, ENUM, or ANNOTATION\_TYPE) or of the enclosing + type (if _kind_ is CONSTRUCTOR, FIELD, METHOD, or + ENUM\_CONSTANT). This value is a _binary name_ [JLS 13.1][jls131] + using a slash character `/` (U+002F) to separate package and + top-level name components, and a dollar sign `$` (U+0024) to + separate nested name components. For example, the `Thread.State` + enum that appears in Java SE would have the following typeName: + + java/lang/Thread$State + + * _descOrName_ - if _kind_ is METHOD or CONSTRUCTOR, this is the method's + or constructor's descriptor [JVMS 4.3.3][jvms433]; if _kind_ is FIELD or + ENUM\_CONSTANT, this is its name; otherwise this field is empty. + A method's descriptor includes its name, parameter types, and return + type. For example, the method + + public void String.getBytes(int srcBegin, + int srcEnd, + byte[] dst, + int dstBegin) + + has the descriptor + + getBytes(II[BI)V + + * _since_ - the value of the `since` element of the `@Deprecated` + annotation, or empty if this element is not present. + + * _forRemoval_ - the value of the `forRemoval` element of the + `@Deprecated` annotation, a boolean, either "true" or "false". + +Note that the _since_ field can have arbitrary text (excluding +line separators) and is thus subject to quoting. + +**EXAMPLE OUTPUT** + +Given the following method declaration and annotation from the +`java.lang.Runtime` class, + + @Deprecated(since="1.2", + forRemoval=true) + public static void runFinalizersOnExit(boolean value) + +the following line will be emitted from **jdeprscan -Xprint-csv**: + + METHOD,java/lang/Runtime,runFinalizersOnExit(Z)V,1.2,true + + +[RFC]: https://www.ietf.org/rfc/rfc4180.txt + +[wiki]: https://en.wikipedia.org/wiki/Comma-separated_values + +[jls131]: http://docs.oracle.com/javase/specs/jls/se8/html/jls-13.html#jls-13.1 + +[jvms433]: http://docs.oracle.com/javase/specs/jvms/se8/html/jvms-4.html#jvms-4.3.3 diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md new file mode 100644 index 00000000000..f51a1ea0c9b --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/readme.md @@ -0,0 +1,180 @@ + + + +JDeprScan Tool Command Reference +----- + +**NAME** + + jdeprscan - Java deprecation scanner + +**SYNOPSIS** + + jdeprscan [options] {dir | jar | class} ... + +**OPTIONS** + + -cp PATH + --class-path PATH + + Sets the classpath to PATH. + + --for-removal + + Limit reporting to deprecations whose forRemoval element + is true. + + --full-version + + Prints the full version string of the tool and exits. + + -h + --help + + Prints a help message and exits. + + -l + --list + + Prints out the set of deprecated APIs. + + --release 6|7|8|9 + + Specifies the Java SE release that is the source of + the list of deprecated APIs. If no --release option is + provided, the latest release is used. + + -v + --verbose + + Enables additional output. + + --version + + Prints the version string of the tool and exits. + +**DESCRIPTION** + +**jdeprscan** scans a class library for uses of deprecated APIs. +**jdeprscan** processes one or more arguments, which can be any +combination of a directory, a jar file, or a class name. + +A directory argument must specify a path to a directory hierarchy that +reflects the Java package hierarchy of the classes it contains. +**jdeprscan** will scan each class found in the directory hierarchy +and report information about how those classes use deprecated APIs. + +Given a jar file, **jdeprscan** will scan the classes found within +that jar file and report information about how those classes use +deprecated APIs. + +Given a class name, **jdeprscan** will search for that class on the +classpath, scan that class, and report information about how that +class uses deprecated APIs. The class name must use the fully +qualified binary name of the class, as described in the +[Java Language Specification, section 13.1][jls131]. This form uses +the '$' character instead of '.' as the separator for nested class names. +For example, the `Thread.State` enum would be specified using the string + + java.lang.Thread$State + +The `--class-path` and `-cp` options specify the classpath used for +class searching. The classpath is used for classes named on the +command line, as well as for dependencies of the classes in jar file +or directory hierarchy to be scanned. + +The `--for-removal` option limits output to uses of deprecated APIs +whose `@Deprecated` annotation includes the `forRemoval` element with +the value `true`. Note: the `forRemoval` attribute of the +`@Deprecated` annotation did not exist prior to Java SE 9, so this +option cannot be used with a release value of 6, 7, or 8. + +The `--release` option specifies the Java SE specification version +that determines the set of deprecated APIs for which scanning is +done. This is useful if a deprecation report is desired that lists +uses of deprecated APIs as of a particular release in the past. If no +`--release` option is given, the latest release is used. + +The `--list` and `-l` options will list the known set of deprecated +APIs instead of doing any scanning. Since no scanning is done, +no directory, jar, or class arguments should be provided. The set +of deprecated APIs listed is affected by the `--release` and the +`--for-removal` options. + + +**EXAMPLE OUTPUT** + +The output is a report that lists program elements that use deprecated +APIs. Output is subject to change. + +Consider the following declarations from Java SE 9: + + // java.lang.Boolean + + @Deprecated(since="9") + public Boolean(boolean value) + + // java.lang.Runtime + + @Deprecated(since="1.2", forRemoval=true) + public static void runFinalizersOnExit(boolean value) + +Running **jdeprscan** over a class that calls these methods will result +in output something like the following: + + class Example uses method java/lang/Boolean.(Z)V deprecated + class Example uses method java/lang/Runtime.runFinalizersOnExit(Z)V deprecated for removal + +Running **jdeprscan** with the `--list` option will result in output +including something like the following: + + ... + @Deprecated(since="9") java.lang.Boolean(boolean) + @Deprecated(since="1.2", forRemoval=true) void java.lang.Runtime.runFinalizersOnExit(boolean) + ... + +**NOTES** + +The **jdeprscan** tool operates by opening Java class files and +reading their structures directly, particularly the constant +pool. Because of this, **jdeprscan** can tell _that_ a deprecated API +is used, but it often cannot tell _where_ in the class that API is +used. + +The **jdeprscan** tool doesn't follow the same set of rules for +emitting warnings as specified for Java compilers in [JLS section +9.6.4.6][jls9646]. In particular, **jdeprscan** does not respond to +the `@SuppressWarnings` annotation, as that is significant only in +source code, not in class files. In addition, **jdeprscan** emits +warnings even if the usage is within the API element that is +deprecated and when the use and declaration are within the same +outermost class. + +[jls9646]: http://docs.oracle.com/javase/specs/jls/se8/html/jls-9.html#jls-9.6.4.6 + +[jls131]: http://docs.oracle.com/javase/specs/jls/se8/html/jls-13.html#jls-13.1 diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties new file mode 100644 index 00000000000..fd92fe813ee --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/resources/jdeprscan.properties @@ -0,0 +1,96 @@ +main.usage=\ +Usage: jdeprscan [options] '{dir|jar|class}' ...\n\ +\n\ +options:\n\ +\ -cp --class-path PATH\n\ +\ --for-removal\n\ +\ --full-version\n\ +\ -h --help\n\ +\ -l --list\n\ +\ --release 6|7|8|9\n\ +\ -v --verbose\n\ +\ --version + +main.help=\ +Scans each argument for usages of deprecated APIs. An argument\n\ +may be a directory specifying the root of a package hierarchy,\n\ +a JAR file, or a class name. The class name must be specified\n\ +using a fully qualified class name using the $ separator character\n\ +for nested classes, for example,\n\ +\n\ +\ java.lang.Thread$State\n\ +\n\ +The --class-path (-cp) option provides a search path for resolution\n\ +of dependent classes.\n\ +\n\ +The --for-removal option limits scanning or listing to APIs that are\n\ +deprecated for removal. Cannot be used with a release value of 6, 7, or 8.\n\ +\n\ +The --full-version option prints out the full version string of the tool.\n\ +\n\ +The --help option prints out a full help message.\n\ +\n\ +The --list (-l) option prints out the set of deprecated APIs. No scanning is done,\n\ +so no directory, jar, or class arguments should be provided.\n\ +\n\ +The --release option specifies the Java SE release that provides the set\n\ +of deprecated APIs for scanning.\n\ +\n\ +The --verbose (-v) option enables additional message output during processing.\n\ +\n\ +The --version option prints out the abbreviated version string of the tool. + +main.xhelp=\ +Unsupported options:\n\ +\n\ +\ --Xload-class CLASS\n\ +\ Loads deprecation information from the named class.\n\ +\ --Xload-csv CSVFILE\n\ +\ Loads deprecation information from the named CSV file.\n\ +\ --Xload-dir DIR\n\ +\ Loads deprecation information from the class hierarchy\n\ +\ at the named directory.\n\ +\ --Xload-jar JARFILE\n\ +\ Loads deprecation information from the named JAR file.\n\ +\ --Xload-jdk9 JAVA_HOME\n\ +\ Loads deprecation information from the JDK located at\n\ +\ JAVA_HOME, which must be a modular JDK.\n\ +\ --Xload-old-jdk JAVA_HOME\n\ +\ Loads deprecation information from the JDK located at\n\ +\ JAVA_HOME, which must not be a modular JDK. Instead, the\n\ +\ named JDK must be a "classic" JDK with an rt.jar file.\n\ +\ --Xload-self\n\ +\ Loads deprecation information by traversing the jrt:\n\ +\ filesystem of the running JDK image.\n\ +\ --Xcompiler-arg ARG\n\ +\ Adds ARG to the list of compiler arguments.\n\ +\ --Xcsv-comment COMMENT\n\ +\ Adds COMMENT as a comment line to the output CSV file.\n\ +\ Only effective if -Xprint-csv is also supplied.\n\ +\ --Xhelp\n\ +\ Prints this message.\n\ +\ --Xprint-csv\n\ +\ Prints a CSV file containing the loaded deprecation information\n\ +\ instead of scanning any classes or JAR files. + +error.prefix=Error: + +scan.process.class=Processing class {0}... + +scan.dep.normal=deprecated +scan.dep.removal=deprecated FOR REMOVAL + +scan.out.extends={0} {1} extends class {2} {3} +scan.out.implements={0} {1} implements interface {2} {3} +scan.out.usestype={0} {1} uses type {2} {3} +scan.out.usesmethodintype={0} {1} uses method in type {2} {3} +scan.out.usesmethod={0} {1} uses method {2} {3} {4} {5} +scan.out.usesintfmethodintype={0} {1} uses interface method in type {2} {3} +scan.out.usesintfmethod={0} {1} uses interface method {2} {3} {4} {5} +scan.out.usesfieldintype={0} {1} uses field in type {2} {3} +scan.out.usesfield={0} {1} uses field {2} {3} {4} +scan.out.usesfieldoftype={0} {1} uses field of type {2} {3} {4} {5} +scan.out.hasfield={0} {1} has field {2} of type {3} {4} +scan.out.methodparmtype={0} {1} method {2} has parameter type {3} {4} +scan.out.methodrettype={0} {1} method {2} has return type {3} {4} +scan.out.methodoverride={0} {1} overrides method {2} {3} {4} {5} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/CPEntries.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/CPEntries.java new file mode 100644 index 00000000000..8314a2b608a --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/CPEntries.java @@ -0,0 +1,76 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan.scan; + +import java.util.ArrayList; +import java.util.Formatter; +import java.util.List; +import java.util.Locale; + +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.ConstantPool; + +import static com.sun.tools.classfile.ConstantPool.CPInfo; + +/** + * A container for selected constant pool entries. There are currently + * lists that contain the following types of CP entries: + * + * - CONSTANT_Class_info + * - CONSTANT_Fieldref_info + * - CONSTANT_Methodref_info + * - CONSTANT_InterfaceMethodref_info + */ +class CPEntries { + final List classes = new ArrayList<>(); + final List fieldRefs = new ArrayList<>(); + final List methodRefs = new ArrayList<>(); + final List intfMethodRefs = new ArrayList<>(); + + public static CPEntries loadFrom(ClassFile cf) { + CPEntries entries = new CPEntries(); + for (CPInfo cpi : cf.constant_pool.entries()) { + cpi.accept(new CPSelector(), entries); + } + return entries; + } + + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + Formatter f = new Formatter(sb, Locale.getDefault()); + f.format("Classes:%n"); + f.format("%s%n", classes); + f.format("FieldRefs:%n"); + f.format("%s%n", fieldRefs); + f.format("MethodRefs:%n"); + f.format("%s%n", methodRefs); + f.format("InterfaceMethodRefs:%n"); + f.format("%s%n", intfMethodRefs); + f.flush(); + return sb.toString(); + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/CPSelector.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/CPSelector.java new file mode 100644 index 00000000000..a9d2afe4d2b --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/CPSelector.java @@ -0,0 +1,108 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan.scan; + +import com.sun.tools.classfile.ConstantPool; + +/** + * A visitor that selects constant pool entries by type and adds + * them to the given CPEntries object. + */ +class CPSelector implements ConstantPool.Visitor { + @Override + public Void visitClass(ConstantPool.CONSTANT_Class_info info, CPEntries p) { + p.classes.add(info); + return null; + } + + @Override + public Void visitDouble(ConstantPool.CONSTANT_Double_info info, CPEntries p) { + return null; + } + + @Override + public Void visitFieldref(ConstantPool.CONSTANT_Fieldref_info info, CPEntries p) { + p.fieldRefs.add(info); + return null; + } + + @Override + public Void visitFloat(ConstantPool.CONSTANT_Float_info info, CPEntries p) { + return null; + } + + @Override + public Void visitInteger(ConstantPool.CONSTANT_Integer_info info, CPEntries p) { + return null; + } + + @Override + public Void visitInterfaceMethodref(ConstantPool.CONSTANT_InterfaceMethodref_info info, CPEntries p) { + p.intfMethodRefs.add(info); + return null; + } + + @Override + public Void visitInvokeDynamic(ConstantPool.CONSTANT_InvokeDynamic_info info, CPEntries p) { + return null; + } + + @Override + public Void visitLong(ConstantPool.CONSTANT_Long_info info, CPEntries p) { + return null; + } + + @Override + public Void visitNameAndType(ConstantPool.CONSTANT_NameAndType_info info, CPEntries p) { + return null; + } + + @Override + public Void visitMethodref(ConstantPool.CONSTANT_Methodref_info info, CPEntries p) { + p.methodRefs.add(info); + return null; + } + + @Override + public Void visitMethodHandle(ConstantPool.CONSTANT_MethodHandle_info info, CPEntries p) { + return null; + } + + @Override + public Void visitMethodType(ConstantPool.CONSTANT_MethodType_info info, CPEntries p) { + return null; + } + + @Override + public Void visitString(ConstantPool.CONSTANT_String_info info, CPEntries p) { + return null; + } + + @Override + public Void visitUtf8(ConstantPool.CONSTANT_Utf8_info info, CPEntries p) { + return null; + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/ClassFinder.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/ClassFinder.java new file mode 100644 index 00000000000..ebb847bbe99 --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/ClassFinder.java @@ -0,0 +1,211 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan.scan; + +import com.sun.tools.classfile.ClassFile; +import com.sun.tools.classfile.ConstantPoolException; + +import java.io.IOException; +import java.net.URI; +import java.nio.file.FileSystem; +import java.nio.file.FileSystems; +import java.nio.file.Files; +import java.nio.file.NoSuchFileException; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayList; +import java.util.List; +import java.util.Optional; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.stream.Stream; + +/** + * A simple search path for classes. + */ +public class ClassFinder { + final List list = new ArrayList<>(); + final boolean verbose; + + public ClassFinder(boolean verbose) { + this.verbose = verbose; + } + + /** + * Adds a directory to this finder's search path, ignoring errors. + * + * @param dirName the directory to add + */ + public void addDir(String dirName) { + Path dir = Paths.get(dirName); + + if (Files.isDirectory(dir)) { + list.add(new DirPathEntry(dir)); + } + } + + /** + * Adds a jar file to this finder's search path, ignoring errors. + * + * @param jarName the jar file name to add + */ + public void addJar(String jarName) { + try { + list.add(new JarPathEntry(new JarFile(jarName))); + } catch (IOException ignore) { } + } + + /** + * Adds the JRT filesystem to this finder's search path. + */ + public void addJrt() { + list.add(new JrtPathEntry()); + } + + /** + * Searches the class path for a class with the given name, + * returning a ClassFile for it. Returns null if not found. + * + * @param className the class to search for + * @return a ClassFile instance, or null if not found + */ + public ClassFile find(String className) { + for (PathEntry pe : list) { + ClassFile cf = pe.find(className); + if (cf != null) { + return cf; + } + } + return null; + } + + /** + * An entry in this finder's class path. + */ + interface PathEntry { + /** + * Returns a ClassFile instance corresponding to this name, + * or null if it's not present in this entry. + * + * @param className the class to search for + * @return a ClassFile instance, or null if not found + */ + ClassFile find(String className); + } + + /** + * An entry that represents a jar file. + */ + class JarPathEntry implements PathEntry { + final JarFile jarFile; + + JarPathEntry(JarFile jf) { + jarFile = jf; + } + + @Override + public ClassFile find(String className) { + JarEntry entry = jarFile.getJarEntry(className + ".class"); + if (entry == null) { + return null; + } + try { + return ClassFile.read(jarFile.getInputStream(entry)); + } catch (IOException | ConstantPoolException ex) { + if (verbose) { + ex.printStackTrace(); + } + } + return null; + } + } + + /** + * An entry that represents a directory containing a class hierarchy. + */ + class DirPathEntry implements PathEntry { + final Path dir; + + DirPathEntry(Path dir) { + this.dir = dir; + } + + @Override + public ClassFile find(String className) { + Path classFileName = dir.resolve(className + ".class"); + try { + return ClassFile.read(classFileName); + } catch (NoSuchFileException nsfe) { + // not found, return silently + } catch (IOException | ConstantPoolException ex) { + if (verbose) { + ex.printStackTrace(); + } + } + return null; + } + } + + /** + * An entry that represents the JRT filesystem in the running image. + * + * JRT filesystem structure is: + * /packages// + * where modlink is a symbolic link to /modules/ which is + * the top of the usual package-class hierarchy + */ + class JrtPathEntry implements PathEntry { + final FileSystem fs = FileSystems.getFileSystem(URI.create("jrt:/")); + + @Override + public ClassFile find(String className) { + int end = className.lastIndexOf('/'); + if (end < 0) { + return null; + } + String pkg = "/packages/" + className.substring(0, end) + .replace('/', '.'); + try (Stream mods = Files.list(fs.getPath(pkg))) { + Optional opath = + mods.map(path -> path.resolve(className + ".class")) + .filter(Files::exists) + .findFirst(); + if (opath.isPresent()) { + return ClassFile.read(opath.get()); + } else { + return null; + } + } catch (NoSuchFileException nsfe) { + // not found, return silently + } catch (IOException | ConstantPoolException ex) { + if (verbose) { + ex.printStackTrace(); + } + } + return null; + } + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/MethodSig.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/MethodSig.java new file mode 100644 index 00000000000..723b489f727 --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/MethodSig.java @@ -0,0 +1,167 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan.scan; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +/** + * Represents a method's signature, that is, its parameter types + * and its return type. + */ +public class MethodSig { + final List parameters; + final String returnType; + + /** + * Parses the method descriptor and returns a MethodSig instance. + * + * @param desc the descriptor to parse + * @return the new MethodSig instance + */ + public static MethodSig fromDesc(String desc) { + return parse(desc, 0, desc.length()); + } + + /** + * Returns this method's return type. + * + * @return the return type + */ + public String getReturnType() { + return returnType; + } + + /** + * Returns a list of parameters of this method. + * + * @return the parameter list + */ + public List getParameters() { + return parameters; + } + + /** + * Returns a string describing this method. + * + * @return the string description + */ + @Override + public String toString() { + StringBuilder sb = new StringBuilder(); + sb.append("parameters"); + if (parameters.isEmpty()) { + sb.append(" none"); + } else { + int i = 0; + for (String p : parameters) { + sb.append(String.format(" %d=%s", i++, p)); + } + } + sb.append(String.format(" return %s", returnType)); + return sb.toString(); + } + + private MethodSig(List parameters, String returnType) { + this.parameters = Collections.unmodifiableList(parameters); + this.returnType = returnType; + } + + private static IllegalArgumentException ex(String desc, int pos) { + return new IllegalArgumentException(String.format( + "illegal descriptor \"%s\" at position %d", desc, pos)); + } + + private static MethodSig parse(String desc, int start, int end) + throws IllegalArgumentException { + int p = start; + int dims = 0; + boolean inReturnType = false; + String returnType = null; + List parameters = new ArrayList<>(); + + while (p < end) { + String type; + char ch; + switch (ch = desc.charAt(p)) { + case '(': + p++; + continue; + + case ')': + p++; + inReturnType = true; + continue; + + case '[': + p++; + dims++; + continue; + + case 'B': // byte + case 'C': // char + case 'D': // double + case 'F': // float + case 'I': // int + case 'J': // long + case 'S': // short + case 'Z': // boolean + case 'V': // void + type = Character.toString(ch); + p++; + break; + + case 'L': + int sep = desc.indexOf(';', p); + if (sep == -1 || sep >= end) + throw ex(desc, p); + type = desc.substring(p, ++sep); + p = sep; + break; + + default: + throw ex(desc, p); + } + + StringBuilder sb = new StringBuilder(); + for ( ; dims > 0; dims-- ) + sb.append("["); + sb.append(type); + if (inReturnType) { + returnType = sb.toString(); + } else { + parameters.add(sb.toString()); + } + } + + if (returnType == null) { + throw ex(desc, end); + } + + return new MethodSig(parameters, returnType); + } +} diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/Scan.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/Scan.java new file mode 100644 index 00000000000..4088e11841d --- /dev/null +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/jdeprscan/scan/Scan.java @@ -0,0 +1,614 @@ +/* + * 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. + */ + +package com.sun.tools.jdeprscan.scan; + +import java.io.IOException; +import java.io.PrintStream; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.ArrayDeque; +import java.util.Deque; +import java.util.Enumeration; +import java.util.List; +import java.util.jar.JarEntry; +import java.util.jar.JarFile; +import java.util.regex.Matcher; +import java.util.regex.Pattern; +import java.util.stream.Collectors; +import java.util.stream.Stream; + +import com.sun.tools.classfile.*; +import com.sun.tools.jdeprscan.DeprData; +import com.sun.tools.jdeprscan.DeprDB; +import com.sun.tools.jdeprscan.Messages; + +import static com.sun.tools.classfile.AccessFlags.*; +import static com.sun.tools.classfile.ConstantPool.*; + +/** + * An object that represents the scanning phase of deprecation usage checking. + * Given a deprecation database, scans the targeted directory hierarchy, jar + * file, or individual class for uses of deprecated APIs. + */ +public class Scan { + final PrintStream out; + final PrintStream err; + final List classPath; + final DeprDB db; + final boolean verbose; + + final ClassFinder finder; + boolean error = false; + + public Scan(PrintStream out, + PrintStream err, + List classPath, + DeprDB db, + boolean verbose) { + this.out = out; + this.err = err; + this.classPath = classPath; + this.db = db; + this.verbose = verbose; + + ClassFinder f = new ClassFinder(verbose); + + // TODO: this isn't quite right. If we've specified a release other than the current + // one, we should instead add a reference to the symbol file for that release instead + // of the current image. The problems are a) it's unclear how to get from a release + // to paths that reference the symbol files, as this might be internal to the file + // manager; and b) the symbol file includes .sig files, not class files, which ClassFile + // might not be able to handle. + f.addJrt(); + + for (String name : classPath) { + if (name.endsWith(".jar")) { + f.addJar(name); + } else { + f.addDir(name); + } + } + + finder = f; + } + + Pattern typePattern = Pattern.compile("\\[*L(.*);"); + + // "flattens" an array type name to its component type + // and a reference type "Lpkg/pkg/pkg/name;" to its base name + // "pkg/pkg/pkg/name". + // TODO: deal with primitive types + String flatten(String typeName) { + Matcher matcher = typePattern.matcher(typeName); + if (matcher.matches()) { + return matcher.group(1); + } else { + return typeName; + } + } + + String typeKind(ClassFile cf) { + AccessFlags flags = cf.access_flags; + if (flags.is(ACC_ENUM)) { + return "enum"; + } else if (flags.is(ACC_ANNOTATION)) { + return "@interface"; + } else if (flags.is(ACC_INTERFACE)) { + return "interface"; + } else { + return "class"; + } + } + + void printType(String key, ClassFile cf, String cname, boolean forRemoval) + throws ConstantPoolException { + String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal"); + out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, dep)); + } + + void printMethod(String key, ClassFile cf, String cname, String mname, String rtype, + boolean forRemoval) throws ConstantPoolException { + String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal"); + out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, mname, rtype, dep)); + } + + void printField(String key, ClassFile cf, String cname, String fname, + boolean forRemoval) throws ConstantPoolException { + String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal"); + out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, fname, dep)); + } + + void printFieldType(String key, ClassFile cf, String cname, String fname, String type, + boolean forRemoval) throws ConstantPoolException { + String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal"); + out.println(Messages.get(key, typeKind(cf), cf.getName(), cname, fname, type, dep)); + } + + void printHasField(ClassFile cf, String fname, String type, boolean forRemoval) + throws ConstantPoolException { + String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal"); + out.println(Messages.get("scan.out.hasfield", typeKind(cf), cf.getName(), fname, type, dep)); + } + + void printHasMethodParmType(ClassFile cf, String mname, String parmType, boolean forRemoval) + throws ConstantPoolException { + String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal"); + out.println(Messages.get("scan.out.methodparmtype", typeKind(cf), cf.getName(), mname, parmType, dep)); + } + + void printHasMethodRetType(ClassFile cf, String mname, String retType, boolean forRemoval) + throws ConstantPoolException { + String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal"); + out.println(Messages.get("scan.out.methodrettype", typeKind(cf), cf.getName(), mname, retType, dep)); + } + + void printHasOverriddenMethod(ClassFile cf, String overridden, String mname, String desc, boolean forRemoval) + throws ConstantPoolException { + String dep = Messages.get(forRemoval ? "scan.dep.removal" : "scan.dep.normal"); + out.println(Messages.get("scan.out.methodoverride", typeKind(cf), cf.getName(), overridden, + mname, desc, dep)); + } + + // format should not have a newline + void err(String format, Object... args) { + error = true; + err.print("error: "); + err.printf(format, args); + err.println(); + } + + void printException(Exception ex) { + err.print(Messages.get("error.prefix")); + err.print(" "); + if (verbose) { + ex.printStackTrace(err); + } else { + err.print(ex); + } + } + + /** + * Checks whether a member (method or field) is present in a class. + * The checkMethod parameter determines whether this checks for a method + * or for a field. + * + * @param targetClass the ClassFile of the class to search + * @param targetName the method or field's name + * @param targetDesc the methods descriptor (ignored if checkMethod is false) + * @param checkMethod true if checking for method, false if checking for field + * @return boolean indicating whether the member is present + * @throws ConstantPoolException if a constant pool entry cannot be found + */ + boolean isMemberPresent(ClassFile targetClass, + String targetName, + String targetDesc, + boolean checkMethod) + throws ConstantPoolException { + if (checkMethod) { + for (Method m : targetClass.methods) { + String mname = m.getName(targetClass.constant_pool); + String mdesc = targetClass.constant_pool.getUTF8Value(m.descriptor.index); + if (targetName.equals(mname) && targetDesc.equals(mdesc)) { + return true; + } + } + } else { + for (Field f : targetClass.fields) { + String fname = f.getName(targetClass.constant_pool); + if (targetName.equals(fname)) { + return true; + } + } + } + return false; + } + + /** + * Adds all interfaces from this class to the deque of interfaces. + * + * @param intfs the deque of interfaces + * @param cf the ClassFile of this class + * @throws ConstantPoolException if a constant pool entry cannot be found + */ + void addInterfaces(Deque intfs, ClassFile cf) + throws ConstantPoolException { + int count = cf.interfaces.length; + for (int i = 0; i < count; i++) { + intfs.addLast(cf.getInterfaceName(i)); + } + } + + /** + * Resolves a member by searching this class and all its superclasses and + * implemented interfaces. + * + * TODO: handles a few too many cases; needs cleanup. + * + * TODO: refine error handling + * + * @param cf the ClassFile of this class + * @param startClassName the name of the class at which to start searching + * @param findName the member name to search for + * @param findDesc the method descriptor to search for (ignored for fields) + * @param resolveMethod true if resolving a method, false if resolving a field + * @param checkStartClass true if the start class should be searched, false if + * it should be skipped + * @return the name of the class where the member resolved, or null + * @throws ConstantPoolException if a constant pool entry cannot be found + */ + String resolveMember( + ClassFile cf, String startClassName, String findName, String findDesc, + boolean resolveMethod, boolean checkStartClass) + throws ConstantPoolException { + ClassFile startClass; + + if (cf.getName().equals(startClassName)) { + startClass = cf; + } else { + startClass = finder.find(startClassName); + if (startClass == null) { + err("can't find class %s", startClassName); + return startClassName; + } + } + + // follow super_class until it's 0, meaning we've reached Object + // accumulate interfaces of superclasses as we go along + + ClassFile curClass = startClass; + Deque intfs = new ArrayDeque<>(); + while (true) { + if ((checkStartClass || curClass != startClass) && + isMemberPresent(curClass, findName, findDesc, resolveMethod)) { + break; + } + + if (curClass.super_class == 0) { // reached Object + curClass = null; + break; + } + + String superName = curClass.getSuperclassName(); + curClass = finder.find(superName); + if (curClass == null) { + err("can't find class %s", superName); + break; + } + addInterfaces(intfs, curClass); + } + + // search interfaces: add all interfaces and superinterfaces to queue + // search until it's empty + + if (curClass == null) { + addInterfaces(intfs, startClass); + while (intfs.size() > 0) { + String intf = intfs.removeFirst(); + curClass = finder.find(intf); + if (curClass == null) { + err("can't find interface %s", intf); + break; + } + + if (isMemberPresent(curClass, findName, findDesc, resolveMethod)) { + break; + } + + addInterfaces(intfs, curClass); + } + } + + if (curClass == null) { + if (checkStartClass) { + err("can't resolve methodref %s %s %s", + startClassName, findName, findDesc); + return startClassName; + } else { + // TODO: refactor this + // checkStartClass == false means we're checking for overrides + // so not being able to resolve a method simply means there's + // no overriding, which isn't an error + return null; + } + } else { + String foundClassName = curClass.getName(); + return foundClassName; + } + } + + /** + * Checks the superclass of this class. + * + * @param cf the ClassFile of this class + * @throws ConstantPoolException if a constant pool entry cannot be found + */ + void checkSuper(ClassFile cf) throws ConstantPoolException { + String sname = cf.getSuperclassName(); + DeprData dd = db.getTypeDeprecated(sname); + if (dd != null) { + printType("scan.out.extends", cf, sname, dd.isForRemoval()); + } + } + + /** + * Checks the interfaces of this class. + * + * @param cf the ClassFile of this class + * @throws ConstantPoolException if a constant pool entry cannot be found + */ + void checkInterfaces(ClassFile cf) throws ConstantPoolException { + int ni = cf.interfaces.length; + for (int i = 0; i < ni; i++) { + String iname = cf.getInterfaceName(i); + DeprData dd = db.getTypeDeprecated(iname); + if (dd != null) { + printType("scan.out.implements", cf, iname, dd.isForRemoval()); + } + } + } + + /** + * Checks types referred to from the constant pool. + * + * @param cf the ClassFile of this class + * @param entries constant pool entries collected from this class + * @throws ConstantPoolException if a constant pool entry cannot be found + */ + void checkTypes(ClassFile cf, CPEntries entries) throws ConstantPoolException { + for (ConstantPool.CONSTANT_Class_info ci : entries.classes) { + String typeName = ci.getName(); + DeprData dd = db.getTypeDeprecated(flatten(typeName)); + if (dd != null) { + printType("scan.out.usestype", cf, typeName, dd.isForRemoval()); + } + } + } + + /** + * Checks methods referred to from the constant pool. + * + * @param cf the ClassFile of this class + * @param nti the NameAndType_info from a MethodRef or InterfaceMethodRef entry + * @param clname the class name + * @param typeKey key for the type message + * @param methKey key for the method message + * @throws ConstantPoolException if a constant pool entry cannot be found + */ + void checkMethodRef(ClassFile cf, + CONSTANT_NameAndType_info nti, + String clname, + String typeKey, + String methKey) throws ConstantPoolException { + DeprData dd = db.getTypeDeprecated(flatten(clname)); + if (dd != null) { + printType(typeKey, cf, clname, dd.isForRemoval()); + } + + String name = nti.getName(); + String type = nti.getType(); + clname = resolveMember(cf, flatten(clname), name, type, true, true); + dd = db.getMethodDeprecated(clname, name, type); + if (dd != null) { + printMethod(methKey, cf, clname, name, type, dd.isForRemoval()); + } + } + + /** + * Checks fields referred to from the constant pool. + * + * @param cf the ClassFile of this class + * @throws ConstantPoolException if a constant pool entry cannot be found + */ + void checkFieldRef(ClassFile cf, + ConstantPool.CONSTANT_Fieldref_info fri) throws ConstantPoolException { + CONSTANT_NameAndType_info nti = fri.getNameAndTypeInfo(); + String clname = fri.getClassName(); + String name = nti.getName(); + String type = nti.getType(); + DeprData dd = db.getTypeDeprecated(clname); + + if (dd != null) { + printType("scan.out.usesfieldintype", cf, clname, dd.isForRemoval()); + } + + clname = resolveMember(cf, flatten(clname), name, type, false, true); + dd = db.getFieldDeprecated(clname, name); + if (dd != null) { + printField("scan.out.usesfield", cf, clname, name, dd.isForRemoval()); + } + + dd = db.getTypeDeprecated(flatten(type)); + if (dd != null) { + printFieldType("scan.out.usesfieldoftype", cf, clname, name, type, dd.isForRemoval()); + } + } + + /** + * Checks the fields declared in this class. + * + * @param cf the ClassFile of this class + * @throws ConstantPoolException if a constant pool entry cannot be found + */ + void checkFields(ClassFile cf) throws ConstantPoolException { + for (Field f : cf.fields) { + String type = cf.constant_pool.getUTF8Value(f.descriptor.index); + DeprData dd = db.getTypeDeprecated(flatten(type)); + if (dd != null) { + printHasField(cf, f.getName(cf.constant_pool), type, dd.isForRemoval()); + } + } + } + + /** + * Checks the methods declared in this class. + * + * @param cf the ClassFile object of this class + * @throws ConstantPoolException if a constant pool entry cannot be found + */ + void checkMethods(ClassFile cf) throws ConstantPoolException { + for (Method m : cf.methods) { + String mname = m.getName(cf.constant_pool); + String desc = cf.constant_pool.getUTF8Value(m.descriptor.index); + MethodSig sig = MethodSig.fromDesc(desc); + DeprData dd; + + for (String parm : sig.getParameters()) { + dd = db.getTypeDeprecated(flatten(parm)); + if (dd != null) { + printHasMethodParmType(cf, mname, parm, dd.isForRemoval()); + } + } + + String ret = sig.getReturnType(); + dd = db.getTypeDeprecated(flatten(ret)); + if (dd != null) { + printHasMethodRetType(cf, mname, ret, dd.isForRemoval()); + } + + // check overrides + String overridden = resolveMember(cf, cf.getName(), mname, desc, true, false); + if (overridden != null) { + dd = db.getMethodDeprecated(overridden, mname, desc); + if (dd != null) { + printHasOverriddenMethod(cf, overridden, mname, desc, dd.isForRemoval()); + } + } + } + } + + /** + * Processes a single class file. + * + * @param cf the ClassFile of the class + * @throws ConstantPoolException if a constant pool entry cannot be found + */ + void processClass(ClassFile cf) throws ConstantPoolException { + if (verbose) { + out.println(Messages.get("scan.process.class", cf.getName())); + } + + CPEntries entries = CPEntries.loadFrom(cf); + + checkSuper(cf); + checkInterfaces(cf); + checkTypes(cf, entries); + + for (ConstantPool.CONSTANT_Methodref_info mri : entries.methodRefs) { + CONSTANT_NameAndType_info nti = mri.getNameAndTypeInfo(); + String clname = mri.getClassName(); + checkMethodRef(cf, nti, clname, "scan.out.usesmethodintype", "scan.out.usesmethod"); + } + + for (ConstantPool.CONSTANT_InterfaceMethodref_info imri : entries.intfMethodRefs) { + CONSTANT_NameAndType_info nti = imri.getNameAndTypeInfo(); + String clname = imri.getClassName(); + checkMethodRef(cf, nti, clname, "scan.out.usesintfmethodintype", "scan.out.usesintfmethod"); + } + + for (ConstantPool.CONSTANT_Fieldref_info fri : entries.fieldRefs) { + checkFieldRef(cf, fri); + } + + checkFields(cf); + checkMethods(cf); + } + + /** + * Scans a jar file for uses of deprecated APIs. + * + * @param jarname the jar file to process + * @return true on success, false on failure + */ + public boolean scanJar(String jarname) { + try (JarFile jf = new JarFile(jarname)) { + finder.addJar(jarname); + Enumeration entries = jf.entries(); + while (entries.hasMoreElements()) { + JarEntry entry = entries.nextElement(); + String name = entry.getName(); + if (name.endsWith(".class") + && !name.endsWith("package-info.class") + && !name.endsWith("module-info.class")) { + processClass(ClassFile.read(jf.getInputStream(entry))); + } + } + return true; + } catch (IOException | ConstantPoolException ex) { + printException(ex); + return false; + } + } + + /** + * Scans class files in the named directory hierarchy for uses of deprecated APIs. + * + * @param dirname the directory hierarchy to process + * @return true on success, false on failure + */ + public boolean scanDir(String dirname) { + Path base = Paths.get(dirname); + int baseCount = base.getNameCount(); + finder.addDir(dirname); + try (Stream paths = Files.walk(Paths.get(dirname))) { + List classes = + paths.filter(p -> p.getNameCount() > baseCount) + .filter(path -> path.toString().endsWith(".class")) + .filter(path -> !path.toString().endsWith("package-info.class")) + .filter(path -> !path.toString().endsWith("module-info.class")) + .collect(Collectors.toList()); + for (Path p : classes) { + processClass(ClassFile.read(p)); + } + return true; + } catch (IOException | ConstantPoolException ex) { + printException(ex); + return false; + } + } + + /** + * Scans the named class for uses of deprecated APIs. + * + * @param className the class to scan + * @return true on success, false on failure + */ + public boolean processClassName(String className) { + try { + ClassFile cf = finder.find(className); + if (cf == null) { + err("can't find class %s", className); + return false; + } else { + processClass(cf); + return true; + } + } catch (ConstantPoolException ex) { + printException(ex); + return false; + } + } +} diff --git a/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleAnnotation.java b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleAnnotation.java new file mode 100644 index 00000000000..c0cf8e9da2c --- /dev/null +++ b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleAnnotation.java @@ -0,0 +1,34 @@ +/* + * 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 jdk.deprcases.members; + +import java.lang.annotation.*; +import static java.lang.annotation.ElementType.*; + +@Retention(value=RetentionPolicy.RUNTIME) +@Target({TYPE, METHOD, FIELD}) +public @interface ExampleAnnotation { + String file(); + @Deprecated String name() default ""; +} diff --git a/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleClass.java b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleClass.java new file mode 100644 index 00000000000..0205afefcfb --- /dev/null +++ b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleClass.java @@ -0,0 +1,49 @@ +/* + * 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 jdk.deprcases.members; + +public class ExampleClass { + public ExampleClass() { } + + @Deprecated + public ExampleClass(boolean deprecatedConstructor) { } + + @Deprecated + public void method1() { } + + @Deprecated + public void method2() { } + + @Deprecated + public int field1 = 0; + + @Deprecated + public int field2 = 0; + + @Deprecated + public static void staticmethod1() { } + + @Deprecated + public static int staticfield3 = 0; +} diff --git a/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleElements.java b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleElements.java new file mode 100644 index 00000000000..f7fb1c6463d --- /dev/null +++ b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleElements.java @@ -0,0 +1,44 @@ +/* + * 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 jdk.deprcases.members; + +public class ExampleElements { + @Deprecated + Object emptyFalse; + + @Deprecated(since="xyzzy") + Object sinceFalse; + + @Deprecated(forRemoval=true) + Object emptyTrue; + + @Deprecated(since="plugh", forRemoval=true) + Object sinceTrue; + + @Deprecated(since="123,456") + Object sinceWithComma; + + @Deprecated(since="7.9 \"pre-beta\" snapshot") + Object sinceWithQuote; +} diff --git a/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleEnum.java b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleEnum.java new file mode 100644 index 00000000000..d0f7541817f --- /dev/null +++ b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleEnum.java @@ -0,0 +1,42 @@ +/* + * 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 jdk.deprcases.members; + +public enum ExampleEnum { + ONE, + TWO { + @Override + public void deprMethod1() { } + @Override @Deprecated + public void deprMethod2() { } + }, + @Deprecated THREE, + FOUR, + @Deprecated FIVE; + + @Deprecated + public void deprMethod1() { } + + public void deprMethod2() { } +} diff --git a/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleInterface.java b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleInterface.java new file mode 100644 index 00000000000..972bb470255 --- /dev/null +++ b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleInterface.java @@ -0,0 +1,44 @@ +/* + * 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 jdk.deprcases.members; + +public interface ExampleInterface { + @Deprecated + static final int DEP_FIELD1 = 1; + + @Deprecated + static final int DEP_FIELD2 = 2; + + @Deprecated + void interfaceMethod1(); + + @Deprecated + void interfaceMethod2(); + + @Deprecated + default void defaultMethod() { } + + @Deprecated + static void staticmethod2() { } +} diff --git a/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleSubclass.java b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleSubclass.java new file mode 100644 index 00000000000..4cfdaa07f32 --- /dev/null +++ b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/members/ExampleSubclass.java @@ -0,0 +1,39 @@ +/* + * 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 jdk.deprcases.members; + +public abstract class ExampleSubclass extends ExampleClass implements ExampleInterface { + @Override + public void method1() { } + + // hides ExampleClass.field1 + public Object field1 = null; + + @Override + public void interfaceMethod2() { + } + + // hides ExampleInterface.DEP_FIELD1 + public Object DEP_FIELD1 = null; +} diff --git a/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedAnnotation.java b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedAnnotation.java new file mode 100644 index 00000000000..b11206caa56 --- /dev/null +++ b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedAnnotation.java @@ -0,0 +1,35 @@ +/* + * 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 jdk.deprcases.types; + +import java.lang.annotation.*; +import static java.lang.annotation.ElementType.*; + +@Retention(value=RetentionPolicy.RUNTIME) +@Target({TYPE, METHOD, FIELD}) +@Deprecated +public @interface DeprecatedAnnotation { + String file() default "x"; + String value() default "y"; +} diff --git a/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedClass.java b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedClass.java new file mode 100644 index 00000000000..3f81060c063 --- /dev/null +++ b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedClass.java @@ -0,0 +1,28 @@ +/* + * 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 jdk.deprcases.types; + +@Deprecated +public class DeprecatedClass { +} diff --git a/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedEnum.java b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedEnum.java new file mode 100644 index 00000000000..b1d05e2759e --- /dev/null +++ b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedEnum.java @@ -0,0 +1,31 @@ +/* + * 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 jdk.deprcases.types; + +@Deprecated +public enum DeprecatedEnum { + FIRST, + SECOND, + THIRD +} diff --git a/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedException.java b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedException.java new file mode 100644 index 00000000000..a956da80ac7 --- /dev/null +++ b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedException.java @@ -0,0 +1,29 @@ +/* + * 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 jdk.deprcases.types; + +@Deprecated +public class DeprecatedException extends RuntimeException { + private static final long serialVersionUID = 0L; +} diff --git a/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedInterface.java b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedInterface.java new file mode 100644 index 00000000000..e54b51b7d4d --- /dev/null +++ b/langtools/test/tools/jdeprscan/cases/jdk/deprcases/types/DeprecatedInterface.java @@ -0,0 +1,28 @@ +/* + * 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 jdk.deprcases.types; + +@Deprecated +public interface DeprecatedInterface { +} diff --git a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestCSV.java b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestCSV.java new file mode 100644 index 00000000000..c4f6a4ba279 --- /dev/null +++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestCSV.java @@ -0,0 +1,144 @@ +/* + * 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 + * @summary Basic tests CSV printing and parsing + * @modules jdk.jdeps/com.sun.tools.jdeprscan + * @build TestCSV + * @run testng jdk.jdeprscan.TestCSV + */ + +package jdk.jdeprscan; + +import java.io.ByteArrayOutputStream; +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; + +import java.util.List; +import org.testng.annotations.BeforeMethod; +import org.testng.annotations.DataProvider; +import org.testng.annotations.Test; + +import static org.testng.Assert.assertEquals; +import static org.testng.Assert.assertTrue; + +import com.sun.tools.jdeprscan.CSV; +import com.sun.tools.jdeprscan.CSVParseException; + +@Test +public class TestCSV { + static String NL = System.lineSeparator(); + ByteArrayOutputStream baos; + PrintStream out; + + @BeforeMethod + public void setup() throws UnsupportedEncodingException { + baos = new ByteArrayOutputStream(); + out = new PrintStream(baos, true, "UTF-8"); + } + + String result() { + out.flush(); + return new String(baos.toByteArray(), java.nio.charset.StandardCharsets.UTF_8); + } + + /** + * Asserts string equality after checking for and removing a trailing line separator. + * + * @param expected expected result + */ + void checkString(String expected) { + String actual = result(); + assertTrue(actual.endsWith(NL)); + assertEquals(actual.substring(0, actual.length() - NL.length()), expected); + } + + @DataProvider(name = "csvdata") + public Object[][] getCSVData() { + return new Object[][] { + { "", List.of("") }, + { "a", List.of("a") }, + { "a,b", List.of("a", "b") }, + { "a,b,c", List.of("a", "b", "c") }, + { ",a,b", List.of("", "a", "b") }, + { "a,b,", List.of("a", "b", "") }, + { ",a,b,", List.of("", "a", "b", "") }, + { ",a,,b,", List.of("", "a", "", "b", "") }, + { ",", List.of("", "") }, + { ",,", List.of("", "", "") }, + { ",,,", List.of("", "", "", "") }, + { " a , b ", List.of(" a ", " b ") }, + { "a,\",\",b", List.of("a", ",", "b") }, + { "a,\"b\"\"c\",d", List.of("a", "b\"c", "d") }, + { "a,\"b,c\",d", List.of("a", "b,c", "d") }, + + // from https://en.wikipedia.org/wiki/Comma-separated_values + // slightly modified to enable round-tripping + + { "Year,Make,Model,Description,Price", + List.of("Year", "Make", "Model", "Description", "Price") }, + { "1997,Ford,E350,\"ac, abs, moon\",3000.00", + List.of("1997", "Ford", "E350", "ac, abs, moon", "3000.00") }, + { "1999,Chevy,\"Venture \"\"Extended Edition\"\"\",,4900.00", + List.of("1999", "Chevy", "Venture \"Extended Edition\"", "", "4900.00") }, + { "1999,Chevy,\"Venture \"\"Extended Edition, Very Large\"\"\",,5000.00", + List.of("1999", "Chevy", "Venture \"Extended Edition, Very Large\"", "", "5000.00") }, + { "1996,Jeep,Grand Cherokee,\"MUST SELL!\nair, moon roof, loaded\",4799.00", + List.of("1996", "Jeep", "Grand Cherokee", "MUST SELL!\nair, moon roof, loaded", "4799.00") } + }; + } + + @Test(dataProvider = "csvdata") + public void roundTrip(String input, List parsed) { + List actual = CSV.split(input); + assertEquals(actual, parsed); + CSV.write(out, actual.toArray()); + checkString(input); + } + + // won't round-trip + public void testExtraQuote() { + assertEquals(CSV.split("a,\"b\",c"), List.of("a", "b", "c")); + } + + // won't round-trip + public void testEmptyQuote() { + assertEquals(CSV.split("a,\"\",b"), List.of("a", "", "b")); + } + + @Test(expectedExceptions=CSVParseException.class) + public void errorUnexpectedQuote() { + CSV.split("ab\"cd"); + } + + @Test(expectedExceptions=CSVParseException.class) + public void errorCharacterAfterQuote() { + CSV.split("a,\"b\"c,d"); + } + + @Test(expectedExceptions=CSVParseException.class) + public void errorUnclosedQuote() { + CSV.split("a,\"b"); + } +} diff --git a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestLoad.java b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestLoad.java new file mode 100644 index 00000000000..cc0e3c5eba3 --- /dev/null +++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestLoad.java @@ -0,0 +1,120 @@ +/* + * 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 + * @summary Test of jdeprscan tool loading and printing to aCSV file. + * @modules jdk.jdeps/com.sun.tools.jdeprscan + * @library ../../../cases + * @build jdk.deprcases.members.* jdk.deprcases.types.* + * @build jdk.jdeprscan.TestLoad + * @run testng jdk.jdeprscan.TestLoad + */ + +package jdk.jdeprscan; + +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.io.UnsupportedEncodingException; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.stream.Collectors; + +import com.sun.tools.jdeprscan.Main; + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertTrue; +import static org.testng.Assert.assertEquals; + + +public class TestLoad { + static final String UTF8 = "UTF-8"; + static final String EXPECTED = "TestLoadExpected.csv"; + + @Test + public void test1() throws IOException, UnsupportedEncodingException { + String testclasses = System.getProperty("test.classes"); + String deprcases = testclasses + "/../../../cases"; + boolean rval; + + System.out.println("test.src = " + System.getProperty("test.src")); + ByteArrayOutputStream bout = new ByteArrayOutputStream(); + ByteArrayOutputStream berr = new ByteArrayOutputStream(); + + try (PrintStream prout = new PrintStream(bout, true, UTF8); + PrintStream prerr = new PrintStream(berr, true, UTF8)) { + System.out.println("Calling JDeprScan --Xprint-csv --Xload-dir " + deprcases); + rval = Main.call(prout, prerr, "--Xprint-csv", "--Xload-dir", deprcases); + System.out.println("JDeprScan returns " + rval); + } + + System.out.println("----- stdout"); + new ByteArrayInputStream(bout.toByteArray()).transferTo(System.out); + System.out.println("----- end stdout"); + System.out.println("----- stderr"); + new ByteArrayInputStream(berr.toByteArray()).transferTo(System.out); + System.out.println("----- end stderr"); + + List actualList; + try (ByteArrayInputStream bais = new ByteArrayInputStream(bout.toByteArray()); + InputStreamReader isr = new InputStreamReader(bais); + BufferedReader br = new BufferedReader(isr)) { + actualList = br.lines().collect(Collectors.toList()); + } + + Path expfile = Paths.get(System.getProperty("test.src"), EXPECTED); + List expectedList = Files.readAllLines(expfile); + + Set actual = new HashSet<>(actualList.subList(1, actualList.size())); + Set expected = new HashSet<>(expectedList.subList(1, expectedList.size())); + + Set diff1 = new HashSet<>(actual); + diff1.removeAll(expected); + Set diff2 = new HashSet<>(expected); + diff2.removeAll(actual); + if (diff1.size() > 0) { + System.out.println("Extra lines in output:"); + diff1.forEach(System.out::println); + } + + if (diff2.size() > 0) { + System.out.println("Lines missing from output:"); + diff2.forEach(System.out::println); + } + + assertTrue(rval); + assertEquals(berr.toByteArray().length, 0); + assertEquals(actual.size(), actualList.size() - 1); + assertEquals(diff1.size(), 0); + assertEquals(diff2.size(), 0); + } +} diff --git a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestLoadExpected.csv b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestLoadExpected.csv new file mode 100644 index 00000000000..dd58eacd90c --- /dev/null +++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestLoadExpected.csv @@ -0,0 +1,30 @@ +#jdepr 1 +METHOD,jdk/deprcases/members/ExampleAnnotation,name()Ljava/lang/String;,,false +FIELD,jdk/deprcases/members/ExampleClass,field1,,false +FIELD,jdk/deprcases/members/ExampleClass,field2,,false +FIELD,jdk/deprcases/members/ExampleClass,staticfield3,,false +CONSTRUCTOR,jdk/deprcases/members/ExampleClass,(Z)V,,false +METHOD,jdk/deprcases/members/ExampleClass,method1()V,,false +METHOD,jdk/deprcases/members/ExampleClass,method2()V,,false +METHOD,jdk/deprcases/members/ExampleClass,staticmethod1()V,,false +METHOD,jdk/deprcases/members/ExampleEnum$1,deprMethod2()V,,false +ENUM_CONSTANT,jdk/deprcases/members/ExampleEnum,THREE,,false +ENUM_CONSTANT,jdk/deprcases/members/ExampleEnum,FIVE,,false +METHOD,jdk/deprcases/members/ExampleEnum,deprMethod1()V,,false +FIELD,jdk/deprcases/members/ExampleInterface,DEP_FIELD1,,false +FIELD,jdk/deprcases/members/ExampleInterface,DEP_FIELD2,,false +METHOD,jdk/deprcases/members/ExampleInterface,interfaceMethod1()V,,false +METHOD,jdk/deprcases/members/ExampleInterface,interfaceMethod2()V,,false +METHOD,jdk/deprcases/members/ExampleInterface,defaultMethod()V,,false +METHOD,jdk/deprcases/members/ExampleInterface,staticmethod2()V,,false +ANNOTATION_TYPE,jdk/deprcases/types/DeprecatedAnnotation,,,false +CLASS,jdk/deprcases/types/DeprecatedClass,,,false +ENUM,jdk/deprcases/types/DeprecatedEnum,,,false +CLASS,jdk/deprcases/types/DeprecatedException,,,false +INTERFACE,jdk/deprcases/types/DeprecatedInterface,,,false +FIELD,jdk/deprcases/members/ExampleElements,emptyFalse,,false +FIELD,jdk/deprcases/members/ExampleElements,sinceFalse,xyzzy,false +FIELD,jdk/deprcases/members/ExampleElements,emptyTrue,,true +FIELD,jdk/deprcases/members/ExampleElements,sinceTrue,plugh,true +FIELD,jdk/deprcases/members/ExampleElements,sinceWithComma,"123,456",false +FIELD,jdk/deprcases/members/ExampleElements,sinceWithQuote,"7.9 ""pre-beta"" snapshot",false diff --git a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestMethodSig.java b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestMethodSig.java new file mode 100644 index 00000000000..e44b8b2e133 --- /dev/null +++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestMethodSig.java @@ -0,0 +1,61 @@ +/* + * 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 + * @summary Simple tests for method signature parsing + * @modules jdk.jdeps/com.sun.tools.jdeprscan.scan + * @build TestMethodSig + * @run testng jdk.jdeprscan.TestMethodSig + */ + +package jdk.jdeprscan; + +import org.testng.annotations.Test; +import static org.testng.Assert.assertEquals; +import static com.sun.tools.jdeprscan.scan.MethodSig.fromDesc; + +public class TestMethodSig { + @Test + public void testSimple() { + assertEquals(fromDesc("(Ljava/rmi/RMISecurityManager;)Ljava/lang/Object;").toString(), + "parameters 0=Ljava/rmi/RMISecurityManager; return Ljava/lang/Object;"); + } + + @Test + public void testMultParamVoidReturn() { + assertEquals(fromDesc("([[IZLjava/lang/String;B[J)V").toString(), + "parameters 0=[[I 1=Z 2=Ljava/lang/String; 3=B 4=[J return V"); + } + + @Test + public void testNoParams() { + assertEquals(fromDesc("()J").toString(), + "parameters none return J"); + } + + @Test(expectedExceptions = IllegalArgumentException.class) + public void testMissingReturnType() { + fromDesc("(ISJZ)"); + } +} diff --git a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java new file mode 100644 index 00000000000..bf18cd96122 --- /dev/null +++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java @@ -0,0 +1,110 @@ +/* + * 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 + * @summary Basic test of jdeprscan's scanning phase. + * @modules jdk.jdeps/com.sun.tools.jdeprscan + * @library ../../../cases + * @library ../../../usage + * @build jdk.deprcases.members.* jdk.deprcases.types.* + * @build jdk.deprusage.* + * @build jdk.jdeprscan.TestScan + * @run testng jdk.jdeprscan.TestScan + */ + +package jdk.jdeprscan; + +import com.sun.tools.jdeprscan.Main; +import java.io.BufferedReader; +import java.io.ByteArrayInputStream; +import java.io.ByteArrayOutputStream; +import java.io.IOException; +import java.io.InputStreamReader; +import java.io.PrintStream; +import java.nio.charset.StandardCharsets; +import java.nio.file.Files; +import java.nio.file.Path; +import java.nio.file.Paths; +import java.util.HashSet; +import java.util.Set; +import java.util.stream.Collectors; +import org.testng.Assert; + +import org.testng.annotations.Test; + +import static org.testng.Assert.assertTrue; + + +public class TestScan { + Set loadExpected() throws IOException { + Path expFile = Paths.get(System.getProperty("test.src"), "TestScanExpected.txt"); + return new HashSet<>(Files.readAllLines(expFile, StandardCharsets.UTF_8)); + } + + @Test + public void testScanAgainstReferenceFile() throws IOException { + String testclasses = System.getProperty("test.classes"); + String deprcases = testclasses + "/../../../cases"; + String deprusage = testclasses + "/../../../usage"; + + Set expected = loadExpected(); + System.out.println("expected = " + expected); + + ByteArrayOutputStream baos = new ByteArrayOutputStream(); + try (PrintStream out = new PrintStream(baos, false, "UTF-8")) { + boolean r = Main.call(out, System.err, + "-cp", deprcases, "--Xload-dir", deprcases, deprusage); + assertTrue(r); + } + byte[] bytes = baos.toByteArray(); + + System.out.println("--- output ---"); + ByteArrayInputStream bais = new ByteArrayInputStream(bytes); + bais.transferTo(System.out); + System.out.println("--- end output ---"); + + Set actual = + new BufferedReader( + new InputStreamReader( + new ByteArrayInputStream(bytes), StandardCharsets.UTF_8)) + .lines() + .map(line -> line.split(" +")) + .map(array -> array[1]) + .collect(Collectors.toSet()); + System.out.println("actual = " + actual); + + Set diff1 = new HashSet<>(expected); + diff1.removeAll(actual); + Set diff2 = new HashSet<>(actual); + diff2.removeAll(expected); + + if (diff1.size() > 0 || diff2.size() > 0) { + System.out.println("missing items: " + diff1); + System.out.println("extra items: " + diff2); + } + + Assert.assertEquals(diff1.size(), 0); + Assert.assertEquals(diff2.size(), 0); + } +} diff --git a/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScanExpected.txt b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScanExpected.txt new file mode 100644 index 00000000000..73568034673 --- /dev/null +++ b/langtools/test/tools/jdeprscan/tests/jdk/jdeprscan/TestScanExpected.txt @@ -0,0 +1,47 @@ +jdk/jdeprusage/UseClass$ArrayCreation +jdk/jdeprusage/UseClass$ArrayFieldUsage +jdk/jdeprusage/UseClass$ArrayMethodCall +jdk/jdeprusage/UseClass$Cast +jdk/jdeprusage/UseClass$ClassLiteral +jdk/jdeprusage/UseClass$Construct +jdk/jdeprusage/UseClass$Extends +jdk/jdeprusage/UseClass$FieldType +jdk/jdeprusage/UseClass$InstanceOf +jdk/jdeprusage/UseClass$MethodParameter +jdk/jdeprusage/UseClass$MethodReturn +jdk/jdeprusage/UseEnum$ClassObject +jdk/jdeprusage/UseEnum$EnumConstant +jdk/jdeprusage/UseEnum$FieldType +jdk/jdeprusage/UseEnum$MethodParameter +jdk/jdeprusage/UseEnum$ReturnValue +jdk/jdeprusage/UseEnum$ValueOfMethod +jdk/jdeprusage/UseEnum$ValuesMethod +jdk/jdeprusage/UseEnumMembers$1 +jdk/jdeprusage/UseEnumMembers$MethodInEnum1 +jdk/jdeprusage/UseEnumMembers$MethodOnConstant1 +jdk/jdeprusage/UseEnumMembers$ReturnValue +jdk/jdeprusage/UseException$Catch +jdk/jdeprusage/UseException$Throws +jdk/jdeprusage/UseField$Direct +jdk/jdeprusage/UseField$FromSubclass +jdk/jdeprusage/UseField$Inherited +jdk/jdeprusage/UseField$StaticField +jdk/jdeprusage/UseField$SuperFromSubclass +jdk/jdeprusage/UseInterface$ClassImplements +jdk/jdeprusage/UseInterface$InterfaceExtends +jdk/jdeprusage/UseMethod$ClassStatic +jdk/jdeprusage/UseMethod$Constructor +jdk/jdeprusage/UseMethod$ConstructorFromSubclass +jdk/jdeprusage/UseMethod$Direct +jdk/jdeprusage/UseMethod$Inherited +jdk/jdeprusage/UseMethod$InheritedDefault +jdk/jdeprusage/UseMethod$InheritedFromSubclass +jdk/jdeprusage/UseMethod$InheritedInterface +jdk/jdeprusage/UseMethod$InheritedInterfaceDefault +jdk/jdeprusage/UseMethod$InterfaceDefault +jdk/jdeprusage/UseMethod$InterfaceDirect +jdk/jdeprusage/UseMethod$InterfaceStatic +jdk/jdeprusage/UseMethod$OverrideClassMethod +jdk/jdeprusage/UseMethod$OverrideDefaultMethod +jdk/jdeprusage/UseMethod$OverrideInterfaceMethod +jdk/jdeprusage/UseMethod$SuperFromSubclass diff --git a/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseAnnotation.java b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseAnnotation.java new file mode 100644 index 00000000000..71ac29f4ef0 --- /dev/null +++ b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseAnnotation.java @@ -0,0 +1,41 @@ +/* + * 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 jdk.jdeprusage; + +import jdk.deprcases.types.DeprecatedAnnotation; + +public class UseAnnotation { + @DeprecatedAnnotation + static class AnnotatedClass { } + + static class AnnotatedMethod { + @DeprecatedAnnotation + void foo() { } + } + + static class AnnotatedField { + @DeprecatedAnnotation + int foo = 1; + } +} diff --git a/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseClass.java b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseClass.java new file mode 100644 index 00000000000..b56accd828a --- /dev/null +++ b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseClass.java @@ -0,0 +1,107 @@ +/* + * 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 jdk.jdeprusage; + +import jdk.deprcases.types.DeprecatedClass; + +public class UseClass { + static class Extends extends DeprecatedClass { + } + + static class ClassLiteral { + Class clazz = DeprecatedClass.class; + } + + static class FieldType { + DeprecatedClass obj = null; + } + + static class MethodParameter { + void foo(DeprecatedClass x) { } + } + + static class MethodReturn { + DeprecatedClass foo() { return null; } + } + + static class ArrayCreation { + Object foo() { + return new DeprecatedClass[1]; + } + } + + static class ArrayFieldUsage { + int foo(Object o) { + return ((DeprecatedClass[])o).length; + } + } + + static class ArrayMethodCall { + Object foo(Object o) { + return ((DeprecatedClass[])o).clone(); + } + } + + static class InstanceOf { + boolean foo(Object o) { + return o instanceof DeprecatedClass; + } + } + + static class Cast { + Object foo(Object o) { + return (DeprecatedClass)o; + } + } + + static class Generic { + static void g() { } + } + + static class ClassTypeArg extends Generic { } + + static class MethodTypeArg { + void foo() { + Generic.g(); + } + } + + static class ConstructorTypeArg { + Object foo() { + return new Generic(); + } + } + + static class Construct { + Object foo() { + return new DeprecatedClass(); + } + } + + static class Local { + void foo() { + DeprecatedClass obj = null; + } + } +} diff --git a/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseEnum.java b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseEnum.java new file mode 100644 index 00000000000..aa1c2106f48 --- /dev/null +++ b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseEnum.java @@ -0,0 +1,62 @@ +/* + * 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 jdk.jdeprusage; + +import jdk.deprcases.types.DeprecatedEnum; + +public class UseEnum { + static class ReturnValue { + static DeprecatedEnum returnValue() { return null; } + } + + static class MethodParameter { + static void methodParameterType(DeprecatedEnum e) { } + } + + static class FieldType { + static DeprecatedEnum field; + } + + static class EnumConstant { + static Object field2 = DeprecatedEnum.FIRST; + } + + static class ValuesMethod { + static Object[] valuesMethod() { + return DeprecatedEnum.values(); + } + } + + static class ValueOfMethod { + static Object valueOfMethod(String s) { + return DeprecatedEnum.valueOf(s); + } + } + + static class ClassObject { + static Object classObject() { + return DeprecatedEnum.class; + } + } +} diff --git a/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseEnumMembers.java b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseEnumMembers.java new file mode 100644 index 00000000000..7b4916bfca3 --- /dev/null +++ b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseEnumMembers.java @@ -0,0 +1,74 @@ +/* + * 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 jdk.jdeprusage; + +import jdk.deprcases.members.ExampleEnum; + +public class UseEnumMembers { + static class ReturnValue { + static ExampleEnum returnValue() { + return ExampleEnum.FIVE; + } + } + + static class UseInSwitch { + // enum switch generates inner class UseEnumMembers$UseInSwitch$1 + static void useInSwitch(ExampleEnum e) { + switch (e) { + case ONE: + case TWO: + case FOUR: + // no deprecation + break; + case THREE: + // deprecated + break; + } + } + } + + static class MethodInEnum1 { + static void methodInEnum1(ExampleEnum e) { + e.deprMethod1(); + } + } + + static class MethodOnConstant1 { + static void methodOnConstant1() { + // surprising that there is a warning here; + // the method deprMethod1 is overridden in TWO + ExampleEnum.TWO.deprMethod1(); + } + } + + static void methodInEnum2(ExampleEnum e) { + e.deprMethod2(); + } + + static void methodOnConstant2() { + // surprising there is no warning here; + // the method is deprecated in TWO + ExampleEnum.TWO.deprMethod2(); + } +} diff --git a/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseException.java b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseException.java new file mode 100644 index 00000000000..87f8a241eaf --- /dev/null +++ b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseException.java @@ -0,0 +1,40 @@ +/* + * 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 jdk.jdeprusage; + +import jdk.deprcases.types.DeprecatedException; + +public class UseException { + static class Throws { + static void foo() throws DeprecatedException { } + } + + static class Catch { + void foo() { + try { + Throws.foo(); + } catch (DeprecatedException de) { } + } + } +} diff --git a/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseField.java b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseField.java new file mode 100644 index 00000000000..ed940c4f0ea --- /dev/null +++ b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseField.java @@ -0,0 +1,72 @@ +/* + * 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 jdk.jdeprusage; + +import jdk.deprcases.members.ExampleClass; +import jdk.deprcases.members.ExampleInterface; +import jdk.deprcases.members.ExampleSubclass; + +public class UseField { + static class Direct { + int f(ExampleClass ec) { + return ec.field1; + } + } + + static class Inherited { + int f(ExampleSubclass esc) { + return esc.field2; + } + } + + static class InterfaceInherited { + int f(ExampleSubclass esc) { + return esc.DEP_FIELD2; + } + } + + static class InterfaceDirect { + int f(ExampleInterface ei) { + return ei.DEP_FIELD1; + } + } + + static class FromSubclass extends ExampleClass { + int f() { + return field1; + } + } + + static class SuperFromSubclass extends ExampleClass { + int f() { + return super.field1; + } + } + + static class StaticField { + int f() { + return ExampleClass.staticfield3; + } + } +} diff --git a/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseInterface.java b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseInterface.java new file mode 100644 index 00000000000..2368a915eb5 --- /dev/null +++ b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseInterface.java @@ -0,0 +1,36 @@ +/* + * 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 jdk.jdeprusage; + +import jdk.deprcases.types.DeprecatedInterface; + +public class UseInterface { + static class ClassImplements implements DeprecatedInterface { + + } + + interface InterfaceExtends extends DeprecatedInterface { + + } +} diff --git a/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseMethod.java b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseMethod.java new file mode 100644 index 00000000000..79aa91ab5b7 --- /dev/null +++ b/langtools/test/tools/jdeprscan/usage/jdk/deprusage/UseMethod.java @@ -0,0 +1,123 @@ +/* + * 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 jdk.jdeprusage; + +import jdk.deprcases.members.ExampleClass; +import jdk.deprcases.members.ExampleInterface; +import jdk.deprcases.members.ExampleSubclass; + +public class UseMethod { + static class Direct { + void m(ExampleClass ec) { + ec.method1(); + } + } + + static class Inherited { + void m(ExampleSubclass esc) { + esc.method2(); + } + } + + static class InheritedDefault { + void m(ExampleSubclass esc) { + esc.defaultMethod(); + } + } + + static class InterfaceDirect { + void m(ExampleInterface ei) { + ei.interfaceMethod1(); + } + } + + static class InterfaceDefault { + void m(ExampleInterface ei) { + ei.defaultMethod(); + } + } + + static class ClassStatic { + void m() { + ExampleClass.staticmethod1(); + } + } + + static class InterfaceStatic { + void m() { + ExampleInterface.staticmethod2(); + } + } + + static class SuperFromSubclass extends ExampleClass { + void m() { + super.method1(); + } + } + + static class InheritedFromSubclass extends ExampleClass { + void m() { + method1(); + } + } + + static class Constructor { + Object m() { + return new ExampleClass(true); + } + } + + static class ConstructorFromSubclass extends ExampleClass { + public ConstructorFromSubclass() { + super(true); + } + } + + abstract static class InheritedInterfaceDefault extends ExampleSubclass { + void m() { + defaultMethod(); + } + } + + abstract static class InheritedInterface extends ExampleSubclass { + void m() { + interfaceMethod1(); + } + } + + static class OverrideClassMethod extends ExampleClass { + @Override + public void method1() { } + } + + abstract static class OverrideInterfaceMethod implements ExampleInterface { + @Override + public void interfaceMethod1() { } + } + + abstract static class OverrideDefaultMethod implements ExampleInterface { + @Override + public void defaultMethod() { } + } +} From 61fab7c84985a5a99f69a43fdd1b1c9312608e6c Mon Sep 17 00:00:00 2001 From: Stuart Marks Date: Thu, 25 Aug 2016 21:58:13 -0700 Subject: [PATCH 53/87] 8164835: add a few tools tests to the problem list Reviewed-by: darcy --- langtools/test/ProblemList.txt | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/langtools/test/ProblemList.txt b/langtools/test/ProblemList.txt index 6d80c431a08..c8158673cd0 100644 --- a/langtools/test/ProblemList.txt +++ b/langtools/test/ProblemList.txt @@ -78,3 +78,10 @@ tools/sjavac/ClasspathDependencies.java 8158002 generic-all Requires i # # jdeps +########################################################################### +# +# jdeprscan + +tools/all/RunCodingRules.java 8164836 generic-all fix @DefinedBy +tools/jdeprscan/tests/jdk/jdeprscan/TestLoad.java 8164837 windows-all probably line breaks or encoding +tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java 8164837 windows-all probably line breaks or encoding From 0b92f8723386c3a5ed5483a4322b61e55ab39ef0 Mon Sep 17 00:00:00 2001 From: Robert Field Date: Fri, 26 Aug 2016 11:36:08 -0700 Subject: [PATCH 54/87] 8158738: jshell tool: Save does not affect jshell if started from another editor Reviewed-by: jlahoda --- .../internal/jshell/tool/ExternalEditor.java | 23 +++++++++++++++---- .../jdk/internal/jshell/tool/JShellTool.java | 19 ++++++++++++--- .../jshell/tool/resources/l10n.properties | 19 +++++++++++---- .../jdk/jshell/ToolCommandOptionTest.java | 4 +++- 4 files changed, 52 insertions(+), 13 deletions(-) diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ExternalEditor.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ExternalEditor.java index a77a95acca2..e725f9cd161 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ExternalEditor.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/ExternalEditor.java @@ -34,6 +34,7 @@ import java.nio.file.Path; import java.nio.file.WatchKey; import java.nio.file.WatchService; import java.util.Arrays; +import java.util.Scanner; import java.util.function.Consumer; import java.util.stream.Collectors; import static java.nio.file.StandardWatchEventKinds.ENTRY_CREATE; @@ -46,17 +47,22 @@ import static java.nio.file.StandardWatchEventKinds.ENTRY_MODIFY; public class ExternalEditor { private final Consumer errorHandler; private final Consumer saveHandler; + private final Consumer printHandler; private final IOContext input; + private final boolean wait; private WatchService watcher; private Thread watchedThread; private Path dir; private Path tmpfile; - ExternalEditor(Consumer errorHandler, Consumer saveHandler, IOContext input) { + ExternalEditor(Consumer errorHandler, Consumer saveHandler, + IOContext input, boolean wait, Consumer printHandler) { this.errorHandler = errorHandler; this.saveHandler = saveHandler; + this.printHandler = printHandler; this.input = input; + this.wait = wait; } private void edit(String[] cmd, String initialText) { @@ -121,7 +127,16 @@ public class ExternalEditor { try { input.suspend(); Process process = pb.start(); - process.waitFor(); + // wait to exit edit mode in one of these ways... + if (wait) { + // -wait option -- ignore process exit, wait for carriage-return + Scanner scanner = new Scanner(System.in); + printHandler.accept("jshell.msg.press.return.to.leave.edit.mode"); + scanner.nextLine(); + } else { + // wait for process to exit + process.waitFor(); + } } catch (IOException ex) { errorHandler.accept("process IO failure: " + ex.getMessage()); } catch (InterruptedException ex) { @@ -148,8 +163,8 @@ public class ExternalEditor { } static void edit(String[] cmd, Consumer errorHandler, String initialText, - Consumer saveHandler, IOContext input) { - ExternalEditor ed = new ExternalEditor(errorHandler, saveHandler, input); + Consumer saveHandler, IOContext input, boolean wait, Consumer printHandler) { + ExternalEditor ed = new ExternalEditor(errorHandler, saveHandler, input, wait, printHandler); ed.edit(cmd, initialText); } } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java index f2d0b13feae..fa83c0fd40e 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/JShellTool.java @@ -185,6 +185,7 @@ public class JShellTool implements MessageHandler { private String cmdlineClasspath = null; private String startup = null; private String[] editor = null; + private boolean editorWait = false; // Commands and snippets which should be replayed private List replayableHistory; @@ -481,6 +482,11 @@ public class JShellTool implements MessageHandler { if (editorString == null || editorString.isEmpty()) { editor = null; } else { + char waitMarker = editorString.charAt(0); + if (waitMarker == '-' || waitMarker == '*') { + editorWait = waitMarker == '-'; + editorString = editorString.substring(1); + } editor = editorString.split(RECORD_SEPARATOR); } @@ -1260,7 +1266,7 @@ public class JShellTool implements MessageHandler { // retain editor setting prefs.put(EDITOR_KEY, (editor == null) ? "" - : String.join(RECORD_SEPARATOR, editor)); + : (editorWait? "-" : "*") + String.join(RECORD_SEPARATOR, editor)); return true; case "start": { if (!setStart(cmd, at, false)) { @@ -1315,7 +1321,7 @@ public class JShellTool implements MessageHandler { // The sub-command: /set editor > boolean setEditor(ArgTokenizer at, boolean argsRequired) { - at.allowedOptions("-default"); + at.allowedOptions("-default", "-wait"); String prog = at.next(); List ed = new ArrayList<>(); while (at.val() != null) { @@ -1326,14 +1332,20 @@ public class JShellTool implements MessageHandler { return false; } boolean defaultOption = at.hasOption("-default"); + boolean waitOption = at.hasOption("-wait"); if (prog != null) { if (defaultOption) { errormsg("jshell.err.default.option.or.program", at.whole()); return false; } editor = ed.toArray(new String[ed.size()]); + editorWait = waitOption; fluffmsg("jshell.msg.set.editor.set", prog); } else if (defaultOption) { + if (waitOption) { + errormsg("jshell.err.wait.applies.to.external.editor", at.whole()); + return false; + } editor = null; } else if (argsRequired) { errormsg("jshell.err.set.editor.arg"); @@ -1720,7 +1732,8 @@ public class JShellTool implements MessageHandler { return false; } } else { - ExternalEditor.edit(editor, errorHandler, src, saveHandler, input); + ExternalEditor.edit(editor, errorHandler, src, saveHandler, input, + editorWait, this::hardrb); } return true; } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties index 5d7a1a111ea..7f7f12c0433 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties +++ b/langtools/src/jdk.jshell/share/classes/jdk/internal/jshell/tool/resources/l10n.properties @@ -56,6 +56,8 @@ jshell.err.set.editor.arg = The ''/set editor'' command requires a path argument jshell.msg.set.editor.set = Editor set to: {0} jshell.err.cant.launch.editor = Cannot launch editor -- unexpected exception: {0} jshell.msg.try.set.editor = Try /set editor to use external editor. +jshell.msg.press.return.to.leave.edit.mode = Press return to leave edit mode. +jshell.err.wait.applies.to.external.editor = -wait applies to external editors, cannot be used with -default jshell.msg.try.command.without.args = Try ''{0}'' without arguments. jshell.msg.no.active = There are no active definitions. @@ -358,7 +360,7 @@ Set jshell configuration information, including:\n\ the external editor to use, the start-up definitions to use, a new feedback mode,\n\ the command prompt, the feedback mode to use, or the format of output.\n\ \n\ -/set editor ...\n\t\ +/set editor [-wait] ...\n\t\ Specify the command to launch for the /edit command.\n\t\ The is an operating system dependent string.\n\n\ /set start \n\t\ @@ -602,12 +604,19 @@ The continuation-prompt is used on the second and subsequent lines of a multi-li help.set.editor =\ Specify the command to launch for the /edit command.\n\ \n\t\ -/set editor |-default\n\ +/set editor [-wait] |-default\n\ \n\ The is an operating system dependent string.\n\ -The may include space-separated arguments (such as flags)\n\ -When /edit is used, the temporary file to edit will be appended as the last argument.\n\ -If instead the -default option is specified, the built-in default editor will be used. +The may include space-separated arguments (such as flags)\n\n\ +If the -default option is specified, the built-in default editor will be used.\n\n\ +Otherwise an external editor should be specified in . When \n\ +is used, the temporary file to edit will be appended as the last argument.\n\ +Normally, edit mode will last until the external editor exits. Some external editors\n\ +will exit immediately (for example, if the edit window exists) either external editor\n\ +flags should be used to prevent immediate exit, or the -wait option should be used to\n\ +prompt the user to indicate when edit mode should end.\n\n\ +Note: while in edit mode no command inputs are seen. After leaving edit mode changes\n\ +to the edited snippets are not seen. help.set.start =\ Set the start-up configuration -- a sequence of snippets and commands read at start-up.\n\ diff --git a/langtools/test/jdk/jshell/ToolCommandOptionTest.java b/langtools/test/jdk/jshell/ToolCommandOptionTest.java index 940bd350096..96efdb01368 100644 --- a/langtools/test/jdk/jshell/ToolCommandOptionTest.java +++ b/langtools/test/jdk/jshell/ToolCommandOptionTest.java @@ -23,7 +23,7 @@ /* * @test - * @bug 8157395 8157393 8157517 + * @bug 8157395 8157393 8157517 8158738 * @summary Tests of jshell comand options, and undoing operations * @modules jdk.jshell/jdk.internal.jshell.tool * @build ToolCommandOptionTest ReplToolTesting @@ -148,6 +148,8 @@ public class ToolCommandOptionTest extends ReplToolTesting { "| Unknown option: -furball -mattress -- /retain editor -furball -mattress"), (a) -> assertCommand(a, "/retain editor -default prog", "| Specify -default option or program, not both -- /retain editor -default prog"), + (a) -> assertCommand(a, "/retain editor -default -wait", + "| -wait applies to external editors, cannot be used with -default"), (a) -> assertCommand(a, "/retain editor prog", "| Editor set to: prog"), (a) -> assertCommand(a, "/retain editor prog -default", From 9cda798a33a4ed33709b0c302f5791caa706bfbd Mon Sep 17 00:00:00 2001 From: Bradford Wetmore Date: Fri, 26 Aug 2016 13:44:20 -0700 Subject: [PATCH 55/87] 8061842: Package jurisdiction policy files as something other than JAR Reviewed-by: xuelei, weijun, mullan --- jdk/make/gendata/Gendata-java.base.gmk | 10 +- jdk/make/gendata/GendataCryptoPolicy.gmk | 72 +++++++++ jdk/make/gendata/GendataPolicyJars.gmk | 150 ------------------ .../makejavasecurity/MakeJavaSecurity.java | 22 ++- .../classes/javax/crypto/JceSecurity.java | 138 ++++++++-------- .../share/conf/security/java.security | 50 ++++++ .../share/conf/security/policy/README.txt | 35 ++++ .../policy/limited}/default_US_export.policy | 3 +- .../policy}/limited/default_local.policy | 0 .../policy}/limited/exempt_local.policy | 4 +- .../policy/unlimited/default_US_export.policy | 6 + .../policy}/unlimited/default_local.policy | 1 + .../CryptoPermissions/TestUnlimited.java | 96 +++++++++++ .../JavaDotSecurity/final_java_security | 1 + .../jdk/security/JavaDotSecurity/ifdefs.sh | 10 +- .../JavaDotSecurity/raw_java_security | 1 + 16 files changed, 374 insertions(+), 225 deletions(-) create mode 100644 jdk/make/gendata/GendataCryptoPolicy.gmk delete mode 100644 jdk/make/gendata/GendataPolicyJars.gmk create mode 100644 jdk/src/java.base/share/conf/security/policy/README.txt rename jdk/{make/data/cryptopolicy/unlimited => src/java.base/share/conf/security/policy/limited}/default_US_export.policy (76%) rename jdk/{make/data/cryptopolicy => src/java.base/share/conf/security/policy}/limited/default_local.policy (100%) rename jdk/{make/data/cryptopolicy => src/java.base/share/conf/security/policy}/limited/exempt_local.policy (76%) create mode 100644 jdk/src/java.base/share/conf/security/policy/unlimited/default_US_export.policy rename jdk/{make/data/cryptopolicy => src/java.base/share/conf/security/policy}/unlimited/default_local.policy (99%) create mode 100644 jdk/test/javax/crypto/CryptoPermissions/TestUnlimited.java diff --git a/jdk/make/gendata/Gendata-java.base.gmk b/jdk/make/gendata/Gendata-java.base.gmk index 8547f205011..88acb5b983b 100644 --- a/jdk/make/gendata/Gendata-java.base.gmk +++ b/jdk/make/gendata/Gendata-java.base.gmk @@ -34,7 +34,7 @@ include GendataTZDB.gmk include GendataBlacklistedCerts.gmk -include GendataPolicyJars.gmk +include GendataCryptoPolicy.gmk ################################################################################ @@ -64,13 +64,19 @@ TARGETS += $(GENDATA_CURDATA) 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) diff --git a/jdk/make/gendata/GendataCryptoPolicy.gmk b/jdk/make/gendata/GendataCryptoPolicy.gmk new file mode 100644 index 00000000000..dff51230b44 --- /dev/null +++ b/jdk/make/gendata/GendataCryptoPolicy.gmk @@ -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 \ + +################################################################################ diff --git a/jdk/make/gendata/GendataPolicyJars.gmk b/jdk/make/gendata/GendataPolicyJars.gmk deleted file mode 100644 index 57f80abe9f2..00000000000 --- a/jdk/make/gendata/GendataPolicyJars.gmk +++ /dev/null @@ -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)) diff --git a/jdk/make/src/classes/build/tools/makejavasecurity/MakeJavaSecurity.java b/jdk/make/src/classes/build/tools/makejavasecurity/MakeJavaSecurity.java index 0e3ca50bc26..963db0b593e 100644 --- a/jdk/make/src/classes/build/tools/makejavasecurity/MakeJavaSecurity.java +++ b/jdk/make/src/classes/build/tools/makejavasecurity/MakeJavaSecurity.java @@ -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 @@ import java.util.*; * * 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 class MakeJavaSecurity { 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 @@ public class MakeJavaSecurity { // more restricted packages List 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 @@ public class MakeJavaSecurity { } } + // 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; diff --git a/jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java b/jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java index d4fffacf38f..cc32f835696 100644 --- a/jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java +++ b/jdk/src/java.base/share/classes/javax/crypto/JceSecurity.java @@ -29,6 +29,7 @@ import java.util.*; 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 @@ final class JceSecurity { 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 @@ final class JceSecurity { } } + // 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); - - // Merge the export and import policies for default applications. - if (defaultExport.isEmpty() || defaultImport.isEmpty()) { - throw new SecurityException("Missing mandatory jurisdiction " + - "policy files"); + if (cryptoPolicyPath.getParent().compareTo(javaHomePolicyPath) != 0) { + throw new SecurityException( + "Invalid cryptographic jurisdiction policy directory path: " + + 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); + if (!Files.isDirectory(cryptoPolicyPath) + || !Files.isReadable(cryptoPolicyPath)) { + throw new SecurityException( + "Can't read cryptographic policy directory: " + + cryptoPolicyProperty); } - } - /** - * 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 { + try (DirectoryStream stream = Files.newDirectoryStream( + cryptoPolicyPath, "{default,exempt}_*.policy")) { + for (Path entry : stream) { + try (InputStream is = new BufferedInputStream( + Files.newInputStream(entry))) { + String filename = entry.getFileName().toString(); - JarFile jf = new JarFile(jarPathName); + CryptoPermissions tmpPerms = new CryptoPermissions(); + tmpPerms.load(is); - Enumeration 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); } } - - // 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()); + } 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); + } + + // Must have a default policy + if ((defaultPolicy == null) || defaultPolicy.isEmpty()) { + throw new SecurityException( + "Missing mandatory jurisdiction policy files: " + + cryptoPolicyProperty); + } + + // If there was an empty exempt policy file, ignore it. + if ((exemptPolicy != null) && exemptPolicy.isEmpty()) { + exemptPolicy = null; } - // Close and nullify the JarFile reference to help GC. - jf.close(); - jf = null; } static CryptoPermissions getDefaultPolicy() { diff --git a/jdk/src/java.base/share/conf/security/java.security b/jdk/src/java.base/share/conf/security/java.security index 5154fd05a0f..34e5ac92b47 100644 --- a/jdk/src/java.base/share/conf/security/java.security +++ b/jdk/src/java.base/share/conf/security/java.security @@ -804,6 +804,56 @@ jdk.tls.legacyAlgorithms= \ # 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 +# /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 diff --git a/jdk/src/java.base/share/conf/security/policy/README.txt b/jdk/src/java.base/share/conf/security/policy/README.txt new file mode 100644 index 00000000000..84e33c972b7 --- /dev/null +++ b/jdk/src/java.base/share/conf/security/policy/README.txt @@ -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. /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. diff --git a/jdk/make/data/cryptopolicy/unlimited/default_US_export.policy b/jdk/src/java.base/share/conf/security/policy/limited/default_US_export.policy similarity index 76% rename from jdk/make/data/cryptopolicy/unlimited/default_US_export.policy rename to jdk/src/java.base/share/conf/security/policy/limited/default_US_export.policy index 67d0acc47a3..1f389340585 100644 --- a/jdk/make/data/cryptopolicy/unlimited/default_US_export.policy +++ b/jdk/src/java.base/share/conf/security/policy/limited/default_US_export.policy @@ -1,4 +1,5 @@ -// Manufacturing policy file. +// Default US Export policy file. + grant { // There is no restriction to any algorithms. permission javax.crypto.CryptoAllPermission; diff --git a/jdk/make/data/cryptopolicy/limited/default_local.policy b/jdk/src/java.base/share/conf/security/policy/limited/default_local.policy similarity index 100% rename from jdk/make/data/cryptopolicy/limited/default_local.policy rename to jdk/src/java.base/share/conf/security/policy/limited/default_local.policy diff --git a/jdk/make/data/cryptopolicy/limited/exempt_local.policy b/jdk/src/java.base/share/conf/security/policy/limited/exempt_local.policy similarity index 76% rename from jdk/make/data/cryptopolicy/limited/exempt_local.policy rename to jdk/src/java.base/share/conf/security/policy/limited/exempt_local.policy index f3255a2d970..9dd5b91b06d 100644 --- a/jdk/make/data/cryptopolicy/limited/exempt_local.policy +++ b/jdk/src/java.base/share/conf/security/policy/limited/exempt_local.policy @@ -1,5 +1,5 @@ -// Some countries have import limits on crypto strength. So this file -// will be useful. +// 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. diff --git a/jdk/src/java.base/share/conf/security/policy/unlimited/default_US_export.policy b/jdk/src/java.base/share/conf/security/policy/unlimited/default_US_export.policy new file mode 100644 index 00000000000..1f389340585 --- /dev/null +++ b/jdk/src/java.base/share/conf/security/policy/unlimited/default_US_export.policy @@ -0,0 +1,6 @@ +// Default US Export policy file. + +grant { + // There is no restriction to any algorithms. + permission javax.crypto.CryptoAllPermission; +}; diff --git a/jdk/make/data/cryptopolicy/unlimited/default_local.policy b/jdk/src/java.base/share/conf/security/policy/unlimited/default_local.policy similarity index 99% rename from jdk/make/data/cryptopolicy/unlimited/default_local.policy rename to jdk/src/java.base/share/conf/security/policy/unlimited/default_local.policy index 8dc9702e9da..2b907e25895 100644 --- a/jdk/make/data/cryptopolicy/unlimited/default_local.policy +++ b/jdk/src/java.base/share/conf/security/policy/unlimited/default_local.policy @@ -1,4 +1,5 @@ // Country-specific policy file for countries with no limits on crypto strength. + grant { // There is no restriction to any algorithms. permission javax.crypto.CryptoAllPermission; diff --git a/jdk/test/javax/crypto/CryptoPermissions/TestUnlimited.java b/jdk/test/javax/crypto/CryptoPermissions/TestUnlimited.java new file mode 100644 index 00000000000..e6a8f7f37cc --- /dev/null +++ b/jdk/test/javax/crypto/CryptoPermissions/TestUnlimited.java @@ -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!"); + } +} diff --git a/jdk/test/jdk/security/JavaDotSecurity/final_java_security b/jdk/test/jdk/security/JavaDotSecurity/final_java_security index cd39bea3560..f5d9c68933c 100644 --- a/jdk/test/jdk/security/JavaDotSecurity/final_java_security +++ b/jdk/test/jdk/security/JavaDotSecurity/final_java_security @@ -10,6 +10,7 @@ foo.5=8 foo.6=9a foo.7=10 foo.8=12 +crypto.policy=somepolicy package.access=sun.,\ solaris.,\ diff --git a/jdk/test/jdk/security/JavaDotSecurity/ifdefs.sh b/jdk/test/jdk/security/JavaDotSecurity/ifdefs.sh index aa1371f71cb..5dc58345fc3 100644 --- a/jdk/test/jdk/security/JavaDotSecurity/ifdefs.sh +++ b/jdk/test/jdk/security/JavaDotSecurity/ifdefs.sh @@ -46,7 +46,13 @@ if [ ! -f $TOOLSRC ]; then 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 diff --git a/jdk/test/jdk/security/JavaDotSecurity/raw_java_security b/jdk/test/jdk/security/JavaDotSecurity/raw_java_security index 8a8a7d3cdde..9aa3c42e668 100644 --- a/jdk/test/jdk/security/JavaDotSecurity/raw_java_security +++ b/jdk/test/jdk/security/JavaDotSecurity/raw_java_security @@ -44,6 +44,7 @@ foo.tbd=11 #ifndef macosx-x64 foo.tbd=12 #endif +crypto.policy=crypto.policydir-tbd package.access=sun.,\ #ifdef solaris From cdcc5575ac194677cc06480d028ee5c8893700c6 Mon Sep 17 00:00:00 2001 From: Joe Wang Date: Fri, 26 Aug 2016 14:50:00 -0700 Subject: [PATCH 56/87] 8163232: Catalog API: Consolidating CatalogResolver to support all XML Resolvers Reviewed-by: dfuchs, lancea --- .../xsltc/compiler/util/ErrorMessages.java | 24 +- .../xsltc/compiler/util/ErrorMsg.java | 20 +- .../xsltc/trax/TransformerFactoryImpl.java | 15 +- .../internal/xsltc/trax/TransformerImpl.java | 9 +- .../internal/impl/XMLEntityManager.java | 38 ++- .../internal/impl/msg/XMLMessages.properties | 2 + .../internal/util/EntityResolverWrapper.java | 19 +- .../internal/xinclude/XIncludeHandler.java | 12 +- .../stream/StaxEntityResolverWrapper.java | 7 +- .../classes/javax/xml/catalog/Catalog.java | 6 +- .../javax/xml/catalog/CatalogManager.java | 42 +-- .../javax/xml/catalog/CatalogResolver.java | 212 ++++++++++++-- .../xml/catalog/CatalogResolverImpl.java | 261 +++++++++++++++++- .../javax/xml/catalog/CatalogUriResolver.java | 58 ---- .../xml/catalog/CatalogUriResolverImpl.java | 191 ------------- .../share/classes/javax/xml/catalog/Util.java | 7 + .../catalog/CatalogReferCircularityTest.java | 1 - .../catalog/DefaultFeaturesTest.java | 1 - .../functional/catalog/DeferFeatureTest.java | 1 - .../catalog/DelegatePublicTest.java | 1 - .../catalog/DelegateSystemTest.java | 1 - .../functional/catalog/DelegateUriTest.java | 5 +- .../jaxp/functional/catalog/GroupTest.java | 1 - .../functional/catalog/LoadCatalogTest.java | 7 +- .../functional/catalog/NextCatalogTest.java | 4 +- .../functional/catalog/NormalizationTest.java | 4 +- .../functional/catalog/PreferFeatureTest.java | 1 - .../jaxp/functional/catalog/PreferTest.java | 1 - .../functional/catalog/PublicFamilyTest.java | 1 - .../jaxp/functional/catalog/PublicTest.java | 1 - .../catalog/ResolveFeatureTest.java | 6 +- .../functional/catalog/RewriteSystemTest.java | 1 - .../functional/catalog/RewriteUriTest.java | 9 +- .../catalog/SpecifyCatalogTest.java | 6 +- .../functional/catalog/SystemFamilyTest.java | 1 - .../functional/catalog/SystemSuffixTest.java | 1 - .../jaxp/functional/catalog/SystemTest.java | 1 - .../functional/catalog/UriFamilyTest.java | 11 +- .../functional/catalog/UriSuffixTest.java | 9 +- .../xml/jaxp/functional/catalog/UriTest.java | 15 +- .../functional/catalog/UrnUnwrappingTest.java | 1 - .../catalog/ValidateCatalogTest.java | 3 +- .../catalog/catalogFiles/deferFeature.xml | 2 +- .../functional/catalog/catalogFiles/uri.xml | 2 +- .../catalog/catalogFiles/uriFamily.xml | 2 +- .../isolatedjdk/catalog/PropertiesTest.java | 5 +- .../jaxp/libs/catalog/CatalogTestUtils.java | 11 +- .../jaxp/libs/catalog/ResolutionChecker.java | 15 +- .../jaxp/unittest/catalog/CatalogSupport.java | 1 - .../jaxp/unittest/catalog/CatalogSupport.xml | 22 +- .../unittest/catalog/CatalogSupport1.java | 1 - .../unittest/catalog/CatalogSupport2.java | 1 - .../unittest/catalog/CatalogSupport3.java | 1 - .../unittest/catalog/CatalogSupport4.java | 1 - .../unittest/catalog/CatalogSupport5.java | 250 +++++++++++++++++ .../unittest/catalog/CatalogSupportBase.java | 27 +- .../unittest/catalog/CatalogSupport_uri.xml | 43 +++ .../jaxp/unittest/catalog/CatalogTest.java | 249 ++++++++++++++++- .../xml/jaxp/unittest/catalog/catalog.xml | 2 +- .../xml/jaxp/unittest/catalog/catalog_uri.xml | 24 ++ .../xml/jaxp/unittest/catalog/delegateuri.xml | 5 + .../catalog/files/delegatecatalog.xml | 2 +- .../catalog/files/delegatecatalog_uri.xml | 7 + .../unittest/catalog/files/delegateuri.dtd | 2 + .../xml/jaxp/unittest/catalog/system.xml | 4 +- 65 files changed, 1197 insertions(+), 499 deletions(-) delete mode 100644 jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolver.java delete mode 100644 jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport_uri.xml create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/catalog_uri.xml create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/delegateuri.xml create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegatecatalog_uri.xml create mode 100644 jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegateuri.dtd diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java index 52f944101dc..4f0ce4794e8 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMessages.java @@ -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, @@ -169,6 +169,14 @@ public class ErrorMessages extends ListResourceBundle { {ErrorMsg.INVALID_URI_ERR, "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. diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java index 4192cf2d7e6..69d410b2fa5 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/compiler/util/ErrorMsg.java @@ -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 final class ErrorMsg { 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"; diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java index 84ed22dcd21..c0b29dbf0e9 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerFactoryImpl.java @@ -51,10 +51,11 @@ import java.util.Vector; 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 @@ public class TransformerFactoryImpl // type checking private Map _xsltcExtensionFunctions; - CatalogUriResolver _catalogUriResolver; + CatalogResolver _catalogUriResolver; CatalogFeatures _catalogFeatures; CatalogFeatures.Builder cfBuilder = CatalogFeatures.builder(); // Catalog features @@ -634,7 +635,7 @@ public class TransformerFactoryImpl } // 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 @@ public class TransformerFactoryImpl String transletClassName = getTransletBaseName(source); if (_packageName != null) - transletClassName = _packageName + "." + transletClassName; + transletClassName = _packageName + "." + transletClassName; if (_jarFileName != null) bytecodes = getBytecodesFromJar(source, transletClassName); @@ -1327,7 +1328,7 @@ public class TransformerFactoryImpl 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 @@ public class TransformerFactoryImpl 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; } diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java index 46dd7b60c56..97de2fdfbdf 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xalan/internal/xsltc/trax/TransformerImpl.java @@ -60,9 +60,10 @@ import java.util.Map; 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 @@ public final class TransformerImpl extends Transformer // Catalog features CatalogFeatures _catalogFeatures; - CatalogUriResolver _catalogUriResolver; + CatalogResolver _catalogUriResolver; // Catalog is enabled by default boolean _useCatalog = true; @@ -1337,7 +1338,7 @@ public final class TransformerImpl extends Transformer 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 @@ public final class TransformerImpl extends Transformer return getDOM(resolvedSource); } - catch (TransformerException e) { + catch (TransformerException | CatalogException e) { if (_errorListener != null) postErrorToListener("File not found: " + e.getMessage()); return(null); diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java index 8e25a0b286a..d3b848c9847 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/XMLEntityManager.java @@ -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.StaxEntityResolverWrapper; 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; 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 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver { private boolean fUseCatalog = true; CatalogFeatures fCatalogFeatures; CatalogResolver fCatalogResolver; - CatalogUriResolver fCatalogUriResolver; private String fCatalogFile; private String fDefer; @@ -1044,12 +1039,18 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver { } 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 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver { 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 @@ public class XMLEntityManager implements XMLComponent, XMLEntityResolver { 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 = null; + try { + source = fCatalogResolver.resolve(literalSystemId, baseSystemId); + } catch (CatalogException e) { + throw new XNIException(e); } - Source source = fCatalogUriResolver.resolve(literalSystemId, baseSystemId); if (source != null && !source.isEmpty()) { xmlInputSource = new XMLInputSource(publicId, source.getSystemId(), baseSystemId, true); } diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties index 01531f7ae62..9707c7690ca 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/impl/msg/XMLMessages.properties @@ -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 diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/EntityResolverWrapper.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/EntityResolverWrapper.java index 9cca074e1af..333342ce562 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/EntityResolverWrapper.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/util/EntityResolverWrapper.java @@ -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.XNIException; 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 @@ public class EntityResolverWrapper } throw new XNIException(ex); } + + catch (CatalogException e) { + throw new XNIException(e); + } } // unable to resolve entity diff --git a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java index b1ccb1bc9cc..3f5410c1741 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java +++ b/jaxp/src/java.xml/share/classes/com/sun/org/apache/xerces/internal/xinclude/XIncludeHandler.java @@ -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.CatalogException; 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 @@ public class XIncludeHandler private boolean fUseCatalog = true; CatalogFeatures fCatalogFeatures; CatalogResolver fCatalogResolver; - CatalogUriResolver fCatalogUriResolver; private String fCatalogFile; private String fDefer; @@ -1638,10 +1636,10 @@ public class XIncludeHandler */ 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 @@ public class XIncludeHandler includedSource.getBaseSystemId(), accept, acceptLanguage); } } - catch (IOException e) { + catch (IOException | CatalogException e) { reportResourceError( "XMLResourceError", new Object[] { href, e.getMessage()}); diff --git a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxEntityResolverWrapper.java b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxEntityResolverWrapper.java index d3b50721bae..d531ca0b3be 100644 --- a/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxEntityResolverWrapper.java +++ b/jaxp/src/java.xml/share/classes/com/sun/xml/internal/stream/StaxEntityResolverWrapper.java @@ -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 javax.xml.stream.XMLStreamReader; 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 class StaxEntityResolverWrapper { 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) ; } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java index 848472c3111..16f70ad7581 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Catalog.java @@ -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 @@ import java.util.stream.Stream; *

* A catalog can be used in two situations: *

    - *
  • Locate the replacement text for an external entity; + *
  • Locate the external resources with a public or system identifier; *
  • - *
  • Locate an alternate URI reference for a resource. + *
  • Locate an alternate URI reference with an URI. *
  • *
*

diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java index 2e3c5b4f74b..bc8518685f7 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogManager.java @@ -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 @@ -76,17 +76,6 @@ public final class CatalogManager { return new CatalogResolverImpl(catalog); } - /** - * 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. @@ -115,33 +104,4 @@ public final class CatalogManager { 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. - *

- * If {@code paths} is empty, system property {@code javax.xml.catalog.files} - * will be read to locate the initial list of catalog files. - *

- * 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. - *

- * As specified in - * - * XML Catalogs, OASIS Standard V1.1, 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); - } } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java index b517f0713f1..ecf506f5cab 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolver.java @@ -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. + *

+ * The + * Catalog Standard 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. + *

+ * 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. + *

+ *

Search Order

+ * 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. + *

+ * If no match is found, {@code public} entries may be searched in accordance with + * the {@code prefer} attribute. + *

+ * The {@code prefer} attribute: 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.) + *

+ * 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. + * + *

+ *

Error Handling

+ * The interfaces that the CatalogResolver extend specified checked exceptions, including: + *
    + *
  • + * {@link org.xml.sax.SAXException} and {@link java.io.IOException} by + * {@link org.xml.sax.EntityResolver#resolveEntity(java.lang.String, java.lang.String)} + *
  • + *
  • + * {@link javax.xml.stream.XMLStreamException} by + * {@link javax.xml.stream.XMLResolver#resolveEntity(java.lang.String, java.lang.String, java.lang.String, java.lang.String)} + *
  • + *
  • + * {@link javax.xml.transform.TransformerException} by + * {@link javax.xml.transform.URIResolver#resolve(java.lang.String, java.lang.String)} + *
  • + *
+ *

+ * 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. - *

- * For resolving external entities, system entries will be matched before - * the public entries. - *

- * The {@code prefer} attribute: 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 @@ public interface CatalogResolver extends EntityResolver { * 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}. + *

+ * 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) }. + *

+ * 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) }. + *

+ * 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); + } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java index 326e61ad542..9bf8b357adc 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogResolverImpl.java @@ -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. * *

- * 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 @@ final class CatalogResolverImpl implements CatalogResolver { 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 @@ final class CatalogResolverImpl implements CatalogResolver { 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. + *

+ * 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: + *

+ * {@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) { + } + } + } diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolver.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolver.java deleted file mode 100644 index 76ba60dd2eb..00000000000 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolver.java +++ /dev/null @@ -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); -} diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java deleted file mode 100644 index 497aacf18fd..00000000000 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/CatalogUriResolverImpl.java +++ /dev/null @@ -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. - *

- * 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 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. - *

- * 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: - *

- * {@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); - } -} diff --git a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java index b164f674dbd..f2b00a21ee6 100644 --- a/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java +++ b/jaxp/src/java.xml/share/classes/javax/xml/catalog/Util.java @@ -55,6 +55,9 @@ class Util { * 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 @@ class Util { 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(); diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java index 41eda62e4ab..21a6780bb8d 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/CatalogReferCircularityTest.java @@ -64,4 +64,3 @@ public class CatalogReferCircularityTest { { "catalogReferCircle-left.xml" } }; } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java index 9a05145738f..0cc05e97da0 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DefaultFeaturesTest.java @@ -69,4 +69,3 @@ public class DefaultFeaturesTest { { Feature.RESOLVE, CatalogTestUtils.RESOLVE_STRICT } }; } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java index 1f046f3bed5..626943a335b 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DeferFeatureTest.java @@ -86,4 +86,3 @@ public class DeferFeatureTest { return (int) method.invoke(catalog); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java index e89c82051b0..b20aba8dbf4 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegatePublicTest.java @@ -100,4 +100,3 @@ public class DelegatePublicTest { return catalogResolver("delegatePublic.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java index f18b6c2eba2..e8452622462 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateSystemTest.java @@ -100,4 +100,3 @@ public class DelegateSystemTest { return catalogResolver("delegateSystem.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateUriTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateUriTest.java index 44addf59575..aa8d00efa1f 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateUriTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/DelegateUriTest.java @@ -27,8 +27,8 @@ import static catalog.CatalogTestUtils.catalogUriResolver; 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 @@ public class DelegateUriTest { CatalogException.class } }; } - private CatalogUriResolver createResolver() { + private CatalogResolver createResolver() { return catalogUriResolver("delegateUri.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/GroupTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/GroupTest.java index fd2766896cd..80772f98927 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/GroupTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/GroupTest.java @@ -131,4 +131,3 @@ public class GroupTest { return catalogResolver(CATALOG_GROUP); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java index b985876bb07..b2fa3a94ce8 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/LoadCatalogTest.java @@ -33,7 +33,6 @@ import static catalog.ResolutionChecker.checkUriResolution; 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 @@ public class LoadCatalogTest { 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 @@ public class LoadCatalogTest { } @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 @@ public class LoadCatalogTest { { new String[] { CATALOG_LOADCATALOGFILES } } }; } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/NextCatalogTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/NextCatalogTest.java index 3f14dcda3e0..4dfc4d7186d 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/NextCatalogTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/NextCatalogTest.java @@ -30,7 +30,6 @@ import static catalog.ResolutionChecker.checkSysIdResolution; 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 @@ public class NextCatalogTest { CATALOG_NEXTCATALOGRIGHT); } - private CatalogUriResolver createUriResolver() { + private CatalogResolver createUriResolver() { return catalogUriResolver(CATALOG_NEXTCATALOGLEFT, CATALOG_NEXTCATALOGRIGHT); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/NormalizationTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/NormalizationTest.java index b7715c0f69b..d66941940cf 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/NormalizationTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/NormalizationTest.java @@ -30,7 +30,6 @@ import static catalog.ResolutionChecker.checkSysIdResolution; 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 @@ public class NormalizationTest { return catalogResolver(CATALOG_NORMALIZATION); } - private CatalogUriResolver createUriResolver() { + private CatalogResolver createUriResolver() { return catalogUriResolver(CATALOG_NORMALIZATION); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java index c449771b135..3f783bebbe7 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PreferFeatureTest.java @@ -81,4 +81,3 @@ public class PreferFeatureTest { "preferFeature.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/PreferTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/PreferTest.java index 2f73bb7cb4a..c9812ead83d 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/PreferTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PreferTest.java @@ -92,4 +92,3 @@ public class PreferTest { return catalogResolver("prefer.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java index e149949f98a..68081e29199 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PublicFamilyTest.java @@ -70,4 +70,3 @@ public class PublicFamilyTest { return catalogResolver("publicFamily.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/PublicTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/PublicTest.java index 48c103e4203..f7a3ebd4376 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/PublicTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/PublicTest.java @@ -92,4 +92,3 @@ public class PublicTest { return catalogResolver(CATALOG_PUBLIC); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java index 9cb29bd3694..7714e66ea12 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/ResolveFeatureTest.java @@ -38,7 +38,6 @@ import javax.xml.catalog.CatalogException; 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 @@ public class ResolveFeatureTest { */ @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 @@ public class ResolveFeatureTest { 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 @@ public class ResolveFeatureTest { return builder().with(Feature.RESOLVE, resolve).build(); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java index fb45816981c..c1a42668827 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteSystemTest.java @@ -95,4 +95,3 @@ public class RewriteSystemTest { return catalogResolver("rewriteSystem.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteUriTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteUriTest.java index 0a449420bd1..f4777dbaaf0 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteUriTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/RewriteUriTest.java @@ -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 @@ public class RewriteUriTest { */ @Test(expectedExceptions = CatalogException.class) public void testNoMatch() { - checkNoMatch(createResolver()); + checkNoUriMatch(createResolver()); } - private CatalogUriResolver createResolver() { + private CatalogResolver createResolver() { return catalogUriResolver("rewriteUri.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java index 6085e6e60a2..47506989742 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SpecifyCatalogTest.java @@ -36,7 +36,6 @@ import static javax.xml.catalog.CatalogFeatures.Feature.FILES; 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 @@ public class SpecifyCatalogTest { } /* - * 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 @@ public class SpecifyCatalogTest { 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 @@ public class SpecifyCatalogTest { return builder().with(FILES, getCatalogPath(catalogName)).build(); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java index aa921b5ef50..0c62b7d72ac 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemFamilyTest.java @@ -84,4 +84,3 @@ public class SystemFamilyTest { return catalogResolver("systemFamily.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java index 97622704682..6b83fdc306e 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemSuffixTest.java @@ -95,4 +95,3 @@ public class SystemSuffixTest { return catalogResolver("systemSuffix.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemTest.java index d78029319bd..4be1e621e17 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/SystemTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/SystemTest.java @@ -92,4 +92,3 @@ public class SystemTest { return catalogResolver(CATALOG_SYSTEM); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/UriFamilyTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/UriFamilyTest.java index f6104e8d15d..7e7d1c28e82 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/UriFamilyTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UriFamilyTest.java @@ -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 @@ public class UriFamilyTest { 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 @@ public class UriFamilyTest { */ @Test(expectedExceptions = CatalogException.class) public void testNoMatch() { - checkNoMatch(createResolver()); + checkNoUriMatch(createResolver()); } - private CatalogUriResolver createResolver() { + private CatalogResolver createResolver() { return catalogUriResolver("uriFamily.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/UriSuffixTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/UriSuffixTest.java index 9cc4a2736e2..c27094fda84 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/UriSuffixTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UriSuffixTest.java @@ -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 @@ public class UriSuffixTest { */ @Test(expectedExceptions = CatalogException.class) public void testNoMatch() { - checkNoMatch(createResolver()); + checkNoUriMatch(createResolver()); } - private CatalogUriResolver createResolver() { + private CatalogResolver createResolver() { return catalogUriResolver("uriSuffix.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/UriTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/UriTest.java index ae17e34c6a1..6b6976d6d9e 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/UriTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UriTest.java @@ -26,12 +26,12 @@ package catalog; 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 @@ public class UriTest { 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 @@ public class UriTest { } /* - * 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 @@ public class UriTest { "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 @@ public class UriTest { */ @Test(expectedExceptions = CatalogException.class) public void testNoMatch() { - checkNoMatch(createResolver()); + checkNoUriMatch(createResolver()); } - private CatalogUriResolver createResolver() { + private CatalogResolver createResolver() { return catalogUriResolver(CATALOG_URI); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java index 468de7ef528..dbdcb446fa7 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/UrnUnwrappingTest.java @@ -67,4 +67,3 @@ public class UrnUnwrappingTest { return catalogResolver("urnUnwrapping.xml"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java b/jaxp/test/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java index d0194ca4009..dc7bf7a7e7b 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/ValidateCatalogTest.java @@ -98,8 +98,7 @@ public class ValidateCatalogTest { "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"); } } - diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/deferFeature.xml b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/deferFeature.xml index 4bdc2591916..d9c58af34ce 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/deferFeature.xml +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/deferFeature.xml @@ -2,7 +2,7 @@ - + diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uri.xml b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uri.xml index 1ce36ea7f7b..9f37a17bc32 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uri.xml +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uri.xml @@ -1,7 +1,7 @@ - + diff --git a/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uriFamily.xml b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uriFamily.xml index 2311cf9aa22..bcdc03c060f 100644 --- a/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uriFamily.xml +++ b/jaxp/test/javax/xml/jaxp/functional/catalog/catalogFiles/uriFamily.xml @@ -4,7 +4,7 @@ - + diff --git a/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java b/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java index 91b29b1d97b..ce95aa410ce 100644 --- a/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java +++ b/jaxp/test/javax/xml/jaxp/isolatedjdk/catalog/PropertiesTest.java @@ -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.HashMap; 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 @@ public class PropertiesTest { } 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()); diff --git a/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java b/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java index a0e83d5b810..01d45ff591b 100644 --- a/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java +++ b/jaxp/test/javax/xml/jaxp/libs/catalog/CatalogTestUtils.java @@ -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 java.util.stream.Stream; 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 @@ final class CatalogTestUtils { /* * 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. diff --git a/jaxp/test/javax/xml/jaxp/libs/catalog/ResolutionChecker.java b/jaxp/test/javax/xml/jaxp/libs/catalog/ResolutionChecker.java index 002ec22ede4..81013a5a7bd 100644 --- a/jaxp/test/javax/xml/jaxp/libs/catalog/ResolutionChecker.java +++ b/jaxp/test/javax/xml/jaxp/libs/catalog/ResolutionChecker.java @@ -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 @@ class ResolutionChecker { * 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 @@ class ResolutionChecker { /* * 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 @@ class ResolutionChecker { /* * 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 @@ class ResolutionChecker { * URI reference with a specified base location. */ static void expectExceptionOnUri( - CatalogUriResolver resolver, String href, String base, + CatalogResolver resolver, String href, String base, Class expectedExceptionClass) { expectThrows(expectedExceptionClass, () -> { resolver.resolve(href, base); @@ -151,7 +150,7 @@ class ResolutionChecker { * URI reference without any specified base location. */ static void expectExceptionOnUri( - CatalogUriResolver resolver, String href, + CatalogResolver resolver, String href, Class expectedExceptionClass) { expectExceptionOnUri(resolver, href, null, expectedExceptionClass); } diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java index f8dbda9310a..1078d7cd2c0 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.java @@ -327,4 +327,3 @@ public class CatalogSupport extends CatalogSupportBase { }; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.xml index 22df286942a..f889ac50a78 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.xml +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport.xml @@ -11,32 +11,32 @@ - - - - + + + + - + - - + + - - - + + + - + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java index cac5e33e99c..251a65fc779 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport1.java @@ -268,4 +268,3 @@ public class CatalogSupport1 extends CatalogSupportBase { } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java index 10159d3567c..8332596e329 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport2.java @@ -270,4 +270,3 @@ public class CatalogSupport2 extends CatalogSupportBase { }; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java index 6760b1981e1..473ca119c90 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport3.java @@ -280,4 +280,3 @@ public class CatalogSupport3 extends CatalogSupportBase { }; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java index 12b15e64348..b565cf30853 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport4.java @@ -269,4 +269,3 @@ public class CatalogSupport4 extends CatalogSupportBase { }; } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java new file mode 100644 index 00000000000..884f34ddb88 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport5.java @@ -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"}, + }; + } +} diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java index 83a1520c45d..87735104855 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupportBase.java @@ -35,9 +35,9 @@ import java.io.Reader; 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.transform.stream.StreamSource; 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 @@ public class CatalogSupportBase { } + + /** + * 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 @@ public class CatalogSupportBase { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport_uri.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport_uri.xml new file mode 100644 index 00000000000..8a4b0dbf290 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogSupport_uri.xml @@ -0,0 +1,43 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java index 4c00ef686c8..6f622f9ab25 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/CatalogTest.java @@ -26,23 +26,37 @@ import static jaxp.library.JAXPTestUtilities.clearSystemProperty; 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 @@ import org.xml.sax.ext.DefaultHandler2; /* * @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 @@ public class CatalogTest { @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 @@ public class CatalogTest { 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 @@ public class CatalogTest { /* - 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 @@ public class CatalogTest { } } } - diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalog.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalog.xml index f7340d77859..0c25770bf3b 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalog.xml +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalog.xml @@ -26,4 +26,4 @@ - \ No newline at end of file + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/catalog_uri.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalog_uri.xml new file mode 100644 index 00000000000..26adf0f3f01 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/catalog_uri.xml @@ -0,0 +1,24 @@ + + + + + + + + + + + + + + + + + + + + + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/delegateuri.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/delegateuri.xml new file mode 100644 index 00000000000..88b802cfe44 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/delegateuri.xml @@ -0,0 +1,5 @@ + + + +Test &delegateuri; entry diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegatecatalog.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegatecatalog.xml index 1344c78101a..b398f5ba30d 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegatecatalog.xml +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegatecatalog.xml @@ -22,4 +22,4 @@ - \ No newline at end of file + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegatecatalog_uri.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegatecatalog_uri.xml new file mode 100644 index 00000000000..a9f6b86be0c --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegatecatalog_uri.xml @@ -0,0 +1,7 @@ + + + + + + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegateuri.dtd b/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegateuri.dtd new file mode 100644 index 00000000000..a8e56d26fb3 --- /dev/null +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/files/delegateuri.dtd @@ -0,0 +1,2 @@ + + diff --git a/jaxp/test/javax/xml/jaxp/unittest/catalog/system.xml b/jaxp/test/javax/xml/jaxp/unittest/catalog/system.xml index a96c4d896f7..0ceb2c633d0 100644 --- a/jaxp/test/javax/xml/jaxp/unittest/catalog/system.xml +++ b/jaxp/test/javax/xml/jaxp/unittest/catalog/system.xml @@ -1,5 +1,5 @@ - -Test &system; entry \ No newline at end of file +Test &system; entry From 1386ffb4f2e026cf2fbaf199548a5f3179f532a9 Mon Sep 17 00:00:00 2001 From: Jonathan Gibbons Date: Fri, 26 Aug 2016 15:54:36 -0700 Subject: [PATCH 57/87] 8164887: update tests to remove use of old-style options Reviewed-by: mchung --- langtools/make/build.xml | 10 ++--- langtools/make/diags-examples.xml | 24 +++++------ .../make/gendata/Gendata-jdk.compiler.gmk | 8 ++-- .../make/intellij/runConfigurations/javah.xml | 2 +- .../make/intellij/runConfigurations/javap.xml | 2 +- .../intellij/runConfigurations/jshell.xml | 2 +- .../intellij/runConfigurations/sjavac.xml | 2 +- langtools/make/netbeans/langtools/build.xml | 10 ++--- .../TestFramesNoFrames.java | 2 +- .../doclet/testModules/TestModules.java | 8 ++-- .../javadoc/tool/modules/FilterOptions.java | 37 ++++++++--------- .../jdk/javadoc/tool/modules/Modules.java | 17 ++++---- .../javadoc/tool/modules/PackageOptions.java | 41 +++++++++---------- langtools/test/tools/javac/VersionOpt.java | 4 +- .../modulesourcepath | 2 +- .../ModuleNotFoundInModuleSourcePath.java | 2 +- .../XModuleWithModulePath.java | 2 +- .../test/tools/javac/file/LimitedImage.java | 4 +- .../test/tools/javac/modules/GraphsTest.java | 2 +- .../javac/modules/ModuleSourcePathTest.java | 2 +- .../tools/javac/modules/NPEEmptyFileTest.java | 2 +- .../jdkinternals/RemovedJDKInternals.java | 2 +- .../test/tools/jdeps/lib/CompilerUtils.java | 2 +- 23 files changed, 93 insertions(+), 96 deletions(-) diff --git a/langtools/make/build.xml b/langtools/make/build.xml index c844103ed54..3fec57e54ef 100644 --- a/langtools/make/build.xml +++ b/langtools/make/build.xml @@ -88,18 +88,18 @@ - + - + - - + + + + + + "Hello World" + + + In a named module and named package + + diff --git a/langtools/test/jdk/javadoc/doclet/testCopyFiles/packages/p1/Foo.java b/langtools/test/jdk/javadoc/doclet/testCopyFiles/packages/p1/Foo.java new file mode 100644 index 00000000000..8e1960b5788 --- /dev/null +++ b/langtools/test/jdk/javadoc/doclet/testCopyFiles/packages/p1/Foo.java @@ -0,0 +1,34 @@ +/* + * 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. + */ + + /** + * A test class. + */ +package p1; + +/** + * A test class. + */ +public class Foo {} diff --git a/langtools/test/jdk/javadoc/doclet/testCopyFiles/packages/p1/doc-files/inpackage.html b/langtools/test/jdk/javadoc/doclet/testCopyFiles/packages/p1/doc-files/inpackage.html new file mode 100644 index 00000000000..4879d78d5a4 --- /dev/null +++ b/langtools/test/jdk/javadoc/doclet/testCopyFiles/packages/p1/doc-files/inpackage.html @@ -0,0 +1,33 @@ + + + + + "Hello World" + + + A named package in an unnamed module. + + diff --git a/langtools/test/jdk/javadoc/doclet/testCopyFiles/unnamed/Foo.java b/langtools/test/jdk/javadoc/doclet/testCopyFiles/unnamed/Foo.java new file mode 100644 index 00000000000..48210d11a77 --- /dev/null +++ b/langtools/test/jdk/javadoc/doclet/testCopyFiles/unnamed/Foo.java @@ -0,0 +1,33 @@ +/* + * 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. + */ + + /** + * A test class. + */ + +/** + * A test class. + */ +public class Foo {} diff --git a/langtools/test/jdk/javadoc/doclet/testCopyFiles/unnamed/doc-files/inpackage.html b/langtools/test/jdk/javadoc/doclet/testCopyFiles/unnamed/doc-files/inpackage.html new file mode 100644 index 00000000000..5321e80d86b --- /dev/null +++ b/langtools/test/jdk/javadoc/doclet/testCopyFiles/unnamed/doc-files/inpackage.html @@ -0,0 +1,33 @@ + + + + + "Hello World" + + + In an unnamed package + + From 10cbe0678ac9e09a5902e1126d5d75e33d4d9986 Mon Sep 17 00:00:00 2001 From: Athijegannathan Sundararajan Date: Mon, 29 Aug 2016 21:09:36 +0530 Subject: [PATCH 66/87] 8159004: jlink attempts to create launcher scripts when root/bin dir does not exist Reviewed-by: jlaskey, alanb --- .../tools/jlink/builder/DefaultImageBuilder.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java index 6f4c7e59041..aaccb4269a0 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/builder/DefaultImageBuilder.java @@ -90,11 +90,9 @@ public final class DefaultImageBuilder implements ImageBuilder { private static List createArgs(Path home) { Objects.requireNonNull(home); - List javaArgs = new ArrayList<>(); Path binDir = home.resolve("bin"); String java = Files.exists(binDir.resolve("java"))? "java" : "java.exe"; - javaArgs.add(binDir.resolve(java).toString()); - return Collections.unmodifiableList(javaArgs); + return List.of(binDir.resolve(java).toString()); } @Override @@ -170,6 +168,7 @@ public final class DefaultImageBuilder implements ImageBuilder { // 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)) { @@ -191,7 +190,6 @@ public final class DefaultImageBuilder implements ImageBuilder { 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")) @@ -209,7 +207,11 @@ public final class DefaultImageBuilder implements ImageBuilder { } } - prepareApplicationFiles(files, modules); + // If native files are stripped completely, /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); } @@ -229,7 +231,7 @@ public final class DefaultImageBuilder implements ImageBuilder { this.targetOsName = props.getProperty("OS_NAME"); if (this.targetOsName == null) { - throw new RuntimeException("can't determine target OS from java.base descriptor"); + throw new PluginException("TargetPlatform attribute is missing for java.base module"); } Optional release = pool.findEntry("/java.base/release"); From af8dc755fd32acba874bc2d2204393d0a071ae48 Mon Sep 17 00:00:00 2001 From: Svetlana Nikandrova Date: Mon, 29 Aug 2016 20:55:06 +0300 Subject: [PATCH 67/87] 8164533: sun/security/ssl/SSLSocketImpl/CloseSocket.java failed with "Error while cleaning up threads after test" Reviewed-by: xuelei --- .../ssl/SSLSocketImpl/CloseSocket.java | 135 +++++++++++------- 1 file changed, 82 insertions(+), 53 deletions(-) diff --git a/jdk/test/sun/security/ssl/SSLSocketImpl/CloseSocket.java b/jdk/test/sun/security/ssl/SSLSocketImpl/CloseSocket.java index 4c532beb8ac..12bfb4ef001 100644 --- a/jdk/test/sun/security/ssl/SSLSocketImpl/CloseSocket.java +++ b/jdk/test/sun/security/ssl/SSLSocketImpl/CloseSocket.java @@ -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 { - 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(); - } - } - }.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..."); + private static ArrayList testCases = new ArrayList<>(); + + static { + testCases.add(socket -> socket.startHandshake()); + testCases.add(socket -> { 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..."); + in.read(); + }); + testCases.add(socket -> { 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"); + }); + } + + public static void main(String[] args) throws Exception { + 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"); + } + } } } + 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; + } } From bc903b0547261120546a1ee9ec71d386fb74c8d2 Mon Sep 17 00:00:00 2001 From: Xueming Shen Date: Mon, 29 Aug 2016 11:39:12 -0700 Subject: [PATCH 68/87] 8066577: Cleanup and make better use of the stream API in the jrtfs code Reviewed-by: alanb, psandoz, redestad --- .../internal/jrtfs/JrtDirectoryStream.java | 30 +++++++++---------- .../jdk/internal/jrtfs/JrtFileSystem.java | 8 ++--- 2 files changed, 16 insertions(+), 22 deletions(-) diff --git a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java index eced854d9d8..f2f2aa684c3 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtDirectoryStream.java @@ -47,8 +47,8 @@ final class JrtDirectoryStream implements DirectoryStream { private final JrtPath dir; private final DirectoryStream.Filter filter; - private volatile boolean isClosed; - private volatile Iterator itr; + private boolean isClosed; + private Iterator itr; JrtDirectoryStream(JrtPath dir, DirectoryStream.Filter filter) @@ -73,24 +73,22 @@ final class JrtDirectoryStream implements DirectoryStream { throw new IllegalStateException(e); } return new Iterator() { - 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(); + } } }; } diff --git a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java index 5f0433b9d3b..cb6c85d11e3 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java +++ b/jdk/src/java.base/share/classes/jdk/internal/jrtfs/JrtFileSystem.java @@ -119,9 +119,7 @@ class JrtFileSystem extends FileSystem { @Override public Iterable getRootDirectories() { - ArrayList dirs = new ArrayList<>(); - dirs.add(getRootPath()); - return dirs; + return Collections.singleton(getRootPath()); } @Override @@ -159,9 +157,7 @@ class JrtFileSystem extends FileSystem { @Override public final Iterable getFileStores() { - ArrayList list = new ArrayList<>(1); - list.add(getFileStore(getRootPath())); - return list; + return Collections.singleton(getFileStore(getRootPath())); } private static final Set supportedFileAttributeViews From dc0db76409cf0c16dd1805502b4ec73f9264c472 Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Mon, 29 Aug 2016 20:55:24 +0200 Subject: [PATCH 69/87] 8164836: TEST_BUG: adjust scope of the DefinedByAnalyzer in tools/all/RunCodingRules.java Only enabling the DefinedByAnalyzer on java.compiler and jdk.compiler; removing the @DefinedBy annotations from other modules Reviewed-by: jjg, ksrini --- .../make/tools/crules/DefinedByAnalyzer.java | 18 +++ .../javadoc/internal/api/JavadocTaskImpl.java | 4 - .../jdk/javadoc/internal/api/JavadocTool.java | 12 +- .../html/AbstractExecutableMemberWriter.java | 10 +- .../formats/html/AbstractIndexWriter.java | 9 +- .../doclets/formats/html/ClassWriterImpl.java | 4 +- .../formats/html/HtmlDocletWriter.java | 72 +++++----- .../formats/html/TagletWriterImpl.java | 11 +- .../doclets/toolkit/OverviewElement.java | 22 ++- .../toolkit/taglets/TagletManager.java | 16 +-- .../doclets/toolkit/util/ClassUseMapper.java | 48 ++++--- .../doclets/toolkit/util/CommentHelper.java | 92 ++++++------- .../internal/doclets/toolkit/util/Utils.java | 129 +++++++++--------- .../toolkit/util/links/LinkFactory.java | 12 +- .../javadoc/internal/tool/ElementsTable.java | 20 ++- .../com/sun/tools/javap/JavapTask.java | 25 ---- .../classes/jdk/jshell/MemoryFileManager.java | 38 +++--- .../jdk/jshell/SourceCodeAnalysisImpl.java | 8 +- .../jdk/jshell/TreeDependencyScanner.java | 16 +-- langtools/test/ProblemList.txt | 1 - 20 files changed, 260 insertions(+), 307 deletions(-) diff --git a/langtools/make/tools/crules/DefinedByAnalyzer.java b/langtools/make/tools/crules/DefinedByAnalyzer.java index b0ab426239e..fe79c8eb745 100644 --- a/langtools/make/tools/crules/DefinedByAnalyzer.java +++ b/langtools/make/tools/crules/DefinedByAnalyzer.java @@ -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,7 +49,20 @@ public class DefinedByAnalyzer extends AbstractCodingRulesAnalyzer { eventKind = Kind.ANALYZE; } + //only java.compiler and jdk.compiler modules implement the APIs, + //so only these need the @DefinedBy annotation: + private static final Set 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))) { diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTaskImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTaskImpl.java index 97ec41633c9..d7cb90d0d5a 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTaskImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTaskImpl.java @@ -34,8 +34,6 @@ import javax.tools.JavaFileObject; 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 @@ public class JavadocTaskImpl implements DocumentationTask { 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(); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java index f85a52bfaeb..f9a5d52e454 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/api/JavadocTool.java @@ -49,8 +49,6 @@ import com.sun.tools.javac.file.JavacFileManager; 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 @@ import jdk.javadoc.internal.tool.ToolOption; * or deletion without notice.

*/ public class JavadocTool implements DocumentationTool { - @Override @DefinedBy(Api.COMPILER) + @Override public DocumentationTask getTask( Writer out, JavaFileManager fileManager, @@ -129,7 +127,7 @@ public class JavadocTool implements DocumentationTool { } // TODO: used shared static method in JavacFileManager - @Override @DefinedBy(Api.COMPILER) + @Override public StandardJavaFileManager getStandardFileManager( DiagnosticListener diagnosticListener, Locale locale, @@ -145,7 +143,7 @@ public class JavadocTool implements DocumentationTool { 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 @@ public class JavadocTool implements DocumentationTool { } } - @Override @DefinedBy(Api.COMPILER) + @Override public Set 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(); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java index 1d13d416b8b..7ce394be641 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractExecutableMemberWriter.java @@ -39,8 +39,6 @@ import javax.lang.model.type.TypeMirror; 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 @@ public abstract class AbstractExecutableMemberWriter extends AbstractMemberWrite SimpleTypeVisitor9 stv = new SimpleTypeVisitor9() { 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; diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java index 118dd3c8941..26e6b1f35fb 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/AbstractIndexWriter.java @@ -37,7 +37,6 @@ import javax.lang.model.element.TypeElement; 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; @@ -183,7 +182,7 @@ public class AbstractIndexWriter extends HtmlDocletWriter { SearchIndexItem si = new SearchIndexItem(); new SimpleElementVisitor9() { - @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 @@ public class AbstractIndexWriter extends HtmlDocletWriter { 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); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java index 1e64848771f..e812649f7cf 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/ClassWriterImpl.java @@ -36,8 +36,6 @@ import javax.lang.model.type.TypeMirror; 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; @@ -560,7 +558,7 @@ public class ClassWriterImpl extends SubWriterHolderWriter implements ClassWrite if (outerClass == null) return; new SimpleElementVisitor8() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitType(TypeElement e, Void p) { Content label = utils.isInterface(e) ? contents.enclosingInterfaceLabel diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java index 0945cc80603..0703094fd3f 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/HtmlDocletWriter.java @@ -62,8 +62,6 @@ 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; @@ -1835,7 +1833,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { 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) { @@ -1884,7 +1882,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitComment(CommentTree node, Content c) { if (isFirstSentence && isFirst(node)) { commentRemoved = true; @@ -1902,7 +1900,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { return content; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitDocRoot(DocRootTree node, Content c) { Content docRootContent = TagletWriter.getInlineTagOutput(element, configuration.tagletManager, @@ -1917,20 +1915,20 @@ public class HtmlDocletWriter extends HtmlDocWriter { return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitEndElement(EndElementTree node, Content c) { RawHtml rawHtml = new RawHtml(""); 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); @@ -1938,7 +1936,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Boolean visitInheritDoc(InheritDocTree node, Content c) { Content output = TagletWriter.getInlineTagOutput(element, configuration.tagletManager, holderTag, @@ -1948,7 +1946,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { 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, @@ -1959,14 +1957,14 @@ public class HtmlDocletWriter extends HtmlDocWriter { 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)); @@ -1976,14 +1974,14 @@ public class HtmlDocletWriter extends HtmlDocWriter { 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)); @@ -2011,7 +2009,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { 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))); @@ -2019,7 +2017,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { return false; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override protected Boolean defaultAction(DocTree node, Content c) { Content output = TagletWriter.getInlineTagOutput(element, configuration.tagletManager, holderTag, tag, @@ -2097,27 +2095,27 @@ public class HtmlDocletWriter extends HtmlDocWriter { } DocPath redirectPathFromRoot = new SimpleElementVisitor9() { - @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; } @@ -2378,13 +2376,13 @@ public class HtmlDocletWriter extends HtmlDocWriter { List annotationTypeValues = new ArrayList<>(); new SimpleAnnotationValueVisitor9>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitArray(List vals, List p) { p.addAll(vals); return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Void defaultAction(Object o, List p) { p.add(annotationValue); return null; @@ -2406,7 +2404,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { List annotationTypeValues = new ArrayList<>(); for (AnnotationValue a : pairs.values()) { new SimpleAnnotationValueVisitor9>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitArray(List vals, List annotationTypeValues) { for (AnnotationValue av : vals) { annotationTypeValues.add(av); @@ -2482,12 +2480,12 @@ public class HtmlDocletWriter extends HtmlDocWriter { AnnotationValue annotationValue = map.get(element); List annotationTypeValues = new ArrayList<>(); new SimpleAnnotationValueVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitArray(List 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; @@ -2520,13 +2518,13 @@ public class HtmlDocletWriter extends HtmlDocWriter { for (ExecutableElement ee : pairs.keySet()) { annotationValue = pairs.get(ee); boolean rvalue = new SimpleAnnotationValueVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitArray(List vals, Void p) { if (vals.size() > 1) { if (vals.get(0) instanceof AnnotationMirror) { isContainerDocumented = true; return new SimpleAnnotationValueVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitAnnotation(AnnotationMirror a, Void p) { isContainerDocumented = true; Element asElement = a.getAnnotationType().asElement(); @@ -2535,7 +2533,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { } return true; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Boolean defaultAction(Object o, Void p) { return false; } @@ -2545,7 +2543,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { return false; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Boolean defaultAction(Object o, Void p) { return false; } @@ -2560,10 +2558,10 @@ public class HtmlDocletWriter extends HtmlDocWriter { private Content annotationValueToContent(AnnotationValue annotationValue) { return new SimpleAnnotationValueVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Content visitType(TypeMirror t, Void p) { return new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Content visitDeclared(DeclaredType t, Void p) { LinkInfoImpl linkInfo = new LinkInfoImpl(configuration, LinkInfoImpl.Kind.ANNOTATION, t); @@ -2573,13 +2571,13 @@ public class HtmlDocletWriter extends HtmlDocWriter { 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 list = getAnnotations(0, a, false); ContentBuilder buf = new ContentBuilder(); @@ -2588,12 +2586,12 @@ public class HtmlDocletWriter extends HtmlDocWriter { } 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 vals, Void p) { ContentBuilder buf = new ContentBuilder(); String sep = ""; @@ -2604,7 +2602,7 @@ public class HtmlDocletWriter extends HtmlDocWriter { } return buf; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Content defaultAction(Object o, Void p) { return new StringContent(annotationValue.toString()); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java index 2f27bee353f..4a51e945149 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/formats/html/TagletWriterImpl.java @@ -37,7 +37,6 @@ import javax.lang.model.util.SimpleElementVisitor9; import com.sun.source.doctree.DocTree; import com.sun.source.doctree.IndexTree; -import com.sun.tools.javac.util.DefinedBy; 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.HtmlTree; @@ -113,14 +112,14 @@ public class TagletWriterImpl extends TagletWriter { si.setLabel(tagText); si.setDescription(desc); new SimpleElementVisitor9() { - @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL) + @Override public Void visitModule(ModuleElement e, Void p) { si.setUrl(DocPaths.moduleSummary(e).getPath() + "#" + anchorName); si.setHolder(utils.getSimpleName(element)); return null; } - @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL) + @Override public Void visitPackage(PackageElement e, Void p) { si.setUrl(DocPath.forPackage(e).getPath() + "/" + DocPaths.PACKAGE_SUMMARY.getPath() + "#" + anchorName); @@ -128,14 +127,14 @@ public class TagletWriterImpl extends TagletWriter { return null; } - @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL) + @Override public Void visitType(TypeElement e, Void p) { si.setUrl(DocPath.forClass(utils, e).getPath() + "#" + anchorName); si.setHolder(utils.getFullyQualifiedName(e)); return null; } - @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL) + @Override public Void visitVariable(VariableElement e, Void p) { TypeElement te = utils.getEnclosingTypeElement(e); si.setUrl(DocPath.forClass(utils, te).getPath() + "#" + anchorName); @@ -143,7 +142,7 @@ public class TagletWriterImpl extends TagletWriter { return null; } - @Override @DefinedBy(DefinedBy.Api.LANGUAGE_MODEL) + @Override protected Void defaultAction(Element e, Void p) { TypeElement te = utils.getEnclosingTypeElement(e); si.setUrl(DocPath.forClass(utils, te).getPath() + "#" + anchorName); diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/OverviewElement.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/OverviewElement.java index 082a0b0432f..042c1afc7b4 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/OverviewElement.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/OverviewElement.java @@ -35,8 +35,6 @@ import javax.lang.model.element.ElementVisitor; import javax.lang.model.element.Name; import javax.lang.model.type.TypeMirror; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import jdk.javadoc.doclet.DocletEnvironment; /** @@ -56,52 +54,52 @@ public class OverviewElement implements Element { this.docEnv = docEnv; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public TypeMirror asType() { throw new UnsupportedOperationException("Unsupported method"); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public ElementKind getKind() { return ElementKind.OTHER; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Set getModifiers() { throw new UnsupportedOperationException("Unsupported method"); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Name getSimpleName() { throw new UnsupportedOperationException("Unsupported method"); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Element getEnclosingElement() { throw new UnsupportedOperationException("Unsupported method"); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public java.util.List getEnclosedElements() { throw new UnsupportedOperationException("Unsupported method"); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public java.util.List getAnnotationMirrors() { throw new UnsupportedOperationException("Unsupported method"); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public A getAnnotation(Class annotationType) { throw new UnsupportedOperationException("Unsupported method"); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public R accept(ElementVisitor v, P p) { return v.visitUnknown(this, p); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public A[] getAnnotationsByType(Class annotationType) { throw new UnsupportedOperationException("Unsupported method"); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java index 24f2a53e4bc..676cabdd4d3 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/taglets/TagletManager.java @@ -39,8 +39,6 @@ import javax.tools.JavaFileManager; import javax.tools.StandardJavaFileManager; 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.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.Messages; import jdk.javadoc.internal.doclets.toolkit.Resources; @@ -377,7 +375,7 @@ public class TagletManager { return; } new SimpleElementVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitModule(ModuleElement e, Void p) { if (!taglet.inModule()) { printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "module"); @@ -385,7 +383,7 @@ public class TagletManager { return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitPackage(PackageElement e, Void p) { if (!taglet.inPackage()) { printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "package"); @@ -393,7 +391,7 @@ public class TagletManager { return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitType(TypeElement e, Void p) { if (!taglet.inType()) { printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "class"); @@ -401,7 +399,7 @@ public class TagletManager { return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitExecutable(ExecutableElement e, Void p) { if (utils.isConstructor(e) && !taglet.inConstructor()) { printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "constructor"); @@ -411,7 +409,7 @@ public class TagletManager { return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitVariable(VariableElement e, Void p) { if (utils.isField(e) && !taglet.inField()) { printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "field"); @@ -419,7 +417,7 @@ public class TagletManager { return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitUnknown(Element e, Void p) { if (utils.isOverviewElement(e) && !taglet.inOverview()) { printTagMisuseWarn(utils.getCommentHelper(e), taglet, tag, "overview"); @@ -427,7 +425,7 @@ public class TagletManager { return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Void defaultAction(Element e, Void p) { return null; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassUseMapper.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassUseMapper.java index 02cfc9ddc0b..ba129673b81 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassUseMapper.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/ClassUseMapper.java @@ -44,8 +44,6 @@ import javax.lang.model.util.SimpleElementVisitor9; import javax.lang.model.util.SimpleTypeVisitor9; import javax.lang.model.util.Types; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import jdk.javadoc.doclet.DocletEnvironment; import jdk.javadoc.internal.doclets.formats.html.ConfigurationImpl; @@ -219,17 +217,17 @@ public class ClassUseMapper { mapTypeParameters(classToFieldTypeParam, fd, fd); mapAnnotations(annotationToField, fd, fd); SimpleTypeVisitor9 stv = new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitArray(ArrayType t, VariableElement p) { return visit(t.getComponentType(), p); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitDeclared(DeclaredType t, VariableElement p) { add(classToField, (TypeElement) t.asElement(), p); return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitTypeVariable(TypeVariable t, VariableElement p) { return visit(typeUtils.erasure(t), p); } @@ -249,7 +247,7 @@ public class ClassUseMapper { mapTypeParameters(classToMethodTypeParam, method, method); mapAnnotations(classToMethodAnnotations, method, method); SimpleTypeVisitor9 stv = new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitArray(ArrayType t, ExecutableElement p) { TypeMirror componentType = t.getComponentType(); return visit(utils.isTypeVariable(componentType) @@ -257,14 +255,14 @@ public class ClassUseMapper { : componentType, p); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitDeclared(DeclaredType t, ExecutableElement p) { mapTypeParameters(classToMethodReturnTypeParam, t, p); add(classToMethodReturn, (TypeElement) t.asElement(), p); return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Void defaultAction(TypeMirror e, ExecutableElement p) { return null; } @@ -349,12 +347,12 @@ public class ClassUseMapper { // no duplicates please if (classArgs.add(pType)) { new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitArray(ArrayType t, ExecutableElement p) { return visit(t.getComponentType(), p); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitDeclared(DeclaredType t, ExecutableElement p) { add(isConstructor ? classToConstructorArgs @@ -362,7 +360,7 @@ public class ClassUseMapper { (TypeElement) t.asElement(), p); return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitTypeVariable(TypeVariable t, ExecutableElement p) { visit(typeUtils.erasure(t), p); return null; @@ -383,27 +381,27 @@ public class ClassUseMapper { for (TypeMirror anException : ee.getThrownTypes()) { SimpleTypeVisitor9 stv = new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitArray(ArrayType t, ExecutableElement p) { super.visit(t.getComponentType(), p); return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitDeclared(DeclaredType t, ExecutableElement p) { add(isConstructor ? classToConstructorThrows : classToMethodThrows, (TypeElement) t.asElement(), p); return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitError(ErrorType t, ExecutableElement p) { add(isConstructor ? classToConstructorThrows : classToMethodThrows, (TypeElement) t.asElement(), p); return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Void defaultAction(TypeMirror e, ExecutableElement p) { throw new AssertionError("this should not happen"); } @@ -488,7 +486,7 @@ public class ClassUseMapper { } } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitType(TypeElement e, Void p) { for (TypeParameterElement param : e.getTypeParameters()) { addParameters(param); @@ -496,7 +494,7 @@ public class ClassUseMapper { return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitExecutable(ExecutableElement e, Void p) { for (TypeParameterElement param : e.getTypeParameters()) { addParameters(param); @@ -504,13 +502,13 @@ public class ClassUseMapper { return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Void defaultAction(Element e, Void p) { mapTypeParameters(map, e.asType(), holder); return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitTypeParameter(TypeParameterElement e, Void p) { addParameters(e); return null; @@ -524,7 +522,7 @@ public class ClassUseMapper { SimpleTypeVisitor9 tv = new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitWildcard(WildcardType t, Void p) { TypeMirror bound = t.getExtendsBound(); if (bound != null) { @@ -538,7 +536,7 @@ public class ClassUseMapper { } // ParameterizedType - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitDeclared(DeclaredType t, Void p) { for (TypeMirror targ : t.getTypeArguments()) { addTypeParameterToMap(map, targ, holder); @@ -566,7 +564,7 @@ public class ClassUseMapper { } } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitPackage(PackageElement e, Void p) { for (AnnotationMirror a : e.getAnnotationMirrors()) { refList(map, a.getAnnotationType().asElement()).add(holder); @@ -574,7 +572,7 @@ public class ClassUseMapper { return null; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Void defaultAction(Element e, Void p) { addAnnotations(e); return null; @@ -586,12 +584,12 @@ public class ClassUseMapper { TypeMirror type, final T holder) { new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Void defaultAction(TypeMirror e, Void p) { return super.defaultAction(e, p); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Void visitDeclared(DeclaredType t, Void p) { add(map, (TypeElement) t.asElement(), holder); return null; diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java index bd07139bd3f..cc9860cebfa 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/CommentHelper.java @@ -67,8 +67,6 @@ import com.sun.source.util.DocTreePath; import com.sun.source.util.DocTrees; import com.sun.source.util.SimpleDocTreeVisitor; import com.sun.source.util.TreePath; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import jdk.javadoc.internal.doclets.toolkit.Configuration; import static com.sun.source.doctree.DocTree.Kind.*; @@ -204,7 +202,7 @@ public class CommentHelper { private StringBuilder getText0(DocTree dt) { final StringBuilder sb = new StringBuilder(); new SimpleDocTreeVisitor() { - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitAttribute(AttributeTree node, Void p) { sb.append(SPACER).append(node.getName()); if (node.getValueKind() == ValueKind.EMPTY) { @@ -232,7 +230,7 @@ public class CommentHelper { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitEndElement(EndElementTree node, Void p) { sb.append(""); @@ -271,13 +269,13 @@ public class CommentHelper { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitReference(ReferenceTree node, Void p) { sb.append(node.getSignature()); return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitSee(SeeTree node, Void p) { node.getReference().stream().forEach((dt) -> { dt.accept(this, null); @@ -285,7 +283,7 @@ public class CommentHelper { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitSerial(SerialTree node, Void p) { node.getDescription().stream().forEach((dt) -> { dt.accept(this, null); @@ -293,7 +291,7 @@ public class CommentHelper { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitStartElement(StartElementTree node, Void p) { sb.append("<"); sb.append(node.getName()); @@ -304,13 +302,13 @@ public class CommentHelper { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitText(TextTree node, Void p) { sb.append(node.getBody()); return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitUnknownBlockTag(UnknownBlockTagTree node, Void p) { node.getContent().stream().forEach((dt) -> { dt.accept(this, null); @@ -318,12 +316,12 @@ public class CommentHelper { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitValue(ValueTree node, Void p) { return node.getReference().accept(this, null); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override protected Void defaultAction(DocTree node, Void p) { sb.append(node.toString()); return null; @@ -334,7 +332,7 @@ public class CommentHelper { public String getLabel(Configuration c, DocTree dtree) { return new SimpleDocTreeVisitor() { - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public String visitLink(LinkTree node, Void p) { StringBuilder sb = new StringBuilder(); node.getLabel().stream().forEach((dt) -> { @@ -343,7 +341,7 @@ public class CommentHelper { return sb.toString(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public String visitSee(SeeTree node, Void p) { StringBuilder sb = new StringBuilder(); node.getReference().stream().filter((dt) -> (c.utils.isText(dt))).forEach((dt) -> { @@ -352,7 +350,7 @@ public class CommentHelper { return sb.toString(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override protected String defaultAction(DocTree node, Void p) { return ""; } @@ -429,7 +427,7 @@ public class CommentHelper { private Element getReferencedElement(Configuration c, DocTree dtree) { return new SimpleDocTreeVisitor() { - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Element visitSee(SeeTree node, Void p) { for (DocTree dt : node.getReference()) { return visit(dt, null); @@ -437,27 +435,27 @@ public class CommentHelper { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Element visitLink(LinkTree node, Void p) { return visit(node.getReference(), null); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Element visitValue(ValueTree node, Void p) { return visit(node.getReference(), null); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Element visitReference(ReferenceTree node, Void p) { return getElement(c, node); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Element visitSerialField(SerialFieldTree node, Void p) { return visit(node.getType(), null); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override protected Element defaultAction(DocTree node, Void p) { return null; } @@ -466,7 +464,7 @@ public class CommentHelper { public String getReferencedSignature(DocTree dtree) { return new SimpleDocTreeVisitor() { - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public String visitSee(SeeTree node, Void p) { for (DocTree dt : node.getReference()) { return visit(dt, null); @@ -474,27 +472,27 @@ public class CommentHelper { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public String visitLink(LinkTree node, Void p) { return visit(node.getReference(), null); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public String visitValue(ValueTree node, Void p) { return visit(node.getReference(), null); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public String visitReference(ReferenceTree node, Void p) { return node.getSignature(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public String visitSerialField(SerialFieldTree node, Void p) { return visit(node.getType(), null); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override protected String defaultAction(DocTree node, Void p) { return null; } @@ -530,87 +528,87 @@ public class CommentHelper { return out; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitAuthor(AuthorTree node, Void p) { return node.getName(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitComment(CommentTree node, Void p) { return asList(node.getBody()); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitDeprecated(DeprecatedTree node, Void p) { return node.getBody(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitDocComment(DocCommentTree node, Void p) { return node.getBody(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitLiteral(LiteralTree node, Void p) { return asList(node.getBody().getBody()); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitSince(SinceTree node, Void p) { return node.getBody(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitText(TextTree node, Void p) { return asList(node.getBody()); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitVersion(VersionTree node, Void p) { return node.getBody(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitParam(ParamTree node, Void p) { return node.getDescription(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitReturn(ReturnTree node, Void p) { return node.getDescription(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitSee(SeeTree node, Void p) { return node.getReference(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitSerial(SerialTree node, Void p) { return node.getDescription(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitSerialData(SerialDataTree node, Void p) { return node.getDescription(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitSerialField(SerialFieldTree node, Void p) { return node.getDescription(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitThrows(ThrowsTree node, Void p) { return node.getDescription(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public List visitUnknownBlockTag(UnknownBlockTagTree node, Void p) { return node.getContent(); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override protected List defaultAction(DocTree node, Void p) { return Collections.emptyList(); } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java index a5362ac3dbb..80e9f0a6d8b 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/Utils.java @@ -75,8 +75,6 @@ import com.sun.source.tree.LineMap; import com.sun.source.util.DocSourcePositions; import com.sun.source.util.DocTrees; import com.sun.source.util.TreePath; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import jdk.javadoc.internal.doclets.toolkit.CommentUtils.DocCommentDuo; import jdk.javadoc.internal.doclets.toolkit.Configuration; import jdk.javadoc.internal.doclets.toolkit.DocletException; @@ -383,17 +381,17 @@ public class Utils { public boolean isAnnotationType(Element e) { return new SimpleElementVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitExecutable(ExecutableElement e, Void p) { return visit(e.getEnclosingElement()); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitUnknown(Element e, Void p) { return false; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Boolean defaultAction(Element e, Void p) { return e.getKind() == ANNOTATION_TYPE; } @@ -553,34 +551,34 @@ public class Utils { } } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitTypeAsInterface(TypeElement e, SortedSet p) { addVisibilityModifier(p); addStatic(p); return finalString("interface"); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitTypeAsEnum(TypeElement e, SortedSet p) { addVisibilityModifier(p); addStatic(p); return finalString("enum"); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitTypeAsAnnotationType(TypeElement e, SortedSet p) { addVisibilityModifier(p); addStatic(p); return finalString("@interface"); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitTypeAsClass(TypeElement e, SortedSet p) { addModifers(p); return finalString("class"); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected String defaultAction(Element e, SortedSet p) { addModifers(p); return sb.toString().trim(); @@ -626,19 +624,19 @@ public class Utils { public boolean isPrimitive(TypeMirror t) { return new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitNoType(NoType t, Void p) { return t.getKind() == VOID; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitPrimitive(PrimitiveType t, Void p) { return true; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitArray(ArrayType t, Void p) { return visit(t.getComponentType()); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Boolean defaultAction(TypeMirror e, Void p) { return false; } @@ -726,7 +724,7 @@ public class Utils { return new SimpleTypeVisitor9() { final StringBuilder sb = new StringBuilder(); - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public StringBuilder visitArray(ArrayType t, Void p) { TypeMirror componentType = t.getComponentType(); visit(componentType); @@ -734,7 +732,7 @@ public class Utils { return sb; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public StringBuilder visitDeclared(DeclaredType t, Void p) { Element e = t.asElement(); sb.append(qualifiedName ? getFullyQualifiedName(e) : getSimpleName(e)); @@ -755,14 +753,14 @@ public class Utils { return sb; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public StringBuilder visitTypeVariable(javax.lang.model.type.TypeVariable t, Void p) { Element e = t.asElement(); sb.append(qualifiedName ? getFullyQualifiedName(e, false) : getSimpleName(e)); return sb; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public StringBuilder visitWildcard(javax.lang.model.type.WildcardType t, Void p) { sb.append("?"); TypeMirror upperBound = t.getExtendsBound(); @@ -778,7 +776,7 @@ public class Utils { return sb; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected StringBuilder defaultAction(TypeMirror e, Void p) { return sb.append(e); } @@ -1176,17 +1174,17 @@ public class Utils { public TypeElement asTypeElement(TypeMirror t) { return new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public TypeElement visitDeclared(DeclaredType t, Void p) { return (TypeElement) t.asElement(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public TypeElement visitArray(ArrayType t, Void p) { return visit(t.getComponentType()); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public TypeElement visitTypeVariable(javax.lang.model.type.TypeVariable t, Void p) { /* * TODO: Check with JJG. @@ -1199,17 +1197,17 @@ public class Utils { return visit(typeUtils.erasure(t)); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public TypeElement visitWildcard(javax.lang.model.type.WildcardType t, Void p) { return visit(typeUtils.erasure(t)); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public TypeElement visitError(ErrorType t, Void p) { return (TypeElement)t.asElement(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected TypeElement defaultAction(TypeMirror e, Void p) { return super.defaultAction(e, p); } @@ -1233,13 +1231,13 @@ public class Utils { public String getDimension(TypeMirror t) { return new SimpleTypeVisitor9() { StringBuilder dimension = new StringBuilder(""); - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitArray(ArrayType t, Void p) { dimension.append("[]"); return visit(t.getComponentType()); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected String defaultAction(TypeMirror e, Void p) { return dimension.toString(); } @@ -1344,12 +1342,12 @@ public class Utils { public String getTypeName(TypeMirror t, boolean fullyQualified) { return new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitArray(ArrayType t, Void p) { return visit(t.getComponentType()); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitDeclared(DeclaredType t, Void p) { TypeElement te = asTypeElement(t); return fullyQualified @@ -1357,27 +1355,27 @@ public class Utils { : getSimpleName(te); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitExecutable(ExecutableType t, Void p) { return t.toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitPrimitive(PrimitiveType t, Void p) { return t.toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitTypeVariable(javax.lang.model.type.TypeVariable t, Void p) { return getSimpleName(t.asElement()); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitWildcard(javax.lang.model.type.WildcardType t, Void p) { return t.toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected String defaultAction(TypeMirror e, Void p) { return e.toString(); } @@ -1840,22 +1838,22 @@ public class Utils { */ public String getQualifiedTypeName(TypeMirror t) { return new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitDeclared(DeclaredType t, Void p) { return getFullyQualifiedName(t.asElement()); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitArray(ArrayType t, Void p) { return visit(t.getComponentType()); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitPrimitive(PrimitiveType t, Void p) { return t.toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitTypeVariable(javax.lang.model.type.TypeVariable t, Void p) { // The knee jerk reaction is to do this but don't!, as we would like // it to be compatible with the old world, now if we decide to do so @@ -1864,7 +1862,7 @@ public class Utils { return t.toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected String defaultAction(TypeMirror e, Void p) { throw new UnsupportedOperationException("should not happen"); } @@ -1885,19 +1883,16 @@ public class Utils { public String getFullyQualifiedName(Element e, final boolean outer) { return new SimpleElementVisitor9() { @Override - @DefinedBy(Api.LANGUAGE_MODEL) public String visitPackage(PackageElement e, Void p) { return e.getQualifiedName().toString(); } @Override - @DefinedBy(Api.LANGUAGE_MODEL) public String visitType(TypeElement e, Void p) { return e.getQualifiedName().toString(); } @Override - @DefinedBy(Api.LANGUAGE_MODEL) protected String defaultAction(Element e, Void p) { return outer ? visit(e.getEnclosingElement()) : e.getSimpleName().toString(); } @@ -2002,15 +1997,15 @@ public class Utils { private String getTypeCode(TypeMirror t) { return new SimpleTypeVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitPrimitive(PrimitiveType t, Void p) { return "P"; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitArray(ArrayType t, Void p) { return visit(t.getComponentType()); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected String defaultAction(TypeMirror e, Void p) { return "R"; } @@ -2049,12 +2044,12 @@ public class Utils { } boolean hasParameters(Element e) { return new SimpleElementVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitExecutable(ExecutableElement e, Void p) { return true; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Boolean defaultAction(Element e, Void p) { return false; } @@ -2072,29 +2067,29 @@ public class Utils { */ private String getFullyQualifiedName(Element e) { return new SimpleElementVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitModule(ModuleElement e, Void p) { return e.getQualifiedName().toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitPackage(PackageElement e, Void p) { return e.getQualifiedName().toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitExecutable(ExecutableElement e, Void p) { // For backward compatibility return getFullyQualifiedName(e.getEnclosingElement()) + "." + e.getSimpleName().toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitType(TypeElement e, Void p) { return e.getQualifiedName().toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected String defaultAction(Element e, Void p) { return getEnclosingTypeElement(e).getQualifiedName().toString() + "." + e.getSimpleName().toString(); @@ -2334,13 +2329,13 @@ public class Utils { return elements; return new SimpleElementVisitor9, Void>() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public List visitPackage(PackageElement e, Void p) { recursiveGetItems(elements, e, filter, select); return elements; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected List defaultAction(Element e0, Void p) { return getItems0(e0, filter, select); } @@ -2402,12 +2397,12 @@ public class Utils { private String getSimpleName0(Element e) { if (snvisitor == null) { snvisitor = new SimpleElementVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitModule(ModuleElement e, Void p) { return e.getSimpleName().toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitType(TypeElement e, Void p) { StringBuilder sb = new StringBuilder(e.getSimpleName()); Element enclosed = e.getEnclosingElement(); @@ -2419,7 +2414,7 @@ public class Utils { return sb.toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitExecutable(ExecutableElement e, Void p) { if (e.getKind() == CONSTRUCTOR || e.getKind() == STATIC_INIT) { return e.getEnclosingElement().getSimpleName().toString(); @@ -2427,7 +2422,7 @@ public class Utils { return e.getSimpleName().toString(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected String defaultAction(Element e, Void p) { return e.getSimpleName().toString(); } @@ -2472,27 +2467,27 @@ public class Utils { * and we should fix this by using getConstantValue and the visitor to * address this in the future. */ - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitPrimitiveAsBoolean(PrimitiveType t, Object val) { return (int)val == 0 ? "false" : "true"; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitPrimitiveAsDouble(PrimitiveType t, Object val) { return sourceForm(((Double)val), 'd'); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitPrimitiveAsFloat(PrimitiveType t, Object val) { return sourceForm(((Float)val).doubleValue(), 'f'); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public String visitPrimitiveAsLong(PrimitiveType t, Object val) { return val + "L"; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected String defaultAction(TypeMirror e, Object val) { if (val == null) return null; @@ -2585,22 +2580,22 @@ public class Utils { public boolean isSpecified(Element e) { if (specifiedVisitor == null) { specifiedVisitor = new SimpleElementVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitModule(ModuleElement e, Void p) { return configuration.getSpecifiedModules().contains(e); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitPackage(PackageElement e, Void p) { return configuration.getSpecifiedPackages().contains(e); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitType(TypeElement e, Void p) { return configuration.getSpecifiedClasses().contains(e); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Boolean defaultAction(Element e, Void p) { return false; } diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java index f3884748618..862726f6b83 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/doclets/toolkit/util/links/LinkFactory.java @@ -42,8 +42,6 @@ import javax.lang.model.util.SimpleTypeVisitor9; import jdk.javadoc.internal.doclets.formats.html.LinkInfoImpl; import jdk.javadoc.internal.doclets.toolkit.Content; import jdk.javadoc.internal.doclets.toolkit.util.Utils; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; /** * A factory that constructs links from given link information. @@ -80,14 +78,14 @@ public abstract class LinkFactory { Content link = newContent(); // handles primitives, no types and error types - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override protected Content defaultAction(TypeMirror type, LinkInfo linkInfo) { link.addContent(utils.getTypeName(type, false)); return link; } int currentDepth = 0; - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Content visitArray(ArrayType type, LinkInfo linkInfo) { // keep track of the dimension depth and replace the last dimension // specifier with vararags, when the stack is fully unwound. @@ -109,7 +107,7 @@ public abstract class LinkFactory { return link; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Content visitWildcard(WildcardType type, LinkInfo linkInfo) { linkInfo.isTypeBound = true; link.addContent("?"); @@ -128,7 +126,7 @@ public abstract class LinkFactory { return link; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Content visitTypeVariable(TypeVariable type, LinkInfo linkInfo) { link.addContent(getTypeAnnotationLinks(linkInfo)); linkInfo.isTypeBound = true; @@ -169,7 +167,7 @@ public abstract class LinkFactory { return link; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Content visitDeclared(DeclaredType type, LinkInfo linkInfo) { if (linkInfo.isTypeBound && linkInfo.excludeTypeBoundsLinks) { // Since we are excluding type parameter links, we should not diff --git a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java index 62bc035f164..b1a5ba08e68 100644 --- a/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java +++ b/langtools/src/jdk.javadoc/share/classes/jdk/javadoc/internal/tool/ElementsTable.java @@ -68,8 +68,6 @@ import com.sun.tools.javac.comp.Modules; import com.sun.tools.javac.tree.JCTree.JCClassDecl; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; 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.ListBuffer; import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Names; @@ -874,22 +872,22 @@ public class ElementsTable { if (shouldDocumentVisitor == null) { shouldDocumentVisitor = new SimpleElementVisitor9() { - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitType(TypeElement e, Void p) { return shouldDocument((ClassSymbol) e); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitVariable(VariableElement e, Void p) { return shouldDocument((VarSymbol) e); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitExecutable(ExecutableElement e, Void p) { return shouldDocument((MethodSymbol) e); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitPackage(PackageElement e, Void p) { return accessFilter.checkModifier(e); } @@ -947,19 +945,19 @@ public class ElementsTable { includedCache = new LinkedHashSet<>(); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitModule(ModuleElement e, Void p) { // deduced by specified and/or requires expansion return includedModuleElements.contains(e); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitPackage(PackageElement e, Void p) { // deduced by specified or downward expansions return includedPackageElements.contains(e); } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitType(TypeElement e, Void p) { if (includedTypeElements.contains(e)) { return true; @@ -988,7 +986,7 @@ public class ElementsTable { } // members - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean defaultAction(Element e, Void p) { if (includedCache.contains(e)) return true; @@ -1006,7 +1004,7 @@ public class ElementsTable { return false; } - @Override @DefinedBy(Api.LANGUAGE_MODEL) + @Override public Boolean visitUnknown(Element e, Void p) { throw new AssertionError("unknown element: " + e); } diff --git a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java index 7cd4090bdc0..6fb6ad0014e 100644 --- a/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java +++ b/langtools/src/jdk.jdeps/share/classes/com/sun/tools/javap/JavapTask.java @@ -68,8 +68,6 @@ import javax.tools.StandardJavaFileManager; import javax.tools.StandardLocation; import com.sun.tools.classfile.*; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; /** * "Main" class for javap, normally accessed from the command line @@ -411,7 +409,6 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { private DiagnosticListener getDiagnosticListenerForWriter(Writer w) { final PrintWriter pw = getPrintWriterForWriter(w); return new DiagnosticListener () { - @DefinedBy(Api.COMPILER) public void report(Diagnostic diagnostic) { switch (diagnostic.getKind()) { case ERROR: @@ -727,67 +724,54 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { final URLConnection conn = url.openConnection(); conn.setUseCaches(false); return new JavaFileObject() { - @DefinedBy(Api.COMPILER) public Kind getKind() { return JavaFileObject.Kind.CLASS; } - @DefinedBy(Api.COMPILER) public boolean isNameCompatible(String simpleName, Kind kind) { throw new UnsupportedOperationException(); } - @DefinedBy(Api.COMPILER) public NestingKind getNestingKind() { throw new UnsupportedOperationException(); } - @DefinedBy(Api.COMPILER) public Modifier getAccessLevel() { throw new UnsupportedOperationException(); } - @DefinedBy(Api.COMPILER) public URI toUri() { return uri; } - @DefinedBy(Api.COMPILER) public String getName() { return uri.toString(); } - @DefinedBy(Api.COMPILER) public InputStream openInputStream() throws IOException { return conn.getInputStream(); } - @DefinedBy(Api.COMPILER) public OutputStream openOutputStream() throws IOException { throw new UnsupportedOperationException(); } - @DefinedBy(Api.COMPILER) public Reader openReader(boolean ignoreEncodingErrors) throws IOException { throw new UnsupportedOperationException(); } - @DefinedBy(Api.COMPILER) public CharSequence getCharContent(boolean ignoreEncodingErrors) throws IOException { throw new UnsupportedOperationException(); } - @DefinedBy(Api.COMPILER) public Writer openWriter() throws IOException { throw new UnsupportedOperationException(); } - @DefinedBy(Api.COMPILER) public long getLastModified() { return conn.getLastModified(); } - @DefinedBy(Api.COMPILER) public boolean delete() { throw new UnsupportedOperationException(); } @@ -1015,47 +999,38 @@ public class JavapTask implements DisassemblerTool.DisassemblerTask, Messages { private Diagnostic createDiagnostic( final Diagnostic.Kind kind, final String key, final Object... args) { return new Diagnostic() { - @DefinedBy(Api.COMPILER) public Kind getKind() { return kind; } - @DefinedBy(Api.COMPILER) public JavaFileObject getSource() { return null; } - @DefinedBy(Api.COMPILER) public long getPosition() { return Diagnostic.NOPOS; } - @DefinedBy(Api.COMPILER) public long getStartPosition() { return Diagnostic.NOPOS; } - @DefinedBy(Api.COMPILER) public long getEndPosition() { return Diagnostic.NOPOS; } - @DefinedBy(Api.COMPILER) public long getLineNumber() { return Diagnostic.NOPOS; } - @DefinedBy(Api.COMPILER) public long getColumnNumber() { return Diagnostic.NOPOS; } - @DefinedBy(Api.COMPILER) public String getCode() { return key; } - @DefinedBy(Api.COMPILER) public String getMessage(Locale locale) { return JavapTask.this.getMessage(locale, key, args); } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java index fcfd3b9f83b..3655b64aad4 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/MemoryFileManager.java @@ -52,8 +52,6 @@ import javax.tools.SimpleJavaFileObject; import javax.tools.StandardJavaFileManager; import javax.tools.StandardLocation; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import static jdk.internal.jshell.debug.InternalDebugControl.DBG_FMGR; @@ -103,7 +101,7 @@ class MemoryFileManager implements JavaFileManager { return origin; } - @Override @DefinedBy(Api.COMPILER) + @Override public CharSequence getCharContent(boolean ignoreEncodingErrors) { return src; } @@ -146,7 +144,7 @@ class MemoryFileManager implements JavaFileManager { } } - @Override @DefinedBy(Api.COMPILER) + @Override public String getName() { return className; } @@ -155,12 +153,12 @@ class MemoryFileManager implements JavaFileManager { * Will provide the compiler with an output stream that leads to our * byte array. */ - @Override @DefinedBy(Api.COMPILER) + @Override public OutputStream openOutputStream() throws IOException { return bos; } - @Override @DefinedBy(Api.COMPILER) + @Override public InputStream openInputStream() throws IOException { return new ByteArrayInputStream(getBytes()); } @@ -187,7 +185,6 @@ class MemoryFileManager implements JavaFileManager { } // Make compatible with Jigsaw - @DefinedBy(Api.COMPILER) public String inferModuleName(Location location) { try { if (inferModuleNameMethod == null) { @@ -206,7 +203,6 @@ class MemoryFileManager implements JavaFileManager { } // Make compatible with Jigsaw - @DefinedBy(Api.COMPILER) public Iterable> listModuleLocations(Location location) throws IOException { try { if (listModuleLocationsMethod == null) { @@ -241,7 +237,7 @@ class MemoryFileManager implements JavaFileManager { * @throws IllegalStateException if {@link #close} has been called * and this file manager cannot be reopened */ - @Override @DefinedBy(Api.COMPILER) + @Override public ClassLoader getClassLoader(JavaFileManager.Location location) { proc.debug(DBG_FMGR, "getClassLoader: location\n", location); return stdFileManager.getClassLoader(location); @@ -267,7 +263,7 @@ class MemoryFileManager implements JavaFileManager { * @throws IllegalStateException if {@link #close} has been called * and this file manager cannot be reopened */ - @Override @DefinedBy(Api.COMPILER) + @Override public Iterable list(JavaFileManager.Location location, String packageName, Set kinds, @@ -324,7 +320,7 @@ class MemoryFileManager implements JavaFileManager { * @throws IllegalStateException if {@link #close} has been called * and this file manager cannot be reopened */ - @Override @DefinedBy(Api.COMPILER) + @Override public String inferBinaryName(JavaFileManager.Location location, JavaFileObject file) { if (file instanceof OutputMemoryJavaFileObject) { OutputMemoryJavaFileObject ofo = (OutputMemoryJavaFileObject) file; @@ -348,7 +344,7 @@ class MemoryFileManager implements JavaFileManager { * were created with another file manager and this file manager * does not support foreign file objects */ - @Override @DefinedBy(Api.COMPILER) + @Override public boolean isSameFile(FileObject a, FileObject b) { return stdFileManager.isSameFile(b, b); } @@ -361,7 +357,7 @@ class MemoryFileManager implements JavaFileManager { * @return the number of arguments the given option takes or -1 if * the option is not supported */ - @Override @DefinedBy(Api.COMPILER) + @Override public int isSupportedOption(String option) { proc.debug(DBG_FMGR, "isSupportedOption: %s\n", option); return stdFileManager.isSupportedOption(option); @@ -381,7 +377,7 @@ class MemoryFileManager implements JavaFileManager { * @throws IllegalStateException if {@link #close} has been called * and this file manager cannot be reopened */ - @Override @DefinedBy(Api.COMPILER) + @Override public boolean handleOption(String current, Iterator remaining) { proc.debug(DBG_FMGR, "handleOption: current: %s\n", current + ", remaining: " + remaining); @@ -394,7 +390,7 @@ class MemoryFileManager implements JavaFileManager { * @param location a location * @return true if the location is known */ - @Override @DefinedBy(Api.COMPILER) + @Override public boolean hasLocation(JavaFileManager.Location location) { proc.debug(DBG_FMGR, "hasLocation: location: %s\n", location); return stdFileManager.hasLocation(location); @@ -430,7 +426,7 @@ class MemoryFileManager implements JavaFileManager { * @throws IllegalStateException if {@link #close} has been called * and this file manager cannot be reopened */ - @Override @DefinedBy(Api.COMPILER) + @Override public JavaFileObject getJavaFileForInput(JavaFileManager.Location location, String className, JavaFileObject.Kind kind) @@ -470,7 +466,7 @@ class MemoryFileManager implements JavaFileManager { * @throws IllegalStateException {@link #close} has been called * and this file manager cannot be reopened */ - @Override @DefinedBy(Api.COMPILER) + @Override public JavaFileObject getJavaFileForOutput(JavaFileManager.Location location, String className, Kind kind, FileObject sibling) throws IOException { @@ -523,7 +519,7 @@ class MemoryFileManager implements JavaFileManager { * @throws IllegalStateException if {@link #close} has been called * and this file manager cannot be reopened */ - @Override @DefinedBy(Api.COMPILER) + @Override public FileObject getFileForInput(JavaFileManager.Location location, String packageName, String relativeName) @@ -572,7 +568,7 @@ class MemoryFileManager implements JavaFileManager { * @throws IllegalStateException if {@link #close} has been called * and this file manager cannot be reopened */ - @Override @DefinedBy(Api.COMPILER) + @Override public FileObject getFileForOutput(JavaFileManager.Location location, String packageName, String relativeName, @@ -592,7 +588,7 @@ class MemoryFileManager implements JavaFileManager { * @throws IOException if an I/O error occurred * @see #close */ - @Override @DefinedBy(Api.COMPILER) + @Override public void flush() throws IOException { // Nothing to flush } @@ -608,7 +604,7 @@ class MemoryFileManager implements JavaFileManager { * @throws IOException if an I/O error occurred * @see #flush */ - @Override @DefinedBy(Api.COMPILER) + @Override public void close() throws IOException { // Nothing to close } diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java index 0c2d85d0d69..090bfb6d969 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/SourceCodeAnalysisImpl.java @@ -55,8 +55,6 @@ import com.sun.tools.javac.code.Symbol.VarSymbol; import com.sun.tools.javac.code.Symtab; import com.sun.tools.javac.code.Type; import com.sun.tools.javac.code.Type.ClassType; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import com.sun.tools.javac.util.Name; import com.sun.tools.javac.util.Names; import com.sun.tools.javac.util.Pair; @@ -534,7 +532,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { TreePath[] deepest = new TreePath[1]; new TreePathScanner() { - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void scan(Tree tree, Void p) { if (tree == null) return null; @@ -552,7 +550,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitErroneous(ErroneousTree node, Void p) { return scan(node.getErrorTrees(), null); } @@ -1250,7 +1248,7 @@ class SourceCodeAnalysisImpl extends SourceCodeAnalysis { Trees trees = Trees.instance(source.fst); new TreePathScanner() { - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitMethod(MethodTree node, Void p) { Element currentMethod = trees.getElement(getCurrentPath()); diff --git a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TreeDependencyScanner.java b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TreeDependencyScanner.java index 5c5840ff080..5dc9e6663c6 100644 --- a/langtools/src/jdk.jshell/share/classes/jdk/jshell/TreeDependencyScanner.java +++ b/langtools/src/jdk.jshell/share/classes/jdk/jshell/TreeDependencyScanner.java @@ -34,8 +34,6 @@ import com.sun.source.tree.PackageTree; import com.sun.source.tree.Tree; import com.sun.source.tree.VariableTree; import com.sun.source.util.TreeScanner; -import com.sun.tools.javac.util.DefinedBy; -import com.sun.tools.javac.util.DefinedBy.Api; import java.util.Collection; import java.util.HashSet; import java.util.Set; @@ -67,7 +65,7 @@ class TreeDependencyScanner extends TreeScanner> { // -- Differentiate declaration references from body references --- - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitClass(ClassTree node, Set p) { scan(node.getModifiers(), p); scan(node.getTypeParameters(), p); @@ -77,7 +75,7 @@ class TreeDependencyScanner extends TreeScanner> { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitMethod(MethodTree node, Set p) { scan(node.getModifiers(), p); scan(node.getReturnType(), p); @@ -90,7 +88,7 @@ class TreeDependencyScanner extends TreeScanner> { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitVariable(VariableTree node, Set p) { scan(node.getModifiers(), p); scan(node.getType(), p); @@ -101,12 +99,12 @@ class TreeDependencyScanner extends TreeScanner> { // --- Ignore these --- - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitPackage(PackageTree node, Set p) { return null; } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitImport(ImportTree node, Set p) { return null; } @@ -114,13 +112,13 @@ class TreeDependencyScanner extends TreeScanner> { // -- Actual Symbol names --- - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitMemberSelect(MemberSelectTree node, Set p) { add(p, node.getIdentifier()); return super.visitMemberSelect(node, p); } - @Override @DefinedBy(Api.COMPILER_TREE) + @Override public Void visitIdentifier(IdentifierTree node, Set p) { add(p, node.getName()); return super.visitIdentifier(node, p); diff --git a/langtools/test/ProblemList.txt b/langtools/test/ProblemList.txt index c8158673cd0..a90395e8734 100644 --- a/langtools/test/ProblemList.txt +++ b/langtools/test/ProblemList.txt @@ -82,6 +82,5 @@ tools/sjavac/ClasspathDependencies.java 8158002 generic-all Requires i # # jdeprscan -tools/all/RunCodingRules.java 8164836 generic-all fix @DefinedBy tools/jdeprscan/tests/jdk/jdeprscan/TestLoad.java 8164837 windows-all probably line breaks or encoding tools/jdeprscan/tests/jdk/jdeprscan/TestScan.java 8164837 windows-all probably line breaks or encoding From a0f04e5b3d7083352a53048b25ef428efa4049df Mon Sep 17 00:00:00 2001 From: "J. Duke" Date: Wed, 5 Jul 2017 22:07:36 +0200 Subject: [PATCH 70/87] Added tag jdk-9+133 for changeset e17429a7e843 --- .hgtags | 1 + 1 file changed, 1 insertion(+) diff --git a/.hgtags b/.hgtags index abf4dd939ca..28f9ad5279c 100644 --- a/.hgtags +++ b/.hgtags @@ -375,3 +375,4 @@ e8373543a3f0f60589b7d72b1f9b172721124caf jdk-9+129 e613affb88d178dc7c589f1679db113d589bddb4 jdk-9+130 4d2a15091124488080d65848b704e25599b2aaeb jdk-9+131 2e83d21d78cd9c1d52e6cd2599e9c8aa36ea1f52 jdk-9+132 +e17429a7e843c4a4ed3651458d0f950970edcbcc jdk-9+133 From 5c73d79296adf88187d3eafe1e63d7f9e29d48f1 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Tue, 30 Aug 2016 09:31:28 +0800 Subject: [PATCH 71/87] 8163934: Remove intermittent key from java/lang/ProcessBuilder/Zombies.java Reviewed-by: darcy --- jdk/test/java/lang/ProcessBuilder/Zombies.java | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/test/java/lang/ProcessBuilder/Zombies.java b/jdk/test/java/lang/ProcessBuilder/Zombies.java index 30f296cc513..10c804ee1d4 100644 --- a/jdk/test/java/lang/ProcessBuilder/Zombies.java +++ b/jdk/test/java/lang/ProcessBuilder/Zombies.java @@ -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 */ From 5ee89f9f22340c5d6577b42e02133537e8ad3c46 Mon Sep 17 00:00:00 2001 From: Amy Lu Date: Tue, 30 Aug 2016 09:36:23 +0800 Subject: [PATCH 72/87] 8164545: Mark java/net/URLPermission/nstest/lookup.sh as intermittently failing Reviewed-by: dfuchs --- jdk/test/java/net/URLPermission/nstest/lookup.sh | 1 + 1 file changed, 1 insertion(+) diff --git a/jdk/test/java/net/URLPermission/nstest/lookup.sh b/jdk/test/java/net/URLPermission/nstest/lookup.sh index 89798669f53..798e1c168f6 100644 --- a/jdk/test/java/net/URLPermission/nstest/lookup.sh +++ b/jdk/test/java/net/URLPermission/nstest/lookup.sh @@ -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` From 5f5e297c52ca415f68e0c37cf9eb9e112e158c2f Mon Sep 17 00:00:00 2001 From: Masayoshi Okutsu Date: Tue, 30 Aug 2016 14:16:16 +0900 Subject: [PATCH 73/87] 8157792: After Integrating tzdata2016d the test/sun/util/calendar/zi/TestZoneInfo310.java fails for "Asia/Oral" and "Asia/Qyzylorda" Timezones Reviewed-by: peytoia --- .../sun/util/calendar/zi/TestZoneInfo310.java | 16 ++++++++-------- jdk/test/sun/util/calendar/zi/Zoneinfo.java | 13 +++++++++++-- 2 files changed, 19 insertions(+), 10 deletions(-) diff --git a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java index 9d124ffb21d..0c1d7650c48 100644 --- a/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java +++ b/jdk/test/sun/util/calendar/zi/TestZoneInfo310.java @@ -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 @@ public class TestZoneInfo310 { } 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)) { diff --git a/jdk/test/sun/util/calendar/zi/Zoneinfo.java b/jdk/test/sun/util/calendar/zi/Zoneinfo.java index 9e48655181f..e58fd188a30 100644 --- a/jdk/test/sun/util/calendar/zi/Zoneinfo.java +++ b/jdk/test/sun/util/calendar/zi/Zoneinfo.java @@ -373,6 +373,7 @@ class Zoneinfo { 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 @@ class Zoneinfo { 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 @@ class Zoneinfo { 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 @@ class Zoneinfo { fromYear = zrec.getUntilYear(); year = zrec.getUntilYear(); } + prevzrec = zrec; } if (tz.getDSTType() == Timezone.UNDEF_DST) { From dba7bcf4f801aafac793b70aec1116bdd99acebe Mon Sep 17 00:00:00 2001 From: Prasanta Sadhukhan Date: Tue, 30 Aug 2016 11:07:58 +0530 Subject: [PATCH 74/87] 6357887: selected printertray is ignored under linux Reviewed-by: prr, vadim --- .../share/classes/sun/print/PSPrinterJob.java | 31 +-- .../unix/classes/sun/print/UnixPrintJob.java | 14 +- .../PrinterJob/TestMediaTraySelection.java | 185 ++++++++++++++++++ 3 files changed, 212 insertions(+), 18 deletions(-) create mode 100644 jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java diff --git a/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java b/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java index abe8bd9ab7a..f80e10c9778 100644 --- a/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java +++ b/jdk/src/java.desktop/share/classes/sun/print/PSPrinterJob.java @@ -33,11 +33,8 @@ import java.awt.GraphicsEnvironment; import java.awt.Graphics; import java.awt.Graphics2D; import java.awt.HeadlessException; -import java.awt.Rectangle; import java.awt.Shape; -import java.awt.image.BufferedImage; - import java.awt.font.FontRenderContext; import java.awt.geom.AffineTransform; @@ -46,7 +43,6 @@ import java.awt.geom.Rectangle2D; import java.awt.image.BufferedImage; -import java.awt.peer.FontPeer; import java.awt.print.Pageable; import java.awt.print.PageFormat; import java.awt.print.Paper; @@ -55,14 +51,12 @@ import java.awt.print.PrinterException; import java.awt.print.PrinterIOException; import java.awt.print.PrinterJob; -import javax.print.DocFlavor; import javax.print.PrintService; import javax.print.StreamPrintService; import javax.print.attribute.HashPrintRequestAttributeSet; import javax.print.attribute.PrintRequestAttributeSet; import javax.print.attribute.PrintServiceAttributeSet; import javax.print.attribute.standard.PrinterName; -import javax.print.attribute.standard.Chromaticity; import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.DialogTypeSelection; @@ -72,7 +66,6 @@ import javax.print.attribute.standard.Sides; import java.io.BufferedInputStream; import java.io.BufferedOutputStream; import java.io.BufferedReader; -import java.io.CharConversionException; import java.io.File; import java.io.InputStream; import java.io.InputStreamReader; @@ -85,17 +78,14 @@ import java.io.PrintWriter; import java.io.StringWriter; import java.util.ArrayList; -import java.util.Enumeration; import java.util.Locale; import java.util.Properties; import sun.awt.CharsetString; import sun.awt.FontConfiguration; -import sun.awt.FontDescriptor; import sun.awt.PlatformFont; import sun.awt.SunToolkit; import sun.font.FontAccess; -import sun.font.FontManagerFactory; import sun.font.FontUtilities; import java.nio.charset.*; @@ -105,7 +95,9 @@ import java.nio.file.Files; //REMIND: Remove use of this class when IPPPrintService is moved to share directory. import java.lang.reflect.Method; +import javax.print.attribute.Attribute; import javax.print.attribute.standard.JobSheets; +import javax.print.attribute.standard.Media; /** * A class which initiates and executes a PostScript printer job. @@ -489,6 +481,23 @@ public class PSPrinterJob extends RasterPrinterJob { return doPrint; } + @Override + protected void setAttributes(PrintRequestAttributeSet attributes) + throws PrinterException { + super.setAttributes(attributes); + if (attributes == null) { + return; // now always use attributes, so this shouldn't happen. + } + Attribute attr = attributes.get(Media.class); + if (attr instanceof CustomMediaTray) { + CustomMediaTray customTray = (CustomMediaTray)attr; + String choice = customTray.getChoiceName(); + if (choice != null) { + mOptions = " InputSlot="+ choice; + } + } + } + /** * Invoked by the RasterPrinterJob super class * this method is called to mark the start of a @@ -1629,7 +1638,7 @@ public class PSPrinterJob extends RasterPrinterJob { execCmd[n++] = "-o job-sheets=standard"; } if ((pFlags & OPTIONS) != 0) { - execCmd[n++] = new String(options); + execCmd[n++] = "-o" + options; } } else { ncomps+=1; //add 1 arg for lp diff --git a/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java b/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java index 7d79243d393..06b086e59a2 100644 --- a/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java +++ b/jdk/src/java.desktop/unix/classes/sun/print/UnixPrintJob.java @@ -41,14 +41,12 @@ import java.io.IOException; import java.io.PrintWriter; import java.io.Reader; import java.io.StringWriter; -import java.io.UnsupportedEncodingException; import java.nio.file.Files; import java.util.Vector; import javax.print.CancelablePrintJob; import javax.print.Doc; import javax.print.DocFlavor; -import javax.print.DocPrintJob; import javax.print.PrintService; import javax.print.PrintException; import javax.print.event.PrintJobEvent; @@ -56,7 +54,6 @@ import javax.print.event.PrintJobListener; import javax.print.event.PrintJobAttributeListener; import javax.print.attribute.Attribute; -import javax.print.attribute.AttributeSet; import javax.print.attribute.AttributeSetUtilities; import javax.print.attribute.DocAttributeSet; import javax.print.attribute.HashPrintJobAttributeSet; @@ -65,7 +62,6 @@ import javax.print.attribute.PrintJobAttribute; import javax.print.attribute.PrintJobAttributeSet; import javax.print.attribute.PrintRequestAttribute; import javax.print.attribute.PrintRequestAttributeSet; -import javax.print.attribute.PrintServiceAttributeSet; import javax.print.attribute.standard.Copies; import javax.print.attribute.standard.Destination; import javax.print.attribute.standard.DocumentName; @@ -77,13 +73,17 @@ import javax.print.attribute.standard.Media; import javax.print.attribute.standard.MediaSize; import javax.print.attribute.standard.MediaSizeName; import javax.print.attribute.standard.OrientationRequested; -import javax.print.attribute.standard.PrinterName; import javax.print.attribute.standard.RequestingUserName; import javax.print.attribute.standard.NumberUp; import javax.print.attribute.standard.Sides; import javax.print.attribute.standard.PrinterIsAcceptingJobs; -import java.awt.print.*; +import java.awt.print.PageFormat; +import java.awt.print.PrinterJob; +import java.awt.print.Pageable; +import java.awt.print.Paper; +import java.awt.print.Printable; +import java.awt.print.PrinterException; @@ -370,7 +370,7 @@ public class UnixPrintJob implements CancelablePrintJob { customTray instanceof CustomMediaTray) { String choice = customTray.getChoiceName(); if (choice != null) { - mOptions += " media="+choice; + mOptions += " InputSlot="+choice; } } diff --git a/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java b/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java new file mode 100644 index 00000000000..374928a56c5 --- /dev/null +++ b/jdk/test/java/awt/print/PrinterJob/TestMediaTraySelection.java @@ -0,0 +1,185 @@ +/* + * 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 6357887 + * @summary Verifies if selected printertray is used + * @requires (os.family == "linux" | os.family == "solaris") + * @run main/manual TestMediaTraySelection + */ + +import java.awt.BorderLayout; +import java.awt.FlowLayout; +import java.awt.Graphics; +import java.awt.event.WindowAdapter; +import java.awt.event.WindowEvent; +import java.awt.print.PageFormat; +import java.awt.print.Printable; +import java.awt.print.PrinterException; +import java.awt.print.PrinterJob; +import javax.print.DocFlavor; +import javax.print.PrintService; +import javax.print.PrintServiceLookup; +import javax.print.attribute.HashPrintRequestAttributeSet; +import javax.print.attribute.PrintRequestAttributeSet; +import javax.print.attribute.standard.Media; +import javax.print.attribute.standard.MediaTray; +import javax.swing.JButton; +import javax.swing.JDialog; +import javax.swing.JPanel; +import javax.swing.JTextArea; +import javax.swing.SwingUtilities; + +public class TestMediaTraySelection implements Printable { + + private static Thread mainThread; + private static boolean testPassed; + private static boolean testGeneratedInterrupt; + private static PrintService prservices; + + public static void main(String[] args) throws Exception { + prservices = PrintServiceLookup.lookupDefaultPrintService(); + if (prservices == null) { + System.out.println("No print service found"); + return; + } + System.out.println(" Print service " + prservices); + SwingUtilities.invokeAndWait(() -> { + doTest(TestMediaTraySelection::printTest); + }); + mainThread = Thread.currentThread(); + try { + Thread.sleep(90000); + } catch (InterruptedException e) { + if (!testPassed && testGeneratedInterrupt) { + throw new RuntimeException("Banner page did not print"); + } + } + if (!testGeneratedInterrupt) { + throw new RuntimeException("user has not executed the test"); + } + } + + private static void printTest() { + + MediaTray tray = null; + //tray = getMediaTray( prservices, "Bypass Tray" ); + tray = getMediaTray( prservices, "Tray 4" ); + PrintRequestAttributeSet atrset = new HashPrintRequestAttributeSet(); + //atrset.add( MediaSizeName.ISO_A4 ); + atrset.add(tray); + PrinterJob pjob = PrinterJob.getPrinterJob(); + pjob.setPrintable(new TestMediaTraySelection()); + try { + pjob.print(atrset); + } catch (PrinterException e) { + e.printStackTrace(); + fail(); + } + } + + static MediaTray getMediaTray( PrintService ps, String name) { + Media[] media = (Media[])ps.getSupportedAttributeValues( Media.class, + DocFlavor.SERVICE_FORMATTED.PAGEABLE, null); + + for (Media m : media) { + if ( m instanceof MediaTray) { + System.out.println("MediaTray=" + m.toString() ); + if ( m.toString().trim().indexOf( name ) > -1 ) { + return (MediaTray)m; + } + } + } + return null; + } + + public static synchronized void pass() { + testPassed = true; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + public static synchronized void fail() { + testPassed = false; + testGeneratedInterrupt = true; + mainThread.interrupt(); + } + + private static void doTest(Runnable action) { + String description + = " Please verify the \"Tray 4\" of printer is used for printout\n" + + " and not standard/auto tray. If yes, press PASS else press FAIL"; + + final JDialog dialog = new JDialog(); + dialog.setTitle("printBannerTest"); + JTextArea textArea = new JTextArea(description); + textArea.setEditable(false); + final JButton testButton = new JButton("Start Test"); + final JButton passButton = new JButton("PASS"); + passButton.setEnabled(false); + passButton.addActionListener((e) -> { + dialog.dispose(); + pass(); + }); + final JButton failButton = new JButton("FAIL"); + failButton.setEnabled(false); + failButton.addActionListener((e) -> { + dialog.dispose(); + fail(); + }); + testButton.addActionListener((e) -> { + testButton.setEnabled(false); + action.run(); + passButton.setEnabled(true); + failButton.setEnabled(true); + }); + JPanel mainPanel = new JPanel(new BorderLayout()); + mainPanel.add(textArea, BorderLayout.CENTER); + JPanel buttonPanel = new JPanel(new FlowLayout()); + buttonPanel.add(testButton); + buttonPanel.add(passButton); + buttonPanel.add(failButton); + mainPanel.add(buttonPanel, BorderLayout.SOUTH); + dialog.add(mainPanel); + dialog.pack(); + dialog.setVisible(true); + dialog.addWindowListener(new WindowAdapter() { + @Override + public void windowClosing(WindowEvent e) { + System.out.println("main dialog closing"); + testGeneratedInterrupt = false; + mainThread.interrupt(); + } + }); + } + + @Override + public int print(Graphics g, PageFormat pf, int pi) { + System.out.println("pi = " + pi); + if (pi > 0) { + return NO_SUCH_PAGE; + } + g.drawString("Testing : " , 200, 200); + return PAGE_EXISTS; + } +} From 3ab913d3984b8e549bdfd7cd41100405a51bee77 Mon Sep 17 00:00:00 2001 From: Ivan Gerasimov Date: Tue, 30 Aug 2016 15:31:46 +0300 Subject: [PATCH 75/87] 6474807: (smartcardio) CardTerminal.connect() throws CardException instead of CardNotPresentException Reviewed-by: valeriep --- .../classes/sun/security/smartcardio/TerminalImpl.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java b/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java index de1410f3ef1..604fac30cc4 100644 --- a/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java +++ b/jdk/src/java.smartcardio/share/classes/sun/security/smartcardio/TerminalImpl.java @@ -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 @@ final class TerminalImpl extends CardTerminal { } } 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); From 0b55f8862f9e9b7a114ad1d5c23b55143f376a6a Mon Sep 17 00:00:00 2001 From: Alexandre Iline Date: Tue, 30 Aug 2016 14:30:32 -0700 Subject: [PATCH 76/87] 8164859: Fix module dependences in java/text tests Reviewed-by: naoto --- jdk/test/java/text/Bidi/BidiConformance.java | 3 ++- jdk/test/java/text/Bidi/BidiEmbeddingTest.java | 3 ++- jdk/test/java/text/Bidi/Bug7042148.java | 3 ++- jdk/test/java/text/Bidi/Bug7051769.java | 3 ++- jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java | 7 ++++--- jdk/test/java/text/Collator/APITest.java | 1 + jdk/test/java/text/Collator/CollationKeyTest.java | 1 + jdk/test/java/text/Collator/DanishTest.java | 1 + jdk/test/java/text/Collator/FinnishTest.java | 1 + jdk/test/java/text/Collator/FrenchTest.java | 1 + jdk/test/java/text/Collator/G7Test.java | 1 + jdk/test/java/text/Collator/JapaneseTest.java | 1 + jdk/test/java/text/Collator/KoreanTest.java | 1 + jdk/test/java/text/Collator/Regression.java | 1 + jdk/test/java/text/Collator/ThaiTest.java | 1 + jdk/test/java/text/Collator/TurkishTest.java | 1 + jdk/test/java/text/Collator/VietnameseTest.java | 1 + jdk/test/java/text/Format/DateFormat/Bug4823811.java | 3 ++- jdk/test/java/text/Format/DateFormat/Bug6683975.java | 3 ++- jdk/test/java/text/Format/DateFormat/Bug8139572.java | 3 ++- .../java/text/Format/DateFormat/ContextMonthNamesTest.java | 3 ++- jdk/test/java/text/Format/DateFormat/DateFormatTest.java | 1 + .../java/text/Format/DateFormat/LocaleDateFormats.java | 3 ++- .../text/Format/DateFormat/NonGregorianFormatTest.java | 1 + jdk/test/java/text/Format/DateFormat/bug4117335.java | 1 + .../java/text/Format/MessageFormat/LargeMessageFormat.java | 1 + jdk/test/java/text/Format/NumberFormat/Bug8132125.java | 3 ++- jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java | 1 + .../text/Format/NumberFormat/IntlTestNumberFormatAPI.java | 1 + .../java/text/Format/NumberFormat/NumberRegression.java | 1 + jdk/test/java/text/Format/NumberFormat/NumberTest.java | 1 + 31 files changed, 44 insertions(+), 13 deletions(-) diff --git a/jdk/test/java/text/Bidi/BidiConformance.java b/jdk/test/java/text/Bidi/BidiConformance.java index 73689659cc3..45e49cb632f 100644 --- a/jdk/test/java/text/Bidi/BidiConformance.java +++ b/jdk/test/java/text/Bidi/BidiConformance.java @@ -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; diff --git a/jdk/test/java/text/Bidi/BidiEmbeddingTest.java b/jdk/test/java/text/Bidi/BidiEmbeddingTest.java index 86578f4f1be..fb4d5f7418c 100644 --- a/jdk/test/java/text/Bidi/BidiEmbeddingTest.java +++ b/jdk/test/java/text/Bidi/BidiEmbeddingTest.java @@ -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; diff --git a/jdk/test/java/text/Bidi/Bug7042148.java b/jdk/test/java/text/Bidi/Bug7042148.java index 92c3001dde9..d905a49b746 100644 --- a/jdk/test/java/text/Bidi/Bug7042148.java +++ b/jdk/test/java/text/Bidi/Bug7042148.java @@ -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.*; diff --git a/jdk/test/java/text/Bidi/Bug7051769.java b/jdk/test/java/text/Bidi/Bug7051769.java index 9b1326021b5..a0737ec0afc 100644 --- a/jdk/test/java/text/Bidi/Bug7051769.java +++ b/jdk/test/java/text/Bidi/Bug7051769.java @@ -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 */ diff --git a/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java b/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java index 467cbc574c3..4e114d75bf3 100644 --- a/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java +++ b/jdk/test/java/text/BreakIterator/NewVSOld_th_TH.java @@ -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; diff --git a/jdk/test/java/text/Collator/APITest.java b/jdk/test/java/text/Collator/APITest.java index f2b0a019a29..43782c5ad90 100644 --- a/jdk/test/java/text/Collator/APITest.java +++ b/jdk/test/java/text/Collator/APITest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Collation API + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/CollationKeyTest.java b/jdk/test/java/text/Collator/CollationKeyTest.java index 9146bf97e9a..901a6347a57 100644 --- a/jdk/test/java/text/Collator/CollationKeyTest.java +++ b/jdk/test/java/text/Collator/CollationKeyTest.java @@ -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 */ diff --git a/jdk/test/java/text/Collator/DanishTest.java b/jdk/test/java/text/Collator/DanishTest.java index b5194a83c2a..0c35d22e488 100644 --- a/jdk/test/java/text/Collator/DanishTest.java +++ b/jdk/test/java/text/Collator/DanishTest.java @@ -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 diff --git a/jdk/test/java/text/Collator/FinnishTest.java b/jdk/test/java/text/Collator/FinnishTest.java index 6df18ef0146..9efc3cd861d 100644 --- a/jdk/test/java/text/Collator/FinnishTest.java +++ b/jdk/test/java/text/Collator/FinnishTest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Finnish Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/FrenchTest.java b/jdk/test/java/text/Collator/FrenchTest.java index 939ef322253..38492db023c 100644 --- a/jdk/test/java/text/Collator/FrenchTest.java +++ b/jdk/test/java/text/Collator/FrenchTest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test French Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/G7Test.java b/jdk/test/java/text/Collator/G7Test.java index 0b41566bd2e..f7bdfa4f868 100644 --- a/jdk/test/java/text/Collator/G7Test.java +++ b/jdk/test/java/text/Collator/G7Test.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test G7 Collation + * @modules jdk.localedata */ /* * diff --git a/jdk/test/java/text/Collator/JapaneseTest.java b/jdk/test/java/text/Collator/JapaneseTest.java index 2bd5f6d0179..7333da34b12 100644 --- a/jdk/test/java/text/Collator/JapaneseTest.java +++ b/jdk/test/java/text/Collator/JapaneseTest.java @@ -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.*; diff --git a/jdk/test/java/text/Collator/KoreanTest.java b/jdk/test/java/text/Collator/KoreanTest.java index fd314ee13ed..fb3c5eae941 100644 --- a/jdk/test/java/text/Collator/KoreanTest.java +++ b/jdk/test/java/text/Collator/KoreanTest.java @@ -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.*; diff --git a/jdk/test/java/text/Collator/Regression.java b/jdk/test/java/text/Collator/Regression.java index 958ce29c524..212ab39d557 100644 --- a/jdk/test/java/text/Collator/Regression.java +++ b/jdk/test/java/text/Collator/Regression.java @@ -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 diff --git a/jdk/test/java/text/Collator/ThaiTest.java b/jdk/test/java/text/Collator/ThaiTest.java index 7d643446434..7a961ed5968 100644 --- a/jdk/test/java/text/Collator/ThaiTest.java +++ b/jdk/test/java/text/Collator/ThaiTest.java @@ -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. diff --git a/jdk/test/java/text/Collator/TurkishTest.java b/jdk/test/java/text/Collator/TurkishTest.java index f83ef228e06..d8c078abb4d 100644 --- a/jdk/test/java/text/Collator/TurkishTest.java +++ b/jdk/test/java/text/Collator/TurkishTest.java @@ -25,6 +25,7 @@ * @test * @library /java/text/testlib * @summary test Turkish Collation + * @modules jdk.localedata */ /* (C) Copyright Taligent, Inc. 1996 - All Rights Reserved diff --git a/jdk/test/java/text/Collator/VietnameseTest.java b/jdk/test/java/text/Collator/VietnameseTest.java index faa4921073c..6708622d096 100644 --- a/jdk/test/java/text/Collator/VietnameseTest.java +++ b/jdk/test/java/text/Collator/VietnameseTest.java @@ -26,6 +26,7 @@ * @bug 4932968 5015215 * @library /java/text/testlib * @summary test Vietnamese Collation + * @modules jdk.localedata */ /* diff --git a/jdk/test/java/text/Format/DateFormat/Bug4823811.java b/jdk/test/java/text/Format/DateFormat/Bug4823811.java index 524f790e1fb..c2d35e9f64f 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug4823811.java +++ b/jdk/test/java/text/Format/DateFormat/Bug4823811.java @@ -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 */ diff --git a/jdk/test/java/text/Format/DateFormat/Bug6683975.java b/jdk/test/java/text/Format/DateFormat/Bug6683975.java index e0c8cd75f15..1f401058e5a 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug6683975.java +++ b/jdk/test/java/text/Format/DateFormat/Bug6683975.java @@ -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.*; diff --git a/jdk/test/java/text/Format/DateFormat/Bug8139572.java b/jdk/test/java/text/Format/DateFormat/Bug8139572.java index d55196b3a23..13154c836c5 100644 --- a/jdk/test/java/text/Format/DateFormat/Bug8139572.java +++ b/jdk/test/java/text/Format/DateFormat/Bug8139572.java @@ -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; diff --git a/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java b/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java index 6f38bfb15c1..60632b0fcce 100644 --- a/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java +++ b/jdk/test/java/text/Format/DateFormat/ContextMonthNamesTest.java @@ -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 */ diff --git a/jdk/test/java/text/Format/DateFormat/DateFormatTest.java b/jdk/test/java/text/Format/DateFormat/DateFormatTest.java index c4f148f3d77..7384a82af0c 100644 --- a/jdk/test/java/text/Format/DateFormat/DateFormatTest.java +++ b/jdk/test/java/text/Format/DateFormat/DateFormatTest.java @@ -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 */ diff --git a/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java b/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java index bff177ff7e4..9241e59c3bd 100644 --- a/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java +++ b/jdk/test/java/text/Format/DateFormat/LocaleDateFormats.java @@ -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 */ diff --git a/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java b/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java index 69808d47645..b811900901d 100644 --- a/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java +++ b/jdk/test/java/text/Format/DateFormat/NonGregorianFormatTest.java @@ -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 */ diff --git a/jdk/test/java/text/Format/DateFormat/bug4117335.java b/jdk/test/java/text/Format/DateFormat/bug4117335.java index 6c9af2a4716..d9b59eda005 100644 --- a/jdk/test/java/text/Format/DateFormat/bug4117335.java +++ b/jdk/test/java/text/Format/DateFormat/bug4117335.java @@ -25,6 +25,7 @@ * @test * * @bug 4117335 4432617 + * @modules jdk.localedata */ import java.text.DateFormatSymbols ; diff --git a/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java b/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java index 1a4ca1d092d..55c9869c373 100644 --- a/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java +++ b/jdk/test/java/text/Format/MessageFormat/LargeMessageFormat.java @@ -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 */ diff --git a/jdk/test/java/text/Format/NumberFormat/Bug8132125.java b/jdk/test/java/text/Format/NumberFormat/Bug8132125.java index e19b2cd17eb..9f713324a21 100644 --- a/jdk/test/java/text/Format/NumberFormat/Bug8132125.java +++ b/jdk/test/java/text/Format/NumberFormat/Bug8132125.java @@ -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.*; diff --git a/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java b/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java index 96fa3976701..44b53d25ec1 100644 --- a/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java +++ b/jdk/test/java/text/Format/NumberFormat/CurrencyFormat.java @@ -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 */ diff --git a/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java b/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java index ab1069bdfc2..011db2bdea3 100644 --- a/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java +++ b/jdk/test/java/text/Format/NumberFormat/IntlTestNumberFormatAPI.java @@ -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 diff --git a/jdk/test/java/text/Format/NumberFormat/NumberRegression.java b/jdk/test/java/text/Format/NumberFormat/NumberRegression.java index 0edaa11ccf5..b194d270a5c 100644 --- a/jdk/test/java/text/Format/NumberFormat/NumberRegression.java +++ b/jdk/test/java/text/Format/NumberFormat/NumberRegression.java @@ -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 */ diff --git a/jdk/test/java/text/Format/NumberFormat/NumberTest.java b/jdk/test/java/text/Format/NumberFormat/NumberTest.java index ca519bb6dab..cf64a431a55 100644 --- a/jdk/test/java/text/Format/NumberFormat/NumberTest.java +++ b/jdk/test/java/text/Format/NumberFormat/NumberTest.java @@ -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 */ From 3f2262b34783eef1a3a42c250dfa4c70dae1628c Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Tue, 30 Aug 2016 17:48:07 -0700 Subject: [PATCH 77/87] 8160851: Remove old launcher module-related options Reviewed-by: jjg, alanb --- jdk/src/java.base/share/native/libjli/java.c | 53 +------------------- 1 file changed, 1 insertion(+), 52 deletions(-) diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c index 12ca2b2c656..4b869ceb56f 100644 --- a/jdk/src/java.base/share/native/libjli/java.c +++ b/jdk/src/java.base/share/native/libjli/java.c @@ -556,20 +556,6 @@ IsLauncherOption(const char* name) { 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 @@ IsModuleOption(const char* name) { 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 @@ GetOpt(int *pargc, char ***pargv, char **poption, char **pvalue) { } } -#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 @@ ParseArguments(int *pargc, char ***pargv, 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 */ From 5afec5d3d638d65d0a0311d708ee3ed5570182a9 Mon Sep 17 00:00:00 2001 From: Claes Redestad Date: Wed, 31 Aug 2016 14:20:02 +0200 Subject: [PATCH 78/87] 8164858: Enable build-time use of java.lang.invoke resolve tracing Reviewed-by: erikj, vlivanov --- jdk/make/GenerateClasslist.gmk | 12 +- .../plugins/GenerateJLIClassesPlugin.java | 103 +++++++++++------- .../tools/jlink/resources/plugins.properties | 6 +- .../plugins/GenerateJLIClassesPluginTest.java | 3 +- 4 files changed, 73 insertions(+), 51 deletions(-) diff --git a/jdk/make/GenerateClasslist.gmk b/jdk/make/GenerateClasslist.gmk index 279cf9da012..3863a57d670 100644 --- a/jdk/make/GenerateClasslist.gmk +++ b/jdk/make/GenerateClasslist.gmk @@ -50,6 +50,8 @@ TARGETS += $(CLASSLIST_JAR) 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 @@ endif $(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 \ - -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 + -Djava.lang.invoke.MethodHandle.TRACE_RESOLVE=true \ + -cp $(SUPPORT_OUTPUTDIR)/classlist.jar \ + build.tools.classlist.HelloClasslist \ + $(LOG_DEBUG) 2>&1 > $(JLI_TRACE_FILE) TARGETS += $(CLASSLIST_FILE) diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java index a60a1e934b5..115020953f3 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/internal/plugins/GenerateJLIClassesPlugin.java @@ -29,12 +29,12 @@ import java.io.IOException; import java.lang.invoke.MethodType; import java.nio.file.Files; import java.util.ArrayList; -import java.util.Arrays; 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; @@ -69,11 +69,11 @@ public final class GenerateJLIClassesPlugin implements Plugin { private static final JavaLangInvokeAccess JLIA = SharedSecrets.getJavaLangInvokeAccess(); - List speciesTypes; + Set speciesTypes; - List invokerTypes; + Set invokerTypes; - Map> dmhMethods; + Map> dmhMethods; public GenerateJLIClassesPlugin() { } @@ -110,8 +110,8 @@ public final class GenerateJLIClassesPlugin implements Plugin { * 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 defaultSpecies() { - return List.of("LL", "L3", "L4", "L5", "L6", "L7", "L7I", + public static Set 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"); @@ -120,23 +120,23 @@ public final class GenerateJLIClassesPlugin implements Plugin { /** * @return the default invoker forms to generate. */ - private static List defaultInvokers() { - return List.of("LL_L", "LL_I", "LILL_I", "L6_L"); + private static Set defaultInvokers() { + return Set.of("LL_L", "LL_I", "LILL_I", "L6_L"); } /** * @return the list of default DirectMethodHandle methods to generate. */ - private static Map> defaultDMHMethods() { + private static Map> defaultDMHMethods() { return Map.of( - DMH_INVOKE_VIRTUAL, List.of("L_L", "LL_L", "LLI_I", "L3_V"), - DMH_INVOKE_SPECIAL, List.of("LL_I", "LL_L", "LLF_L", "LLD_L", "L3_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, List.of("LII_I", "LIL_I", "LILIL_I", "LILII_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", @@ -159,15 +159,48 @@ public final class GenerateJLIClassesPlugin implements Plugin { public void configure(Map config) { String mainArgument = config.get(NAME); - if (mainArgument != null && mainArgument.startsWith("@")) { + if ("none".equals(mainArgument)) { + speciesTypes = Set.of(); + invokerTypes = Set.of(); + dmhMethods = Map.of(); + return; + } + + // Start with the default configuration + Set defaultBMHSpecies = defaultSpecies(); + // Expand BMH species signatures + defaultBMHSpecies = defaultBMHSpecies.stream() + .map(type -> expandSignature(type)) + .collect(Collectors.toSet()); + + Set defaultInvokerTypes = defaultInvokers(); + validateMethodTypes(defaultInvokerTypes); + + Map> defaultDmhMethods = defaultDMHMethods(); + for (Set dmhMethodTypes : defaultDmhMethods.values()) { + validateMethodTypes(dmhMethodTypes); + } + + // Extend the default configuration with the contents in the supplied + // input file + if (mainArgument == null || !mainArgument.startsWith("@")) { + speciesTypes = defaultBMHSpecies; + invokerTypes = defaultInvokerTypes; + dmhMethods = defaultDmhMethods; + } else { File file = new File(mainArgument.substring(1)); if (file.exists()) { - speciesTypes = new ArrayList<>(); - invokerTypes = new ArrayList<>(); - dmhMethods = new HashMap<>(); - Stream lines = fileLines(file); - - lines.map(line -> line.split(" ")) + // 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> entry : defaultDmhMethods.entrySet()) { + dmhMethods.put(entry.getKey(), new TreeSet<>(entry.getValue())); + } + fileLines(file) + .map(line -> line.split(" ")) .forEach(parts -> { switch (parts[0]) { case "[BMH_RESOLVE]": @@ -191,28 +224,14 @@ public final class GenerateJLIClassesPlugin implements Plugin { } }); } - } else { - List bmhSpecies = defaultSpecies(); - // Expand BMH species signatures - speciesTypes = bmhSpecies.stream() - .map(type -> expandSignature(type)) - .collect(Collectors.toList()); - - invokerTypes = defaultInvokers(); - validateMethodTypes(invokerTypes); - - dmhMethods = defaultDMHMethods(); - for (List dmhMethodTypes : dmhMethods.values()) { - validateMethodTypes(dmhMethodTypes); - } } } private void addDMHMethodType(String dmh, String methodType) { validateMethodType(methodType); - List methodTypes = dmhMethods.get(dmh); + Set methodTypes = dmhMethods.get(dmh); if (methodTypes == null) { - methodTypes = new ArrayList<>(); + methodTypes = new TreeSet<>(); dmhMethods.put(dmh, methodTypes); } methodTypes.add(methodType); @@ -226,7 +245,7 @@ public final class GenerateJLIClassesPlugin implements Plugin { } } - private void validateMethodTypes(List dmhMethodTypes) { + private void validateMethodTypes(Set dmhMethodTypes) { for (String type : dmhMethodTypes) { validateMethodType(type); } @@ -291,13 +310,13 @@ public final class GenerateJLIClassesPlugin implements Plugin { private void generateHolderClasses(ResourcePoolBuilder out) { int count = 0; - for (List entry : dmhMethods.values()) { + for (Set entry : dmhMethods.values()) { count += entry.size(); } MethodType[] directMethodTypes = new MethodType[count]; int[] dmhTypes = new int[count]; int index = 0; - for (Map.Entry> entry : dmhMethods.entrySet()) { + for (Map.Entry> entry : dmhMethods.entrySet()) { String dmhType = entry.getKey(); for (String type : entry.getValue()) { // The DMH type to actually ask for is retrieved by removing @@ -314,10 +333,11 @@ public final class GenerateJLIClassesPlugin implements Plugin { } } MethodType[] invokerMethodTypes = new MethodType[this.invokerTypes.size()]; - for (int i = 0; i < invokerTypes.size(); 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(invokerTypes.get(i)); + MethodType mt = asMethodType(invokerType); final int lastParam = mt.parameterCount() - 1; if (mt.parameterCount() < 2 || mt.parameterType(0) != Object.class || @@ -327,6 +347,7 @@ public final class GenerateJLIClassesPlugin implements Plugin { } mt = mt.dropParameterTypes(lastParam, lastParam + 1); invokerMethodTypes[i] = mt.dropParameterTypes(0, 1); + i++; } try { byte[] bytes = JLIA.generateDirectMethodHandleHolderClassBytes( diff --git a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties index 67c40903eb9..309187dc2d7 100644 --- a/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties +++ b/jdk/src/jdk.jlink/share/classes/jdk/tools/jlink/resources/plugins.properties @@ -68,12 +68,12 @@ exclude-resources.argument= resources to exclude exclude-resources.description=\ Specify resources to exclude. e.g.: **.jcov,glob:**/META-INF/** -generate-jli-classes.argument=<@filename> +generate-jli-classes.argument= generate-jli-classes.description=\ 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, so to \n\ -disable pre-generation supply the name of an empty or non-existing file +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) diff --git a/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java b/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java index ae2d3ec5945..d1510affb5e 100644 --- a/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java +++ b/jdk/test/tools/jlink/plugins/GenerateJLIClassesPluginTest.java @@ -22,6 +22,7 @@ */ import java.nio.file.Path; +import java.util.Collection; import java.util.List; import java.util.stream.Collectors; @@ -75,7 +76,7 @@ public class GenerateJLIClassesPluginTest { } - private static List classFilesForSpecies(List species) { + private static List classFilesForSpecies(Collection species) { return species.stream() .map(s -> "/java.base/java/lang/invoke/BoundMethodHandle$Species_" + s + ".class") .collect(Collectors.toList()); From 2822e9e2d60beb26b8b42460d0996cb08266f9c6 Mon Sep 17 00:00:00 2001 From: Sibabrata Sahoo Date: Wed, 31 Aug 2016 08:34:59 -0700 Subject: [PATCH 79/87] 8015595: Test sun/security/krb5/auto/Unreachable.java fails with Timeout error Unreachable.java was getting timeout due to PortUnreachableException was not thrown Reviewed-by: weijun --- jdk/test/ProblemList.txt | 2 - .../sun/security/krb5/auto/Unreachable.java | 105 +++++++++++++++--- .../security/krb5/auto/unreachable.krb5.conf | 9 -- 3 files changed, 91 insertions(+), 25 deletions(-) delete mode 100644 jdk/test/sun/security/krb5/auto/unreachable.krb5.conf diff --git a/jdk/test/ProblemList.txt b/jdk/test/ProblemList.txt index 2165bef4aba..38f2392ea0f 100644 --- a/jdk/test/ProblemList.txt +++ b/jdk/test/ProblemList.txt @@ -213,8 +213,6 @@ java/rmi/transport/dgcDeadLock/DGCDeadLock.java 8029360 macosx-a 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 diff --git a/jdk/test/sun/security/krb5/auto/Unreachable.java b/jdk/test/sun/security/krb5/auto/Unreachable.java index b010b54837e..fdc1aa2ee25 100644 --- a/jdk/test/sun/security/krb5/auto/Unreachable.java +++ b/jdk/test/sun/security/krb5/auto/Unreachable.java @@ -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 { - 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(); + // 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"; - // If PortUnreachableException is not received, the login will consume - // about 3*3*30 seconds and the test will timeout. + public static void main(String[] args) throws Exception { + + // - 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 future = executor.submit(new Callable() { + @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; + } } diff --git a/jdk/test/sun/security/krb5/auto/unreachable.krb5.conf b/jdk/test/sun/security/krb5/auto/unreachable.krb5.conf deleted file mode 100644 index 8ff4cc173aa..00000000000 --- a/jdk/test/sun/security/krb5/auto/unreachable.krb5.conf +++ /dev/null @@ -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 -} From 3d17ae2b1d1fee894b805e91f87866161127fc41 Mon Sep 17 00:00:00 2001 From: Sibabrata Sahoo Date: Wed, 31 Aug 2016 08:44:12 -0700 Subject: [PATCH 80/87] 8164922: sun/security/provider/SecureRandom/AutoReseed.java failed with timeout in Ubuntu Linux The test timeout waiting to get seed in an exhausted Linux platform. Reviewed-by: weijun --- .../provider/SecureRandom/AutoReseed.java | 17 +++++++++++------ 1 file changed, 11 insertions(+), 6 deletions(-) diff --git a/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java b/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java index 48361f225d5..0cdce177b1e 100644 --- a/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java +++ b/jdk/test/sun/security/provider/SecureRandom/AutoReseed.java @@ -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 @@ import java.security.Security; * @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 @@ public class AutoReseed { 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"); } } } From 3ff1d554b483076f40115746558a89b6d88ba1ef Mon Sep 17 00:00:00 2001 From: Alexandre Iline Date: Wed, 31 Aug 2016 09:46:50 -0700 Subject: [PATCH 81/87] 8164982: Fix legal notices in java/lang, java/net, java/util tests Reviewed-by: darcy, iris --- jdk/test/java/lang/Class/GetModuleTest.java | 2 +- jdk/test/java/lang/Class/GetPackageTest.java | 2 +- jdk/test/java/lang/ClassLoader/GetSystemPackage.java | 2 +- jdk/test/java/lang/ClassLoader/deadlock/GetResource.java | 2 +- jdk/test/java/lang/ProcessBuilder/CloseRace.java | 2 +- jdk/test/java/lang/ProcessBuilder/PipelineTest.java | 1 - jdk/test/java/lang/StackWalker/CountLocalSlots.java | 2 +- jdk/test/java/lang/StackWalker/LocalsAndOperands.java | 2 +- jdk/test/java/lang/StackWalker/LocalsCrash.java | 2 +- .../java/lang/String/concat/CompactStringsInitialCoder.java | 2 +- .../lang/String/concat/StringConcatFactoryEmptyMethods.java | 2 +- jdk/test/java/lang/String/concat/WithSecurityManager.java | 2 +- jdk/test/java/lang/Thread/ThreadStateController.java | 2 +- .../annotation/typeAnnotations/GetAnnotatedReceiverType.java | 2 +- jdk/test/java/lang/instrument/NMTHelper.java | 2 +- jdk/test/java/lang/invoke/6987555/Test6987555.java | 1 - jdk/test/java/lang/invoke/6991596/Test6991596.java | 1 - jdk/test/java/lang/invoke/6998541/Test6998541.java | 1 - jdk/test/java/lang/invoke/7087570/Test7087570.java | 1 - jdk/test/java/lang/invoke/7157574/Test7157574.java | 1 - jdk/test/java/lang/invoke/7196190/ClassForNameTest.java | 1 - jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java | 1 - jdk/test/java/lang/invoke/8009222/Test8009222.java | 1 - jdk/test/java/lang/invoke/8022701/BogoLoader.java | 1 - jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java | 1 - jdk/test/java/lang/invoke/8022701/Invoker.java | 1 - jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java | 1 - jdk/test/java/lang/invoke/8022701/MethodSupplier.java | 1 - jdk/test/java/lang/invoke/CallSiteTest.java | 1 - jdk/test/java/lang/invoke/CallStaticInitOrder.java | 1 - .../lang/invoke/ProtectedMemberDifferentPackage/Test.java | 1 - .../lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java | 2 +- .../lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java | 2 +- .../invoke/VarHandles/VarHandleTestMethodTypeBoolean.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java | 2 +- .../invoke/VarHandles/VarHandleTestMethodTypeDouble.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java | 2 +- .../lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java | 2 +- .../invoke/VarHandles/VarHandleTestMethodTypeString.java | 2 +- .../java/lang/invoke/accessProtectedSuper/BogoLoader.java | 1 - .../java/lang/invoke/accessProtectedSuper/MethodInvoker.java | 1 - jdk/test/java/lang/invoke/accessProtectedSuper/Test.java | 1 - .../accessProtectedSuper/anotherpkg/MethodSupplierOuter.java | 1 - .../GarbageCollectorMXBean/GcInfoCompositeType.java | 2 +- jdk/test/java/net/Inet4Address/textToNumericFormat.java | 2 +- jdk/test/java/net/ProxySelector/B8035158.java | 1 + .../java/net/URLClassLoader/definePackage/SplitPackage.java | 2 +- jdk/test/java/net/URLPermission/nstest/LookupTest.java | 2 +- jdk/test/java/net/httpclient/BasicAuthTest.java | 1 + jdk/test/java/net/httpclient/HeadersTest1.java | 1 + jdk/test/java/net/httpclient/ImmutableHeaders.java | 1 + jdk/test/java/net/httpclient/security/Driver.java | 1 + jdk/test/java/net/httpclient/security/Security.java | 1 + jdk/test/java/util/Arrays/Correct.java | 2 +- jdk/test/java/util/Map/FunctionalCMEs.java | 3 ++- jdk/test/java/util/Objects/CheckIndex.java | 2 +- .../java/util/concurrent/FutureTask/NegativeTimeout.java | 2 +- .../logging/Logger/entering/LoggerEnteringWithParams.java | 1 - jdk/test/java/util/logging/XMLFormatterDate.java | 2 +- jdk/test/java/util/regex/PatternStreamTest.java | 2 +- jdk/test/java/util/zip/TestCRC32.java | 5 ++--- jdk/test/java/util/zip/TestCRC32C.java | 5 ++--- jdk/test/java/util/zip/ZipFile/TestZipFile.java | 2 +- 66 files changed, 47 insertions(+), 64 deletions(-) diff --git a/jdk/test/java/lang/Class/GetModuleTest.java b/jdk/test/java/lang/Class/GetModuleTest.java index 918e4dd9dd1..359f7ca2ff7 100644 --- a/jdk/test/java/lang/Class/GetModuleTest.java +++ b/jdk/test/java/lang/Class/GetModuleTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2014, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/jdk/test/java/lang/Class/GetPackageTest.java b/jdk/test/java/lang/Class/GetPackageTest.java index f9cb5fb31ff..5f6c96f0d44 100644 --- a/jdk/test/java/lang/Class/GetPackageTest.java +++ b/jdk/test/java/lang/Class/GetPackageTest.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2015, 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/jdk/test/java/lang/ClassLoader/GetSystemPackage.java b/jdk/test/java/lang/ClassLoader/GetSystemPackage.java index fba5648f5f4..56152b5907f 100644 --- a/jdk/test/java/lang/ClassLoader/GetSystemPackage.java +++ b/jdk/test/java/lang/ClassLoader/GetSystemPackage.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java b/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java index 26fbe3dd586..691c509e2e9 100644 --- a/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java +++ b/jdk/test/java/lang/ClassLoader/deadlock/GetResource.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 diff --git a/jdk/test/java/lang/ProcessBuilder/CloseRace.java b/jdk/test/java/lang/ProcessBuilder/CloseRace.java index a9afbd2ba91..1fa6d8d5e15 100644 --- a/jdk/test/java/lang/ProcessBuilder/CloseRace.java +++ b/jdk/test/java/lang/ProcessBuilder/CloseRace.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/jdk/test/java/lang/ProcessBuilder/PipelineTest.java b/jdk/test/java/lang/ProcessBuilder/PipelineTest.java index 9f6ec99fb70..90b277ad9eb 100644 --- a/jdk/test/java/lang/ProcessBuilder/PipelineTest.java +++ b/jdk/test/java/lang/ProcessBuilder/PipelineTest.java @@ -19,7 +19,6 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ import java.io.File; diff --git a/jdk/test/java/lang/StackWalker/CountLocalSlots.java b/jdk/test/java/lang/StackWalker/CountLocalSlots.java index c78a4cb7bf4..066055b0a1d 100644 --- a/jdk/test/java/lang/StackWalker/CountLocalSlots.java +++ b/jdk/test/java/lang/StackWalker/CountLocalSlots.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/jdk/test/java/lang/StackWalker/LocalsAndOperands.java b/jdk/test/java/lang/StackWalker/LocalsAndOperands.java index b253ab27e81..f4f646549ec 100644 --- a/jdk/test/java/lang/StackWalker/LocalsAndOperands.java +++ b/jdk/test/java/lang/StackWalker/LocalsAndOperands.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 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 diff --git a/jdk/test/java/lang/StackWalker/LocalsCrash.java b/jdk/test/java/lang/StackWalker/LocalsCrash.java index b50dd263f00..87415e4df0c 100644 --- a/jdk/test/java/lang/StackWalker/LocalsCrash.java +++ b/jdk/test/java/lang/StackWalker/LocalsCrash.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016 Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java b/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java index 6f566c33eb9..5669bce2fd8 100644 --- a/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java +++ b/jdk/test/java/lang/String/concat/CompactStringsInitialCoder.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java b/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java index 31b29cd30fd..7ee0d988529 100644 --- a/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java +++ b/jdk/test/java/lang/String/concat/StringConcatFactoryEmptyMethods.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/jdk/test/java/lang/String/concat/WithSecurityManager.java b/jdk/test/java/lang/String/concat/WithSecurityManager.java index 9359d29fbb1..2835a3813f4 100644 --- a/jdk/test/java/lang/String/concat/WithSecurityManager.java +++ b/jdk/test/java/lang/String/concat/WithSecurityManager.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2016, 2016, Oracle and/or its affiliates. All rights reserved. + * 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 diff --git a/jdk/test/java/lang/Thread/ThreadStateController.java b/jdk/test/java/lang/Thread/ThreadStateController.java index 728a115c271..c426d1b34b4 100644 --- a/jdk/test/java/lang/Thread/ThreadStateController.java +++ b/jdk/test/java/lang/Thread/ThreadStateController.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java b/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java index e9608089763..084ed563809 100644 --- a/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java +++ b/jdk/test/java/lang/annotation/typeAnnotations/GetAnnotatedReceiverType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/jdk/test/java/lang/instrument/NMTHelper.java b/jdk/test/java/lang/instrument/NMTHelper.java index 09e60e4a623..07ee25be38d 100644 --- a/jdk/test/java/lang/instrument/NMTHelper.java +++ b/jdk/test/java/lang/instrument/NMTHelper.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/jdk/test/java/lang/invoke/6987555/Test6987555.java b/jdk/test/java/lang/invoke/6987555/Test6987555.java index 7a2f45c6efe..eb939007326 100644 --- a/jdk/test/java/lang/invoke/6987555/Test6987555.java +++ b/jdk/test/java/lang/invoke/6987555/Test6987555.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/6991596/Test6991596.java b/jdk/test/java/lang/invoke/6991596/Test6991596.java index a7083bd8114..193009deafd 100644 --- a/jdk/test/java/lang/invoke/6991596/Test6991596.java +++ b/jdk/test/java/lang/invoke/6991596/Test6991596.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/6998541/Test6998541.java b/jdk/test/java/lang/invoke/6998541/Test6998541.java index 1edf14f9dc6..983c23b3640 100644 --- a/jdk/test/java/lang/invoke/6998541/Test6998541.java +++ b/jdk/test/java/lang/invoke/6998541/Test6998541.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/7087570/Test7087570.java b/jdk/test/java/lang/invoke/7087570/Test7087570.java index 732467b8c62..165968c6069 100644 --- a/jdk/test/java/lang/invoke/7087570/Test7087570.java +++ b/jdk/test/java/lang/invoke/7087570/Test7087570.java @@ -19,7 +19,6 @@ * 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 diff --git a/jdk/test/java/lang/invoke/7157574/Test7157574.java b/jdk/test/java/lang/invoke/7157574/Test7157574.java index acf9ef48a04..d2a91d92626 100644 --- a/jdk/test/java/lang/invoke/7157574/Test7157574.java +++ b/jdk/test/java/lang/invoke/7157574/Test7157574.java @@ -19,7 +19,6 @@ * 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. - * */ /* diff --git a/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java b/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java index 4730efafb6c..e0797f0f741 100644 --- a/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java +++ b/jdk/test/java/lang/invoke/7196190/ClassForNameTest.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java b/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java index 24a9512ffaf..57a06d16b05 100644 --- a/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java +++ b/jdk/test/java/lang/invoke/7196190/GetUnsafeTest.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/8009222/Test8009222.java b/jdk/test/java/lang/invoke/8009222/Test8009222.java index 711969387ed..62ee09c066a 100644 --- a/jdk/test/java/lang/invoke/8009222/Test8009222.java +++ b/jdk/test/java/lang/invoke/8009222/Test8009222.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/8022701/BogoLoader.java b/jdk/test/java/lang/invoke/8022701/BogoLoader.java index e77be6f44ff..e8c579a27c8 100644 --- a/jdk/test/java/lang/invoke/8022701/BogoLoader.java +++ b/jdk/test/java/lang/invoke/8022701/BogoLoader.java @@ -19,7 +19,6 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ import java.io.BufferedInputStream; diff --git a/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java b/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java index 5c1f64bf9b0..011ae7f43a5 100644 --- a/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java +++ b/jdk/test/java/lang/invoke/8022701/InvokeSeveralWays.java @@ -19,7 +19,6 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ import java.lang.reflect.InvocationTargetException; diff --git a/jdk/test/java/lang/invoke/8022701/Invoker.java b/jdk/test/java/lang/invoke/8022701/Invoker.java index a97159e9e29..62015fae371 100644 --- a/jdk/test/java/lang/invoke/8022701/Invoker.java +++ b/jdk/test/java/lang/invoke/8022701/Invoker.java @@ -19,7 +19,6 @@ * 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. - * */ public class Invoker { diff --git a/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java b/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java index badc1a817f3..18d4a4c6752 100644 --- a/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java +++ b/jdk/test/java/lang/invoke/8022701/MHIllegalAccess.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/8022701/MethodSupplier.java b/jdk/test/java/lang/invoke/8022701/MethodSupplier.java index 4699a52aaff..5ef4d20f1ac 100644 --- a/jdk/test/java/lang/invoke/8022701/MethodSupplier.java +++ b/jdk/test/java/lang/invoke/8022701/MethodSupplier.java @@ -19,7 +19,6 @@ * 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. - * */ /* diff --git a/jdk/test/java/lang/invoke/CallSiteTest.java b/jdk/test/java/lang/invoke/CallSiteTest.java index 48b0d7b6d9a..bf0fe2e4dc7 100644 --- a/jdk/test/java/lang/invoke/CallSiteTest.java +++ b/jdk/test/java/lang/invoke/CallSiteTest.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/CallStaticInitOrder.java b/jdk/test/java/lang/invoke/CallStaticInitOrder.java index 83808f8fb9f..4090e8fff2d 100644 --- a/jdk/test/java/lang/invoke/CallStaticInitOrder.java +++ b/jdk/test/java/lang/invoke/CallStaticInitOrder.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java index edfe52af8a7..7356b290768 100644 --- a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java +++ b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/Test.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java index 154109c883a..771e87f67aa 100644 --- a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java +++ b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p1/T2.java @@ -19,8 +19,8 @@ * 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 p1; import p2.T3; diff --git a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java index 9f4d7cee9bc..0deba761a74 100644 --- a/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java +++ b/jdk/test/java/lang/invoke/ProtectedMemberDifferentPackage/p2/T3.java @@ -19,8 +19,8 @@ * 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 p2; import p1.T2; diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java index 624f98a8407..4a1d0103411 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeBoolean.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java index 692d667ac05..a067b57182a 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeByte.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java index 268e521f294..0638b88aef4 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeChar.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java index e3bf8363a15..0bc17bab3b9 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeDouble.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java index 34617e2102e..12efef61cda 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeFloat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java index 33b33970f80..7291c0ebbc2 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeInt.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java index 654619335fe..d081ddec842 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeLong.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java index 82b6f3cab78..eba0cd204b3 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeShort.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 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 diff --git a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java index 41d0e6b4702..91e25c99bb9 100644 --- a/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java +++ b/jdk/test/java/lang/invoke/VarHandles/VarHandleTestMethodTypeString.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 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 diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java b/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java index 190761dd6df..a129ea254a4 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/BogoLoader.java @@ -19,7 +19,6 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ import java.io.BufferedInputStream; diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java b/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java index d14e7ef8a35..fae5e466646 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/MethodInvoker.java @@ -19,7 +19,6 @@ * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA * or visit www.oracle.com if you need additional information or have any * questions. - * */ import anotherpkg.MethodSupplierOuter; diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java b/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java index b83496f692f..96b3fb637a1 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/Test.java @@ -19,7 +19,6 @@ * 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. - * */ /** diff --git a/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java b/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java index 314f8eab707..cd40ed2050c 100644 --- a/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java +++ b/jdk/test/java/lang/invoke/accessProtectedSuper/anotherpkg/MethodSupplierOuter.java @@ -19,7 +19,6 @@ * 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 anotherpkg; diff --git a/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java b/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java index a8bb8badf9b..13ae1e030c5 100644 --- a/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java +++ b/jdk/test/java/lang/management/GarbageCollectorMXBean/GcInfoCompositeType.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2006, 2016 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2006, 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 diff --git a/jdk/test/java/net/Inet4Address/textToNumericFormat.java b/jdk/test/java/net/Inet4Address/textToNumericFormat.java index 1d010d0b912..7d75bc9f534 100644 --- a/jdk/test/java/net/Inet4Address/textToNumericFormat.java +++ b/jdk/test/java/net/Inet4Address/textToNumericFormat.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2016 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 diff --git a/jdk/test/java/net/ProxySelector/B8035158.java b/jdk/test/java/net/ProxySelector/B8035158.java index 21b1e99d702..432e457c303 100644 --- a/jdk/test/java/net/ProxySelector/B8035158.java +++ b/jdk/test/java/net/ProxySelector/B8035158.java @@ -20,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + /* * @test * @bug 8035158 8145732 diff --git a/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java b/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java index 0b009606624..c31441d8b1a 100644 --- a/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java +++ b/jdk/test/java/net/URLClassLoader/definePackage/SplitPackage.java @@ -1,4 +1,4 @@ -/** +/* * Copyright (c) 2016, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * diff --git a/jdk/test/java/net/URLPermission/nstest/LookupTest.java b/jdk/test/java/net/URLPermission/nstest/LookupTest.java index f69522de22f..d5b9141c1d4 100644 --- a/jdk/test/java/net/URLPermission/nstest/LookupTest.java +++ b/jdk/test/java/net/URLPermission/nstest/LookupTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2016 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 diff --git a/jdk/test/java/net/httpclient/BasicAuthTest.java b/jdk/test/java/net/httpclient/BasicAuthTest.java index fb227e3f672..b78739e682a 100644 --- a/jdk/test/java/net/httpclient/BasicAuthTest.java +++ b/jdk/test/java/net/httpclient/BasicAuthTest.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/HeadersTest1.java b/jdk/test/java/net/httpclient/HeadersTest1.java index 79f62006722..e3c892ef2c1 100644 --- a/jdk/test/java/net/httpclient/HeadersTest1.java +++ b/jdk/test/java/net/httpclient/HeadersTest1.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/ImmutableHeaders.java b/jdk/test/java/net/httpclient/ImmutableHeaders.java index 7286c2e1b0b..7773061dc30 100644 --- a/jdk/test/java/net/httpclient/ImmutableHeaders.java +++ b/jdk/test/java/net/httpclient/ImmutableHeaders.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/security/Driver.java b/jdk/test/java/net/httpclient/security/Driver.java index 078be5f5e51..3253fe2fd3c 100644 --- a/jdk/test/java/net/httpclient/security/Driver.java +++ b/jdk/test/java/net/httpclient/security/Driver.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/net/httpclient/security/Security.java b/jdk/test/java/net/httpclient/security/Security.java index 2108c9fce29..5c282be9a36 100644 --- a/jdk/test/java/net/httpclient/security/Security.java +++ b/jdk/test/java/net/httpclient/security/Security.java @@ -20,6 +20,7 @@ * * 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. */ /** diff --git a/jdk/test/java/util/Arrays/Correct.java b/jdk/test/java/util/Arrays/Correct.java index e9ddc7edef5..f69ea9160ff 100644 --- a/jdk/test/java/util/Arrays/Correct.java +++ b/jdk/test/java/util/Arrays/Correct.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2002, 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2002, 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/jdk/test/java/util/Map/FunctionalCMEs.java b/jdk/test/java/util/Map/FunctionalCMEs.java index 6f92b018185..4d83d241c94 100644 --- a/jdk/test/java/util/Map/FunctionalCMEs.java +++ b/jdk/test/java/util/Map/FunctionalCMEs.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015 Oracle and/or its affiliates. All rights reserved. + * 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 @@ -22,6 +22,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + import java.util.Arrays; import java.util.ConcurrentModificationException; import java.util.HashMap; diff --git a/jdk/test/java/util/Objects/CheckIndex.java b/jdk/test/java/util/Objects/CheckIndex.java index bcfa1d5b23d..594e806dcd0 100644 --- a/jdk/test/java/util/Objects/CheckIndex.java +++ b/jdk/test/java/util/Objects/CheckIndex.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2015, 2016 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 diff --git a/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java b/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java index f2e18f6d1bf..37cf4359580 100644 --- a/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java +++ b/jdk/test/java/util/concurrent/FutureTask/NegativeTimeout.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2014 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. * * This code is free software; you can redistribute it and/or modify it diff --git a/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java b/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java index d63e619830a..d9b494741ab 100644 --- a/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java +++ b/jdk/test/java/util/logging/Logger/entering/LoggerEnteringWithParams.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. diff --git a/jdk/test/java/util/logging/XMLFormatterDate.java b/jdk/test/java/util/logging/XMLFormatterDate.java index ee0eeb98b57..3b0d7029464 100644 --- a/jdk/test/java/util/logging/XMLFormatterDate.java +++ b/jdk/test/java/util/logging/XMLFormatterDate.java @@ -1,4 +1,3 @@ - /* * Copyright (c) 2013, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -21,6 +20,7 @@ * or visit www.oracle.com if you need additional information or have any * questions. */ + import java.io.ByteArrayInputStream; import java.io.ByteArrayOutputStream; import java.io.IOException; diff --git a/jdk/test/java/util/regex/PatternStreamTest.java b/jdk/test/java/util/regex/PatternStreamTest.java index 1f02e410321..9809ea20aef 100644 --- a/jdk/test/java/util/regex/PatternStreamTest.java +++ b/jdk/test/java/util/regex/PatternStreamTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2013, 2015 Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2013, 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 diff --git a/jdk/test/java/util/zip/TestCRC32.java b/jdk/test/java/util/zip/TestCRC32.java index 68c15aed44b..15d919ddb61 100644 --- a/jdk/test/java/util/zip/TestCRC32.java +++ b/jdk/test/java/util/zip/TestCRC32.java @@ -1,6 +1,3 @@ - -import java.util.zip.CRC32; - /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -24,6 +21,8 @@ import java.util.zip.CRC32; * questions. */ +import java.util.zip.CRC32; + /** * @test @summary Check that CRC-32 returns the expected CRC value for the * string 123456789 diff --git a/jdk/test/java/util/zip/TestCRC32C.java b/jdk/test/java/util/zip/TestCRC32C.java index bb5ea0447c5..6adf260dbab 100644 --- a/jdk/test/java/util/zip/TestCRC32C.java +++ b/jdk/test/java/util/zip/TestCRC32C.java @@ -1,6 +1,3 @@ - -import java.util.zip.CRC32C; - /* * Copyright (c) 2014, Oracle and/or its affiliates. All rights reserved. * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER. @@ -24,6 +21,8 @@ import java.util.zip.CRC32C; * questions. */ +import java.util.zip.CRC32C; + /** * @test @summary Check that CRC-32C returns the expected CRC value for the * string 123456789 diff --git a/jdk/test/java/util/zip/ZipFile/TestZipFile.java b/jdk/test/java/util/zip/ZipFile/TestZipFile.java index 515ed356c2b..25b87ff1242 100644 --- a/jdk/test/java/util/zip/ZipFile/TestZipFile.java +++ b/jdk/test/java/util/zip/ZipFile/TestZipFile.java @@ -8,7 +8,7 @@ * * 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 + * 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). * From 4a0362efffba9e29c10644e29dd97f81c9a68af4 Mon Sep 17 00:00:00 2001 From: Henry Jen Date: Wed, 31 Aug 2016 11:53:58 -0700 Subject: [PATCH 82/87] 8081388: JNI exception pending in jdk/src/windows/bin/java_md.c Reviewed-by: ksrini --- jdk/src/java.base/share/native/libjli/java.c | 1 + jdk/src/java.base/share/native/libjli/java.h | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/jdk/src/java.base/share/native/libjli/java.c b/jdk/src/java.base/share/native/libjli/java.c index 4b869ceb56f..6dc9674a6ed 100644 --- a/jdk/src/java.base/share/native/libjli/java.c +++ b/jdk/src/java.base/share/native/libjli/java.c @@ -1497,6 +1497,7 @@ NewPlatformStringArray(JNIEnv *env, char **strv, int strc) NULL_CHECK0(cls = FindBootStrapClass(env, "java/lang/String")); NULL_CHECK0(ary = (*env)->NewObjectArray(env, strc, cls, 0)); + CHECK_EXCEPTION_RETURN_VALUE(0); for (i = 0; i < strc; i++) { jstring str = NewPlatformString(env, *strv++); NULL_CHECK0(str); diff --git a/jdk/src/java.base/share/native/libjli/java.h b/jdk/src/java.base/share/native/libjli/java.h index c18c66e5b51..41a232714c8 100644 --- a/jdk/src/java.base/share/native/libjli/java.h +++ b/jdk/src/java.base/share/native/libjli/java.h @@ -253,6 +253,13 @@ typedef struct { #define NULL_CHECK(NC_check_pointer) \ NULL_CHECK_RETURN_VALUE(NC_check_pointer, ) +#define CHECK_EXCEPTION_RETURN_VALUE(CER_value) \ + do { \ + if ((*env)->ExceptionOccurred(env)) { \ + return CER_value; \ + } \ + } while (JNI_FALSE) + #define CHECK_EXCEPTION_RETURN() \ do { \ if ((*env)->ExceptionOccurred(env)) { \ From b5172ce65ea0fe1d0f658e206cab279562a0f3cc Mon Sep 17 00:00:00 2001 From: Mandy Chung Date: Wed, 31 Aug 2016 15:20:31 -0700 Subject: [PATCH 83/87] 8165180: Provide a shared secret to access non-public ServerSocket constructor Reviewed-by: chegar --- .../share/classes/java/net/ServerSocket.java | 28 +++++++++++++ .../internal/misc/JavaNetSocketAccess.java | 41 +++++++++++++++++++ .../jdk/internal/misc/SharedSecrets.java | 11 +++++ 3 files changed, 80 insertions(+) create mode 100644 jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetSocketAccess.java diff --git a/jdk/src/java.base/share/classes/java/net/ServerSocket.java b/jdk/src/java.base/share/classes/java/net/ServerSocket.java index a86fca6af3c..256c9a6e2ee 100644 --- a/jdk/src/java.base/share/classes/java/net/ServerSocket.java +++ b/jdk/src/java.base/share/classes/java/net/ServerSocket.java @@ -25,8 +25,13 @@ package java.net; +import jdk.internal.misc.JavaNetSocketAccess; +import jdk.internal.misc.SharedSecrets; + import java.io.FileDescriptor; import java.io.IOException; +import java.lang.reflect.Constructor; +import java.lang.reflect.InvocationTargetException; import java.nio.channels.ServerSocketChannel; import java.security.AccessController; import java.security.PrivilegedExceptionAction; @@ -1011,4 +1016,27 @@ class ServerSocket implements java.io.Closeable { return options; } } + + static { + SharedSecrets.setJavaNetSocketAccess( + new JavaNetSocketAccess() { + @Override + public ServerSocket newServerSocket(SocketImpl impl) { + return new ServerSocket(impl); + } + + @Override + public SocketImpl newSocketImpl(Class implClass) { + try { + Constructor ctor = + implClass.getDeclaredConstructor(); + return ctor.newInstance(); + } catch (NoSuchMethodException | InstantiationException | + IllegalAccessException | InvocationTargetException e) { + throw new AssertionError(e); + } + } + } + ); + } } diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetSocketAccess.java b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetSocketAccess.java new file mode 100644 index 00000000000..39dd153731e --- /dev/null +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/JavaNetSocketAccess.java @@ -0,0 +1,41 @@ +/* + * 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. + */ + +package jdk.internal.misc; + +import java.net.ServerSocket; +import java.net.SocketImpl; + +public interface JavaNetSocketAccess { + /** + * Creates a ServerSocket associated with the given SocketImpl. + */ + ServerSocket newServerSocket(SocketImpl impl); + + /* + * Constructs a SocketImpl instance of the given class. + */ + SocketImpl newSocketImpl(Class implClass); +} diff --git a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java index fed1b694548..052d1119f09 100644 --- a/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java +++ b/jdk/src/java.base/share/classes/jdk/internal/misc/SharedSecrets.java @@ -55,6 +55,7 @@ public class SharedSecrets { private static JavaNetAccess javaNetAccess; private static JavaNetInetAddressAccess javaNetInetAddressAccess; private static JavaNetHttpCookieAccess javaNetHttpCookieAccess; + private static JavaNetSocketAccess javaNetSocketAccess; private static JavaNioAccess javaNioAccess; private static JavaIOFileDescriptorAccess javaIOFileDescriptorAccess; private static JavaSecurityProtectionDomainAccess javaSecurityProtectionDomainAccess; @@ -161,6 +162,16 @@ public class SharedSecrets { return javaNetHttpCookieAccess; } + public static void setJavaNetSocketAccess(JavaNetSocketAccess jnsa) { + javaNetSocketAccess = jnsa; + } + + public static JavaNetSocketAccess getJavaNetSocketAccess() { + if (javaNetSocketAccess == null) + unsafe.ensureClassInitialized(java.net.ServerSocket.class); + return javaNetSocketAccess; + } + public static void setJavaNioAccess(JavaNioAccess jna) { javaNioAccess = jna; } From 53db4a4609e9b11fbd4d9c2c3b92c5f3cdc5321d Mon Sep 17 00:00:00 2001 From: Rajan Halade Date: Wed, 31 Aug 2016 16:16:01 -0700 Subject: [PATCH 84/87] 8164229: Redundant "sun/net/www/protocol/https" tests in jdk_security3 group Reviewed-by: chegar --- jdk/test/TEST.groups | 1 - 1 file changed, 1 deletion(-) diff --git a/jdk/test/TEST.groups b/jdk/test/TEST.groups index be1540695df..d24280a517b 100644 --- a/jdk/test/TEST.groups +++ b/jdk/test/TEST.groups @@ -189,7 +189,6 @@ jdk_security3 = \ -sun/security/krb5 \ -sun/security/jgss \ javax/net \ - sun/net/www/protocol/https \ com/sun/net/ssl \ lib/security From d2f0ab6d8e22a4fe4e1b68c483a5a88883ec7cdc Mon Sep 17 00:00:00 2001 From: Jan Lahoda Date: Thu, 1 Sep 2016 10:30:13 +0200 Subject: [PATCH 85/87] 8131023: JShell: System.in does not work Read prompt lentgh directly from the terminal Reviewed-by: rfield --- .../internal/jline/console/ConsoleReader.java | 32 ++++++++++++++++++- 1 file changed, 31 insertions(+), 1 deletion(-) diff --git a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java index 9b7edac4d33..84341e1e181 100644 --- a/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java +++ b/jdk/src/jdk.internal.le/share/classes/jdk/internal/jline/console/ConsoleReader.java @@ -39,6 +39,7 @@ import java.util.ListIterator; //import java.util.Map; import java.util.ResourceBundle; import java.util.Stack; +import java.util.regex.Matcher; import java.util.regex.Pattern; import jdk.internal.jline.Terminal; @@ -2336,6 +2337,33 @@ public class ConsoleReader out.flush(); } + Stack pushBackChar = new Stack(); + + if (terminal.isAnsiSupported()) { + //detect the prompt length by reading the cursor position from the terminal + //the real prompt length could differ from the simple prompt length due to + //use of escape sequences: + out.write("\033[6n"); + out.flush(); + StringBuilder input = new StringBuilder(); + while (true) { + int read; + while ((read = in.read()) != 'R') { + input.appendCodePoint(read); + } + input.appendCodePoint(read); + Matcher m = CURSOR_COLUMN_PATTERN.matcher(input); + if (m.matches()) { + promptLen = Integer.parseInt(m.group("column")) - 1; + String prefix = m.group("prefix"); + for (int i = prefix.length() - 1; i >= 0; i--) { + pushBackChar.push(prefix.charAt(i)); + } + break; + } + } + } + // if the terminal is unsupported, just use plain-java reading if (!terminal.isSupported()) { return readLineSimple(); @@ -2352,7 +2380,6 @@ public class ConsoleReader boolean success = true; StringBuilder sb = new StringBuilder(); - Stack pushBackChar = new Stack(); while (true) { int c = pushBackChar.isEmpty() ? readCharacter() : pushBackChar.pop (); if (c == -1) { @@ -3193,6 +3220,9 @@ public class ConsoleReader } } } + //where: + private Pattern CURSOR_COLUMN_PATTERN = + Pattern.compile("(?.*)\033\\[[0-9]+;(?[0-9]+)R"); /** * Read a line for unsupported terminals. From 277a5b423f98b52f9e507f5969dd53c3284df659 Mon Sep 17 00:00:00 2001 From: Amit Sapre Date: Thu, 1 Sep 2016 15:02:32 +0530 Subject: [PATCH 86/87] 8164609: javax/management/remote/mandatory/notif/DeadListenerTest.java fails with Assertion Error Increased test timeout to ensure test case gets all notifications. Reviewed-by: dholmes --- .../remote/mandatory/notif/DeadListenerTest.java | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java b/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java index 3f91fc38085..50777b00220 100644 --- a/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java +++ b/jdk/test/javax/management/remote/mandatory/notif/DeadListenerTest.java @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2015, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 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 @@ -115,9 +115,8 @@ public class DeadListenerTest { mbean.sendNotification(notif); // Make sure notifs are working normally. - long deadline = System.currentTimeMillis() + 2000; - while ((count1Val.get() != 1 || count2Val.get() != 1) && System.currentTimeMillis() < deadline) { - Thread.sleep(10); + while ((count1Val.get() != 1 || count2Val.get() != 1) ) { + Thread.sleep(20); } assertTrue("New value of count1 == 1", count1Val.get() == 1); assertTrue("Initial value of count2 == 1", count2Val.get() == 1); From 9807f64dfc49de8aeeaee586bd84b4086d68ce5e Mon Sep 17 00:00:00 2001 From: Sean Coffey Date: Thu, 1 Sep 2016 11:01:47 +0100 Subject: [PATCH 87/87] 8164846: CertificateException missing cause of underlying exception Reviewed-by: xuelei --- .../sun/security/ssl/SSLContextImpl.java | 2 +- .../ssl/SSLContextImpl/TrustTrustedCert.java | 87 ++++++++++++------- 2 files changed, 58 insertions(+), 31 deletions(-) diff --git a/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java b/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java index 764f04cd545..86727b91997 100644 --- a/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java +++ b/jdk/src/java.base/share/classes/sun/security/ssl/SSLContextImpl.java @@ -1496,7 +1496,7 @@ final class AbstractTrustManagerWrapper extends X509ExtendedTrustManager } } catch (CertPathValidatorException cpve) { throw new CertificateException( - "Certificates does not conform to algorithm constraints"); + "Certificates do not conform to algorithm constraints", cpve); } } } diff --git a/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java b/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java index b812ba5f60e..b10431b6444 100644 --- a/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java +++ b/jdk/test/sun/security/ssl/SSLContextImpl/TrustTrustedCert.java @@ -30,12 +30,13 @@ /* * @test - * @bug 7113275 + * @bug 7113275 8164846 * @summary compatibility issue with MD2 trust anchor and old X509TrustManager - * @run main/othervm TrustTrustedCert PKIX TLSv1.1 - * @run main/othervm TrustTrustedCert SunX509 TLSv1.1 - * @run main/othervm TrustTrustedCert PKIX TLSv1.2 - * @run main/othervm TrustTrustedCert SunX509 TLSv1.2 + * @run main/othervm TrustTrustedCert PKIX TLSv1.1 true + * @run main/othervm TrustTrustedCert PKIX TLSv1.1 false + * @run main/othervm TrustTrustedCert SunX509 TLSv1.1 false + * @run main/othervm TrustTrustedCert PKIX TLSv1.2 false + * @run main/othervm TrustTrustedCert SunX509 TLSv1.2 false */ import java.net.*; @@ -181,23 +182,32 @@ public class TrustTrustedCert { Thread.sleep(50); } - SSLContext context = generateSSLContext(); - SSLSocketFactory sslsf = context.getSocketFactory(); + SSLSocket sslSocket = null; + try { + SSLContext context = generateSSLContext(); + SSLSocketFactory sslsf = context.getSocketFactory(); - SSLSocket sslSocket = - (SSLSocket)sslsf.createSocket("localhost", serverPort); + sslSocket = (SSLSocket)sslsf.createSocket("localhost", serverPort); - // enable the specified TLS protocol - sslSocket.setEnabledProtocols(new String[] {tlsProtocol}); + // enable the specified TLS protocol + sslSocket.setEnabledProtocols(new String[] {tlsProtocol}); - InputStream sslIS = sslSocket.getInputStream(); - OutputStream sslOS = sslSocket.getOutputStream(); - - sslOS.write('B'); - sslOS.flush(); - sslIS.read(); - - sslSocket.close(); + InputStream sslIS = sslSocket.getInputStream(); + OutputStream sslOS = sslSocket.getOutputStream(); + sslOS.write('B'); + sslOS.flush(); + sslIS.read(); + } catch (SSLHandshakeException e) { + // focus in on the CertPathValidatorException + Throwable t = e.getCause().getCause(); + if ((t == null) || (expectFail && + !t.toString().contains("MD5withRSA"))) { + throw new RuntimeException( + "Expected to see MD5withRSA in exception output " + t); + } + } finally { + if (sslSocket != null) sslSocket.close(); + } } /* @@ -206,10 +216,13 @@ public class TrustTrustedCert { */ private static String tmAlgorithm; // trust manager private static String tlsProtocol; // trust manager + // set this flag to test context of CertificateException + private static boolean expectFail; private static void parseArguments(String[] args) { tmAlgorithm = args[0]; tlsProtocol = args[1]; + expectFail = Boolean.parseBoolean(args[2]); } private static SSLContext generateSSLContext() throws Exception { @@ -232,7 +245,7 @@ public class TrustTrustedCert { // generate the private key. PKCS8EncodedKeySpec priKeySpec = new PKCS8EncodedKeySpec( - Base64.getMimeDecoder().decode(targetPrivateKey)); + Base64.getMimeDecoder().decode(targetPrivateKey)); KeyFactory kf = KeyFactory.getInstance("RSA"); RSAPrivateKey priKey = (RSAPrivateKey)kf.generatePrivate(priKeySpec); @@ -338,20 +351,25 @@ public class TrustTrustedCert { volatile Exception clientException = null; public static void main(String[] args) throws Exception { - // MD5 is used in this test case, don't disable MD5 algorithm. - Security.setProperty("jdk.certpath.disabledAlgorithms", + /* + * Get the customized arguments. + */ + parseArguments(args); + + /* + * MD5 is used in this test case, don't disable MD5 algorithm. + * if expectFail is set, we're testing exception message + */ + if (!expectFail) { + Security.setProperty("jdk.certpath.disabledAlgorithms", "MD2, RSA keySize < 1024"); + } Security.setProperty("jdk.tls.disabledAlgorithms", "SSLv3, RC4, DH keySize < 768"); if (debug) System.setProperty("javax.net.debug", "all"); - /* - * Get the customized arguments. - */ - parseArguments(args); - /* * Start the tests. */ @@ -376,7 +394,8 @@ public class TrustTrustedCert { startServer(false); } } catch (Exception e) { - // swallow for now. Show later + System.out.println("Unexpected exception: "); + e.printStackTrace(); } /* @@ -440,7 +459,11 @@ public class TrustTrustedCert { */ System.err.println("Server died..."); serverReady = true; - serverException = e; + if (!expectFail) { + // only record if we weren't expecting. + // client side will record exception + serverException = e; + } } } }; @@ -449,7 +472,11 @@ public class TrustTrustedCert { try { doServerSide(); } catch (Exception e) { - serverException = e; + // only record if we weren't expecting. + // client side will record exception + if (!expectFail) { + serverException = e; + } } finally { serverReady = true; }