From e6b5e0d57f0e9deb2ab5f2e36caec3c892fd45ed Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Thu, 8 Feb 2024 07:11:32 +0100 Subject: [PATCH 01/12] Prefer Files#createTempFile over File#createTempFile. Files.createTempFile uses more restrictive file permissions if possible. project wide refactoring, skipped most tests and some dead code to shrink the change set. --- .../installer/maven/actions/BuildInstallersAction.java | 3 ++- .../installer/actions/BuildInstallersAction.java | 3 ++- .../modules/j2ee/jboss4/ide/JBStartRunnable.java | 7 ++++--- .../modules/websvc/wsitconf/util/TestUtil.java | 3 ++- .../modules/glassfish/common/CreateDomain.java | 3 ++- .../modules/jakarta/web/beans/xdm/model/Util.java | 3 ++- .../javaee/wildfly/ide/WildflyStartRunnable.java | 7 ++++--- .../netbeans/modules/payara/common/CreateDomain.java | 5 ++++- .../modules/tomcat5/deploy/TomcatManagerImpl.java | 3 ++- .../org/netbeans/modules/web/beans/xdm/model/Util.java | 3 ++- .../org/netbeans/modules/web/jsf/xdm/model/Util.java | 3 ++- .../modules/websvc/manager/codegen/Wsdl2Java.java | 3 ++- .../websvc/manager/ui/TestWebServiceMethodDlg.java | 3 ++- .../nbjunit/src/org/netbeans/junit/NbModuleSuite.java | 5 +++-- .../src/org/netbeans/junit/diff/NativeDiff.java | 3 ++- .../modules/db/dataview/util/FileBackedBlob.java | 3 ++- .../modules/db/dataview/util/FileBackedClob.java | 3 ++- ide/diff/src/org/netbeans/api/diff/StreamSource.java | 3 ++- .../src/org/netbeans/modules/diff/PatchAction.java | 3 ++- .../modules/diff/cmdline/CmdlineDiffProvider.java | 5 +++-- .../nativeexecution/TerminalLocalNativeProcess.java | 3 ++- .../editor/settings/storage/EditorTestLookup.java | 3 ++- .../editor/settings/storage/EditorTestLookup.java | 3 ++- .../src/org/netbeans/modules/git/utils/GitUtils.java | 7 ++++--- .../libs/git/jgit/commands/IgnoreUnignoreCommand.java | 2 +- .../modules/mercurial/ui/diff/ExportBundle.java | 3 ++- .../mercurial/ui/update/ResolveConflictsExecutor.java | 7 ++++--- .../org/netbeans/modules/mercurial/util/HgCommand.java | 10 +++++----- .../org/netbeans/modules/mercurial/util/HgUtils.java | 7 ++++--- .../modules/refactoring/spi/BackupFacility.java | 5 +++-- .../modules/refactoring/spi/BackupFacility2.java | 7 ++++--- .../modules/subversion/DiskMapTurboProvider.java | 3 ++- .../modules/subversion/client/cli/SvnCommand.java | 3 ++- .../subversion/ui/update/ResolveConflictsExecutor.java | 7 ++++--- .../subversion/client/commands/StatusTestHidden.java | 5 +++-- .../modules/bugtracking/commons/AttachmentsPanel.java | 5 ++++- .../modules/versioning/util/ExportDiffSupport.java | 3 ++- .../org/netbeans/modules/xml/schema/model/Util.java | 3 ++- .../src/org/netbeans/modules/xml/wsdl/model/Util.java | 3 ++- .../unit/src/org/netbeans/modules/xml/xam/Util.java | 3 ++- .../unit/src/org/netbeans/modules/xml/xdm/Util.java | 3 ++- .../modules/debugger/jpda/truffle/MIMETypes.java | 3 ++- .../j2seembedded/platform/RemotePlatformProbe.java | 5 +++-- .../java/j2seplatform/wizard/NewJ2SEPlatform.java | 3 ++- .../org/netbeans/modules/maven/NbArtifactFixer.java | 3 ++- .../modules/maven/newproject/CatalogRepoProvider.java | 3 ++- .../netbeans/modules/deadlock/detector/Detector.java | 3 ++- .../php/doctrine2/commands/Doctrine2Script.java | 3 ++- .../modules/php/project/connections/TmpLocalFile.java | 3 ++- .../modules/php/project/connections/ftp/FtpClient.java | 3 ++- .../php/project/ui/actions/support/FileRunner.java | 3 ++- .../modules/php/samples/PHPSamplesWizardIterator.java | 3 ++- .../netbeans/modules/php/symfony/SymfonyScript.java | 3 ++- .../modules/php/symfony2/commands/SymfonyScript.java | 3 ++- .../updateprovider/AutoupdateCatalogCache.java | 3 ++- .../netbeans/core/startup/layers/ArchiveURLMapper.java | 3 ++- .../modules/javahelp/HelpSetRegistrationProcessor.java | 5 +++-- .../masterfs/filebasedfs/FileBasedFileSystem.java | 3 ++- .../o.n.bootstrap/src/org/netbeans/JarClassLoader.java | 3 ++- platform/o.n.bootstrap/src/org/netbeans/Util.java | 3 ++- .../swing/tabcontrol/plaf/VectorIconTester.java | 3 ++- .../unit/src/org/openide/util/test/JarBuilder.java | 3 ++- .../unit/src/org/openide/util/test/JarBuilder.java | 3 ++- .../org/netbeans/modules/sampler/InternalSampler.java | 4 +++- .../src/org/netbeans/modules/uihandler/Installer.java | 7 ++++--- .../src/org/netbeans/lib/profiler/heap/JavaIoFile.java | 5 +++-- .../lib/profiler/server/EventBufferManager.java | 3 ++- .../modules/javascript/cdnjs/LibraryProvider.java | 3 ++- .../wizard/InstallJasmineWizardDescriptorPanel.java | 5 +++-- 69 files changed, 169 insertions(+), 97 deletions(-) diff --git a/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/actions/BuildInstallersAction.java b/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/actions/BuildInstallersAction.java index 0773a5ef7d7f..f9562769ebbf 100644 --- a/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/actions/BuildInstallersAction.java +++ b/apisupport/apisupport.installer.maven/src/org/netbeans/modules/apisupport/installer/maven/actions/BuildInstallersAction.java @@ -26,6 +26,7 @@ import java.io.OutputStream; import java.net.MalformedURLException; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -171,7 +172,7 @@ void actionPerformed(ActionEvent e) { URL url = new URL(licenseResource); is = url.openStream(); if (is != null) { - licenseFile = File.createTempFile("license", ".txt"); + licenseFile = Files.createTempFile("license", ".txt").toFile(); licenseFile.getParentFile().mkdirs(); licenseFile.deleteOnExit(); diff --git a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/actions/BuildInstallersAction.java b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/actions/BuildInstallersAction.java index c5265e64cf87..f707ceec5633 100644 --- a/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/actions/BuildInstallersAction.java +++ b/apisupport/apisupport.installer/src/org/netbeans/modules/apisupport/installer/actions/BuildInstallersAction.java @@ -26,6 +26,7 @@ import java.io.OutputStream; import java.net.MalformedURLException; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.Locale; @@ -175,7 +176,7 @@ public ContextBuildInstaller(Lookup actionContext) { URL url = new URL(licenseResource); is = url.openStream(); if (is != null) { - licenseFile = File.createTempFile("license", ".txt"); + licenseFile = Files.createTempFile("license", ".txt").toFile(); licenseFile.getParentFile().mkdirs(); licenseFile.deleteOnExit(); diff --git a/contrib/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java b/contrib/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java index a65dd2ab1828..881261695849 100644 --- a/contrib/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java +++ b/contrib/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/ide/JBStartRunnable.java @@ -26,6 +26,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.StringReader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.concurrent.TimeoutException; @@ -452,11 +453,11 @@ String getRunFileName(){ boolean needChangeConf = matcherConf != null && matcherConf.matches(); try { if (needChangeRun || needChangeConf) { - File startBat = File.createTempFile(RUN_FILE_NAME, ".bat"); // NOI18N + File startBat = Files.createTempFile(RUN_FILE_NAME, ".bat").toFile(); // NOI18N File confBat = null; if (contentConf != null) { - confBat = File.createTempFile(CONF_FILE_NAME, ".bat", // NOI18N - startBat.getParentFile()); // NOI18N + confBat = Files.createTempFile(// NOI18N + startBat.getParentFile().toPath(), CONF_FILE_NAME, ".bat").toFile(); // NOI18N } startBat.deleteOnExit(); contentRun = replaceJavaOpts(contentRun, matcherRun); diff --git a/contrib/websvc.wsitconf/test/unit/src/org/netbeans/modules/websvc/wsitconf/util/TestUtil.java b/contrib/websvc.wsitconf/test/unit/src/org/netbeans/modules/websvc/wsitconf/util/TestUtil.java index 327eba384238..e3b87814a6cd 100644 --- a/contrib/websvc.wsitconf/test/unit/src/org/netbeans/modules/websvc/wsitconf/util/TestUtil.java +++ b/contrib/websvc.wsitconf/test/unit/src/org/netbeans/modules/websvc/wsitconf/util/TestUtil.java @@ -29,6 +29,7 @@ import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; +import java.nio.file.Files; import javax.swing.text.Document; import org.netbeans.modules.xml.wsdl.model.WSDLModel; import org.openide.filesystems.FileObject; @@ -99,7 +100,7 @@ public static void dumpToFile(Document doc, File f) throws Exception { } public static File dumpToTempFile(Document doc) throws Exception { - File f = File.createTempFile("xsm", "xsd"); + File f = Files.createTempFile("xsm", "xsd").toFile(); dumpToFile(doc, f); return f; } diff --git a/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/CreateDomain.java b/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/CreateDomain.java index 515819477762..b4fe2daa3885 100644 --- a/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/CreateDomain.java +++ b/enterprise/glassfish.common/src/org/netbeans/modules/glassfish/common/CreateDomain.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; +import java.nio.file.Files; import java.util.Date; import java.util.HashMap; import java.util.Map; @@ -272,7 +273,7 @@ private static File createTempPasswordFile(String password, String masterPasswor PrintWriter p = null; File retVal = null; try { - retVal = File.createTempFile("admin", null);//NOI18N + retVal = Files.createTempFile("admin", null).toFile();//NOI18N retVal.deleteOnExit(); output = new FileOutputStream(retVal); diff --git a/enterprise/jakarta.web.beans/test/unit/src/org/netbeans/modules/jakarta/web/beans/xdm/model/Util.java b/enterprise/jakarta.web.beans/test/unit/src/org/netbeans/modules/jakarta/web/beans/xdm/model/Util.java index 230206175e58..2c482df520dc 100644 --- a/enterprise/jakarta.web.beans/test/unit/src/org/netbeans/modules/jakarta/web/beans/xdm/model/Util.java +++ b/enterprise/jakarta.web.beans/test/unit/src/org/netbeans/modules/jakarta/web/beans/xdm/model/Util.java @@ -31,6 +31,7 @@ import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; +import java.nio.file.Files; import javax.swing.text.Document; import org.netbeans.modules.jakarta.web.beans.xml.WebBeansModel; @@ -153,7 +154,7 @@ public static WebBeansModel dumpAndReloadModel(WebBeansModel sm) throws Exceptio } public static File dumpToTempFile(Document doc) throws Exception { - File f = File.createTempFile("faces-config-tmp", "xml"); + File f = Files.createTempFile("faces-config-tmp", "xml").toFile(); System.out.println("file: " + f.getAbsolutePath()); dumpToFile(doc, f); return f; diff --git a/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/WildflyStartRunnable.java b/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/WildflyStartRunnable.java index 58d9ea5d67b3..de4dc79037d1 100644 --- a/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/WildflyStartRunnable.java +++ b/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/WildflyStartRunnable.java @@ -27,6 +27,7 @@ import java.io.FileWriter; import java.io.IOException; import java.io.StringReader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.LinkedList; import java.util.List; @@ -452,11 +453,11 @@ String getRunFileName() { boolean needChangeConf = matcherConf != null && matcherConf.matches(); try { if (needChangeRun || needChangeConf) { - File startBat = File.createTempFile(RUN_FILE_NAME, ".bat"); // NOI18N + File startBat = Files.createTempFile(RUN_FILE_NAME, ".bat").toFile(); // NOI18N File confBat = null; if (contentConf != null) { - confBat = File.createTempFile(CONF_FILE_NAME, ".bat", // NOI18N - startBat.getParentFile()); // NOI18N + confBat = Files.createTempFile(// NOI18N + startBat.getParentFile().toPath(), CONF_FILE_NAME, ".bat").toFile(); // NOI18N } startBat.deleteOnExit(); contentRun = replaceJavaOpts(contentRun, matcherRun); diff --git a/enterprise/payara.common/src/org/netbeans/modules/payara/common/CreateDomain.java b/enterprise/payara.common/src/org/netbeans/modules/payara/common/CreateDomain.java index a2f2e4fb877b..cc6554ac0b4d 100644 --- a/enterprise/payara.common/src/org/netbeans/modules/payara/common/CreateDomain.java +++ b/enterprise/payara.common/src/org/netbeans/modules/payara/common/CreateDomain.java @@ -24,8 +24,11 @@ import java.io.IOException; import java.io.OutputStream; import java.io.PrintWriter; +import java.nio.file.Files; import java.util.ArrayList; + import static java.util.Arrays.asList; + import java.util.Date; import java.util.HashMap; import java.util.List; @@ -277,7 +280,7 @@ private static File createTempPasswordFile(String password, String masterPasswor PrintWriter p = null; File retVal = null; try { - retVal = File.createTempFile("admin", null);//NOI18N + retVal = Files.createTempFile("admin", null).toFile();//NOI18N retVal.deleteOnExit(); output = new FileOutputStream(retVal); diff --git a/enterprise/tomcat5/src/org/netbeans/modules/tomcat5/deploy/TomcatManagerImpl.java b/enterprise/tomcat5/src/org/netbeans/modules/tomcat5/deploy/TomcatManagerImpl.java index 3b5a6978b76c..172b82e2de79 100644 --- a/enterprise/tomcat5/src/org/netbeans/modules/tomcat5/deploy/TomcatManagerImpl.java +++ b/enterprise/tomcat5/src/org/netbeans/modules/tomcat5/deploy/TomcatManagerImpl.java @@ -47,6 +47,7 @@ import java.io.*; import java.net.Proxy; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.Base64; import java.util.MissingResourceException; import java.util.logging.Level; @@ -348,7 +349,7 @@ private static String encodePath(String str) { * @return properly escaped URL (application/x-www-form-urlencoded) in string form */ private String createTempContextXml(String docBase, Context ctx) throws IOException { - File tmpContextXml = File.createTempFile("context", ".xml"); // NOI18N + File tmpContextXml = Files.createTempFile("context", ".xml").toFile(); // NOI18N tmpContextXml.deleteOnExit(); if (!docBase.equals (ctx.getAttributeValue ("docBase"))) { //NOI18N ctx.setAttributeValue ("docBase", docBase); //NOI18N diff --git a/enterprise/web.beans/test/unit/src/org/netbeans/modules/web/beans/xdm/model/Util.java b/enterprise/web.beans/test/unit/src/org/netbeans/modules/web/beans/xdm/model/Util.java index b7946a406ae8..db9aff1e01af 100644 --- a/enterprise/web.beans/test/unit/src/org/netbeans/modules/web/beans/xdm/model/Util.java +++ b/enterprise/web.beans/test/unit/src/org/netbeans/modules/web/beans/xdm/model/Util.java @@ -31,6 +31,7 @@ import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; +import java.nio.file.Files; import javax.swing.text.Document; import org.netbeans.modules.web.beans.xml.WebBeansModel; @@ -153,7 +154,7 @@ public static WebBeansModel dumpAndReloadModel(WebBeansModel sm) throws Exceptio } public static File dumpToTempFile(Document doc) throws Exception { - File f = File.createTempFile("faces-config-tmp", "xml"); + File f = Files.createTempFile("faces-config-tmp", "xml").toFile(); System.out.println("file: " + f.getAbsolutePath()); dumpToFile(doc, f); return f; diff --git a/enterprise/web.jsf/test/unit/src/org/netbeans/modules/web/jsf/xdm/model/Util.java b/enterprise/web.jsf/test/unit/src/org/netbeans/modules/web/jsf/xdm/model/Util.java index 8366147ac84b..712c7dabb843 100644 --- a/enterprise/web.jsf/test/unit/src/org/netbeans/modules/web/jsf/xdm/model/Util.java +++ b/enterprise/web.jsf/test/unit/src/org/netbeans/modules/web/jsf/xdm/model/Util.java @@ -31,6 +31,7 @@ import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; +import java.nio.file.Files; import javax.swing.text.Document; import org.netbeans.modules.web.jsf.api.facesmodel.JSFConfigModel; import org.netbeans.modules.web.jsf.api.facesmodel.JSFConfigModelFactory; @@ -151,7 +152,7 @@ public static JSFConfigModel dumpAndReloadModel(JSFConfigModel sm) throws Except } public static File dumpToTempFile(Document doc) throws Exception { - File f = File.createTempFile("faces-config-tmp", "xml"); + File f = Files.createTempFile("faces-config-tmp", "xml").toFile(); System.out.println("file: " + f.getAbsolutePath()); dumpToFile(doc, f); return f; diff --git a/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/codegen/Wsdl2Java.java b/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/codegen/Wsdl2Java.java index edd8aeb14be6..28624fd8e389 100644 --- a/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/codegen/Wsdl2Java.java +++ b/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/codegen/Wsdl2Java.java @@ -43,6 +43,7 @@ import java.net.InetSocketAddress; import java.net.ProxySelector; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.modules.websvc.manager.util.ManagerUtil; @@ -299,7 +300,7 @@ private File getAntScript() { private void createJaxrpcConfigFile(String wsdlFileName, Properties properties){ try { - File cf = File.createTempFile("jaxrpcconfigfile", ".xml"); // NOI81N + File cf = Files.createTempFile("jaxrpcconfigfile", ".xml").toFile(); // NOI81N cf.deleteOnExit(); OutputStream out = new FileOutputStream(cf); String packageName = webServiceData.getEffectivePackageName(); diff --git a/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/ui/TestWebServiceMethodDlg.java b/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/ui/TestWebServiceMethodDlg.java index 95e540d10ab9..213bb0c01637 100644 --- a/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/ui/TestWebServiceMethodDlg.java +++ b/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/ui/TestWebServiceMethodDlg.java @@ -35,6 +35,7 @@ import java.io.File; import java.io.IOException; import java.net.*; +import java.nio.file.Files; import java.util.*; import javax.swing.JButton; import javax.swing.JPanel; @@ -171,7 +172,7 @@ private URLClassLoader getRuntimeClassLoader() { private File createTempCopy(File src) { try { - java.io.File tempFile = java.io.File.createTempFile("proxyjar", "jar"); + java.io.File tempFile = Files.createTempFile("proxyjar", "jar").toFile(); java.nio.channels.FileChannel inChannel = new java.io.FileInputStream(src).getChannel(); java.nio.channels.FileChannel outChannel = new java.io.FileOutputStream(tempFile).getChannel(); inChannel.transferTo(0, inChannel.size(), outChannel); diff --git a/harness/nbjunit/src/org/netbeans/junit/NbModuleSuite.java b/harness/nbjunit/src/org/netbeans/junit/NbModuleSuite.java index 415d333c7a7c..3aee9ed044d4 100644 --- a/harness/nbjunit/src/org/netbeans/junit/NbModuleSuite.java +++ b/harness/nbjunit/src/org/netbeans/junit/NbModuleSuite.java @@ -29,6 +29,7 @@ import java.net.URL; import java.net.URLClassLoader; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -1129,7 +1130,7 @@ private static File rewrite(File jar, String[] mavenCP, String classpath) throws if (dep == null) { throw new IOException("no match for " + artifact + " found in " + classpath); } - File depCopy = File.createTempFile(artifact.replace(':', '-') + '-', ".jar"); + File depCopy = Files.createTempFile(artifact.replace(':', '-') + '-', ".jar").toFile(); depCopy.deleteOnExit(); NbTestCase.copytree(dep, depCopy); if (classPathHeader.length() > 0) { @@ -1139,7 +1140,7 @@ private static File rewrite(File jar, String[] mavenCP, String classpath) throws } String n = jar.getName(); int dot = n.lastIndexOf('.'); - File jarCopy = File.createTempFile(n.substring(0, dot) + '-', n.substring(dot)); + File jarCopy = Files.createTempFile(n.substring(0, dot) + '-', n.substring(dot)).toFile(); jarCopy.deleteOnExit(); InputStream is = new FileInputStream(jar); try { diff --git a/harness/nbjunit/src/org/netbeans/junit/diff/NativeDiff.java b/harness/nbjunit/src/org/netbeans/junit/diff/NativeDiff.java index 9a92450dd5ce..3c3921721d79 100644 --- a/harness/nbjunit/src/org/netbeans/junit/diff/NativeDiff.java +++ b/harness/nbjunit/src/org/netbeans/junit/diff/NativeDiff.java @@ -19,6 +19,7 @@ package org.netbeans.junit.diff; import java.io.*; +import java.nio.file.Files; import java.util.StringTokenizer; /** Implementation of native OS diff. @@ -66,7 +67,7 @@ public boolean diff(final String first, final String second, String diff) throws File diffFile = null; if (null == diff) - diffFile = File.createTempFile("~diff", "tmp~"); + diffFile = Files.createTempFile("~diff", "tmp~").toFile(); else diffFile = new File(diff); diff --git a/ide/db.dataview/src/org/netbeans/modules/db/dataview/util/FileBackedBlob.java b/ide/db.dataview/src/org/netbeans/modules/db/dataview/util/FileBackedBlob.java index 77712a927a20..056daf4e3880 100644 --- a/ide/db.dataview/src/org/netbeans/modules/db/dataview/util/FileBackedBlob.java +++ b/ide/db.dataview/src/org/netbeans/modules/db/dataview/util/FileBackedBlob.java @@ -25,6 +25,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.RandomAccessFile; +import java.nio.file.Files; import java.sql.Blob; import java.sql.SQLException; import org.openide.util.Exceptions; @@ -45,7 +46,7 @@ public class FileBackedBlob implements Blob { public FileBackedBlob() throws SQLException { try { - backingFile = File.createTempFile("netbeans-db-blob", null); + backingFile = Files.createTempFile("netbeans-db-blob", null).toFile(); backingFile.deleteOnExit(); } catch (IOException ex) { throw new SQLException(ex); diff --git a/ide/db.dataview/src/org/netbeans/modules/db/dataview/util/FileBackedClob.java b/ide/db.dataview/src/org/netbeans/modules/db/dataview/util/FileBackedClob.java index 99afbe1dcb86..9a8da4b78e7e 100644 --- a/ide/db.dataview/src/org/netbeans/modules/db/dataview/util/FileBackedClob.java +++ b/ide/db.dataview/src/org/netbeans/modules/db/dataview/util/FileBackedClob.java @@ -33,6 +33,7 @@ import java.io.UnsupportedEncodingException; import java.io.Writer; import java.nio.CharBuffer; +import java.nio.file.Files; import java.sql.Clob; import java.sql.SQLException; import org.openide.util.Exceptions; @@ -55,7 +56,7 @@ public class FileBackedClob implements Clob { public FileBackedClob() throws SQLException { try { - backingFile = File.createTempFile("netbeans-db-blob", null); + backingFile = Files.createTempFile("netbeans-db-blob", null).toFile(); backingFile.deleteOnExit(); } catch (IOException ex) { throw new SQLException(ex); diff --git a/ide/diff/src/org/netbeans/api/diff/StreamSource.java b/ide/diff/src/org/netbeans/api/diff/StreamSource.java index 29932888e175..03952cecb92d 100644 --- a/ide/diff/src/org/netbeans/api/diff/StreamSource.java +++ b/ide/diff/src/org/netbeans/api/diff/StreamSource.java @@ -22,6 +22,7 @@ import java.io.*; import java.nio.charset.Charset; import java.nio.charset.UnsupportedCharsetException; +import java.nio.file.Files; import org.openide.util.io.ReaderInputStream; import org.openide.util.Lookup; @@ -164,7 +165,7 @@ private static class Impl extends StreamSource { private File createReaderSource(Reader r) throws IOException { File tmp = null; - tmp = FileUtil.normalizeFile(File.createTempFile("sss", "tmp")); + tmp = FileUtil.normalizeFile(Files.createTempFile("sss", "tmp").toFile()); tmp.deleteOnExit(); tmp.createNewFile(); InputStream in = null; diff --git a/ide/diff/src/org/netbeans/modules/diff/PatchAction.java b/ide/diff/src/org/netbeans/modules/diff/PatchAction.java index 14421d89ead9..762fc6b670d0 100644 --- a/ide/diff/src/org/netbeans/modules/diff/PatchAction.java +++ b/ide/diff/src/org/netbeans/modules/diff/PatchAction.java @@ -23,6 +23,7 @@ import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.io.*; +import java.nio.file.Files; import java.util.*; import java.text.DateFormat; import javax.swing.JFileChooser; @@ -288,7 +289,7 @@ private static void showDiffs(List files, List binaries, if (binaries.contains(file)) continue; if (backup == null) { try { - backup = FileUtil.toFileObject(FileUtil.normalizeFile(File.createTempFile("diff-empty-backup", ""))); + backup = FileUtil.toFileObject(FileUtil.normalizeFile(Files.createTempFile("diff-empty-backup", "").toFile())); } catch (IOException e) { // ignore } diff --git a/ide/diff/src/org/netbeans/modules/diff/cmdline/CmdlineDiffProvider.java b/ide/diff/src/org/netbeans/modules/diff/cmdline/CmdlineDiffProvider.java index 16b928e95bac..966df0ec3a94 100644 --- a/ide/diff/src/org/netbeans/modules/diff/cmdline/CmdlineDiffProvider.java +++ b/ide/diff/src/org/netbeans/modules/diff/cmdline/CmdlineDiffProvider.java @@ -20,6 +20,7 @@ package org.netbeans.modules.diff.cmdline; import java.io.*; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import java.util.regex.Pattern; @@ -132,8 +133,8 @@ public Difference[] computeDiff(Reader r1, Reader r2) throws IOException { File f1 = null; File f2 = null; try { - f1 = FileUtil.normalizeFile(File.createTempFile("TempDiff".intern(), null)); - f2 = FileUtil.normalizeFile(File.createTempFile("TempDiff".intern(), null)); + f1 = FileUtil.normalizeFile(Files.createTempFile("TempDiff".intern(), null).toFile()); + f2 = FileUtil.normalizeFile(Files.createTempFile("TempDiff".intern(), null).toFile()); FileWriter fw1 = new FileWriter(f1); FileWriter fw2 = new FileWriter(f2); char[] buffer = new char[BUFF_LENGTH]; diff --git a/ide/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/TerminalLocalNativeProcess.java b/ide/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/TerminalLocalNativeProcess.java index f906709e1194..fc47fdf71e5f 100644 --- a/ide/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/TerminalLocalNativeProcess.java +++ b/ide/dlight.nativeexecution/src/org/netbeans/modules/nativeexecution/TerminalLocalNativeProcess.java @@ -30,6 +30,7 @@ import java.io.InterruptedIOException; import java.io.OutputStreamWriter; import java.nio.charset.Charset; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -106,7 +107,7 @@ protected void create() throws Throwable { final File workingDirectory = (wDir == null) ? new File(".") : new File(wDir); // NOI18N - pidFileFile = File.createTempFile("dlight", "termexec", hostInfo.getTempDirFile()).getAbsoluteFile(); // NOI18N + pidFileFile = Files.createTempFile(hostInfo.getTempDirFile().toPath(), "dlight", "termexec").toFile().getAbsoluteFile(); // NOI18N shFileFile = new File(pidFileFile.getPath() + ".sh"); // NOI18N resultFile = new File(shFileFile.getPath() + ".res"); // NOI18N diff --git a/ide/editor.settings.lib/test/unit/src/org/netbeans/modules/editor/settings/storage/EditorTestLookup.java b/ide/editor.settings.lib/test/unit/src/org/netbeans/modules/editor/settings/storage/EditorTestLookup.java index e52298ff0283..775a8adc0d74 100644 --- a/ide/editor.settings.lib/test/unit/src/org/netbeans/modules/editor/settings/storage/EditorTestLookup.java +++ b/ide/editor.settings.lib/test/unit/src/org/netbeans/modules/editor/settings/storage/EditorTestLookup.java @@ -27,6 +27,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -294,7 +295,7 @@ private static final class ZipFileSystem extends AbstractFileSystem { public ZipFileSystem(URL zipURL) throws IOException { this.zipPath = zipURL.toString(); - File zipFile = File.createTempFile("ZipFileSystem", ".zip"); + File zipFile = Files.createTempFile("ZipFileSystem", ".zip").toFile(); zipFile.deleteOnExit(); OutputStream os = new FileOutputStream(zipFile); diff --git a/ide/editor.settings.storage/test/unit/src/org/netbeans/modules/editor/settings/storage/EditorTestLookup.java b/ide/editor.settings.storage/test/unit/src/org/netbeans/modules/editor/settings/storage/EditorTestLookup.java index e52298ff0283..775a8adc0d74 100644 --- a/ide/editor.settings.storage/test/unit/src/org/netbeans/modules/editor/settings/storage/EditorTestLookup.java +++ b/ide/editor.settings.storage/test/unit/src/org/netbeans/modules/editor/settings/storage/EditorTestLookup.java @@ -27,6 +27,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.MissingResourceException; import java.util.ResourceBundle; @@ -294,7 +295,7 @@ private static final class ZipFileSystem extends AbstractFileSystem { public ZipFileSystem(URL zipURL) throws IOException { this.zipPath = zipURL.toString(); - File zipFile = File.createTempFile("ZipFileSystem", ".zip"); + File zipFile = Files.createTempFile("ZipFileSystem", ".zip").toFile(); zipFile.deleteOnExit(); OutputStream os = new FileOutputStream(zipFile); diff --git a/ide/git/src/org/netbeans/modules/git/utils/GitUtils.java b/ide/git/src/org/netbeans/modules/git/utils/GitUtils.java index d4adf7409289..d1607c6dc474 100644 --- a/ide/git/src/org/netbeans/modules/git/utils/GitUtils.java +++ b/ide/git/src/org/netbeans/modules/git/utils/GitUtils.java @@ -27,6 +27,7 @@ import java.io.File; import java.io.IOException; import java.net.URISyntaxException; +import java.nio.file.Files; import java.text.DateFormat; import java.text.MessageFormat; import java.util.ArrayList; @@ -742,7 +743,7 @@ public static void openInRevision (File originalFile, String revision1, int line String revisionToOpen, boolean showAnnotations, ProgressMonitor pm) throws IOException { File file1 = VersionsCache.getInstance().getFileRevision(originalFile, revision1, pm); if (file1 == null) { // can be null if the file does not exist or is empty in the given revision - file1 = File.createTempFile("tmp", "-" + originalFile.getName(), Utils.getTempFolder()); //NOI18N + file1 = Files.createTempFile(Utils.getTempFolder().toPath(), "tmp", "-" + originalFile.getName()).toFile(); //NOI18N file1.deleteOnExit(); } if (pm.isCanceled()) { @@ -750,7 +751,7 @@ public static void openInRevision (File originalFile, String revision1, int line } File file = VersionsCache.getInstance().getFileRevision(originalFile, revisionToOpen, pm); if (file == null) { // can be null if the file does not exist or is empty in the given revision - file = File.createTempFile("tmp", "-" + originalFile.getName(), Utils.getTempFolder()); //NOI18N + file = Files.createTempFile(Utils.getTempFolder().toPath(), "tmp", "-" + originalFile.getName()).toFile(); //NOI18N file.deleteOnExit(); } if (pm.isCanceled()) { @@ -767,7 +768,7 @@ public static void openInRevision (File originalFile, int lineNumber, String rev return; } if (file == null) { // can be null if the file does not exist or is empty in the given revision - file = File.createTempFile("tmp", "-" + originalFile.getName(), Utils.getTempFolder()); //NOI18N + file = Files.createTempFile(Utils.getTempFolder().toPath(), "tmp", "-" + originalFile.getName()).toFile(); //NOI18N file.deleteOnExit(); } openInRevision(file, originalFile, lineNumber, revision, showAnnotations, pm); diff --git a/ide/libs.git/src/org/netbeans/libs/git/jgit/commands/IgnoreUnignoreCommand.java b/ide/libs.git/src/org/netbeans/libs/git/jgit/commands/IgnoreUnignoreCommand.java index 778797bb2999..fc44c75729ee 100644 --- a/ide/libs.git/src/org/netbeans/libs/git/jgit/commands/IgnoreUnignoreCommand.java +++ b/ide/libs.git/src/org/netbeans/libs/git/jgit/commands/IgnoreUnignoreCommand.java @@ -131,7 +131,7 @@ private boolean addStatement (File gitIgnore, String path, boolean isDirectory, protected final void save (File gitIgnore, List ignoreRules) throws IOException { BufferedWriter bw = null; - File tmpFile = File.createTempFile(Constants.DOT_GIT_IGNORE, "tmp", gitIgnore.getParentFile()); //NOI18N + File tmpFile = Files.createTempFile(gitIgnore.getParentFile().toPath(), Constants.DOT_GIT_IGNORE, "tmp").toFile(); //NOI18N try { bw = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(tmpFile), Constants.CHARSET)); for (ListIterator it = ignoreRules.listIterator(); it.hasNext(); ) { diff --git a/ide/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportBundle.java b/ide/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportBundle.java index 19fae8302543..ee7afb9be938 100644 --- a/ide/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportBundle.java +++ b/ide/mercurial/src/org/netbeans/modules/mercurial/ui/diff/ExportBundle.java @@ -29,6 +29,7 @@ import org.openide.DialogDescriptor; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.util.HashMap; import java.util.List; import javax.swing.DefaultComboBoxModel; @@ -132,7 +133,7 @@ protected void createComplexDialog(AbstractExportDiffPanel insidePanel) { @Override protected File createTempFile () throws IOException { - return File.createTempFile("hg-bundle", ".hg"); // NOI18N + return Files.createTempFile("hg-bundle", ".hg").toFile(); // NOI18N } @Override diff --git a/ide/mercurial/src/org/netbeans/modules/mercurial/ui/update/ResolveConflictsExecutor.java b/ide/mercurial/src/org/netbeans/modules/mercurial/ui/update/ResolveConflictsExecutor.java index 2c71ea9afe2a..5ff7fce7ec58 100644 --- a/ide/mercurial/src/org/netbeans/modules/mercurial/ui/update/ResolveConflictsExecutor.java +++ b/ide/mercurial/src/org/netbeans/modules/mercurial/ui/update/ResolveConflictsExecutor.java @@ -24,6 +24,7 @@ import java.io.*; import java.util.*; import java.nio.charset.Charset; +import java.nio.file.Files; import java.util.logging.Level; import javax.swing.*; import org.netbeans.modules.mercurial.HgException; @@ -114,9 +115,9 @@ private boolean handleMergeFor(final File file, FileObject fo, FileLock lock, final MergeVisualizer merge) throws IOException { String mimeType = (fo == null) ? "text/plain" : fo.getMIMEType(); // NOI18N String ext = (fo == null) ? "" : "." + fo.getExt(); //NOI18N - File f1 = FileUtil.normalizeFile(File.createTempFile(TMP_PREFIX, ext)); - File f2 = FileUtil.normalizeFile(File.createTempFile(TMP_PREFIX, ext)); - File f3 = FileUtil.normalizeFile(File.createTempFile(TMP_PREFIX, ext)); + File f1 = FileUtil.normalizeFile(Files.createTempFile(TMP_PREFIX, ext).toFile()); + File f2 = FileUtil.normalizeFile(Files.createTempFile(TMP_PREFIX, ext).toFile()); + File f3 = FileUtil.normalizeFile(Files.createTempFile(TMP_PREFIX, ext).toFile()); f1.deleteOnExit(); f2.deleteOnExit(); f3.deleteOnExit(); diff --git a/ide/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java b/ide/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java index 89d5c83e0eea..3c51c88abb94 100644 --- a/ide/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java +++ b/ide/mercurial/src/org/netbeans/modules/mercurial/util/HgCommand.java @@ -37,6 +37,7 @@ import java.net.URI; import java.net.URISyntaxException; import java.nio.charset.Charset; +import java.nio.file.Files; import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; @@ -2372,7 +2373,7 @@ public static void doCommit(File repository, List commitFiles, String comm commitMessage = HG_COMMIT_DEFAULT_MESSAGE; } // Create temporary file. - tempfile = File.createTempFile(HG_COMMIT_TEMPNAME, HG_COMMIT_TEMPNAME_SUFFIX); + tempfile = Files.createTempFile(HG_COMMIT_TEMPNAME, HG_COMMIT_TEMPNAME_SUFFIX).toFile(); // Write to temp file BufferedWriter out = new BufferedWriter(ENCODING == null @@ -3614,7 +3615,7 @@ private static void qCreateRefreshPatch (File repository, Collection inclu commitMessage = HG_COMMIT_DEFAULT_MESSAGE; } // Create temporary file. - tempfile = File.createTempFile(HG_COMMIT_TEMPNAME, HG_COMMIT_TEMPNAME_SUFFIX); + tempfile = Files.createTempFile(HG_COMMIT_TEMPNAME, HG_COMMIT_TEMPNAME_SUFFIX).toFile(); // Write to temp file BufferedWriter out = new BufferedWriter(ENCODING == null @@ -3944,9 +3945,8 @@ private static File createOutputStyleFile(List cmdLine) throws String template = str.substring("--template=".length()); //NOI18N - File tempFile = File.createTempFile( - "hg-output-style", //NOI18N - null); //extension (default) + File tempFile = Files.createTempFile("hg-output-style", //NOI18N + null).toFile(); //extension (default) Writer writer = ENCODING == null ? new OutputStreamWriter(new FileOutputStream(tempFile)) : new OutputStreamWriter(new FileOutputStream(tempFile), ENCODING); diff --git a/ide/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java b/ide/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java index e7199d23e1cb..70710340fb36 100644 --- a/ide/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java +++ b/ide/mercurial/src/org/netbeans/modules/mercurial/util/HgUtils.java @@ -31,6 +31,7 @@ import java.io.IOException; import java.io.OutputStreamWriter; import java.io.PrintWriter; +import java.nio.file.Files; import java.text.MessageFormat; import java.util.List; import java.util.ArrayList; @@ -1341,14 +1342,14 @@ public static void openInRevision (File fileRevision1, HgRevision revision1, int File fileToOpen, HgRevision revisionToOpen, boolean showAnnotations) throws IOException { File file = org.netbeans.modules.mercurial.VersionsCache.getInstance().getFileRevision(fileRevision1, revision1); if (file == null) { // can be null if the file does not exist or is empty in the given revision - file = File.createTempFile("tmp", "-" + fileRevision1.getName()); //NOI18N + file = Files.createTempFile("tmp", "-" + fileRevision1.getName()).toFile(); //NOI18N file.deleteOnExit(); } fileRevision1 = file; file = org.netbeans.modules.mercurial.VersionsCache.getInstance().getFileRevision(fileToOpen, revisionToOpen); if (file == null) { // can be null if the file does not exist or is empty in the given revision - file = File.createTempFile("tmp", "-" + fileToOpen.getName()); //NOI18N + file = Files.createTempFile("tmp", "-" + fileToOpen.getName()).toFile(); //NOI18N file.deleteOnExit(); } int matchingLine = DiffUtils.getMatchingLine(fileRevision1, file, lineNumber); @@ -1360,7 +1361,7 @@ public static void openInRevision (File originalFile, int lineNumber, HgRevision File file = org.netbeans.modules.mercurial.VersionsCache.getInstance().getFileRevision(originalFile, revision); if (file == null) { // can be null if the file does not exist or is empty in the given revision - file = File.createTempFile("tmp", "-" + originalFile.getName()); //NOI18N + file = Files.createTempFile("tmp", "-" + originalFile.getName()).toFile(); //NOI18N file.deleteOnExit(); } openFile(file, originalFile, lineNumber, revision, showAnnotations); diff --git a/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/BackupFacility.java b/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/BackupFacility.java index 951867056c57..59ff77020326 100644 --- a/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/BackupFacility.java +++ b/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/BackupFacility.java @@ -27,6 +27,7 @@ import java.io.OutputStream; import java.net.URI; import java.net.URISyntaxException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; @@ -184,7 +185,7 @@ public Handle backup(FileObject ... file) throws IOException { public long backup(FileObject file) throws IOException { try { BackupEntry entry = new BackupEntry(); - entry.file = File.createTempFile("nbbackup", null); //NOI18N + entry.file = Files.createTempFile("nbbackup", null).toFile(); //NOI18N copy(file, entry.file); entry.path = file.getURL().toURI(); map.put(currentId, entry); @@ -204,7 +205,7 @@ void restore(long id) throws IOException { if(entry==null) { throw new IllegalArgumentException("Backup with id " + id + "does not exist"); // NOI18N } - File backup = File.createTempFile("nbbackup", null); //NOI18N + File backup = Files.createTempFile("nbbackup", null).toFile(); //NOI18N backup.deleteOnExit(); File f = new File(entry.path); if (createNewFile(f)) { diff --git a/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/BackupFacility2.java b/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/BackupFacility2.java index 77381f074765..b57d9e5b8875 100644 --- a/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/BackupFacility2.java +++ b/ide/refactoring.api/src/org/netbeans/modules/refactoring/spi/BackupFacility2.java @@ -19,6 +19,7 @@ package org.netbeans.modules.refactoring.spi; import java.io.*; +import java.nio.file.Files; import java.security.DigestInputStream; import java.security.MessageDigest; import java.security.NoSuchAlgorithmException; @@ -335,7 +336,7 @@ public Handle backup(File... files) throws IOException { */ public long backup(FileObject file) throws IOException { BackupEntry entry = new BackupEntry(); - entry.file = File.createTempFile("nbbackup", null); //NOI18N + entry.file = Files.createTempFile("nbbackup", null).toFile(); //NOI18N copy(file, entry.file); entry.orig = file; map.put(currentId, entry); @@ -352,7 +353,7 @@ public long backup(FileObject file) throws IOException { */ public long backup(File file) throws IOException { BackupEntry entry = new BackupEntry(); - entry.file = File.createTempFile("nbbackup", null); //NOI18N + entry.file = Files.createTempFile("nbbackup", null).toFile(); //NOI18N entry.exists = file.exists(); if(entry.exists) { FileObject fo = FileUtil.toFileObject(file); @@ -453,7 +454,7 @@ void restore(long id) throws IOException { if (entry == null) { throw new IllegalArgumentException("Backup with id " + id + "does not exist"); // NOI18N } - File backup = File.createTempFile("nbbackup", null); //NOI18N + File backup = Files.createTempFile("nbbackup", null).toFile(); //NOI18N backup.deleteOnExit(); boolean exists = false; FileObject fo = entry.orig; diff --git a/ide/subversion/src/org/netbeans/modules/subversion/DiskMapTurboProvider.java b/ide/subversion/src/org/netbeans/modules/subversion/DiskMapTurboProvider.java index bca18f21cfc1..d9a80c944bad 100644 --- a/ide/subversion/src/org/netbeans/modules/subversion/DiskMapTurboProvider.java +++ b/ide/subversion/src/org/netbeans/modules/subversion/DiskMapTurboProvider.java @@ -24,6 +24,7 @@ import org.netbeans.modules.subversion.util.*; import org.netbeans.modules.turbo.TurboProvider; import java.io.*; +import java.nio.file.Files; import java.util.*; import java.util.logging.Level; import java.util.logging.Logger; @@ -425,7 +426,7 @@ private void adjustIndex(File dir, Object value) { */ private void logCorruptedCacheFile(File file, int itemIndex, EOFException e) { try { - File tmpFile = File.createTempFile("svn_", ".bin"); + File tmpFile = Files.createTempFile("svn_", ".bin").toFile(); Subversion.LOG.log(Level.INFO, "Corrupted cache file " + file.getAbsolutePath() + " at position " + itemIndex, e); FileUtils.copyFile(file, tmpFile); byte[] contents = FileUtils.getFileContentsAsByteArray(tmpFile); diff --git a/ide/subversion/src/org/netbeans/modules/subversion/client/cli/SvnCommand.java b/ide/subversion/src/org/netbeans/modules/subversion/client/cli/SvnCommand.java index 6448d9ea518f..4dcb6622543f 100644 --- a/ide/subversion/src/org/netbeans/modules/subversion/client/cli/SvnCommand.java +++ b/ide/subversion/src/org/netbeans/modules/subversion/client/cli/SvnCommand.java @@ -24,6 +24,7 @@ import java.io.OutputStreamWriter; import java.io.PrintWriter; import java.net.MalformedURLException; +import java.nio.file.Files; import java.util.*; import java.util.ArrayList; import java.util.logging.Level; @@ -265,7 +266,7 @@ protected String createTempCommandFile(File[] files) throws IOException { } protected String createTempCommandFile(String[] lines) throws IOException { - File targetFile = File.createTempFile("svn_", "", getTempCommandFolder(true)); + File targetFile = Files.createTempFile(getTempCommandFolder(true).toPath(), "svn_", "").toFile(); targetFile.deleteOnExit(); PrintWriter writer = null; diff --git a/ide/subversion/src/org/netbeans/modules/subversion/ui/update/ResolveConflictsExecutor.java b/ide/subversion/src/org/netbeans/modules/subversion/ui/update/ResolveConflictsExecutor.java index ac412c6d6edd..0fcf9d69ce9a 100644 --- a/ide/subversion/src/org/netbeans/modules/subversion/ui/update/ResolveConflictsExecutor.java +++ b/ide/subversion/src/org/netbeans/modules/subversion/ui/update/ResolveConflictsExecutor.java @@ -22,6 +22,7 @@ import java.awt.*; import java.io.*; import java.nio.charset.Charset; +import java.nio.file.Files; import java.util.*; import java.util.logging.Level; import javax.swing.*; @@ -120,9 +121,9 @@ private boolean handleMergeFor(final File file, FileObject fo, FileLock lock, final MergeVisualizer merge) throws IOException { String mimeType = (fo == null) ? "text/plain" : fo.getMIMEType(); // NOI18N String ext = "."+fo.getExt(); // NOI18N - File f1 = FileUtil.normalizeFile(File.createTempFile(TMP_PREFIX, ext)); - File f2 = FileUtil.normalizeFile(File.createTempFile(TMP_PREFIX, ext)); - File f3 = FileUtil.normalizeFile(File.createTempFile(TMP_PREFIX, ext)); + File f1 = FileUtil.normalizeFile(Files.createTempFile(TMP_PREFIX, ext).toFile()); + File f2 = FileUtil.normalizeFile(Files.createTempFile(TMP_PREFIX, ext).toFile()); + File f3 = FileUtil.normalizeFile(Files.createTempFile(TMP_PREFIX, ext).toFile()); f1.deleteOnExit(); f2.deleteOnExit(); f3.deleteOnExit(); diff --git a/ide/subversion/test/unit/src/org/netbeans/modules/subversion/client/commands/StatusTestHidden.java b/ide/subversion/test/unit/src/org/netbeans/modules/subversion/client/commands/StatusTestHidden.java index e5a7d3ea6264..6b901385c309 100644 --- a/ide/subversion/test/unit/src/org/netbeans/modules/subversion/client/commands/StatusTestHidden.java +++ b/ide/subversion/test/unit/src/org/netbeans/modules/subversion/client/commands/StatusTestHidden.java @@ -21,6 +21,7 @@ import org.netbeans.modules.subversion.client.AbstractCommandTestCase; import java.io.File; +import java.nio.file.Files; import java.text.DateFormat; import java.util.Arrays; import java.util.HashSet; @@ -95,7 +96,7 @@ public void testStatusFileArray() throws Exception { File notmanagedfolder = createFolder("notmanagedfolder"); File notmanagedfile = createFile(notmanagedfolder, "notmanagedfile"); - File unversioned = File.createTempFile("unversioned", null); // XXX extra test in unversioned WC + File unversioned = Files.createTempFile("unversioned", null).toFile(); // XXX extra test in unversioned WC File added = createFile("added"); add(added); remove(deleted); @@ -185,7 +186,7 @@ public void testStatusFile() throws Exception { File notmanagedfolder = createFolder("notmanagedfolder"); File notmanagedfile = createFile(notmanagedfolder, "notmanagedfile"); - File unversioned = File.createTempFile("unversioned", null); // XXX extra test in unversioned WC + File unversioned = Files.createTempFile("unversioned", null).toFile(); // XXX extra test in unversioned WC File added = createFile("added"); add(added); remove(deleted); diff --git a/ide/team.commons/src/org/netbeans/modules/bugtracking/commons/AttachmentsPanel.java b/ide/team.commons/src/org/netbeans/modules/bugtracking/commons/AttachmentsPanel.java index dabba59863a9..500c235f7952 100644 --- a/ide/team.commons/src/org/netbeans/modules/bugtracking/commons/AttachmentsPanel.java +++ b/ide/team.commons/src/org/netbeans/modules/bugtracking/commons/AttachmentsPanel.java @@ -33,6 +33,7 @@ import java.io.IOException; import java.io.OutputStream; import java.lang.reflect.Method; +import java.nio.file.Files; import java.text.DateFormat; import java.text.MessageFormat; import java.util.ArrayList; @@ -46,7 +47,9 @@ import java.util.logging.Logger; import javax.swing.AbstractAction; import javax.swing.Action; + import static javax.swing.Action.NAME; + import javax.swing.GroupLayout; import javax.swing.GroupLayout.ParallelGroup; import javax.swing.GroupLayout.SequentialGroup; @@ -910,7 +913,7 @@ private File saveToTempFile () throws IOException { if (prefix.length()<3) { prefix = prefix + "tmp"; //NOI18N } - File file = File.createTempFile(prefix, suffix); + File file = Files.createTempFile(prefix, suffix).toFile(); getAttachmentData(file); return file; } diff --git a/ide/versioning.util/src/org/netbeans/modules/versioning/util/ExportDiffSupport.java b/ide/versioning.util/src/org/netbeans/modules/versioning/util/ExportDiffSupport.java index 322229afa65b..ff21fcd4f66f 100644 --- a/ide/versioning.util/src/org/netbeans/modules/versioning/util/ExportDiffSupport.java +++ b/ide/versioning.util/src/org/netbeans/modules/versioning/util/ExportDiffSupport.java @@ -27,6 +27,7 @@ import java.beans.PropertyChangeSupport; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.util.prefs.Preferences; import javax.swing.JComponent; import javax.swing.JFileChooser; @@ -203,7 +204,7 @@ public void run() { } protected File createTempFile () throws IOException { - return File.createTempFile("vcs-diff", ".patch"); // NOI18N + return Files.createTempFile("vcs-diff", ".patch").toFile(); // NOI18N } protected String getMessage (String resourceName) { diff --git a/ide/xml.schema.model/test/unit/src/org/netbeans/modules/xml/schema/model/Util.java b/ide/xml.schema.model/test/unit/src/org/netbeans/modules/xml/schema/model/Util.java index fb319e80d399..e551b6ca379b 100644 --- a/ide/xml.schema.model/test/unit/src/org/netbeans/modules/xml/schema/model/Util.java +++ b/ide/xml.schema.model/test/unit/src/org/netbeans/modules/xml/schema/model/Util.java @@ -43,6 +43,7 @@ import java.lang.management.ManagementFactory; import java.net.URI; import java.net.URL; +import java.nio.file.Files; import java.util.Collection; import javax.swing.text.Document; import org.netbeans.editor.BaseDocument; @@ -169,7 +170,7 @@ public static void dumpToFile(Document doc, File f) throws Exception { } public static File dumpToTempFile(Document doc) throws Exception { - File f = File.createTempFile("xsm", "xsd"); + File f = Files.createTempFile("xsm", "xsd").toFile(); dumpToFile(doc, f); return f; } diff --git a/ide/xml.wsdl.model/test/unit/src/org/netbeans/modules/xml/wsdl/model/Util.java b/ide/xml.wsdl.model/test/unit/src/org/netbeans/modules/xml/wsdl/model/Util.java index 50624bd0d972..3aed84545016 100644 --- a/ide/xml.wsdl.model/test/unit/src/org/netbeans/modules/xml/wsdl/model/Util.java +++ b/ide/xml.wsdl.model/test/unit/src/org/netbeans/modules/xml/wsdl/model/Util.java @@ -32,6 +32,7 @@ import java.io.PrintWriter; import java.net.URI; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.Collection; import javax.swing.text.Document; import org.netbeans.modules.xml.schema.model.GlobalSimpleType; @@ -153,7 +154,7 @@ public static void dumpToFile(Document doc, File f) throws Exception { } public static File dumpToTempFile(Document doc) throws Exception { - File f = File.createTempFile("xsm", "xsd"); + File f = Files.createTempFile("xsm", "xsd").toFile(); dumpToFile(doc, f); return f; } diff --git a/ide/xml.xam/test/unit/src/org/netbeans/modules/xml/xam/Util.java b/ide/xml.xam/test/unit/src/org/netbeans/modules/xml/xam/Util.java index 88c7aefb8045..91b61ce80c69 100644 --- a/ide/xml.xam/test/unit/src/org/netbeans/modules/xml/xam/Util.java +++ b/ide/xml.xam/test/unit/src/org/netbeans/modules/xml/xam/Util.java @@ -39,6 +39,7 @@ import java.io.OutputStream; import java.io.PrintWriter; import java.net.URI; +import java.nio.file.Files; import javax.swing.text.Document; import org.netbeans.modules.xml.xam.dom.DocumentModel; import org.netbeans.modules.xml.xam.dom.ReadOnlyAccess; @@ -83,7 +84,7 @@ public static void dumpToFile(Document doc, File f) throws Exception { } public static File dumpToTempFile(Document doc) throws Exception { - File f = File.createTempFile("xsm", "xsd"); + File f = Files.createTempFile("xsm", "xsd").toFile(); dumpToFile(doc, f); return f; } diff --git a/ide/xml.xdm/test/unit/src/org/netbeans/modules/xml/xdm/Util.java b/ide/xml.xdm/test/unit/src/org/netbeans/modules/xml/xdm/Util.java index b60596d53e0a..abfbc9e4ffc0 100644 --- a/ide/xml.xdm/test/unit/src/org/netbeans/modules/xml/xdm/Util.java +++ b/ide/xml.xdm/test/unit/src/org/netbeans/modules/xml/xdm/Util.java @@ -30,6 +30,7 @@ import java.io.OutputStream; import java.io.PrintWriter; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.util.ArrayList; import java.util.List; import javax.swing.text.Document; @@ -130,7 +131,7 @@ public static void dumpToFile(Document doc, File f) throws Exception { } public static File dumpToTempFile(Document doc) throws Exception { - File f = File.createTempFile("xdm-tester-", null); + File f = Files.createTempFile("xdm-tester-", null).toFile(); dumpToFile(doc, f); return f; } diff --git a/java/debugger.jpda.truffle/src/org/netbeans/modules/debugger/jpda/truffle/MIMETypes.java b/java/debugger.jpda.truffle/src/org/netbeans/modules/debugger/jpda/truffle/MIMETypes.java index 611fbc48d641..bb4900106a9a 100644 --- a/java/debugger.jpda.truffle/src/org/netbeans/modules/debugger/jpda/truffle/MIMETypes.java +++ b/java/debugger.jpda.truffle/src/org/netbeans/modules/debugger/jpda/truffle/MIMETypes.java @@ -27,6 +27,7 @@ import java.io.FileOutputStream; import java.io.IOException; import java.io.InputStreamReader; +import java.nio.file.Files; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -124,7 +125,7 @@ private synchronized Set get(JavaPlatform jp) { private static synchronized String getTruffleJarPath() throws IOException { if (TEMP_TRUFFLE_JAR == null) { - File truffleJarFile = File.createTempFile("TmpTruffleBcknd", ".jar"); // NOI18N + File truffleJarFile = Files.createTempFile("TmpTruffleBcknd", ".jar").toFile(); // NOI18N truffleJarFile.deleteOnExit(); FileUtil.copy(RemoteServices.openRemoteClasses(), new FileOutputStream(truffleJarFile)); TEMP_TRUFFLE_JAR = truffleJarFile.getAbsolutePath(); diff --git a/java/java.j2seembedded/src/org/netbeans/modules/java/j2seembedded/platform/RemotePlatformProbe.java b/java/java.j2seembedded/src/org/netbeans/modules/java/j2seembedded/platform/RemotePlatformProbe.java index 7fa29fb672ed..b8fcf67e045b 100644 --- a/java/java.j2seembedded/src/org/netbeans/modules/java/j2seembedded/platform/RemotePlatformProbe.java +++ b/java/java.j2seembedded/src/org/netbeans/modules/java/j2seembedded/platform/RemotePlatformProbe.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; import java.util.Collections; import java.util.HashMap; import java.util.Map; @@ -60,7 +61,7 @@ public static File createBuildScript() { final String resourcesPath = "org/netbeans/modules/java/j2seembedded/resources/validateconnection.xml"; //NOI18N File buildScript = null; try { - buildScript = FileUtil.normalizeFile(File.createTempFile("antScript", ".xml")); //NOI18N + buildScript = FileUtil.normalizeFile(Files.createTempFile("antScript", ".xml").toFile()); //NOI18N } catch (IOException ioe) { Exceptions.printStackTrace(ioe); } @@ -102,7 +103,7 @@ public static Properties verifyPlatform( ExecutorTask executorTask = null; int antResult = -1; try { - platformProperties = File.createTempFile("platform", ".properties"); //NOI18N + platformProperties = Files.createTempFile("platform", ".properties").toFile(); //NOI18N prop.setProperty("platform.properties.file", platformProperties.getAbsolutePath()); //NOI18N final Set concealedProps; if (connectionMethod.getAuthentification().getKind() == ConnectionMethod.Authentification.Kind.PASSWORD) { diff --git a/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/wizard/NewJ2SEPlatform.java b/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/wizard/NewJ2SEPlatform.java index 2506d9841258..1ccbd4c7a107 100644 --- a/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/wizard/NewJ2SEPlatform.java +++ b/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/wizard/NewJ2SEPlatform.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.InputStream; import java.net.URL; +import java.nio.file.Files; import java.util.Collection; import java.util.Collections; import java.util.Enumeration; @@ -102,7 +103,7 @@ public void run() { return; } String javacpath = javacFile.getAbsolutePath(); - String filePath = File.createTempFile("nb-platformdetect", "properties").getAbsolutePath(); //NOI18N + String filePath = Files.createTempFile("nb-platformdetect", "properties").toFile().getAbsolutePath(); //NOI18N final String probePath = getSDKProperties(javapath, javacpath, filePath); File f = new File(filePath); Properties p = new Properties(); diff --git a/java/maven/src/org/netbeans/modules/maven/NbArtifactFixer.java b/java/maven/src/org/netbeans/modules/maven/NbArtifactFixer.java index 0d8e7ae2cff7..a72a3e5f57d1 100644 --- a/java/maven/src/org/netbeans/modules/maven/NbArtifactFixer.java +++ b/java/maven/src/org/netbeans/modules/maven/NbArtifactFixer.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.IOException; import java.io.PrintWriter; +import java.nio.file.Files; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; @@ -133,7 +134,7 @@ private static synchronized File createFallbackPOM(String groupId, String artifa String k = groupId + ':' + artifactId + ':' + version; File fallbackPOM = fallbackPOMs.get(k); if (fallbackPOM == null) { - fallbackPOM = File.createTempFile("fallback", ".netbeans.pom"); + fallbackPOM = Files.createTempFile("fallback", ".netbeans.pom").toFile(); fallbackPOM.deleteOnExit(); PrintWriter w = new PrintWriter(fallbackPOM); try { diff --git a/java/maven/src/org/netbeans/modules/maven/newproject/CatalogRepoProvider.java b/java/maven/src/org/netbeans/modules/maven/newproject/CatalogRepoProvider.java index c604df7e766e..db00568a21b1 100644 --- a/java/maven/src/org/netbeans/modules/maven/newproject/CatalogRepoProvider.java +++ b/java/maven/src/org/netbeans/modules/maven/newproject/CatalogRepoProvider.java @@ -24,6 +24,7 @@ import java.net.MalformedURLException; import java.net.URI; import java.net.URL; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collections; import java.util.List; @@ -269,7 +270,7 @@ private void download(String id, String url, File catalog, SettingsDecryptionRes } } - File temp = File.createTempFile("maven", "catalog"); //NOI18N + File temp = Files.createTempFile("maven", "catalog").toFile(); //NOI18N try { wagon.get("archetype-catalog.xml", temp); //NOI18N //only overwrite the old file or create file if the content is there. diff --git a/nb/deadlock.detector/src/org/netbeans/modules/deadlock/detector/Detector.java b/nb/deadlock.detector/src/org/netbeans/modules/deadlock/detector/Detector.java index 7de34c0456c4..1a9c96306ea4 100644 --- a/nb/deadlock.detector/src/org/netbeans/modules/deadlock/detector/Detector.java +++ b/nb/deadlock.detector/src/org/netbeans/modules/deadlock/detector/Detector.java @@ -27,6 +27,7 @@ import java.lang.management.MonitorInfo; import java.lang.management.ThreadInfo; import java.lang.management.ThreadMXBean; +import java.nio.file.Files; import java.util.logging.Level; import java.util.logging.Logger; import org.openide.util.Exceptions; @@ -141,7 +142,7 @@ private void detectDeadlock() { PrintStream out; File file = null; try { - file = File.createTempFile("deadlock", ".txt"); // NOI18N + file = Files.createTempFile("deadlock", ".txt").toFile(); // NOI18N out = new PrintStream(new FileOutputStream(file)); if (LOG.isLoggable(Level.FINE)) { LOG.log(Level.FINE, "Temporrary file created: {0}" , file); // NOI18N diff --git a/php/php.doctrine2/src/org/netbeans/modules/php/doctrine2/commands/Doctrine2Script.java b/php/php.doctrine2/src/org/netbeans/modules/php/doctrine2/commands/Doctrine2Script.java index 8f454684c6e2..5b8c7adb64f1 100644 --- a/php/php.doctrine2/src/org/netbeans/modules/php/doctrine2/commands/Doctrine2Script.java +++ b/php/php.doctrine2/src/org/netbeans/modules/php/doctrine2/commands/Doctrine2Script.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -101,7 +102,7 @@ public void runCommand(PhpModule phpModule, List parameters, Runnable po public List getCommands(PhpModule phpModule) { File tmpFile; try { - tmpFile = File.createTempFile("nb-doctrine2-commands-", ".xml"); // NOI18N + tmpFile = Files.createTempFile("nb-doctrine2-commands-", ".xml").toFile(); // NOI18N tmpFile.deleteOnExit(); } catch (IOException ex) { LOGGER.log(Level.WARNING, null, ex); diff --git a/php/php.project/src/org/netbeans/modules/php/project/connections/TmpLocalFile.java b/php/php.project/src/org/netbeans/modules/php/project/connections/TmpLocalFile.java index b5d5dc2924fd..6087fdb47ef7 100644 --- a/php/php.project/src/org/netbeans/modules/php/project/connections/TmpLocalFile.java +++ b/php/php.project/src/org/netbeans/modules/php/project/connections/TmpLocalFile.java @@ -29,6 +29,7 @@ import java.io.IOException; import java.io.InputStream; import java.io.OutputStream; +import java.nio.file.Files; import java.util.logging.Level; import java.util.logging.Logger; import org.openide.filesystems.FileUtil; @@ -162,7 +163,7 @@ private static final class DiskTmpLocalFile extends TmpLocalFile { public DiskTmpLocalFile(String extension) throws IOException { - file = FileUtil.normalizeFile(File.createTempFile("nb-php-remote-tmp-file-", extension != null ? "." + extension : null)); // NOI18N + file = FileUtil.normalizeFile(Files.createTempFile("nb-php-remote-tmp-file-", extension != null ? "." + extension : null).toFile()); // NOI18N file.deleteOnExit(); } diff --git a/php/php.project/src/org/netbeans/modules/php/project/connections/ftp/FtpClient.java b/php/php.project/src/org/netbeans/modules/php/project/connections/ftp/FtpClient.java index f40ad9bb672d..3c67e9ffd5cb 100644 --- a/php/php.project/src/org/netbeans/modules/php/project/connections/ftp/FtpClient.java +++ b/php/php.project/src/org/netbeans/modules/php/project/connections/ftp/FtpClient.java @@ -25,6 +25,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.UnknownHostException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Calendar; import java.util.HashMap; @@ -576,7 +577,7 @@ synchronized long getTimestampDiff() { // try to calculate the time difference between remote and local pc removeProtocolCommandListener(); try { - File tmpFile = File.createTempFile("netbeans-timestampdiff-", ".txt"); // NOI18N + File tmpFile = Files.createTempFile("netbeans-timestampdiff-", ".txt").toFile(); // NOI18N long now = tmpFile.lastModified(); final String remotePath = configuration.getInitialDirectory() + "/" + tmpFile.getName(); // NOI18N diff --git a/php/php.project/src/org/netbeans/modules/php/project/ui/actions/support/FileRunner.java b/php/php.project/src/org/netbeans/modules/php/project/ui/actions/support/FileRunner.java index 2d2df442241c..5ff53480e411 100644 --- a/php/php.project/src/org/netbeans/modules/php/project/ui/actions/support/FileRunner.java +++ b/php/php.project/src/org/netbeans/modules/php/project/ui/actions/support/FileRunner.java @@ -22,6 +22,7 @@ import java.io.IOException; import java.net.MalformedURLException; import java.nio.charset.Charset; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -202,7 +203,7 @@ boolean getRedirectToFile() { File createTempFile() { try { - File tmpFile = File.createTempFile(file.getName(), ".html"); // NOI18N + File tmpFile = Files.createTempFile(file.getName(), ".html").toFile(); // NOI18N tmpFile.deleteOnExit(); return tmpFile; } catch (IOException ex) { diff --git a/php/php.samples/src/org/netbeans/modules/php/samples/PHPSamplesWizardIterator.java b/php/php.samples/src/org/netbeans/modules/php/samples/PHPSamplesWizardIterator.java index 126787f35f0b..d5a6ea84f2dc 100644 --- a/php/php.samples/src/org/netbeans/modules/php/samples/PHPSamplesWizardIterator.java +++ b/php/php.samples/src/org/netbeans/modules/php/samples/PHPSamplesWizardIterator.java @@ -26,6 +26,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.io.PrintWriter; +import java.nio.file.Files; import java.text.MessageFormat; import java.util.Enumeration; import java.util.LinkedHashSet; @@ -106,7 +107,7 @@ private String[] createSteps() { if (!DO_NOT_OPEN_README_HTML) { // Open readme.html in a browser - File urlTempF = File.createTempFile("phpSamplesReadme", ".url"); // NOI18N + File urlTempF = Files.createTempFile("phpSamplesReadme", ".url").toFile(); // NOI18N urlTempF.deleteOnExit(); FileObject readmeURL = FileUtil.toFileObject(FileUtil.normalizeFile(urlTempF)); diff --git a/php/php.symfony/src/org/netbeans/modules/php/symfony/SymfonyScript.java b/php/php.symfony/src/org/netbeans/modules/php/symfony/SymfonyScript.java index 50efa40da2d9..3dc6ff5b53ec 100644 --- a/php/php.symfony/src/org/netbeans/modules/php/symfony/SymfonyScript.java +++ b/php/php.symfony/src/org/netbeans/modules/php/symfony/SymfonyScript.java @@ -25,6 +25,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -283,7 +284,7 @@ private ExecutionDescriptor getSilentDescriptor() { private List getFrameworkCommandsInternalXml(PhpModule phpModule) { File tmpFile; try { - tmpFile = File.createTempFile("nb-symfony-commands-", ".xml"); // NOI18N + tmpFile = Files.createTempFile("nb-symfony-commands-", ".xml").toFile(); // NOI18N tmpFile.deleteOnExit(); } catch (IOException ex) { LOGGER.log(Level.WARNING, null, ex); diff --git a/php/php.symfony2/src/org/netbeans/modules/php/symfony2/commands/SymfonyScript.java b/php/php.symfony2/src/org/netbeans/modules/php/symfony2/commands/SymfonyScript.java index 0c24e3c6226e..37a110013f0a 100644 --- a/php/php.symfony2/src/org/netbeans/modules/php/symfony2/commands/SymfonyScript.java +++ b/php/php.symfony2/src/org/netbeans/modules/php/symfony2/commands/SymfonyScript.java @@ -24,6 +24,7 @@ import java.io.IOException; import java.io.InputStreamReader; import java.io.Reader; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.Collections; @@ -132,7 +133,7 @@ public void runCommand(PhpModule phpModule, List parameters, Runnable po public List getCommands(PhpModule phpModule) { File tmpFile; try { - tmpFile = File.createTempFile("nb-symfony23-commands-", ".xml"); // NOI18N + tmpFile = Files.createTempFile("nb-symfony23-commands-", ".xml").toFile(); // NOI18N tmpFile.deleteOnExit(); } catch (IOException ex) { LOGGER.log(Level.WARNING, null, ex); diff --git a/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogCache.java b/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogCache.java index ba81ccd2165a..d415c08f7c89 100644 --- a/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogCache.java +++ b/platform/autoupdate.services/src/org/netbeans/modules/autoupdate/updateprovider/AutoupdateCatalogCache.java @@ -26,6 +26,7 @@ import java.net.MalformedURLException; import java.net.URISyntaxException; import java.net.URL; +import java.nio.file.Files; import java.util.logging.Level; import java.util.logging.Logger; import org.netbeans.modules.autoupdate.services.AutoupdateSettings; @@ -211,7 +212,7 @@ private void copy (final URL sourceUrl, final File cache, final boolean allowZer while (prefix.length () < 3) { prefix += cache.getName(); } - final File temp = File.createTempFile (prefix, null, cache.getParentFile ()); //NOI18N + final File temp = Files.createTempFile(cache.getParentFile ().toPath(), prefix, null).toFile (); //NOI18N temp.deleteOnExit(); DownloadListener nwl = new DownloadListener(sourceUrl, temp, allowZeroSize); diff --git a/platform/core.startup.base/src/org/netbeans/core/startup/layers/ArchiveURLMapper.java b/platform/core.startup.base/src/org/netbeans/core/startup/layers/ArchiveURLMapper.java index 0a39ad5b8c1a..9868f9eeb222 100644 --- a/platform/core.startup.base/src/org/netbeans/core/startup/layers/ArchiveURLMapper.java +++ b/platform/core.startup.base/src/org/netbeans/core/startup/layers/ArchiveURLMapper.java @@ -30,6 +30,7 @@ import java.net.URISyntaxException; import java.net.URL; import java.net.URLDecoder; +import java.nio.file.Files; import java.util.Enumeration; import java.util.HashMap; import java.util.Map; @@ -237,7 +238,7 @@ private static File copyJAR(FileObject fo, URI archiveFileURI, boolean replace) File copy = copiedJARs.get(archiveFileURI); if (copy == null || replace) { if (copy == null) { - copy = File.createTempFile("copy", "-" + archiveFileURI.toString().replaceFirst(".+/", "")); // NOI18N + copy = Files.createTempFile("copy", "-" + archiveFileURI.toString().replaceFirst(".+/", "")).toFile(); // NOI18N copy = copy.getCanonicalFile(); copy.deleteOnExit(); } diff --git a/platform/javahelp/src/org/netbeans/modules/javahelp/HelpSetRegistrationProcessor.java b/platform/javahelp/src/org/netbeans/modules/javahelp/HelpSetRegistrationProcessor.java index 0cabb67a5e26..9264d1126c88 100644 --- a/platform/javahelp/src/org/netbeans/modules/javahelp/HelpSetRegistrationProcessor.java +++ b/platform/javahelp/src/org/netbeans/modules/javahelp/HelpSetRegistrationProcessor.java @@ -31,6 +31,7 @@ import java.net.URI; import java.net.URL; import java.net.URLDecoder; +import java.nio.file.Files; import java.util.Arrays; import java.util.Collections; import java.util.HashSet; @@ -122,7 +123,7 @@ public class HelpSetRegistrationProcessor extends LayerGeneratingProcessor { File d = Utilities.toFile(loc).getParentFile(); String out = hs.replaceFirst("/[^/]+$", "/") + searchDir + "/"; try { - File config = File.createTempFile("jhindexer-config", ".txt"); + File config = Files.createTempFile("jhindexer-config", ".txt").toFile(); try { AtomicInteger cnt = new AtomicInteger(); OutputStream os = new FileOutputStream(config); @@ -195,7 +196,7 @@ public class HelpSetRegistrationProcessor extends LayerGeneratingProcessor { */ static File createTempFile(String pref, String suff) throws IOException { - File f = File.createTempFile(pref, suff); //file in default tmp folder + File f = Files.createTempFile(pref, suff).toFile(); //file in default tmp folder if (!isUrlCompatible(f)) { if (Utilities.isWindows()) { f = replaceTempFile(f, "c:\\Temp", pref, suff); //NOI18N diff --git a/platform/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/FileBasedFileSystem.java b/platform/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/FileBasedFileSystem.java index 18ba602bd68b..c4c651b547d5 100644 --- a/platform/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/FileBasedFileSystem.java +++ b/platform/masterfs/src/org/netbeans/modules/masterfs/filebasedfs/FileBasedFileSystem.java @@ -23,6 +23,7 @@ import java.io.IOException; import java.io.ObjectStreamException; import java.io.Serializable; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collection; import java.util.Collections; @@ -217,7 +218,7 @@ public FileObject getTempFolder() throws IOException { @Override public FileObject createTempFile(FileObject parent, String prefix, String suffix, boolean deleteOnExit) throws IOException { if (parent.isFolder() && parent.isValid()) { - File tmpFile = File.createTempFile(prefix, suffix, FileUtil.toFile(parent)); + File tmpFile = Files.createTempFile(FileUtil.toFile(parent).toPath(), prefix, suffix).toFile(); if (deleteOnExit) { tmpFile.deleteOnExit(); } diff --git a/platform/o.n.bootstrap/src/org/netbeans/JarClassLoader.java b/platform/o.n.bootstrap/src/org/netbeans/JarClassLoader.java index 799cfa92f91b..afe2621f54b6 100644 --- a/platform/o.n.bootstrap/src/org/netbeans/JarClassLoader.java +++ b/platform/o.n.bootstrap/src/org/netbeans/JarClassLoader.java @@ -39,6 +39,7 @@ import java.net.URL; import java.net.URLConnection; import java.net.URLStreamHandler; +import java.nio.file.Files; import java.nio.file.NoSuchFileException; import java.security.CodeSource; import java.security.PermissionCollection; @@ -789,7 +790,7 @@ protected void destroy() throws IOException { } while (prefix.length() < 3) prefix += "x"; // NOI18N - File temp = File.createTempFile(prefix, suffix); + File temp = Files.createTempFile(prefix, suffix).toFile(); temp.deleteOnExit(); InputStream is = new FileInputStream(orig); diff --git a/platform/o.n.bootstrap/src/org/netbeans/Util.java b/platform/o.n.bootstrap/src/org/netbeans/Util.java index 2287d871442d..05d0494699fd 100644 --- a/platform/o.n.bootstrap/src/org/netbeans/Util.java +++ b/platform/o.n.bootstrap/src/org/netbeans/Util.java @@ -20,6 +20,7 @@ package org.netbeans; import java.io.*; +import java.nio.file.Files; import java.util.*; import java.util.ArrayList; import java.util.logging.Level; @@ -57,7 +58,7 @@ static File makeTempJar(File moduleFile) throws IOException { if (prefix.length() < 3) prefix += '.'; if (prefix.length() < 3) prefix += '.'; String suffix = "-test.jar"; // NOI18N - File physicalModuleFile = File.createTempFile(prefix, suffix); + File physicalModuleFile = Files.createTempFile(prefix, suffix).toFile(); physicalModuleFile.deleteOnExit(); InputStream is = new FileInputStream(moduleFile); try { diff --git a/platform/o.n.swing.tabcontrol/test/unit/src/org/netbeans/swing/tabcontrol/plaf/VectorIconTester.java b/platform/o.n.swing.tabcontrol/test/unit/src/org/netbeans/swing/tabcontrol/plaf/VectorIconTester.java index bd11f6ff69bc..e0cefa801bc3 100644 --- a/platform/o.n.swing.tabcontrol/test/unit/src/org/netbeans/swing/tabcontrol/plaf/VectorIconTester.java +++ b/platform/o.n.swing.tabcontrol/test/unit/src/org/netbeans/swing/tabcontrol/plaf/VectorIconTester.java @@ -36,6 +36,7 @@ import java.awt.image.BufferedImage; import java.io.File; import java.io.IOException; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Collections; import java.util.LinkedHashMap; @@ -104,7 +105,7 @@ public void dumpGraphicsToFile() { @Override public void run() { try { - File tempFile = File.createTempFile("VectorIconTester", ".png"); + File tempFile = Files.createTempFile("VectorIconTester", ".png").toFile(); ImageIO.write(bi, "PNG", tempFile); System.out.println("Output was written to " + tempFile); } catch (IOException e) { diff --git a/platform/openide.util.ui/test/unit/src/org/openide/util/test/JarBuilder.java b/platform/openide.util.ui/test/unit/src/org/openide/util/test/JarBuilder.java index e63959a779b9..195d912184e2 100644 --- a/platform/openide.util.ui/test/unit/src/org/openide/util/test/JarBuilder.java +++ b/platform/openide.util.ui/test/unit/src/org/openide/util/test/JarBuilder.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -43,7 +44,7 @@ public final class JarBuilder { * @param workdir as in {@link NbTestCase#getWorkDir} */ public JarBuilder(File workdir) throws Exception { - jar = File.createTempFile("test", ".jar", workdir); + jar = Files.createTempFile(workdir.toPath(), "test", ".jar").toFile(); String n = jar.getName().replaceAll("^test|[.]jar$", ""); src = new File(workdir, "src" + n); dest = new File(workdir, "classes" + n); diff --git a/platform/openide.util/test/unit/src/org/openide/util/test/JarBuilder.java b/platform/openide.util/test/unit/src/org/openide/util/test/JarBuilder.java index e63959a779b9..195d912184e2 100644 --- a/platform/openide.util/test/unit/src/org/openide/util/test/JarBuilder.java +++ b/platform/openide.util/test/unit/src/org/openide/util/test/JarBuilder.java @@ -22,6 +22,7 @@ import java.io.File; import java.io.FileOutputStream; import java.io.OutputStream; +import java.nio.file.Files; import java.util.ArrayList; import java.util.Arrays; import java.util.List; @@ -43,7 +44,7 @@ public final class JarBuilder { * @param workdir as in {@link NbTestCase#getWorkDir} */ public JarBuilder(File workdir) throws Exception { - jar = File.createTempFile("test", ".jar", workdir); + jar = Files.createTempFile(workdir.toPath(), "test", ".jar").toFile(); String n = jar.getName().replaceAll("^test|[.]jar$", ""); src = new File(workdir, "src" + n); dest = new File(workdir, "classes" + n); diff --git a/platform/sampler/src/org/netbeans/modules/sampler/InternalSampler.java b/platform/sampler/src/org/netbeans/modules/sampler/InternalSampler.java index 5c055bdd352c..bbd0960732dd 100644 --- a/platform/sampler/src/org/netbeans/modules/sampler/InternalSampler.java +++ b/platform/sampler/src/org/netbeans/modules/sampler/InternalSampler.java @@ -25,6 +25,7 @@ import java.lang.management.ManagementFactory; import java.lang.management.RuntimeMXBean; import java.lang.management.ThreadMXBean; +import java.nio.file.Files; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -35,6 +36,7 @@ import org.openide.modules.Places; import org.openide.util.Exceptions; import org.openide.util.NbBundle.Messages; + import static org.netbeans.modules.sampler.Bundle.*; /** @@ -123,7 +125,7 @@ protected void printStackTrace(Throwable ex) { "SelfSamplerAction_SavedFile=Snapshot was saved to {0}" }) protected void saveSnapshot(byte[] arr) throws IOException { // save snapshot - File outFile = File.createTempFile(SAMPLER_NAME, SamplesOutputStream.FILE_EXT); + File outFile = Files.createTempFile(SAMPLER_NAME, SamplesOutputStream.FILE_EXT).toFile(); File userDir = Places.getUserDirectory(); File gestures = null; SelfSampleVFS fs; diff --git a/platform/uihandler/src/org/netbeans/modules/uihandler/Installer.java b/platform/uihandler/src/org/netbeans/modules/uihandler/Installer.java index 9c2bae507538..63813c82878d 100644 --- a/platform/uihandler/src/org/netbeans/modules/uihandler/Installer.java +++ b/platform/uihandler/src/org/netbeans/modules/uihandler/Installer.java @@ -35,6 +35,7 @@ import java.lang.reflect.Method; import java.net.*; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.security.GeneralSecurityException; import java.security.SecureRandom; import java.security.cert.X509Certificate; @@ -1420,7 +1421,7 @@ static URL uploadLogs(URL postURL, String id, Map attrs, List replacements = new HashMap<>(); @@ -2538,7 +2539,7 @@ public void actionPerformed(ActionEvent e) { private void showProfilerSnapshot(ActionEvent e){ File tempFile = null; try { - tempFile = File.createTempFile("selfsampler", ".npss"); // NOI18N + tempFile = Files.createTempFile("selfsampler", ".npss").toFile(); // NOI18N tempFile = FileUtil.normalizeFile(tempFile); try (OutputStream os = new FileOutputStream(tempFile)) { os.write(slownData.getNpsContent()); diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/JavaIoFile.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/JavaIoFile.java index f72b970c67d8..030f27f148c2 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/JavaIoFile.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/heap/JavaIoFile.java @@ -29,6 +29,7 @@ import java.nio.ByteBuffer; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; +import java.nio.file.Files; final class JavaIoFile extends File { static final Factory IO = new Factory() { @@ -50,9 +51,9 @@ public File newFile(java.io.File real) { @Override public File createTempFile(String prefix, String suffix, File cacheDirectory) throws IOException { if (cacheDirectory == null) { - return newFile(java.io.File.createTempFile(prefix, suffix)); + return newFile(Files.createTempFile(prefix, suffix).toFile()); } else { - return newFile(java.io.File.createTempFile(prefix, suffix, ((JavaIoFile)cacheDirectory).delegate)); + return newFile(Files.createTempFile(((JavaIoFile)cacheDirectory).delegate.toPath(), prefix, suffix).toFile()); } } }; diff --git a/profiler/lib.profiler/src/org/netbeans/lib/profiler/server/EventBufferManager.java b/profiler/lib.profiler/src/org/netbeans/lib/profiler/server/EventBufferManager.java index b4992d6ac32a..dc5ba7cdd8c8 100644 --- a/profiler/lib.profiler/src/org/netbeans/lib/profiler/server/EventBufferManager.java +++ b/profiler/lib.profiler/src/org/netbeans/lib/profiler/server/EventBufferManager.java @@ -27,6 +27,7 @@ import org.netbeans.lib.profiler.global.Platform; import java.nio.MappedByteBuffer; import java.nio.channels.FileChannel; +import java.nio.file.Files; /** @@ -123,7 +124,7 @@ public void openBufferFile(int sizeInBytes) throws IOException { try { bufFileSent = false; - bufFile = File.createTempFile("jfluidbuf", null); // NOI18N + bufFile = Files.createTempFile("jfluidbuf", null).toFile(); // NOI18N bufFileName = bufFile.getCanonicalPath(); // Bugfix: http://profiler.netbeans.org/issues/show_bug.cgi?id=59166 diff --git a/webcommon/javascript.cdnjs/src/org/netbeans/modules/javascript/cdnjs/LibraryProvider.java b/webcommon/javascript.cdnjs/src/org/netbeans/modules/javascript/cdnjs/LibraryProvider.java index c11c4cdda0e8..555ada7b06ba 100644 --- a/webcommon/javascript.cdnjs/src/org/netbeans/modules/javascript/cdnjs/LibraryProvider.java +++ b/webcommon/javascript.cdnjs/src/org/netbeans/modules/javascript/cdnjs/LibraryProvider.java @@ -32,6 +32,7 @@ import java.net.URLConnection; import java.net.URLEncoder; import java.nio.charset.StandardCharsets; +import java.nio.file.Files; import java.text.MessageFormat; import java.util.Arrays; import java.util.Collections; @@ -248,7 +249,7 @@ public File downloadLibraryFile(Library.Version version, int fileIndex) throws I prefix = "tmp" + prefix; // NOI18N } String suffix = (index == -1) ? "" : fileName.substring(index); - File file = File.createTempFile(prefix, suffix); + File file = Files.createTempFile(prefix, suffix).toFile(); try (OutputStream output = new FileOutputStream(file)) { FileUtil.copy(input, output); return file; diff --git a/webcommon/javascript.jstestdriver/src/org/netbeans/modules/javascript/jstestdriver/wizard/InstallJasmineWizardDescriptorPanel.java b/webcommon/javascript.jstestdriver/src/org/netbeans/modules/javascript/jstestdriver/wizard/InstallJasmineWizardDescriptorPanel.java index cf307b2235b7..0b03ed53adc1 100644 --- a/webcommon/javascript.jstestdriver/src/org/netbeans/modules/javascript/jstestdriver/wizard/InstallJasmineWizardDescriptorPanel.java +++ b/webcommon/javascript.jstestdriver/src/org/netbeans/modules/javascript/jstestdriver/wizard/InstallJasmineWizardDescriptorPanel.java @@ -28,6 +28,7 @@ import java.io.InputStream; import java.io.OutputStream; import java.net.URL; +import java.nio.file.Files; import java.util.logging.Level; import java.util.logging.Logger; import java.util.zip.ZipEntry; @@ -90,8 +91,8 @@ public void removeChangeListener(ChangeListener l) { @NbBundle.Messages("DownloadFailure=Download of remote files failed. See IDE log for more details.") public void downloadJasmine(FileObject libs) { try { - File jasmine = File.createTempFile("jasmine", "zip"); // NOI18N - File jasmineJSTD = File.createTempFile("jasmine-jstd", "zip"); // NOI18N + File jasmine = Files.createTempFile("jasmine", "zip").toFile(); // NOI18N + File jasmineJSTD = Files.createTempFile("jasmine-jstd", "zip").toFile(); // NOI18N download("https://github.com/pivotal/jasmine/zipball/v1.2.0", jasmine); // NOI18N download("https://github.com/ibolmo/jasmine-jstd-adapter/zipball/1.1.2", jasmineJSTD); // NOI18N unzip(new FileInputStream(jasmine), FileUtil.createFolder(libs, "jasmine"), "1.2.0"); // NOI18N From 115edc8df80e6603de483705996b2395d66122ec Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Fri, 9 Feb 2024 01:32:58 +0100 Subject: [PATCH 02/12] Prefer String.equalsIgnoreCase() over toUpper/LowerCase patterns String.toUpper/LowerCase() without setting Locale.ROOT can lead to unintended results on certain locales. String.equalsIgnoreCase() can be sometimes used instead and the method does not depend on the locale. This reduces the toUpper/LowerCase usage a bit further before the great Locale.ROOT refactoring starts. --- .../singlefilerun/SingleGroovySourceRunActionProvider.java | 4 ++-- .../netbeans/modules/db/mysql/impl/BaseSampleProvider.java | 4 ++-- .../lib/editor/codetemplates/CodeTemplateParameterImpl.java | 2 +- .../src/org/netbeans/spi/palette/PaletteSwitch.java | 2 +- .../modules/bugtracking/commons/SimpleIssueFinder.java | 6 ++---- java/form/src/org/netbeans/modules/form/FormUtils.java | 2 +- .../org/netbeans/modules/java/guards/JavaGuardedReader.java | 2 +- .../org/netbeans/modules/javadoc/search/IndexBuilder.java | 2 +- .../modules/xml/jaxb/actions/OpenJAXBCustomizerAction.java | 2 +- .../editor/completion/impl/ResourcePathCompleter.java | 2 +- .../php/editor/verification/ErrorControlOperatorHint.java | 2 +- .../src/org/netbeans/core/windows/Switches.java | 2 +- .../src/org/netbeans/core/windows/services/NbPresenter.java | 2 +- .../modules/javascript2/editor/JsCodeCompletion.java | 2 +- .../javascript2/jade/editor/JadeJsEmbeddingProvider.java | 2 +- .../javascript2/nodejs/editor/NodeJsDataProvider.java | 2 +- .../modules/javascript2/react/ReactHtmlExtension.java | 2 +- .../javascript2/requirejs/html/RequireJsHtmlExtension.java | 2 +- 18 files changed, 21 insertions(+), 23 deletions(-) diff --git a/groovy/groovy.support/src/org/netbeans/modules/groovy/support/actions/singlefilerun/SingleGroovySourceRunActionProvider.java b/groovy/groovy.support/src/org/netbeans/modules/groovy/support/actions/singlefilerun/SingleGroovySourceRunActionProvider.java index bed05568121b..39767cdc6224 100644 --- a/groovy/groovy.support/src/org/netbeans/modules/groovy/support/actions/singlefilerun/SingleGroovySourceRunActionProvider.java +++ b/groovy/groovy.support/src/org/netbeans/modules/groovy/support/actions/singlefilerun/SingleGroovySourceRunActionProvider.java @@ -108,12 +108,12 @@ private static boolean isSingleSourceFile(FileObject fileObject) { private static FileObject getGroovyFile(Lookup lookup) { for (DataObject dObj : lookup.lookupAll(DataObject.class)) { FileObject fObj = dObj.getPrimaryFile(); - if (GROOVY_EXTENSION.equals(fObj.getExt().toLowerCase())) { + if (GROOVY_EXTENSION.equalsIgnoreCase(fObj.getExt())) { return fObj; } } for (FileObject fObj : lookup.lookupAll(FileObject.class)) { - if (GROOVY_EXTENSION.equals(fObj.getExt().toLowerCase())) { + if (GROOVY_EXTENSION.equalsIgnoreCase(fObj.getExt())) { return fObj; } } diff --git a/ide/db.mysql/src/org/netbeans/modules/db/mysql/impl/BaseSampleProvider.java b/ide/db.mysql/src/org/netbeans/modules/db/mysql/impl/BaseSampleProvider.java index e5ac6f2db5dc..b60ecf6c2f45 100644 --- a/ide/db.mysql/src/org/netbeans/modules/db/mysql/impl/BaseSampleProvider.java +++ b/ide/db.mysql/src/org/netbeans/modules/db/mysql/impl/BaseSampleProvider.java @@ -98,8 +98,8 @@ private boolean checkInnodbSupport(Connection conn) throws DatabaseException { ResultSet rs = stmt.executeQuery("SHOW STORAGE ENGINES"); // NOI18N while (rs.next()) { - if ("INNODB".equals(rs.getString(1).toUpperCase()) && - ("YES".equals(rs.getString(2).toUpperCase()) || "DEFAULT".equals(rs.getString(2).toUpperCase()))) { // NOI18N + if ("INNODB".equalsIgnoreCase(rs.getString(1)) && + ("YES".equalsIgnoreCase(rs.getString(2)) || "DEFAULT".equalsIgnoreCase(rs.getString(2)))) { // NOI18N return true; } } diff --git a/ide/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateParameterImpl.java b/ide/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateParameterImpl.java index 74a26c4d662d..b1d9fcd7cbb0 100644 --- a/ide/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateParameterImpl.java +++ b/ide/editor.codetemplates/src/org/netbeans/lib/editor/codetemplates/CodeTemplateParameterImpl.java @@ -378,7 +378,7 @@ private void parseParameterContent(String parametrizedText) { private boolean isHintValueFalse(String hintName) { String hintValue = getHints().get(hintName); - return (hintValue != null) && "false".equals(hintValue.toLowerCase()); // NOI18N + return (hintValue != null) && "false".equalsIgnoreCase(hintValue); // NOI18N } /** diff --git a/ide/spi.palette/src/org/netbeans/spi/palette/PaletteSwitch.java b/ide/spi.palette/src/org/netbeans/spi/palette/PaletteSwitch.java index c636ea635dee..4c154c94216f 100644 --- a/ide/spi.palette/src/org/netbeans/spi/palette/PaletteSwitch.java +++ b/ide/spi.palette/src/org/netbeans/spi/palette/PaletteSwitch.java @@ -364,7 +364,7 @@ private static boolean isPaletteWindowEnabled() { boolean result = true; try { String resValue = NbBundle.getMessage(PaletteModule.class, "Palette.Window.Enabled" ); //NOI18N - result = "true".equals( resValue.toLowerCase() ); //NOI18N + result = "true".equalsIgnoreCase(resValue); //NOI18N } catch( MissingResourceException mrE ) { //ignore } diff --git a/ide/team.commons/src/org/netbeans/modules/bugtracking/commons/SimpleIssueFinder.java b/ide/team.commons/src/org/netbeans/modules/bugtracking/commons/SimpleIssueFinder.java index 5fa064c9ab8b..64cf42b9cd4d 100644 --- a/ide/team.commons/src/org/netbeans/modules/bugtracking/commons/SimpleIssueFinder.java +++ b/ide/team.commons/src/org/netbeans/modules/bugtracking/commons/SimpleIssueFinder.java @@ -137,12 +137,10 @@ private static final class Impl { * - all bugwords the bug number prefix are lowercase: */ for (int i = 0; i < BUGWORDS.length; i++) { - assert BUGWORDS[i].equals( - BUGWORDS[i].toLowerCase()); + assert BUGWORDS[i].equalsIgnoreCase(BUGWORDS[i]); } for (int i = 0; i < BUGNUM_PREFIX_PARTS.length; i++) { - assert BUGNUM_PREFIX_PARTS[i].equals( - BUGNUM_PREFIX_PARTS[i].toLowerCase()); + assert BUGNUM_PREFIX_PARTS[i].equalsIgnoreCase(BUGNUM_PREFIX_PARTS[i]); } /* diff --git a/java/form/src/org/netbeans/modules/form/FormUtils.java b/java/form/src/org/netbeans/modules/form/FormUtils.java index 9c09478d9e2f..0548ba422865 100644 --- a/java/form/src/org/netbeans/modules/form/FormUtils.java +++ b/java/form/src/org/netbeans/modules/form/FormUtils.java @@ -477,7 +477,7 @@ public static String getFormattedBundleString(String key, Object... arguments) { public static boolean getPresetValue(String key, boolean defaultValue) { try { String s = NbBundle.getMessage(FormUtils.class, key); - return "true".equals(s.toLowerCase()); // NOI18N + return "true".equalsIgnoreCase(s); // NOI18N } catch( MissingResourceException ex) { // ignore } return defaultValue; diff --git a/java/java.guards/src/org/netbeans/modules/java/guards/JavaGuardedReader.java b/java/java.guards/src/org/netbeans/modules/java/guards/JavaGuardedReader.java index f87899824fe3..7207cfc44b22 100644 --- a/java/java.guards/src/org/netbeans/modules/java/guards/JavaGuardedReader.java +++ b/java/java.guards/src/org/netbeans/modules/java/guards/JavaGuardedReader.java @@ -364,7 +364,7 @@ List fillSections(List descs) { private static boolean getPresetValue(String key, boolean defaultValue) { try { String s = NbBundle.getMessage(JavaGuardedReader.class, key); - return "true".equals(s.toLowerCase()); // NOI18N + return "true".equalsIgnoreCase(s); // NOI18N } catch( MissingResourceException ex) { // ignore } return defaultValue; diff --git a/java/javadoc/src/org/netbeans/modules/javadoc/search/IndexBuilder.java b/java/javadoc/src/org/netbeans/modules/javadoc/search/IndexBuilder.java index 175ff5883335..e3246909c050 100644 --- a/java/javadoc/src/org/netbeans/modules/javadoc/search/IndexBuilder.java +++ b/java/javadoc/src/org/netbeans/modules/javadoc/search/IndexBuilder.java @@ -402,7 +402,7 @@ private void handleTitleTag() throws IOException { case (char) -1: // EOF return; case '>': // - if (" collectFromClasspath(ClassPath cp, String parentD !f.getNameExt().toLowerCase().startsWith(filesMatch)) { continue; } - if (f.isFolder() || extMatch == null || extMatch.equals(f.getExt().toLowerCase())) { + if (f.isFolder() || extMatch == null || extMatch.equalsIgnoreCase(f.getExt())) { String k = f.getNameExt(); if (names.add(k)) { result.add(f); diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/verification/ErrorControlOperatorHint.java b/php/php.editor/src/org/netbeans/modules/php/editor/verification/ErrorControlOperatorHint.java index cdaf22d53dba..c509851ade1c 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/verification/ErrorControlOperatorHint.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/verification/ErrorControlOperatorHint.java @@ -201,7 +201,7 @@ private boolean isValid(FunctionInvocation functionInvocation) { boolean result = false; String functionInvocationName = CodeUtils.extractFunctionName(functionInvocation); if (functionInvocationName != null) { - result = functionName.equals(functionInvocationName.toLowerCase()); + result = functionName.equalsIgnoreCase(functionInvocationName); } return result; } diff --git a/platform/core.windows/src/org/netbeans/core/windows/Switches.java b/platform/core.windows/src/org/netbeans/core/windows/Switches.java index 1cc999e88ff4..beca6f4f8cdf 100644 --- a/platform/core.windows/src/org/netbeans/core/windows/Switches.java +++ b/platform/core.windows/src/org/netbeans/core/windows/Switches.java @@ -309,7 +309,7 @@ private static boolean getSwitchValue( String switchName, boolean defaultValue ) boolean result = defaultValue; try { String resValue = NbBundle.getMessage(Switches.class, switchName ); - result = "true".equals( resValue.toLowerCase() ); //NOI18N + result = "true".equalsIgnoreCase(resValue); //NOI18N } catch( MissingResourceException mrE ) { //ignore } diff --git a/platform/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java b/platform/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java index e69ac49d4cb4..677b11226572 100644 --- a/platform/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java +++ b/platform/core.windows/src/org/netbeans/core/windows/services/NbPresenter.java @@ -888,7 +888,7 @@ private boolean helpButtonLeft() { boolean result = false; try { String resValue = NbBundle.getMessage(NbPresenter.class, "HelpButtonAtTheLeftSide" ); //NOI18N - result = "true".equals( resValue.toLowerCase() ); //NOI18N + result = "true".equalsIgnoreCase(resValue); //NOI18N } catch( MissingResourceException e ) { //ignore } diff --git a/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/JsCodeCompletion.java b/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/JsCodeCompletion.java index c5519a3da8ed..2699e3e167fe 100644 --- a/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/JsCodeCompletion.java +++ b/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/JsCodeCompletion.java @@ -1085,7 +1085,7 @@ private void completeJsModuleNames(CompletionRequest request, List relativeFiles = FileUtils.computeRelativeItems(Collections.singletonList(fo), writtenPath, offset, false, false, (FileObject file) -> { - return file.isFolder() || ("js".equals(file.getExt().toLowerCase()) && file.getName().startsWith(prefix)); //NOI18N + return file.isFolder() || ("js".equalsIgnoreCase(file.getExt()) && file.getName().startsWith(prefix)); //NOI18N }); resultList.addAll(relativeFiles); } catch (IOException ex) { diff --git a/webcommon/javascript2.jade/src/org/netbeans/modules/javascript2/jade/editor/JadeJsEmbeddingProvider.java b/webcommon/javascript2.jade/src/org/netbeans/modules/javascript2/jade/editor/JadeJsEmbeddingProvider.java index 4664c1f2a2e8..17d7dda8139b 100644 --- a/webcommon/javascript2.jade/src/org/netbeans/modules/javascript2/jade/editor/JadeJsEmbeddingProvider.java +++ b/webcommon/javascript2.jade/src/org/netbeans/modules/javascript2/jade/editor/JadeJsEmbeddingProvider.java @@ -101,7 +101,7 @@ public List getEmbeddings(Snapshot snapshot) { } if (token.id() == JadeTokenId.PLAIN_TEXT_DELIMITER) { // check whether there is not - if (lastTag != null && SCRIPT_TAG_NAME.equals(lastTag.text().toString().toLowerCase()) && ts.moveNext()) { + if (lastTag != null && SCRIPT_TAG_NAME.equalsIgnoreCase(lastTag.text().toString()) && ts.moveNext()) { token = ts.token(); while (token.id() == JadeTokenId.EOL && ts.moveNext()) { token = ts.token(); diff --git a/webcommon/javascript2.nodejs/src/org/netbeans/modules/javascript2/nodejs/editor/NodeJsDataProvider.java b/webcommon/javascript2.nodejs/src/org/netbeans/modules/javascript2/nodejs/editor/NodeJsDataProvider.java index b7217798a4a8..965b60262d9f 100644 --- a/webcommon/javascript2.nodejs/src/org/netbeans/modules/javascript2/nodejs/editor/NodeJsDataProvider.java +++ b/webcommon/javascript2.nodejs/src/org/netbeans/modules/javascript2/nodejs/editor/NodeJsDataProvider.java @@ -348,7 +348,7 @@ public String getDocForModule(final String moduleName) { if (jsonValue instanceof JSONObject) { JSONObject jsonModule = (JSONObject) jsonValue; jsonValue = jsonModule.get(NAME); - if (jsonValue instanceof String && moduleName.equals(((String) jsonValue).toLowerCase())) { + if (jsonValue instanceof String && moduleName.equalsIgnoreCase(((String) jsonValue))) { jsonValue = jsonModule.get(DESCRIPTION); if (jsonValue instanceof String) { return (String) jsonValue; diff --git a/webcommon/javascript2.react/src/org/netbeans/modules/javascript2/react/ReactHtmlExtension.java b/webcommon/javascript2.react/src/org/netbeans/modules/javascript2/react/ReactHtmlExtension.java index d34adfbce7fb..0b657d23c1c3 100644 --- a/webcommon/javascript2.react/src/org/netbeans/modules/javascript2/react/ReactHtmlExtension.java +++ b/webcommon/javascript2.react/src/org/netbeans/modules/javascript2/react/ReactHtmlExtension.java @@ -41,7 +41,7 @@ public class ReactHtmlExtension extends HtmlExtension { private static String REACT_MIMETYPE = JsTokenId.JAVASCRIPT_MIME_TYPE + "/text/html"; //NOI18N @Override public boolean isCustomAttribute(Attribute attribute, HtmlSource source) { - if (CLASSNAME.equals(attribute.name().toString().toLowerCase())) { + if (CLASSNAME.equalsIgnoreCase(attribute.name().toString())) { return true; } return false; diff --git a/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/html/RequireJsHtmlExtension.java b/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/html/RequireJsHtmlExtension.java index 1efee164a8f4..42e6d3daa28a 100644 --- a/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/html/RequireJsHtmlExtension.java +++ b/webcommon/javascript2.requirejs/src/org/netbeans/modules/javascript2/requirejs/html/RequireJsHtmlExtension.java @@ -73,7 +73,7 @@ public List completeAttributes(HtmlExtension.CompletionContext c case OPEN_TAG: OpenTag ot = (OpenTag) element; String name = ot.unqualifiedName().toString(); - if (SCRIPT.equals(name.toLowerCase())) { + if (SCRIPT.equalsIgnoreCase(name)) { Collection customAttributes = RequireJsCustomAttribute.getCustomAttributes(); for (CustomAttribute ca : customAttributes) { if (LexerUtils.startsWith(ca.getName(), context.getPrefix(), true, false)) { From f338b967a0ddde6ef7ea34fb068be4209a28e8f1 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Fri, 9 Feb 2024 07:20:21 +0100 Subject: [PATCH 03/12] Replace underscore identifiers with regular characters. - '_' is a reserved keyword since java 8 and causes javac warnings --- .../modules/apisupport/project/ui/ModuleActions.java | 6 +----- .../test/unit/src/org/netbeans/core/startup/AsmTest.java | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModuleActions.java b/apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModuleActions.java index ae6f8ce80b82..32b8a7aec2a7 100644 --- a/apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModuleActions.java +++ b/apisupport/apisupport.ant/src/org/netbeans/modules/apisupport/project/ui/ModuleActions.java @@ -441,11 +441,7 @@ public void invokeAction(final String command, final Lookup context) throws Ille doRun(); } finally { if (task != null) { - task.addTaskListener(new TaskListener() { - @Override public void taskFinished(Task _) { - listener.finished(task.result() == 0); - } - }); + task.addTaskListener((Task t) -> listener.finished(task.result() == 0)); } else { listener.finished(false); } diff --git a/platform/core.startup/test/unit/src/org/netbeans/core/startup/AsmTest.java b/platform/core.startup/test/unit/src/org/netbeans/core/startup/AsmTest.java index 28a01bab51c8..64e43427277f 100644 --- a/platform/core.startup/test/unit/src/org/netbeans/core/startup/AsmTest.java +++ b/platform/core.startup/test/unit/src/org/netbeans/core/startup/AsmTest.java @@ -43,9 +43,9 @@ public AsmTest(String n) { public static class C { static final long x = 123L; // test CONSTANT_Long, tricky! - private C(boolean _) {} + private C(boolean b) {} @PatchedPublic - private C(int _) {} + private C(int i) {} private void m1() {} @PatchedPublic private void m2() {} From 1f4e851722366ae4a4dd79d7d4d3d5c2c2ffc723 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Fri, 9 Feb 2024 06:10:13 +0100 Subject: [PATCH 04/12] Fix Class#newInstance deprecation warnings - c.getDeclaredConstructor().newInstance() can be used instead. - simplified exception handling in related code --- .../j2ee/jboss4/JBDeploymentFactory.java | 4 +- .../dd/impl/webservices/CommonDDAccess.java | 2 +- .../j2ee/dd/impl/common/CommonDDAccess.java | 2 +- .../j2ee/sun/api/ServerLocationManager.java | 2 +- .../modules/j2ee/sun/dd/api/DDProvider.java | 2 +- .../j2ee/sun/dd/impl/common/SunBaseBean.java | 2 +- .../customizers/common/GenericTablePanel.java | 7 +- .../j2ee/sun/validation/util/Utils.java | 22 +--- .../deployment/impl/DeployOnSaveManager.java | 2 +- .../wildfly/ide/commands/WildflyClient.java | 77 ++++++------- .../ide/commands/WildflyManagementAPI.java | 100 ++++++---------- .../eecommon/dd/loader/PayaraDDProvider.java | 2 +- .../micro/project/DeployOnSaveManager.java | 2 +- .../websvc/manager/ui/ReflectionHelper.java | 97 +++++----------- .../ant/module/bridge/impl/BridgeImpl.java | 2 +- .../tools/ant/module/bridge/AntBridge.java | 2 +- .../netbeans/jellytools/actions/Action.java | 4 +- .../jellytools/actions/ActionNoBlock.java | 2 +- .../src/org/netbeans/junit/Manager.java | 2 +- .../src/org/netbeans/junit/NbModuleSuite.java | 2 +- .../org/netbeans/api/debugger/Properties.java | 20 +--- .../spi/debugger/ContextAwareSupport.java | 4 +- .../db/sql/execute/ui/util/DbUtil.java | 2 +- .../spi/DBConnectionProviderImpl.java | 14 +-- .../modules/db/dataview/util/DbUtil.java | 2 +- .../modules/db/mysql/util/DatabaseUtils.java | 2 +- .../lib/ddl/impl/CreateProcedure.java | 2 +- .../netbeans/lib/ddl/impl/CreateTrigger.java | 2 +- .../modules/db/explorer/DbDriverManager.java | 2 +- .../db/explorer/node/NodePropertySupport.java | 6 +- .../netbeans/modules/db/test/DBTestBase.java | 5 +- .../modules/derby/DerbyDatabasesImpl.java | 10 +- .../src/org/netbeans/test/db/util/DbUtil.java | 9 +- .../editor/bracesmatching/BraceToolTip.java | 2 +- .../modules/editor/fold/ui/FoldToolTip.java | 2 +- .../src/org/netbeans/editor/BaseKit.java | 14 +-- .../src/org/netbeans/editor/BaseTextUI.java | 11 +- .../src/org/netbeans/editor/ext/ExtKit.java | 2 +- .../html/editor/options/ui/FmtOptions.java | 13 +-- .../test/ide/CountingSecurityManager.java | 2 +- .../impl/indexing/RepositoryUpdater2Test.java | 4 +- .../project/libraries/LibrariesTestUtil.java | 2 +- .../modules/schema2beans/BaseBean.java | 2 +- .../modules/schema2beans/BeanProp.java | 2 +- .../modules/schema2beans/DOMBinding.java | 2 +- .../server/Selenium2ServerSupport.java | 2 +- .../ui/actions/BreakpointCustomizeAction.java | 2 +- .../palette/ActiveEditorDropProvider.java | 2 +- .../lexer/CreateRegistrationProcessor.java | 2 +- .../modules/xml/catalog/lib/Util.java | 16 +-- .../netbeans/modules/xml/tax/beans/Lib.java | 16 +-- .../modules/ant/debugger/StepTest.java | 4 +- .../deserializer/XMLGraphDeserializer.java | 13 ++- .../modules/dbschema/ColumnElementTest.java | 2 +- .../modules/form/CreationFactory.java | 4 +- .../org/netbeans/modules/form/FormLAF.java | 4 +- .../form/FormPropertyEditorManager.java | 2 +- .../form/GandalfPersistenceManager.java | 10 +- .../modules/form/PersistenceManager.java | 2 +- .../form/PersistenceObjectRegistry.java | 4 +- .../modules/form/RADComponentNode.java | 9 +- .../modules/form/actions/TestAction.java | 2 +- .../form/editors2/TableColumnModelEditor.java | 2 +- .../layoutsupport/AbstractLayoutSupport.java | 2 +- .../form/layoutsupport/LayoutNode.java | 8 +- .../layoutsupport/LayoutSupportRegistry.java | 22 ++-- .../delegates/GridBagLayoutSupport.java | 2 +- .../modules/form/menu/DragOperation.java | 4 +- .../action/EntityManagerGenerator.java | 4 +- .../persistence/jpqleditor/JPQLExecutor.java | 2 +- .../dbscript/GenerateScriptExecutor.java | 4 +- .../EntityManagerGenerationTestSupport.java | 4 +- .../infrastructure/ErrorHintsTestBase.java | 4 +- .../jrtfs/NBJRTFileSystem.java | 2 +- .../j2seplatform/queries/QueriesCache.java | 17 +-- .../java/source/indexing/APTUtils.java | 2 +- .../modules/java/ui/CategorySupport.java | 2 +- .../lib/jshell/agent/AgentWorker.java | 8 +- .../simplewizard/EnsureJavaFXPresent.java | 2 +- .../netbeans/modules/performance/Inst.java | 2 +- .../test/ide/PerfCountingSecurityManager.java | 2 +- .../scalability/AWTThreadFreeTest.java | 2 +- .../scalability/TabSwitchSpeedTest.java | 2 +- .../WhiteListImplementationBuilder.java | 8 +- .../generator/SAXGeneratorAbstractPanel.java | 6 +- .../systemoptions/SettingsRecognizer.java | 2 +- .../modules/php/editor/indent/FmtOptions.java | 4 +- .../src/org/netbeans/api/io/IOProvider.java | 2 +- .../core/netigso/NetigsoUsesSwingTest.java | 2 +- .../src/org/netbeans/core/osgi/Activator.java | 2 +- .../core/startup/layers/SystemFileSystem.java | 2 +- .../core/startup/ManifestSection.java | 2 +- .../layers/CountingSecurityManager.java | 2 +- .../core/windows/options/LafPanel.java | 6 +- .../view/ui/toolbars/ToolbarContainer.java | 2 +- .../editor/mimelookup/impl/SwitchLookup.java | 7 +- .../CreateRegistrationProcessor.java | 2 +- .../netbeans/modules/netbinox/AgentTest.java | 2 +- .../netbinox/CountingSecurityManager.java | 2 +- .../netbinox/NetigsoUsesSwingTest.java | 2 +- .../test/unit/src/org/netbeans/AgentTest.java | 2 +- .../src/org/netbeans/ModuleManagerTest.java | 109 ++++++++++-------- .../src/org/netbeans/swing/plaf/Startup.java | 8 +- .../modules/openide/awt/ActionProcessor.java | 2 +- .../openide/execution/NbClassLoaderTest.java | 2 +- .../propertysheet/IndexedPropertyEditor.java | 2 +- .../explorer/propertysheet/ModelProperty.java | 2 +- .../propertysheet/RendererFactory.java | 2 +- .../org/openide/loaders/XMLDataObject.java | 9 +- .../src/org/openide/nodes/BeanNode.java | 9 +- .../src/org/openide/nodes/TMUtil.java | 17 +-- .../src/org/openide/util/Lookup.java | 2 +- .../util/lookup/MetaInfServicesLookup.java | 2 +- .../util/lookup/AbstractLookupBaseHid.java | 2 +- .../openide/util/NbBundleProcessorTest.java | 24 ++-- .../src/org/openide/util/NbBundle.java | 2 +- .../netbeans/api/sendopts/CommandLine.java | 8 +- .../modules/sendopts/DefaultProcessor.java | 2 +- .../editor/formatter/FmtOptions.java | 4 +- .../netbeans/libs/graaljs/GraalJSTest2.java | 2 +- 120 files changed, 370 insertions(+), 567 deletions(-) diff --git a/contrib/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java b/contrib/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java index 5f928acc049b..5b1517cc246c 100644 --- a/contrib/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java +++ b/contrib/j2ee.jboss4/src/org/netbeans/modules/j2ee/jboss4/JBDeploymentFactory.java @@ -413,9 +413,9 @@ private DeploymentFactory getFactory(String instanceURL) { if(version!= null && "7".equals(version.getMajorNumber())) { Class c = loader.loadClass("org.jboss.as.ee.deployment.spi.factories.DeploymentFactoryImpl"); c.getMethod("register").invoke(null); - jbossFactory = (DeploymentFactory) c.newInstance();//NOI18N + jbossFactory = (DeploymentFactory) c.getDeclaredConstructor().newInstance();//NOI18N } else { - jbossFactory = (DeploymentFactory) loader.loadClass("org.jboss.deployment.spi.factories.DeploymentFactoryImpl").newInstance();//NOI18N + jbossFactory = (DeploymentFactory) loader.loadClass("org.jboss.deployment.spi.factories.DeploymentFactoryImpl").getDeclaredConstructor().newInstance();//NOI18N } diff --git a/enterprise/j2ee.dd.webservice/src/org/netbeans/modules/j2ee/dd/impl/webservices/CommonDDAccess.java b/enterprise/j2ee.dd.webservice/src/org/netbeans/modules/j2ee/dd/impl/webservices/CommonDDAccess.java index ca79217ff4ea..1411b9f8f165 100644 --- a/enterprise/j2ee.dd.webservice/src/org/netbeans/modules/j2ee/dd/impl/webservices/CommonDDAccess.java +++ b/enterprise/j2ee.dd.webservice/src/org/netbeans/modules/j2ee/dd/impl/webservices/CommonDDAccess.java @@ -58,7 +58,7 @@ public static BaseBean newBean(CommonDDBean parent, String beanName, String vers PACKAGE_PREFIX + version + DOT + beanName); - return (BaseBean) beanClass.newInstance(); + return (BaseBean) beanClass.getDeclaredConstructor().newInstance(); } catch (Exception e) { if (e instanceof ClassNotFoundException) diff --git a/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/common/CommonDDAccess.java b/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/common/CommonDDAccess.java index d26277440d24..5fd6d6d889a2 100644 --- a/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/common/CommonDDAccess.java +++ b/enterprise/j2ee.dd/src/org/netbeans/modules/j2ee/dd/impl/common/CommonDDAccess.java @@ -90,7 +90,7 @@ public static BaseBean newBean(CommonDDBean parent, String beanName, String pkgN pkgName + DOT + beanName); - return (BaseBean) beanClass.newInstance(); + return (BaseBean) beanClass.getDeclaredConstructor().newInstance(); } catch (Exception e) { if (e instanceof ClassNotFoundException) diff --git a/enterprise/j2ee.sun.appsrv/src/org/netbeans/modules/j2ee/sun/api/ServerLocationManager.java b/enterprise/j2ee.sun.appsrv/src/org/netbeans/modules/j2ee/sun/api/ServerLocationManager.java index c76606ddffd5..1908b09141e9 100644 --- a/enterprise/j2ee.sun.appsrv/src/org/netbeans/modules/j2ee/sun/api/ServerLocationManager.java +++ b/enterprise/j2ee.sun.appsrv/src/org/netbeans/modules/j2ee/sun/api/ServerLocationManager.java @@ -210,7 +210,7 @@ public static synchronized ClassLoader getNetBeansAndServerClassLoader(File plat try { data.cachedClassLoader =new ExtendedClassLoader( new Empty().getClass().getClassLoader()); updatePluginLoader( platformLocation, data.cachedClassLoader); - data.deploymentFactory = (DeploymentFactory) data.cachedClassLoader.loadClass("com.sun.enterprise.deployapi.SunDeploymentFactory").newInstance();//NOI18N + data.deploymentFactory = (DeploymentFactory) data.cachedClassLoader.loadClass("com.sun.enterprise.deployapi.SunDeploymentFactory").getDeclaredConstructor().newInstance();//NOI18N data.serverOnlyClassLoader = new ExtendedClassLoader(); updatePluginLoader(platformLocation, data.serverOnlyClassLoader); } catch (Exception ex2) { diff --git a/enterprise/j2ee.sun.dd/src/org/netbeans/modules/j2ee/sun/dd/api/DDProvider.java b/enterprise/j2ee.sun.dd/src/org/netbeans/modules/j2ee/sun/dd/api/DDProvider.java index 1d4452084358..be02763b51c8 100644 --- a/enterprise/j2ee.sun.dd/src/org/netbeans/modules/j2ee/sun/dd/api/DDProvider.java +++ b/enterprise/j2ee.sun.dd/src/org/netbeans/modules/j2ee/sun/dd/api/DDProvider.java @@ -472,7 +472,7 @@ public RootInterface newGraph(Class rootType, String version) { try { // Formerly invoked static 'createGraph()' method, but that is merely a wrapper // for the default constructor so we'll call it directly. - graphRoot = (SunBaseBean) vInfo.getImplClass().newInstance(); + graphRoot = (SunBaseBean) vInfo.getImplClass().getDeclaredConstructor().newInstance(); graphRoot.graphManager().setDoctype(vInfo.getPublicId(), vInfo.getSystemId()); Class proxyClass = vInfo.getProxyClass(); diff --git a/enterprise/j2ee.sun.dd/src/org/netbeans/modules/j2ee/sun/dd/impl/common/SunBaseBean.java b/enterprise/j2ee.sun.dd/src/org/netbeans/modules/j2ee/sun/dd/impl/common/SunBaseBean.java index 40843bff45ea..c2936c378fa9 100644 --- a/enterprise/j2ee.sun.dd/src/org/netbeans/modules/j2ee/sun/dd/impl/common/SunBaseBean.java +++ b/enterprise/j2ee.sun.dd/src/org/netbeans/modules/j2ee/sun/dd/impl/common/SunBaseBean.java @@ -223,7 +223,7 @@ public CommonDDBean cloneVersion(String version) { return (SunBaseBean) this.clone(); } - bean = (SunBaseBean) newBeanClass.newInstance(); + bean = (SunBaseBean) newBeanClass.getDeclaredConstructor().newInstance(); } catch(Exception e) { throw new IllegalArgumentException(e.getMessage(), e); } diff --git a/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/GenericTablePanel.java b/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/GenericTablePanel.java index 99ae13ed057a..e4e563fa22fa 100644 --- a/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/GenericTablePanel.java +++ b/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/share/configbean/customizers/common/GenericTablePanel.java @@ -238,7 +238,7 @@ private GenericTableDialogPanelAccessor internalGetDialogPanel() { GenericTableDialogPanelAccessor subPanel = null; try { - subPanel = (GenericTableDialogPanelAccessor) entryPanelClass.newInstance(); + subPanel = (GenericTableDialogPanelAccessor) entryPanelClass.getDeclaredConstructor().newInstance(); subPanel.init(getTableModel().getAppServerVersion(), GenericTablePanel.this.getWidth()*3/4, entryList, extraData); @@ -246,10 +246,7 @@ private GenericTableDialogPanelAccessor internalGetDialogPanel() { resourceBundle.getString("ACSN_POPUP_" + resourceBase)); // NOI18N ((JPanel) subPanel).getAccessibleContext().setAccessibleDescription( resourceBundle.getString("ACSD_POPUP_" + resourceBase)); // NOI18N - } catch(InstantiationException ex) { - // !PW Should never happen, but it's fatal for field editing if - // it does so what should exception should we throw? - } catch(IllegalAccessException ex) { + } catch(ReflectiveOperationException ex) { // !PW Should never happen, but it's fatal for field editing if // it does so what should exception should we throw? } diff --git a/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/validation/util/Utils.java b/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/validation/util/Utils.java index 3334ebc821c2..287f96af7181 100644 --- a/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/validation/util/Utils.java +++ b/enterprise/j2ee.sun.ddui/src/org/netbeans/modules/j2ee/sun/validation/util/Utils.java @@ -119,12 +119,8 @@ public Object createObject(String type) { Object object = null; try { Class classObject = Class.forName(type); - object = classObject.newInstance(); - } catch (InstantiationException e) { - System.out.println(e); - } catch (IllegalAccessException e) { - System.out.println(e); - } catch (ClassNotFoundException e) { + object = classObject.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException e) { System.out.println(e); } return object; @@ -142,10 +138,8 @@ public Object createObject(String type) { public Object createObject(Class classObject) { Object object = null; try { - object = classObject.newInstance(); - } catch (InstantiationException e) { - System.out.println(e); - } catch (IllegalAccessException e) { + object = classObject.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException e) { System.out.println(e); } return object; @@ -171,13 +165,7 @@ public Object createObject(Constructor constructor, object = constructor.newInstance(arguments); //System.out.println ("Object: " + object.toString()); return object; - } catch (InstantiationException e) { - System.out.println(e); - } catch (IllegalAccessException e) { - System.out.println(e); - } catch (IllegalArgumentException e) { - System.out.println(e); - } catch (InvocationTargetException e) { + } catch (ReflectiveOperationException e) { System.out.println(e); } return object; diff --git a/enterprise/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java b/enterprise/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java index cfb5e42a4464..04b70ec0e13e 100644 --- a/enterprise/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java +++ b/enterprise/j2eeserver/src/org/netbeans/modules/j2ee/deployment/impl/DeployOnSaveManager.java @@ -586,7 +586,7 @@ private void runJPDAAppReloaded() { ClassLoader reloadedClassLoader = customDefClassLoaders.get(reloadedPackageName); if (reloadedClassLoader != null) { Class reloadedClass = reloadedClassLoader.loadClass(reloadedClassName); - reloadedClass.getMethod("execute").invoke(reloadedClass.newInstance()); + reloadedClass.getMethod("execute").invoke(reloadedClass.getDeclaredConstructor().newInstance()); } } catch (Exception ex) { Exceptions.printStackTrace(ex); diff --git a/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/commands/WildflyClient.java b/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/commands/WildflyClient.java index c963e52d921d..9bd8eb9665f2 100644 --- a/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/commands/WildflyClient.java +++ b/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/commands/WildflyClient.java @@ -205,7 +205,7 @@ private String resolvePath(WildflyClassLoader cl, LinkedHashMap return modelNodeAsString(cl, readResult(cl, response)); } return ""; - } catch (InvocationTargetException | ClassNotFoundException | NoSuchMethodException | InstantiationException | IllegalAccessException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -272,7 +272,7 @@ public synchronized void shutdownServer(int timeout) throws IOException, Interru throw new IOException(ex); } close(); - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -304,7 +304,7 @@ public synchronized boolean isServerRunning(String homeDir, String configFile) { LOGGER.log(Level.FINE, null, ex.getTargetException()); close(); return false; - } catch (IllegalAccessException | ClassNotFoundException | InstantiationException | NoSuchMethodException | IOException | InterruptedException | ExecutionException ex) { + } catch (ReflectiveOperationException | IOException | InterruptedException | ExecutionException ex) { LOGGER.log(Level.FINE, null, ex); close(); return false; @@ -375,7 +375,7 @@ public Collection listAvailableModules() throws IOException { } } return modules; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -410,7 +410,7 @@ public Collection listWebModules(Lookup lookup) throws IOE } } return modules; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -452,7 +452,7 @@ public String getWebModuleURL(String webModuleName) throws IOException { } } return ""; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -487,7 +487,7 @@ public Collection listEJBModules(Lookup lookup) throws IOE } } return modules; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -505,7 +505,7 @@ public boolean startModule(WildflyTargetModuleID tmid) throws IOException { return true; } return false; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -519,7 +519,7 @@ public boolean startModule(String moduleName) throws IOException { Object enableDeployment = createOperation(cl, DEPLOYMENT_REDEPLOY_OPERATION, deploymentAddressModelNode); Object result = executeOnModelNode(cl, enableDeployment); return isSuccessfulOutcome(cl, result); - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -532,7 +532,7 @@ public boolean stopModule(String moduleName) throws IOException { // ModelNode Object enableDeployment = createOperation(cl, DEPLOYMENT_UNDEPLOY_OPERATION, deploymentAddressModelNode); return isSuccessfulOutcome(cl, executeOnModelNode(cl, enableDeployment)); - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -552,7 +552,7 @@ public boolean undeploy(String fileName) throws IOException { addModelNodeChild(cl, steps, createOperation(cl, DEPLOYMENT_UNDEPLOY_OPERATION, deploymentAddressModelNode)); addModelNodeChild(cl, steps, createRemoveOperation(cl, deploymentAddressModelNode)); return isSuccessfulOutcome(cl, executeOnModelNode(cl, undeploy)); - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -586,7 +586,7 @@ public boolean deploy(DeploymentContext deployment) throws IOException { // ModelNode Object result = executeOnModelNode(cl, deploy); return isSuccessfulOutcome(cl, result); - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -626,7 +626,7 @@ private Set listDatasources() throws IOException { } } return listedDatasources; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -655,7 +655,7 @@ private WildflyDatasource getDatasource(WildflyClassLoader cl, String name) thro modelNodeAsString(cl, getModelNodeChild(cl, datasource, "driver-class"))); } return null; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -672,7 +672,7 @@ public boolean removeDatasource(String name) throws IOException { // ModelNode Object response = executeOnModelNode(cl, operation); return (isSuccessfulOutcome(cl, response)); - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -703,7 +703,7 @@ private Pair getServerPaths(WildflyClassLoader cl) { } } return null; - } catch (IOException | ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (IOException | ReflectiveOperationException ex) { return null; } } @@ -755,7 +755,7 @@ public List listDestinationForDeployment(String deplo } } return destinations; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -788,7 +788,7 @@ public List listDestinations() throws IOException { } } return destinations; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -834,7 +834,7 @@ private List getJMSDestinationForServerDeployment(Str } } return listedDestinations; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -878,7 +878,7 @@ private List getJMSDestinationForServer(String server } } return listedDestinations; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -915,7 +915,7 @@ public boolean addMessageDestination(WildflyMessageDestination destination) thro } Object response = executeOnModelNode(cl, operation); return (isSuccessfulOutcome(cl, response)); - } catch (ClassNotFoundException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ex) { + } catch (ReflectiveOperationException ex) { return false; } } @@ -935,7 +935,7 @@ public boolean removeMessageDestination(WildflyMessageDestination destination) t Object operation = createRemoveOperation(cl, address); Object response = executeOnModelNode(cl, operation); return (isSuccessfulOutcome(cl, response)); - } catch (ClassNotFoundException | IllegalAccessException | NoSuchMethodException | InvocationTargetException ex) { + } catch (ReflectiveOperationException ex) { return false; } } @@ -984,7 +984,7 @@ private Collection listJaxrsResources(String deployment) t } } return jaxrsResources.values(); - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -1014,7 +1014,7 @@ public Collection listMailSessions() throws IOExcept } } return modules; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -1037,7 +1037,7 @@ public Collection listEarApplications(Lookup lookup) throws IOException { } } return modules; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -1080,7 +1080,7 @@ public Collection listEarSubModules(Lookup lookup, String jeeApplicationName) th } } return modules; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -1107,14 +1107,13 @@ public Collection listEJBForDeployment(Lookup lookup, String applicationName) th } return modules; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } private List listEJBs(WildflyClassLoader cl, - Object deployment, WildflyEjbComponentNode.Type type) throws IllegalAccessException, NoSuchMethodException, - InvocationTargetException { + Object deployment, WildflyEjbComponentNode.Type type) throws ReflectiveOperationException { List modules = new ArrayList<>(); if (modelNodeHasDefinedChild(cl, deployment, type.getPropertyName())) { List ejbs = modelNodeAsList(cl, getModelNodeChild(cl, deployment, type.getPropertyName())); @@ -1125,9 +1124,7 @@ private List listEJBs(WildflyClassLoader cl, return modules; } - private WildflySocket fillSocket(String name, boolean outBound) throws - ClassNotFoundException, NoSuchMethodException, - InvocationTargetException, IllegalAccessException, InstantiationException, IOException { + private WildflySocket fillSocket(String name, boolean outBound) throws ReflectiveOperationException, IOException { WildflyClassLoader cl = WildflyDeploymentFactory.getInstance().getWildFlyClassLoader(ip); WildflySocket socket = new WildflySocket(); LinkedHashMap values = new LinkedHashMap<>(); @@ -1187,7 +1184,7 @@ public Collection listConnectionFactories() throws IOE } } return connectionFactories; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -1224,14 +1221,12 @@ private Collection getConnectionFactoriesFor } } return listedConnectionFactories; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } - private WildflyConnectionFactory fillConnectionFactory(String name, Object configuration) throws - ClassNotFoundException, NoSuchMethodException, - InvocationTargetException, IllegalAccessException, InstantiationException, IOException { + private WildflyConnectionFactory fillConnectionFactory(String name, Object configuration) throws ReflectiveOperationException, IOException { WildflyClassLoader cl = WildflyDeploymentFactory.getInstance().getWildFlyClassLoader(ip); List properties = modelNodeAsPropertyList(cl, configuration); Map attributes = new HashMap<>(properties.size()); @@ -1245,9 +1240,7 @@ private WildflyConnectionFactory fillConnectionFactory(String name, Object confi return new WildflyConnectionFactory(attributes, name); } - private WildflyMailSessionResource fillMailSession(String name, Object mailSession) throws - ClassNotFoundException, NoSuchMethodException, - InvocationTargetException, IllegalAccessException, InstantiationException, IOException { + private WildflyMailSessionResource fillMailSession(String name, Object mailSession) throws ReflectiveOperationException, IOException { WildflyClassLoader cl = WildflyDeploymentFactory.getInstance().getWildFlyClassLoader(ip); Object configuration = modelNodeAsPropertyForValue(cl, mailSession); @@ -1307,7 +1300,7 @@ private String resolveExpression(String unresolvedString) throws IOException { return modelNodeAsString(cl, resolvedExpression); } return unresolvedString; - } catch (ClassNotFoundException | IllegalAccessException | NoSuchMethodException | InvocationTargetException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } @@ -1351,7 +1344,7 @@ public Collection listResourceAdapters() throws IOExcept } } return resourceAdapters; - } catch (ClassNotFoundException | NoSuchMethodException | InvocationTargetException | IllegalAccessException | InstantiationException ex) { + } catch (ReflectiveOperationException ex) { throw new IOException(ex); } } diff --git a/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/commands/WildflyManagementAPI.java b/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/commands/WildflyManagementAPI.java index 40e7a1df5094..7db923e80d65 100644 --- a/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/commands/WildflyManagementAPI.java +++ b/enterprise/javaee.wildfly/src/org/netbeans/modules/javaee/wildfly/ide/commands/WildflyManagementAPI.java @@ -49,8 +49,7 @@ public class WildflyManagementAPI { private static final int TIMEOUT = 1000; static Object createClient(WildflyClassLoader cl, Version version, final String serverAddress, final int serverPort, - final CallbackHandler handler) throws ClassNotFoundException, NoSuchMethodException, - IllegalAccessException, InvocationTargetException, NoSuchAlgorithmException, InstantiationException { + final CallbackHandler handler) throws ReflectiveOperationException, NoSuchAlgorithmException { Class clazz = cl.loadClass("org.jboss.as.controller.client.ModelControllerClient$Factory"); // NOI18N if (version.compareTo(WildflyPluginUtils.WILDFLY_26_0_0) >= 0) { Class configurationBuilderClazz = cl.loadClass("org.jboss.as.controller.client.ModelControllerClientConfiguration$Builder"); @@ -71,15 +70,13 @@ static Object createClient(WildflyClassLoader cl, Version version, final String return method.invoke(null, serverAddress, serverPort, handler, SSLContext.getDefault(), TIMEOUT); } - static void closeClient(WildflyClassLoader cl, Object client) throws ClassNotFoundException, NoSuchMethodException, - IllegalAccessException, InvocationTargetException { + static void closeClient(WildflyClassLoader cl, Object client) throws ReflectiveOperationException { Method method = client.getClass().getMethod("close", new Class[]{}); method.invoke(client, (Object[]) null); } // ModelNode - static Object createDeploymentPathAddressAsModelNode(WildflyClassLoader cl, String name) - throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + static Object createDeploymentPathAddressAsModelNode(WildflyClassLoader cl, String name) throws ReflectiveOperationException { Class paClazz = cl.loadClass("org.jboss.as.controller.PathAddress"); // NOI18N Class peClazz = cl.loadClass("org.jboss.as.controller.PathElement"); // NOI18N @@ -98,8 +95,7 @@ static Object createDeploymentPathAddressAsModelNode(WildflyClassLoader cl, Stri } // ModelNode - static Object createPathAddressAsModelNode(WildflyClassLoader cl, LinkedHashMap elements) - throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + static Object createPathAddressAsModelNode(WildflyClassLoader cl, LinkedHashMap elements) throws ReflectiveOperationException { Class paClazz = cl.loadClass("org.jboss.as.controller.PathAddress"); // NOI18N Class peClazz = cl.loadClass("org.jboss.as.controller.PathElement"); // NOI18N @@ -119,8 +115,7 @@ static Object createPathAddressAsModelNode(WildflyClassLoader cl, LinkedHashMap< } // ModelNode - static Object createOperation(WildflyClassLoader cl, Object name, Object modelNode) - throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException { + static Object createOperation(WildflyClassLoader cl, Object name, Object modelNode) throws ReflectiveOperationException { Class clazz = cl.loadClass("org.jboss.as.controller.client.helpers.Operations"); // NOI18N Class modelClazz = cl.loadClass("org.jboss.dmr.ModelNode"); // NOI18N Method method = clazz.getDeclaredMethod("createOperation", new Class[]{String.class, modelClazz}); @@ -128,8 +123,7 @@ static Object createOperation(WildflyClassLoader cl, Object name, Object modelNo } // ModelNode - static Object createReadResourceOperation(WildflyClassLoader cl, Object modelNode, boolean recursive, boolean runtime) - throws ClassNotFoundException, NoSuchMethodException, IllegalAccessException, InvocationTargetException, InstantiationException { + static Object createReadResourceOperation(WildflyClassLoader cl, Object modelNode, boolean recursive, boolean runtime) throws ReflectiveOperationException { Class clazz = cl.loadClass("org.jboss.as.controller.client.helpers.Operations"); // NOI18N Class modelClazz = cl.loadClass("org.jboss.dmr.ModelNode"); // NOI18N Method method = clazz.getDeclaredMethod("createReadResourceOperation", new Class[]{modelClazz, boolean.class}); @@ -139,8 +133,7 @@ static Object createReadResourceOperation(WildflyClassLoader cl, Object modelNod } // ModelNode - static Object createRemoveOperation(WildflyClassLoader cl, Object modelNode) throws ClassNotFoundException, - NoSuchMethodException, IllegalAccessException, InvocationTargetException { + static Object createRemoveOperation(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Class clazz = cl.loadClass("org.jboss.as.controller.client.helpers.Operations"); // NOI18N Class modelClazz = cl.loadClass("org.jboss.dmr.ModelNode"); // NOI18N Method method = clazz.getDeclaredMethod("createRemoveOperation", new Class[]{modelClazz}); @@ -148,8 +141,7 @@ static Object createRemoveOperation(WildflyClassLoader cl, Object modelNode) thr } // ModelNode - static Object createAddOperation(WildflyClassLoader cl, Object modelNode) throws ClassNotFoundException, - NoSuchMethodException, IllegalAccessException, InvocationTargetException { + static Object createAddOperation(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Class clazz = cl.loadClass("org.jboss.as.controller.client.helpers.Operations"); // NOI18N Class modelClazz = cl.loadClass("org.jboss.dmr.ModelNode"); // NOI18N Method method = clazz.getDeclaredMethod("createAddOperation", new Class[]{modelClazz}); @@ -157,8 +149,7 @@ static Object createAddOperation(WildflyClassLoader cl, Object modelNode) throws } // ModelNode - static Object readResult(WildflyClassLoader cl, Object modelNode) throws ClassNotFoundException, - NoSuchMethodException, IllegalAccessException, InvocationTargetException { + static Object readResult(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Class clazz = cl.loadClass("org.jboss.as.controller.client.helpers.Operations"); // NOI18N Class modelClazz = cl.loadClass("org.jboss.dmr.ModelNode"); // NOI18N Method method = clazz.getDeclaredMethod("readResult", new Class[]{modelClazz}); @@ -166,22 +157,19 @@ static Object readResult(WildflyClassLoader cl, Object modelNode) throws ClassNo } // ModelNode - static Object getModelNodeChild(WildflyClassLoader cl, Object modelNode, Object name) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static Object getModelNodeChild(WildflyClassLoader cl, Object modelNode, Object name) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("get", String.class); return method.invoke(modelNode, name); } // ModelNode - static Object getModelNodeChildAtIndex(WildflyClassLoader cl, Object modelNode, int index) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static Object getModelNodeChildAtIndex(WildflyClassLoader cl, Object modelNode, int index) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("get", int.class); return method.invoke(modelNode, index); } // ModelNode - static Object getModelNodeChildAtPath(WildflyClassLoader cl, Object modelNode, Object[] path) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static Object getModelNodeChildAtPath(WildflyClassLoader cl, Object modelNode, Object[] path) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("get", String[].class); Object array = Array.newInstance(String.class, path.length); for (int i = 0; i < path.length; i++) { @@ -191,36 +179,32 @@ static Object getModelNodeChildAtPath(WildflyClassLoader cl, Object modelNode, O } // ModelNode - static boolean modelNodeHasChild(WildflyClassLoader cl, Object modelNode, String child) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static boolean modelNodeHasChild(WildflyClassLoader cl, Object modelNode, String child) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("has", String.class); return (Boolean) method.invoke(modelNode, child); } // ModelNode - static boolean modelNodeHasDefinedChild(WildflyClassLoader cl, Object modelNode, String child) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static boolean modelNodeHasDefinedChild(WildflyClassLoader cl, Object modelNode, String child) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("hasDefined", String.class); return (Boolean) method.invoke(modelNode, child); } // ModelNode - static Object createModelNode(WildflyClassLoader cl) throws IllegalAccessException, ClassNotFoundException, InstantiationException { + static Object createModelNode(WildflyClassLoader cl) throws ReflectiveOperationException { Class modelClazz = cl.loadClass("org.jboss.dmr.ModelNode"); // NOI18N - return modelClazz.newInstance(); + return modelClazz.getDeclaredConstructor().newInstance(); } // ModelNode - static Object setModelNodeChildString(WildflyClassLoader cl, Object modelNode, Object value) throws IllegalAccessException, - ClassNotFoundException, InstantiationException, NoSuchMethodException, InvocationTargetException { + static Object setModelNodeChildString(WildflyClassLoader cl, Object modelNode, Object value) throws ReflectiveOperationException { assert value != null; Method method = modelNode.getClass().getMethod("set", String.class); return method.invoke(modelNode, value); } // ModelNode - static Object setModelNodeChild(WildflyClassLoader cl, Object modelNode, Object value) throws IllegalAccessException, - ClassNotFoundException, InstantiationException, NoSuchMethodException, InvocationTargetException { + static Object setModelNodeChild(WildflyClassLoader cl, Object modelNode, Object value) throws ReflectiveOperationException { assert value != null; Class modelClazz = cl.loadClass("org.jboss.dmr.ModelNode"); // NOI18N Method method = modelNode.getClass().getMethod("set", modelClazz); @@ -228,51 +212,44 @@ static Object setModelNodeChild(WildflyClassLoader cl, Object modelNode, Object } // ModelNode - static Object setModelNodeChild(WildflyClassLoader cl, Object modelNode, int value) throws IllegalAccessException, - ClassNotFoundException, InstantiationException, NoSuchMethodException, InvocationTargetException { + static Object setModelNodeChild(WildflyClassLoader cl, Object modelNode, int value) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("set", int.class); return method.invoke(modelNode, value); } // ModelNode - static Object setModelNodeChild(WildflyClassLoader cl, Object modelNode, boolean value) throws IllegalAccessException, - ClassNotFoundException, InstantiationException, NoSuchMethodException, InvocationTargetException { + static Object setModelNodeChild(WildflyClassLoader cl, Object modelNode, boolean value) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("set", boolean.class); return method.invoke(modelNode, value); } // ModelNode - static Object setModelNodeChildEmptyList(WildflyClassLoader cl, Object modelNode) throws IllegalAccessException, - ClassNotFoundException, InstantiationException, NoSuchMethodException, InvocationTargetException { + static Object setModelNodeChildEmptyList(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("setEmptyList", (Class[]) null); return method.invoke(modelNode, (Object[]) null); } // ModelNode - static Object setModelNodeChildBytes(WildflyClassLoader cl, Object modelNode, byte[] value) throws IllegalAccessException, - ClassNotFoundException, InstantiationException, NoSuchMethodException, InvocationTargetException { + static Object setModelNodeChildBytes(WildflyClassLoader cl, Object modelNode, byte[] value) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("set", byte[].class); return method.invoke(modelNode, value); } // ModelNode - static Object addModelNodeChild(WildflyClassLoader cl, Object modelNode, Object toAddModelNode) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException, ClassNotFoundException { + static Object addModelNodeChild(WildflyClassLoader cl, Object modelNode, Object toAddModelNode) throws ReflectiveOperationException { Class modelClazz = cl.loadClass("org.jboss.dmr.ModelNode"); // NOI18N Method method = modelNode.getClass().getMethod("add", modelClazz); return method.invoke(modelNode, toAddModelNode); } - static Object addModelNodeChildString(WildflyClassLoader cl, Object modelNode, String toAddModelNode) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException, ClassNotFoundException { + static Object addModelNodeChildString(WildflyClassLoader cl, Object modelNode, String toAddModelNode) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("add", String.class); return method.invoke(modelNode, toAddModelNode); } - static boolean modelNodeIsDefined(WildflyClassLoader cl, Object modelNode) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static boolean modelNodeIsDefined(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("isDefined", (Class[]) null); return (Boolean) method.invoke(modelNode, (Object[]) null); } @@ -283,60 +260,51 @@ static String modelNodeAsString(WildflyClassLoader cl, Object modelNode) throws return (String) method.invoke(modelNode, (Object[]) null); } - static String modelNodeAsPropertyForName(WildflyClassLoader cl, Object modelNode) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static String modelNodeAsPropertyForName(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("asProperty", (Class[]) null); Object property = method.invoke(modelNode, (Object[]) null); return getPropertyName(cl, property); } - static Object modelNodeAsPropertyForValue(WildflyClassLoader cl, Object modelNode) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static Object modelNodeAsPropertyForValue(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("asProperty", (Class[]) null); Object property = method.invoke(modelNode, (Object[]) null); return getPropertyValue(cl, property); } - static String getPropertyName(WildflyClassLoader cl, Object property) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static String getPropertyName(WildflyClassLoader cl, Object property) throws ReflectiveOperationException { Method method = property.getClass().getMethod("getName", (Class[]) null); return (String) method.invoke(property, (Object[]) null); } - static Object getPropertyValue(WildflyClassLoader cl, Object property) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static Object getPropertyValue(WildflyClassLoader cl, Object property) throws ReflectiveOperationException { Method method = property.getClass().getMethod("getValue", (Class[]) null); return method.invoke(property, (Object[]) null); } // List - static List modelNodeAsList(WildflyClassLoader cl, Object modelNode) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static List modelNodeAsList(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("asList", (Class[]) null); return (List) method.invoke(modelNode, (Object[]) null); } - static List modelNodeAsPropertyList(WildflyClassLoader cl, Object modelNode) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static List modelNodeAsPropertyList(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("asPropertyList", (Class[]) null); return (List) method.invoke(modelNode, (Object[]) null); } - static boolean modelNodeAsBoolean(WildflyClassLoader cl, Object modelNode) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static boolean modelNodeAsBoolean(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("asBoolean", (Class[]) null); return (boolean) method.invoke(modelNode, (Object[]) null); } - static int modelNodeAsInt(WildflyClassLoader cl, Object modelNode) throws IllegalAccessException, - NoSuchMethodException, InvocationTargetException { + static int modelNodeAsInt(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Method method = modelNode.getClass().getMethod("asInt", (Class[]) null); return (int) method.invoke(modelNode, (Object[]) null); } - static boolean isSuccessfulOutcome(WildflyClassLoader cl, Object modelNode) throws ClassNotFoundException, - NoSuchMethodException, IllegalAccessException, InvocationTargetException { + static boolean isSuccessfulOutcome(WildflyClassLoader cl, Object modelNode) throws ReflectiveOperationException { Class clazz = cl.loadClass("org.jboss.as.controller.client.helpers.Operations"); // NOI18N Class modelClazz = cl.loadClass("org.jboss.dmr.ModelNode"); // NOI18N Method method = clazz.getDeclaredMethod("isSuccessfulOutcome", modelClazz); diff --git a/enterprise/payara.eecommon/src/org/netbeans/modules/payara/eecommon/dd/loader/PayaraDDProvider.java b/enterprise/payara.eecommon/src/org/netbeans/modules/payara/eecommon/dd/loader/PayaraDDProvider.java index 5d26df031fb5..2fbaa2b370b4 100644 --- a/enterprise/payara.eecommon/src/org/netbeans/modules/payara/eecommon/dd/loader/PayaraDDProvider.java +++ b/enterprise/payara.eecommon/src/org/netbeans/modules/payara/eecommon/dd/loader/PayaraDDProvider.java @@ -475,7 +475,7 @@ public RootInterface newGraph(Class rootType, String version) { try { // Formerly invoked static 'createGraph()' method, but that is merely a wrapper // for the default constructor so we'll call it directly. - graphRoot = (SunBaseBean) vInfo.getImplClass().newInstance(); + graphRoot = (SunBaseBean) vInfo.getImplClass().getDeclaredConstructor().newInstance(); graphRoot.graphManager().setDoctype(vInfo.getPublicId(), vInfo.getSystemId()); Class proxyClass = vInfo.getProxyClass(); diff --git a/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/DeployOnSaveManager.java b/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/DeployOnSaveManager.java index bbd6fbb0a9bb..c75aa62c3e89 100644 --- a/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/DeployOnSaveManager.java +++ b/enterprise/payara.micro/src/org/netbeans/modules/fish/payara/micro/project/DeployOnSaveManager.java @@ -506,7 +506,7 @@ private void runJPDAAppReloaded() { ClassLoader reloadedClassLoader = customDefClassLoaders.get(reloadedPackageName); if (reloadedClassLoader != null) { Class reloadedClass = reloadedClassLoader.loadClass(reloadedClassName); - reloadedClass.getMethod("execute").invoke(reloadedClass.newInstance()); + reloadedClass.getMethod("execute").invoke(reloadedClass.getDeclaredConstructor().newInstance()); } } catch (Exception ex) { Exceptions.printStackTrace(ex); diff --git a/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/ui/ReflectionHelper.java b/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/ui/ReflectionHelper.java index 46adb5267fef..7432fd8c40bf 100644 --- a/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/ui/ReflectionHelper.java +++ b/enterprise/websvc.manager/src/org/netbeans/modules/websvc/manager/ui/ReflectionHelper.java @@ -24,7 +24,6 @@ import java.lang.reflect.Array; import java.lang.reflect.Constructor; import java.lang.reflect.Field; -import java.lang.reflect.InvocationTargetException; import java.lang.reflect.Method; import java.net.URLClassLoader; import java.util.ArrayList; @@ -169,7 +168,7 @@ public static Object makeGenericArray(String componentType, int length, ClassLoa } return Array.newInstance(componentClass, length); - } catch (Exception ex) { + } catch (ReflectiveOperationException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } } @@ -198,16 +197,8 @@ public static Object makeJAXBElement(String valueType, String localPart, Object Constructor jaxBConstr = jaxBClass.getConstructor(new Class[]{qNameClass, Class.class, Object.class}); return jaxBConstr.newInstance(qName, declaredClass, value); - } catch (ClassNotFoundException cnfe) { - throw new WebServiceReflectionException("ClassNotFoundException", cnfe); - } catch (InstantiationException ie) { - throw new WebServiceReflectionException("InstantiationException", ie); - } catch (IllegalAccessException iae) { - throw new WebServiceReflectionException("IllegalAccessException", iae); - } catch (InvocationTargetException ite) { - throw new WebServiceReflectionException("InvocationTargetException", ite); - } catch (NoSuchMethodException nsme) { - throw new WebServiceReflectionException("NoSuchMethodException", nsme); + } catch (ReflectiveOperationException ex) { + throw new WebServiceReflectionException(ex.getClass().getName(), ex); } finally { if (savedLoader != null) { Thread.currentThread().setContextClassLoader(savedLoader); @@ -222,7 +213,7 @@ public static Object makeEnumeration(String enumeration, ClassLoader loader) Class enumClass = Class.forName(enumeration, true, loader); return Enum.valueOf(enumClass, enumerationValues.get(0)); - } catch (Exception ex) { + } catch (ReflectiveOperationException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } } @@ -232,7 +223,7 @@ public static Object getEnumeration(String enumeration, String name, ClassLoader try { Class enumClass = Class.forName(enumeration, true, loader); return Enum.valueOf(enumClass, name); - } catch (Exception ex) { + } catch (ReflectiveOperationException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } } @@ -251,16 +242,16 @@ public static Object makeCollection(String className, ClassLoader loader) } else { Class cls = Class.forName(className, true, loader); if (cls.isInterface()) { - return new ArrayList(); + return new ArrayList<>(); } else { savedLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(loader); - Object result = cls.newInstance(); + Object result = cls.getDeclaredConstructor().newInstance(); return result; } } - } catch (Exception ex) { + } catch (ReflectiveOperationException | SecurityException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } finally { if (savedLoader != null) { @@ -279,15 +270,11 @@ public static Object makeComplexType(String typeName, ClassLoader loader) Thread.currentThread().setContextClassLoader(loader); Class typeClass = Class.forName(typeName, true, loader); - Object result = typeClass.newInstance(); + Object result = typeClass.getDeclaredConstructor().newInstance(); return result; - } catch (ClassNotFoundException cnfe) { - throw new WebServiceReflectionException("ClassNotFoundException", cnfe); - } catch (InstantiationException ie) { - throw new WebServiceReflectionException("InstantiationException", ie); - } catch (IllegalAccessException iae) { - throw new WebServiceReflectionException("IllegalAccessException", iae); + } catch (ReflectiveOperationException ex) { + throw new WebServiceReflectionException(ex.getClass().getName(), ex); } finally { if (savedLoader != null) { Thread.currentThread().setContextClassLoader(savedLoader); @@ -298,7 +285,7 @@ public static Object makeComplexType(String typeName, ClassLoader loader) public static List getEnumerationValues(String enumeration, ClassLoader loader) throws WebServiceReflectionException { try { - List enumerations = new ArrayList(); + List enumerations = new ArrayList<>(); Class enumerClass = Class.forName(enumeration, true, loader); Field[] fields = enumerClass.getDeclaredFields(); @@ -310,7 +297,7 @@ public static List getEnumerationValues(String enumeration, ClassLoader } return enumerations; - } catch (Exception ex) { + } catch (ClassNotFoundException | SecurityException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } } @@ -319,7 +306,7 @@ public static List getPropertyNames(String complexType, ClassLoader load throws WebServiceReflectionException { ClassLoader savedLoader = null; try { - List properties = new ArrayList(); + List properties = new ArrayList<>(); savedLoader = Thread.currentThread().getContextClassLoader(); Thread.currentThread().setContextClassLoader(loader); @@ -341,12 +328,11 @@ public static List getPropertyNames(String complexType, ClassLoader load properties.add(props[i]); } } - } catch (Exception ex) { - } + } catch (ReflectiveOperationException | SecurityException ex) {} } return properties; - } catch (Exception ex) { + } catch (ClassNotFoundException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } finally { if (savedLoader != null) { @@ -380,7 +366,7 @@ public static String getPropertyType(String type, String propName, ClassLoader l } return TypeUtil.typeToString(method.getGenericReturnType()); - } catch (Exception ex) { + } catch (ReflectiveOperationException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } finally { if (savedLoader != null) { @@ -393,7 +379,7 @@ public static Object getHolderValue(Object holder) throws WebServiceReflectionEx try { Field valueField = holder.getClass().getField("value"); // NO18N return valueField.get(holder); - } catch (Exception ex) { + } catch (ReflectiveOperationException | SecurityException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } } @@ -402,7 +388,7 @@ public static void setHolderValue(Object holder, Object value) throws WebService try { Field valueField = holder.getClass().getField("value"); // NO18N valueField.set(holder, value); - } catch (Exception ex) { + } catch (ReflectiveOperationException | SecurityException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } } @@ -411,7 +397,7 @@ public static Object getJAXBElementValue(Object jaxBElement) throws WebServiceRe try { Method m = jaxBElement.getClass().getMethod("getValue", new Class[0]); // NOI18N return m.invoke(jaxBElement); - } catch (Exception ex) { + } catch (ReflectiveOperationException | SecurityException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } } @@ -423,7 +409,7 @@ public static String getQNameLocalPart(Object jaxBElement) throws WebServiceRefl Method getLocalPart = qName.getClass().getMethod("getLocalPart", new Class[0]); // NOI18N return (String) getLocalPart.invoke(qName); - } catch (Exception ex) { + } catch (ReflectiveOperationException | SecurityException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } } @@ -432,7 +418,7 @@ public static void setJAXBElementValue(Object jaxBElement, Object value) throws try { Method m = jaxBElement.getClass().getMethod("setValue", new Class[]{Object.class}); // NOI18N m.invoke(jaxBElement, value); - } catch (Exception ex) { + } catch (ReflectiveOperationException | SecurityException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } } @@ -461,7 +447,7 @@ public static boolean isPropertySettable(String className, String propName, Clas } return false; - } catch (Exception ex) { + } catch (ClassNotFoundException | SecurityException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } finally { if (savedLoader != null) { @@ -508,14 +494,8 @@ public static void setPropertyValue(Object objValue, String propName, Object[] args = new Object[]{propValue}; method.invoke(objValue, args); - } catch (ClassNotFoundException cnfe) { - throw new WebServiceReflectionException("ClassNotFoundException", cnfe); - } catch (NoSuchMethodException nsme) { - throw new WebServiceReflectionException("NoSuchMethodException", nsme); - } catch (IllegalAccessException iae) { - throw new WebServiceReflectionException("IllegalAccessException", iae); - } catch (InvocationTargetException ite) { - throw new WebServiceReflectionException("InvocationTargetException", ite); + } catch (ReflectiveOperationException ex) { + throw new WebServiceReflectionException(ex.getClass().getName(), ex); } } finally { @@ -555,7 +535,7 @@ public static Object getPropertyValue(Object obj, String propertyName, } return method.invoke(obj, new Object[0]); - } catch (Exception ex) { + } catch (ReflectiveOperationException ex) { throw new WebServiceReflectionException(ex.getClass().getName(), ex); } } finally { @@ -654,7 +634,7 @@ public static Object callMethodWithParams( Object serviceObject; if (isRPCEncoded) { - serviceObject = serviceClass.newInstance(); + serviceObject = serviceClass.getDeclaredConstructor().newInstance(); } else { Constructor constructor = serviceClass.getConstructor(java.net.URL.class, javax.xml.namespace.QName.class); serviceObject = constructor.newInstance(jarWsdlUrl, name); @@ -665,19 +645,10 @@ public static Object callMethodWithParams( classInstance = getPort.invoke(serviceObject); clazz = classInstance.getClass(); - } catch (InstantiationException ia) { - throw new WebServiceReflectionException("InstantiationExceptoin", ia); - } catch (IllegalAccessException iae) { - throw new WebServiceReflectionException("IllegalAccessException", iae); - } catch (NoSuchMethodException nsme) { - throw new WebServiceReflectionException("NoSuchMethodException", nsme); - } catch (InvocationTargetException ite) { - throw new WebServiceReflectionException("InvocationTargetException", ite); - } catch (IOException ioe) { - throw new WebServiceReflectionException("IOException", ioe); + } catch (ReflectiveOperationException | IOException ex) { + throw new WebServiceReflectionException(ex.getClass().getName(), ex); } - Method method = null; Object[] paramValues = inParamList.toArray(); /** @@ -734,14 +705,8 @@ public static Object callMethodWithParams( Object returnObject = null; try { returnObject = method.invoke(classInstance, paramValues); - } catch (InvocationTargetException ite) { - throw new WebServiceReflectionException("InvocationTargetException", ite); - } catch (IllegalArgumentException ia) { - throw new WebServiceReflectionException("IllegalArgumentException", ia); - } catch (IllegalAccessException iae) { - throw new WebServiceReflectionException("IllegalAccessException", iae); - } catch (Exception e) { - throw new WebServiceReflectionException("Exception", e); + } catch (ReflectiveOperationException ex) { + throw new WebServiceReflectionException(ex.getClass().getName(), ex); } return returnObject; diff --git a/extide/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/BridgeImpl.java b/extide/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/BridgeImpl.java index d8f972b9bf56..4f0b4d085b53 100644 --- a/extide/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/BridgeImpl.java +++ b/extide/o.apache.tools.ant.module/src-bridge/org/apache/tools/ant/module/bridge/impl/BridgeImpl.java @@ -120,7 +120,7 @@ public boolean toBoolean(String val) { public String[] getEnumeratedValues(Class c) { if (EnumeratedAttribute.class.isAssignableFrom(c)) { try { - return ((EnumeratedAttribute)c.newInstance()).getValues(); + return ((EnumeratedAttribute)c.getDeclaredConstructor().newInstance()).getValues(); } catch (Exception e) { AntModule.err.notify(ErrorManager.INFORMATIONAL, e); } diff --git a/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/bridge/AntBridge.java b/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/bridge/AntBridge.java index 935700aef957..9b0459ccfd96 100644 --- a/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/bridge/AntBridge.java +++ b/extide/o.apache.tools.ant.module/src/org/apache/tools/ant/module/bridge/AntBridge.java @@ -307,7 +307,7 @@ private static AntInstance createAntInstance() { } } // in classpath mode, these checks do not apply Map cDCLs = createCustomDefClassLoaders(main); - return new AntInstance(classPathToString(mainClassPath), main, bridgeLoader, impl.newInstance(), createCustomDefs(cDCLs), cDCLs); + return new AntInstance(classPathToString(mainClassPath), main, bridgeLoader, impl.getDeclaredConstructor().newInstance(), createCustomDefs(cDCLs), cDCLs); } catch (Exception e) { return fallback(e); } catch (LinkageError e) { diff --git a/harness/jellytools.platform/src/org/netbeans/jellytools/actions/Action.java b/harness/jellytools.platform/src/org/netbeans/jellytools/actions/Action.java index 8aa364c31cd1..3838a781e4c7 100644 --- a/harness/jellytools.platform/src/org/netbeans/jellytools/actions/Action.java +++ b/harness/jellytools.platform/src/org/netbeans/jellytools/actions/Action.java @@ -782,14 +782,14 @@ public void run() { } else if (javax.swing.Action.class.isAssignableFrom(systemActionClass)) { // action implements javax.swing.Action try { - ((javax.swing.Action) systemActionClass.newInstance()).actionPerformed( + ((javax.swing.Action) systemActionClass.getDeclaredConstructor().newInstance()).actionPerformed( new ActionEvent(new Container(), 0, null)); } catch (Exception e) { throw new JemmyException("Exception when trying to create instance of action \"" + systemActionClass.getName() + "\".", e); } } else if (ActionListener.class.isAssignableFrom(systemActionClass)) { try { - ((ActionListener) systemActionClass.newInstance()).actionPerformed( + ((ActionListener) systemActionClass.getDeclaredConstructor().newInstance()).actionPerformed( new ActionEvent(new Container(), 0, null)); } catch (Exception e) { throw new JemmyException("Exception when trying to create instance of action \"" + systemActionClass.getName() + "\".", e); diff --git a/harness/jellytools.platform/src/org/netbeans/jellytools/actions/ActionNoBlock.java b/harness/jellytools.platform/src/org/netbeans/jellytools/actions/ActionNoBlock.java index b4720f7e9a5b..f401b6778156 100644 --- a/harness/jellytools.platform/src/org/netbeans/jellytools/actions/ActionNoBlock.java +++ b/harness/jellytools.platform/src/org/netbeans/jellytools/actions/ActionNoBlock.java @@ -313,7 +313,7 @@ public void run() { } else { // action implements javax.swing.Action try { - ((javax.swing.Action) systemActionClass.newInstance()).actionPerformed( + ((javax.swing.Action) systemActionClass.getDeclaredConstructor().newInstance()).actionPerformed( new ActionEvent(new Container(), 0, null)); } catch (Exception e) { throw new JemmyException("Exception when trying to create instance of action \"" + systemActionClass.getName() + "\".", e); diff --git a/harness/nbjunit/src/org/netbeans/junit/Manager.java b/harness/nbjunit/src/org/netbeans/junit/Manager.java index a7bc291fd2e5..f401cac8fe35 100644 --- a/harness/nbjunit/src/org/netbeans/junit/Manager.java +++ b/harness/nbjunit/src/org/netbeans/junit/Manager.java @@ -140,7 +140,7 @@ protected static Diff instantiateDiffImpl(String diffImplName) { // instantiate the diff class clazz = Class.forName(diffImplName); - diffImpl = clazz.newInstance(); + diffImpl = clazz.getDeclaredConstructor().newInstance(); if (diffImpl instanceof Diff) { impl = (Diff) diffImpl; diff --git a/harness/nbjunit/src/org/netbeans/junit/NbModuleSuite.java b/harness/nbjunit/src/org/netbeans/junit/NbModuleSuite.java index 3aee9ed044d4..a4a80ef5d6b2 100644 --- a/harness/nbjunit/src/org/netbeans/junit/NbModuleSuite.java +++ b/harness/nbjunit/src/org/netbeans/junit/NbModuleSuite.java @@ -929,7 +929,7 @@ private void runInRuntimeContainer(TestResult result) throws Exception { }else{ Class sndClazz = testLoader.loadClass(item.clazz.getName()).asSubclass(Test.class); - toRun.addTest(sndClazz.newInstance()); + toRun.addTest(sndClazz.getDeclaredConstructor().newInstance()); } } diff --git a/ide/api.debugger/src/org/netbeans/api/debugger/Properties.java b/ide/api.debugger/src/org/netbeans/api/debugger/Properties.java index 3f5fc8f7bd40..8a9fcf794d71 100644 --- a/ide/api.debugger/src/org/netbeans/api/debugger/Properties.java +++ b/ide/api.debugger/src/org/netbeans/api/debugger/Properties.java @@ -1272,14 +1272,8 @@ public Collection getCollection (String propertyName, Collection defaultValue) { } Collection c; try { - c = (Collection) Class.forName (typeID.substring (2)).newInstance (); - } catch (ClassNotFoundException ex) { - LOG.log(Level.WARNING, ex.getLocalizedMessage(), ex); - return defaultValue; - } catch (InstantiationException ex) { - LOG.log(Level.WARNING, ex.getLocalizedMessage(), ex); - return defaultValue; - } catch (IllegalAccessException ex) { + c = (Collection) Class.forName(typeID.substring(2)).getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage(), ex); return defaultValue; } @@ -1338,14 +1332,8 @@ public Map getMap (String propertyName, Map defaultValue) { } Map m; try { - m = (Map) Class.forName (typeID.substring (2)).newInstance (); - } catch (ClassNotFoundException ex) { - LOG.log(Level.WARNING, ex.getLocalizedMessage(), ex); - return defaultValue; - } catch (InstantiationException ex) { - LOG.log(Level.WARNING, ex.getLocalizedMessage(), ex); - return defaultValue; - } catch (IllegalAccessException ex) { + m = (Map) Class.forName(typeID.substring(2)).getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException ex) { LOG.log(Level.WARNING, ex.getLocalizedMessage(), ex); return defaultValue; } diff --git a/ide/api.debugger/src/org/netbeans/spi/debugger/ContextAwareSupport.java b/ide/api.debugger/src/org/netbeans/spi/debugger/ContextAwareSupport.java index f14f7d2fc75b..90f233e7d86f 100644 --- a/ide/api.debugger/src/org/netbeans/spi/debugger/ContextAwareSupport.java +++ b/ide/api.debugger/src/org/netbeans/spi/debugger/ContextAwareSupport.java @@ -111,7 +111,7 @@ public static Object createInstance(String service, ContextProvider context) { } } if (o == null) - o = cls.newInstance (); + o = cls.getDeclaredConstructor().newInstance(); if (Logger.getLogger(ContextAwareSupport.class.getName()).isLoggable(Level.FINE)) { Logger.getLogger(ContextAwareSupport.class.getName()).fine("instance "+o+" created."); } @@ -121,7 +121,7 @@ public static Object createInstance(String service, ContextProvider context) { Exceptions.attachMessage( e, "The service "+service+" not found.")); - } catch (InstantiationException e) { + } catch (InstantiationException | NoSuchMethodException e) { Exceptions.printStackTrace( Exceptions.attachMessage( e, diff --git a/ide/db.core/test/unit/src/org/netbeans/modules/db/sql/execute/ui/util/DbUtil.java b/ide/db.core/test/unit/src/org/netbeans/modules/db/sql/execute/ui/util/DbUtil.java index d7e2959dc621..04630646090b 100644 --- a/ide/db.core/test/unit/src/org/netbeans/modules/db/sql/execute/ui/util/DbUtil.java +++ b/ide/db.core/test/unit/src/org/netbeans/modules/db/sql/execute/ui/util/DbUtil.java @@ -55,7 +55,7 @@ public static Connection createConnection(Properties p,File[] f) throws Exceptio URL[] driverURLs=(URL[])list.toArray(new URL[0]); URLClassLoader l = new URLClassLoader(driverURLs); Class c = Class.forName(driver_name, true, l); - Driver driver=(Driver)c.newInstance(); + Driver driver=(Driver)c.getDeclaredConstructor().newInstance(); Connection con=driver.connect(url,p); return con; } diff --git a/ide/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImpl.java b/ide/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImpl.java index 210f3ee83124..cf7701c2627c 100644 --- a/ide/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImpl.java +++ b/ide/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/spi/DBConnectionProviderImpl.java @@ -89,25 +89,17 @@ public Connection getConnection(DatabaseConnection dbConn) { TestCaseContext context = DbUtil.getContext(); File[] jars = context.getJars(); - ArrayList list = new java.util.ArrayList(); + ArrayList list = new ArrayList<>(); for (int i = 0; i < jars.length; i++) { list.add(jars[i].toURI().toURL()); } URL[] driverURLs = list.toArray(new URL[0]); URLClassLoader l = new URLClassLoader(driverURLs); Class c = Class.forName(driver, true, l); - Driver drv = (Driver) c.newInstance(); + Driver drv = (Driver) c.getDeclaredConstructor().newInstance(); Connection con = drv.connect(url, prop); return con; - } catch (SQLException ex) { - Exceptions.printStackTrace(ex); - } catch (InstantiationException ex) { - Exceptions.printStackTrace(ex); - } catch (IllegalAccessException ex) { - Exceptions.printStackTrace(ex); - } catch (ClassNotFoundException ex) { - Exceptions.printStackTrace(ex); - } catch (MalformedURLException ex) { + } catch (ReflectiveOperationException | SQLException | MalformedURLException ex) { Exceptions.printStackTrace(ex); } return null; diff --git a/ide/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java b/ide/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java index 638db47b9106..c20c69933620 100644 --- a/ide/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java +++ b/ide/db.dataview/test/unit/src/org/netbeans/modules/db/dataview/util/DbUtil.java @@ -292,7 +292,7 @@ private static Connection getConnection(JDBCDriver drv, String driverName, Strin // get the driver jar files and load them manually URL[] urls = drv.getURLs(); ClassLoader cl = new URLClassLoader(urls, Thread.currentThread().getContextClassLoader()); - newDriverClass = (Driver) cl.loadClass(driverName).newInstance(); + newDriverClass = (Driver) cl.loadClass(driverName).getDeclaredConstructor().newInstance(); Properties prop = new Properties(); prop.setProperty("user", username); prop.setProperty("password", password); diff --git a/ide/db.mysql/src/org/netbeans/modules/db/mysql/util/DatabaseUtils.java b/ide/db.mysql/src/org/netbeans/modules/db/mysql/util/DatabaseUtils.java index f3928d01e015..d73733ad9db8 100644 --- a/ide/db.mysql/src/org/netbeans/modules/db/mysql/util/DatabaseUtils.java +++ b/ide/db.mysql/src/org/netbeans/modules/db/mysql/util/DatabaseUtils.java @@ -129,7 +129,7 @@ public static Driver getDriver() throws DatabaseException { try { ClassLoader driverLoader = new DriverClassLoader(jdbcDriver); driver = (Driver)Class.forName(jdbcDriver.getClassName(), - true, driverLoader).newInstance(); + true, driverLoader).getDeclaredConstructor().newInstance(); } catch ( Exception e ) { DatabaseException dbe = new DatabaseException( Utils.getMessage( diff --git a/ide/db/libsrc/org/netbeans/lib/ddl/impl/CreateProcedure.java b/ide/db/libsrc/org/netbeans/lib/ddl/impl/CreateProcedure.java index d304c74c9a9e..3be56c511d63 100644 --- a/ide/db/libsrc/org/netbeans/lib/ddl/impl/CreateProcedure.java +++ b/ide/db/libsrc/org/netbeans/lib/ddl/impl/CreateProcedure.java @@ -118,7 +118,7 @@ public Argument createArgument(String name, int type, int datatype) new String[] {tname})); Class typeclass = Class.forName((String)typemap.get("Class")); // NOI18N String format = (String)typemap.get("Format"); // NOI18N - ProcedureArgument arg = (ProcedureArgument)typeclass.newInstance(); + ProcedureArgument arg = (ProcedureArgument)typeclass.getDeclaredConstructor().newInstance(); arg.setName(name); arg.setType(type); arg.setDataType(datatype); diff --git a/ide/db/libsrc/org/netbeans/lib/ddl/impl/CreateTrigger.java b/ide/db/libsrc/org/netbeans/lib/ddl/impl/CreateTrigger.java index 724810d569a5..a529fcc695ff 100644 --- a/ide/db/libsrc/org/netbeans/lib/ddl/impl/CreateTrigger.java +++ b/ide/db/libsrc/org/netbeans/lib/ddl/impl/CreateTrigger.java @@ -163,7 +163,7 @@ public TriggerEvent createTriggerEvent(int when, String columnname) new String[] {tname})); Class typeclass = Class.forName((String)typemap.get("Class")); // NOI18N String format = (String)typemap.get("Format"); // NOI18N - TriggerEvent evt = (TriggerEvent)typeclass.newInstance(); + TriggerEvent evt = (TriggerEvent)typeclass.getDeclaredConstructor().newInstance(); Map temap = (Map)props.get("TriggerEventMap"); // NOI18N evt.setName(TriggerEvent.getName(when)); evt.setColumn(columnname); diff --git a/ide/db/src/org/netbeans/modules/db/explorer/DbDriverManager.java b/ide/db/src/org/netbeans/modules/db/explorer/DbDriverManager.java index d70c1a9440b6..a361378f6119 100644 --- a/ide/db/src/org/netbeans/modules/db/explorer/DbDriverManager.java +++ b/ide/db/src/org/netbeans/modules/db/explorer/DbDriverManager.java @@ -202,7 +202,7 @@ public Driver getDriver(JDBCDriver jdbcDriver) throws SQLException { ClassLoader l = getClassLoader(jdbcDriver); Object driver; try { - driver = Class.forName(jdbcDriver.getClassName(), true, l).newInstance(); + driver = Class.forName(jdbcDriver.getClassName(), true, l).getDeclaredConstructor().newInstance(); } catch (Exception e) { SQLException sqlex = createDriverNotFoundException(); sqlex.initCause(e); diff --git a/ide/db/src/org/netbeans/modules/db/explorer/node/NodePropertySupport.java b/ide/db/src/org/netbeans/modules/db/explorer/node/NodePropertySupport.java index 1c916e01a0bb..a59e6368dbb1 100644 --- a/ide/db/src/org/netbeans/modules/db/explorer/node/NodePropertySupport.java +++ b/ide/db/src/org/netbeans/modules/db/explorer/node/NodePropertySupport.java @@ -73,15 +73,13 @@ public PropertyEditor getPropertyEditor() { result = (PropertyEditor) potentialEditor; } else if (potentialEditor instanceof Class) { try { - potentialEditor = ((Class) potentialEditor).newInstance(); + potentialEditor = ((Class) potentialEditor).getDeclaredConstructor().newInstance(); if (!(potentialEditor instanceof PropertyEditor)) { throw new IllegalArgumentException( "Editor class does not derive from property editor"); //NOI18N } return (PropertyEditor) potentialEditor; - } catch (InstantiationException ex) { - throw new RuntimeException(ex); - } catch (IllegalAccessException ex) { + } catch (ReflectiveOperationException ex) { throw new RuntimeException(ex); } } diff --git a/ide/db/test/unit/src/org/netbeans/modules/db/test/DBTestBase.java b/ide/db/test/unit/src/org/netbeans/modules/db/test/DBTestBase.java index bc57c8a72992..567fae67c240 100644 --- a/ide/db/test/unit/src/org/netbeans/modules/db/test/DBTestBase.java +++ b/ide/db/test/unit/src/org/netbeans/modules/db/test/DBTestBase.java @@ -30,10 +30,7 @@ import java.sql.SQLException; import java.util.Collection; import java.util.Properties; -import java.util.logging.Filter; -import java.util.logging.Handler; import java.util.logging.Level; -import java.util.logging.LogRecord; import java.util.logging.Logger; import org.netbeans.api.db.explorer.ConnectionManager; import org.netbeans.api.db.explorer.DatabaseConnection; @@ -697,7 +694,7 @@ private void createDBProvider() { private Driver getDriver() throws Exception { if (driver == null) { URLClassLoader driverLoader = new URLClassLoader(new URL[]{new URL(driverJar)}); - driver = (Driver)driverLoader.loadClass(driverClassName).newInstance(); + driver = (Driver)driverLoader.loadClass(driverClassName).getDeclaredConstructor().newInstance(); } return driver; diff --git a/ide/derby/src/org/netbeans/modules/derby/DerbyDatabasesImpl.java b/ide/derby/src/org/netbeans/modules/derby/DerbyDatabasesImpl.java index 2ffdc13fc8cc..a06ccf96f7e5 100644 --- a/ide/derby/src/org/netbeans/modules/derby/DerbyDatabasesImpl.java +++ b/ide/derby/src/org/netbeans/modules/derby/DerbyDatabasesImpl.java @@ -552,14 +552,8 @@ private Driver loadDerbyNetDriver() throws DatabaseException, IllegalStateExcep URL[] driverURLs = new URL[] { derbyClient.toURI().toURL() }; // NOI18N DbURLClassLoader l = new DbURLClassLoader(driverURLs); Class c = Class.forName(DerbyOptions.DRIVER_CLASS_NET, true, l); - return (Driver)c.newInstance(); - } catch (MalformedURLException e) { - exception = e; - } catch (IllegalAccessException e) { - exception = e; - } catch (ClassNotFoundException e) { - exception = e; - } catch (InstantiationException e) { + return (Driver)c.getDeclaredConstructor().newInstance(); + } catch (MalformedURLException | ReflectiveOperationException e) { exception = e; } if (exception != null) { diff --git a/ide/derby/test/qa-functional/src/org/netbeans/test/db/util/DbUtil.java b/ide/derby/test/qa-functional/src/org/netbeans/test/db/util/DbUtil.java index 35bbaf4da026..d63a16fdc5d8 100644 --- a/ide/derby/test/qa-functional/src/org/netbeans/test/db/util/DbUtil.java +++ b/ide/derby/test/qa-functional/src/org/netbeans/test/db/util/DbUtil.java @@ -20,6 +20,7 @@ package org.netbeans.test.db.util; import java.io.File; +import java.lang.reflect.InvocationTargetException; import java.net.MalformedURLException; import java.net.URL; import java.sql.Connection; @@ -42,10 +43,10 @@ public static Connection createDerbyConnection(String dbURL) { File clientJar = new File(location, "lib/derbyclient.jar"); Connection con = null; try { - System.out.println("> Creating Derby connection using: "+clientJar.toURL()); - URL[] driverURLs = new URL[]{clientJar.toURL()}; + System.out.println("> Creating Derby connection using: "+clientJar.toURI().toURL()); + URL[] driverURLs = new URL[]{clientJar.toURI().toURL()}; DbURLClassLoader loader = new DbURLClassLoader(driverURLs); - Driver driver = (Driver) Class.forName(DRIVER_CLASS_NAME, true, loader).newInstance(); + Driver driver = (Driver) Class.forName(DRIVER_CLASS_NAME, true, loader).getDeclaredConstructor().newInstance(); con = driver.connect(dbURL, null); } catch (MalformedURLException ex) { Exceptions.attachMessage(ex, "Cannot convert to URL: "+clientJar); @@ -53,7 +54,7 @@ public static Connection createDerbyConnection(String dbURL) { } catch (SQLException ex) { Exceptions.attachMessage(ex, "Cannot conect to: "+dbURL); Exceptions.printStackTrace(ex); - } catch (InstantiationException ex) { + } catch (InstantiationException | NoSuchMethodException | InvocationTargetException ex) { Exceptions.attachMessage(ex, "Cannot instantiate: "+DRIVER_CLASS_NAME+" from: "+clientJar); Exceptions.printStackTrace(ex); } catch (IllegalAccessException ex) { diff --git a/ide/editor.bracesmatching/src/org/netbeans/modules/editor/bracesmatching/BraceToolTip.java b/ide/editor.bracesmatching/src/org/netbeans/modules/editor/bracesmatching/BraceToolTip.java index 951734c2e08d..d48e4e647d00 100644 --- a/ide/editor.bracesmatching/src/org/netbeans/modules/editor/bracesmatching/BraceToolTip.java +++ b/ide/editor.bracesmatching/src/org/netbeans/modules/editor/bracesmatching/BraceToolTip.java @@ -70,7 +70,7 @@ private void addGlyphGutter(JTextComponent jtx) { try { clazz = Class.forName("org.netbeans.editor.GlyphGutter", true, cls); // NOI18N // get the factory instance - Object o = clazz.newInstance(); + Object o = clazz.getDeclaredConstructor().newInstance(); Method m = clazz.getDeclaredMethod("createSideBar", JTextComponent.class); // NOI18N gutter = (JComponent)m.invoke(o, jtx); } catch (IllegalArgumentException ex) { diff --git a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldToolTip.java b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldToolTip.java index fee39f733b7d..e4d4ee04e233 100644 --- a/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldToolTip.java +++ b/ide/editor.fold.nbui/src/org/netbeans/modules/editor/fold/ui/FoldToolTip.java @@ -92,7 +92,7 @@ private void addGlyphGutter(JTextComponent jtx) { clazz = Class.forName("org.netbeans.editor.GlyphGutter", true, cls); // NOI18N editorUiClass = Class.forName("org.netbeans.editor.EditorUI", true, cls); // NOI18N // get the factory instance - Object o = clazz.newInstance(); + Object o = clazz.getDeclaredConstructor().newInstance(); Method m = clazz.getDeclaredMethod("createSideBar", JTextComponent.class); // NOI18N gutter = (JComponent)m.invoke(o, jtx); } catch (IllegalArgumentException ex) { diff --git a/ide/editor.lib/src/org/netbeans/editor/BaseKit.java b/ide/editor.lib/src/org/netbeans/editor/BaseKit.java index 80814a961de1..bfd14e37bd2d 100644 --- a/ide/editor.lib/src/org/netbeans/editor/BaseKit.java +++ b/ide/editor.lib/src/org/netbeans/editor/BaseKit.java @@ -34,7 +34,6 @@ import java.util.Iterator; import java.util.List; import java.util.ArrayList; -import java.util.LinkedList; import java.util.prefs.PreferenceChangeEvent; import javax.swing.Action; import javax.swing.InputMap; @@ -73,10 +72,6 @@ import javax.swing.text.EditorKit; import javax.swing.text.Position; import javax.swing.text.View; -import javax.swing.undo.AbstractUndoableEdit; -import javax.swing.undo.CannotRedoException; -import javax.swing.undo.CannotUndoException; -import javax.swing.undo.UndoableEdit; import org.netbeans.api.editor.caret.CaretInfo; import org.netbeans.api.editor.EditorActionRegistration; import org.netbeans.api.editor.EditorActionRegistrations; @@ -102,7 +97,6 @@ import org.netbeans.spi.editor.caret.CaretMoveHandler; import org.netbeans.lib.editor.util.swing.PositionRegion; import org.netbeans.modules.editor.lib.SettingsConversions; -import org.netbeans.modules.editor.lib2.CaretUndo; import org.netbeans.modules.editor.lib2.RectangularSelectionCaretAccessor; import org.netbeans.modules.editor.lib2.RectangularSelectionUtils; import org.netbeans.modules.editor.lib2.actions.KeyBindingsUpdater; @@ -116,7 +110,6 @@ import org.openide.util.LookupEvent; import org.openide.util.LookupListener; import org.openide.util.NbBundle; -import org.openide.util.Pair; import org.openide.util.WeakListeners; import org.openide.util.WeakSet; @@ -469,14 +462,13 @@ public static BaseKit getKit(Class kitClass) { BaseKit kit = (BaseKit)kits.get(classToTry); if (kit == null) { try { - kit = (BaseKit)classToTry.newInstance(); + kit = (BaseKit)classToTry.getDeclaredConstructor().newInstance(); kits.put(classToTry, kit); return kit; - } catch (IllegalAccessException e) { - LOG.log(Level.WARNING, "Can't instantiate editor kit from: " + classToTry, e); //NOI18N - } catch (InstantiationException e) { + } catch (ReflectiveOperationException e) { LOG.log(Level.WARNING, "Can't instantiate editor kit from: " + classToTry, e); //NOI18N } + //NOI18N if (classToTry != BaseKit.class) { classToTry = BaseKit.class; diff --git a/ide/editor.lib/src/org/netbeans/editor/BaseTextUI.java b/ide/editor.lib/src/org/netbeans/editor/BaseTextUI.java index 4be9b3f6c3f0..82b8e4a8ab5a 100644 --- a/ide/editor.lib/src/org/netbeans/editor/BaseTextUI.java +++ b/ide/editor.lib/src/org/netbeans/editor/BaseTextUI.java @@ -28,8 +28,6 @@ import java.util.StringTokenizer; import java.util.logging.Level; import java.util.logging.Logger; -import java.util.prefs.PreferenceChangeEvent; -import java.util.prefs.PreferenceChangeListener; import java.util.prefs.Preferences; import javax.swing.text.*; import javax.swing.event.DocumentListener; @@ -47,7 +45,6 @@ import org.netbeans.modules.editor.lib2.EditorApiPackageAccessor; import org.netbeans.editor.view.spi.LockView; import org.netbeans.lib.editor.view.GapDocumentView; -import org.netbeans.modules.editor.lib2.EditorPreferencesDefaults; import org.netbeans.modules.editor.lib2.EditorPreferencesKeys; import org.netbeans.modules.editor.lib.SettingsConversions; import org.netbeans.modules.editor.lib.drawing.DrawEngineDocView; @@ -55,7 +52,6 @@ import org.netbeans.modules.editor.lib2.view.LockedViewHierarchy; import org.netbeans.modules.editor.lib2.view.ViewHierarchy; import org.netbeans.spi.lexer.MutableTextInput; -import org.openide.util.WeakListeners; /** * Text UI implementation @@ -604,6 +600,7 @@ static class UIWatcher implements PropertyChangeListener { this.uiClass = uiClass; } + @Override public void propertyChange(PropertyChangeEvent evt) { Object newValue = evt.getNewValue(); if ("UI".equals(evt.getPropertyName())) { @@ -617,7 +614,7 @@ public void propertyChange(PropertyChangeEvent evt) { if (kit instanceof BaseKit) { // BaseKit but not BaseTextUI -> restore BaseTextUI try { - BaseTextUI newUI = (BaseTextUI) uiClass.newInstance(); + BaseTextUI newUI = (BaseTextUI) uiClass.getDeclaredConstructor().newInstance(); c.setUI(newUI); if (evt.getOldValue() instanceof BaseTextUI) { BaseTextUI oldUI = (BaseTextUI) evt.getOldValue(); @@ -633,9 +630,7 @@ public void propertyChange(PropertyChangeEvent evt) { } } - } catch (InstantiationException e) { - } catch (IllegalAccessException e) { - } + } catch (ReflectiveOperationException ignored) {} } } } diff --git a/ide/editor.lib/src/org/netbeans/editor/ext/ExtKit.java b/ide/editor.lib/src/org/netbeans/editor/ext/ExtKit.java index 5ebf4b0e320e..d72acbb00baf 100644 --- a/ide/editor.lib/src/org/netbeans/editor/ext/ExtKit.java +++ b/ide/editor.lib/src/org/netbeans/editor/ext/ExtKit.java @@ -176,7 +176,7 @@ public ExtKit() { try { ClassLoader loader = Lookup.getDefault().lookup(ClassLoader.class); Class extEditorUIClass = loader.loadClass("org.netbeans.editor.ext.ExtEditorUI"); //NOI18N - return (EditorUI) extEditorUIClass.newInstance(); + return (EditorUI) extEditorUIClass.getDeclaredConstructor().newInstance(); } catch (Exception e) { noExtEditorUIClass = true; } diff --git a/ide/html.editor/src/org/netbeans/modules/html/editor/options/ui/FmtOptions.java b/ide/html.editor/src/org/netbeans/modules/html/editor/options/ui/FmtOptions.java index 41d15bd830e1..9fc60a1319c8 100644 --- a/ide/html.editor/src/org/netbeans/modules/html/editor/options/ui/FmtOptions.java +++ b/ide/html.editor/src/org/netbeans/modules/html/editor/options/ui/FmtOptions.java @@ -18,16 +18,12 @@ */ package org.netbeans.modules.html.editor.options.ui; -import java.awt.Component; -import java.awt.Container; import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.util.Arrays; import java.util.HashMap; import java.util.HashSet; -import java.util.LinkedList; -import java.util.List; import java.util.Map; import java.util.Set; import java.util.logging.Level; @@ -35,14 +31,9 @@ import java.util.prefs.AbstractPreferences; import java.util.prefs.BackingStoreException; import java.util.prefs.Preferences; -import javax.swing.ComboBoxModel; -import javax.swing.DefaultComboBoxModel; -import javax.swing.JCheckBox; -import javax.swing.JComboBox; import javax.swing.JComponent; import javax.swing.JEditorPane; import javax.swing.JPanel; -import javax.swing.JTextField; import javax.swing.event.DocumentEvent; import javax.swing.event.DocumentListener; import javax.swing.text.BadLocationException; @@ -625,8 +616,8 @@ public Factory(String mimeType, String id, Class panelClass, S @Override public PreferencesCustomizer create(Preferences preferences) { try { - return new CategorySupport(mimeType, preferences, id, panelClass.newInstance(), previewText, forcedOptions); - } catch (InstantiationException | IllegalAccessException e) { + return new CategorySupport(mimeType, preferences, id, panelClass.getDeclaredConstructor().newInstance(), previewText, forcedOptions); + } catch (ReflectiveOperationException e) { LOGGER.log(Level.WARNING, "Exception during creating formatter customiezer", e); return null; } diff --git a/ide/ide.kit/test/qa-functional/src/org/netbeans/test/ide/CountingSecurityManager.java b/ide/ide.kit/test/qa-functional/src/org/netbeans/test/ide/CountingSecurityManager.java index 770c2081a322..45b65e53bbb3 100755 --- a/ide/ide.kit/test/qa-functional/src/org/netbeans/test/ide/CountingSecurityManager.java +++ b/ide/ide.kit/test/qa-functional/src/org/netbeans/test/ide/CountingSecurityManager.java @@ -161,7 +161,7 @@ public void checkPermission(Permission p) { try { ClassLoader l = Thread.currentThread().getContextClassLoader(); Class manClass = Class.forName("org.netbeans.TopSecurityManager", false, l); - man = (SecurityManager) manClass.newInstance(); + man = (SecurityManager) manClass.getDeclaredConstructor().newInstance(); } catch (Exception ex) { throw new IllegalStateException(ex); } diff --git a/ide/parsing.indexing/test/unit/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater2Test.java b/ide/parsing.indexing/test/unit/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater2Test.java index 3a103b8d34ee..753b0acd141d 100644 --- a/ide/parsing.indexing/test/unit/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater2Test.java +++ b/ide/parsing.indexing/test/unit/src/org/netbeans/modules/parsing/impl/indexing/RepositoryUpdater2Test.java @@ -596,7 +596,7 @@ public T createIndexer() { return customIndexerInstance; } else { try { - return customIndexerClass.newInstance(); + return customIndexerClass.getDeclaredConstructor().newInstance(); } catch (Exception ex) { throw new IllegalStateException(ex); } @@ -652,7 +652,7 @@ public FixedParserFactory(T parserInstance) { return parserInstance; } else { try { - return parserClass.newInstance(); + return parserClass.getDeclaredConstructor().newInstance(); } catch (Exception ex) { throw new IllegalStateException(ex); } diff --git a/ide/project.libraries/test/unit/src/org/netbeans/modules/project/libraries/LibrariesTestUtil.java b/ide/project.libraries/test/unit/src/org/netbeans/modules/project/libraries/LibrariesTestUtil.java index 10bd49bda826..f5ead75a1769 100644 --- a/ide/project.libraries/test/unit/src/org/netbeans/modules/project/libraries/LibrariesTestUtil.java +++ b/ide/project.libraries/test/unit/src/org/netbeans/modules/project/libraries/LibrariesTestUtil.java @@ -393,7 +393,7 @@ public static void assertLibEquals (LibraryImplementation[] libs, String[] names public static void registerLibraryTypeProvider (final Class provider) throws Exception { final MockLibraryTypeRegistry mr = Lookup.getDefault().lookup(MockLibraryTypeRegistry.class); if (mr != null) { - mr.register(provider.newInstance()); + mr.register(provider.getDeclaredConstructor().newInstance()); return; } FileObject root = FileUtil.getConfigRoot(); diff --git a/ide/schema2beans/src/org/netbeans/modules/schema2beans/BaseBean.java b/ide/schema2beans/src/org/netbeans/modules/schema2beans/BaseBean.java index 7010ba0091c0..3ae0d84b4a58 100644 --- a/ide/schema2beans/src/org/netbeans/modules/schema2beans/BaseBean.java +++ b/ide/schema2beans/src/org/netbeans/modules/schema2beans/BaseBean.java @@ -1217,7 +1217,7 @@ public Object clone() { try { // FIXME this seriosly breaks the clone contract :( // Create a new instance of ourself - bean = (BaseBean)this.getClass().newInstance(); + bean = (BaseBean)this.getClass().getDeclaredConstructor().newInstance(); } catch(Exception e) { TraceLogger.error(e); throw new Schema2BeansRuntimeException(Common. diff --git a/ide/schema2beans/src/org/netbeans/modules/schema2beans/BeanProp.java b/ide/schema2beans/src/org/netbeans/modules/schema2beans/BeanProp.java index 72b52dbf5300..45095a6d089e 100644 --- a/ide/schema2beans/src/org/netbeans/modules/schema2beans/BeanProp.java +++ b/ide/schema2beans/src/org/netbeans/modules/schema2beans/BeanProp.java @@ -1702,7 +1702,7 @@ BaseBean newBeanInstance() { c = this.propClass.getDeclaredConstructor(cc); } catch(NoSuchMethodException me) { - return (BaseBean)this.propClass.newInstance(); + return (BaseBean)this.propClass.getDeclaredConstructor().newInstance(); } // Do not initialize the default values diff --git a/ide/schema2beans/src/org/netbeans/modules/schema2beans/DOMBinding.java b/ide/schema2beans/src/org/netbeans/modules/schema2beans/DOMBinding.java index 6639a7acd328..31d862f16d16 100644 --- a/ide/schema2beans/src/org/netbeans/modules/schema2beans/DOMBinding.java +++ b/ide/schema2beans/src/org/netbeans/modules/schema2beans/DOMBinding.java @@ -386,7 +386,7 @@ Object getValue(BeanProp prop) { try { // If cls implements Wrapper, use it first if ((Wrapper.class).isAssignableFrom(cls)) { - Wrapper w = (Wrapper)cls.newInstance(); + Wrapper w = (Wrapper)cls.getDeclaredConstructor().newInstance(); w.setWrapperValue(ret); return w; } diff --git a/ide/selenium2.server/src/org/netbeans/modules/selenium2/server/Selenium2ServerSupport.java b/ide/selenium2.server/src/org/netbeans/modules/selenium2/server/Selenium2ServerSupport.java index a5db7eb14c88..c8a748ebad94 100644 --- a/ide/selenium2.server/src/org/netbeans/modules/selenium2/server/Selenium2ServerSupport.java +++ b/ide/selenium2.server/src/org/netbeans/modules/selenium2/server/Selenium2ServerSupport.java @@ -234,7 +234,7 @@ private static void initializeServer() throws Exception { Class remoteControlConfiguration = urlClassLoader.loadClass( "org.openqa.selenium.server.RemoteControlConfiguration"); //NOI18N - Object remoteControlConfigurationInstance = remoteControlConfiguration.newInstance(); + Object remoteControlConfigurationInstance = remoteControlConfiguration.getDeclaredConstructor().newInstance(); int port = getPrefs().getInt(PORT, PORT_DEFAULT); remoteControlConfiguration.getMethod("setPort", int.class).invoke( remoteControlConfigurationInstance, port); //NOI18N diff --git a/ide/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/BreakpointCustomizeAction.java b/ide/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/BreakpointCustomizeAction.java index 96bb52700ab8..33ce823dede2 100644 --- a/ide/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/BreakpointCustomizeAction.java +++ b/ide/spi.debugger.ui/src/org/netbeans/modules/debugger/ui/actions/BreakpointCustomizeAction.java @@ -166,7 +166,7 @@ private Customizer getCustomizer(Breakpoint b) { Class cc = getCustomizerClass(b); if (cc == null) return null; try { - Customizer c = (Customizer) cc.newInstance(); + Customizer c = (Customizer) cc.getDeclaredConstructor().newInstance(); c.setObject(b); return c; } catch (Exception ex) { diff --git a/ide/spi.palette/src/org/netbeans/modules/palette/ActiveEditorDropProvider.java b/ide/spi.palette/src/org/netbeans/modules/palette/ActiveEditorDropProvider.java index 7cde6e3e291f..f831a1b3cadb 100644 --- a/ide/spi.palette/src/org/netbeans/modules/palette/ActiveEditorDropProvider.java +++ b/ide/spi.palette/src/org/netbeans/modules/palette/ActiveEditorDropProvider.java @@ -67,7 +67,7 @@ private ActiveEditorDrop getActiveEditorDrop(String instanceName) { if (loader == null) loader = getClass ().getClassLoader (); Class instanceClass = loader.loadClass (instanceName); - drop = (ActiveEditorDrop)instanceClass.newInstance(); + drop = (ActiveEditorDrop)instanceClass.getDeclaredConstructor().newInstance(); } catch (Exception ex) { ErrorManager.getDefault().notify(ErrorManager.INFORMATIONAL, ex); diff --git a/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/CreateRegistrationProcessor.java b/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/CreateRegistrationProcessor.java index 35b31c099eb1..ca3014252020 100644 --- a/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/CreateRegistrationProcessor.java +++ b/ide/textmate.lexer/src/org/netbeans/modules/textmate/lexer/CreateRegistrationProcessor.java @@ -261,7 +261,7 @@ private Iterable completeMimePath( l = CreateRegistrationProcessor.class.getClassLoader(); } try { - COMPLETIONS = (Processor)Class.forName(pathCompletions, true, l).newInstance(); + COMPLETIONS = (Processor)Class.forName(pathCompletions, true, l).getDeclaredConstructor().newInstance(); } catch (Exception ex) { Exceptions.printStackTrace(ex); // no completions, OK diff --git a/ide/xml.catalog.ui/src/org/netbeans/modules/xml/catalog/lib/Util.java b/ide/xml.catalog.ui/src/org/netbeans/modules/xml/catalog/lib/Util.java index b5866bf60a01..a19839906b47 100644 --- a/ide/xml.catalog.ui/src/org/netbeans/modules/xml/catalog/lib/Util.java +++ b/ide/xml.catalog.ui/src/org/netbeans/modules/xml/catalog/lib/Util.java @@ -57,14 +57,8 @@ public static Customizer getProviderCustomizer(Class clazz) { try { Class customizer = Introspector.getBeanInfo(clazz).getBeanDescriptor().getCustomizerClass(); - - return (Customizer) customizer.newInstance(); - - } catch (InstantiationException ex) { - return null; - } catch (IntrospectionException ex) { - return null; - } catch (IllegalAccessException ex) { + return (Customizer) customizer.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException | IntrospectionException ex) { return null; } } @@ -75,10 +69,8 @@ public static Customizer getProviderCustomizer(Class clazz) { */ public static Object createProvider(Class clazz) { try { - return clazz.newInstance(); - } catch (InstantiationException ex) { - return null; - } catch (IllegalAccessException ex) { + return clazz.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException ex) { return null; } } diff --git a/ide/xml.tax/src/org/netbeans/modules/xml/tax/beans/Lib.java b/ide/xml.tax/src/org/netbeans/modules/xml/tax/beans/Lib.java index 07447feb896d..ae1f2338335d 100644 --- a/ide/xml.tax/src/org/netbeans/modules/xml/tax/beans/Lib.java +++ b/ide/xml.tax/src/org/netbeans/modules/xml/tax/beans/Lib.java @@ -68,12 +68,8 @@ public static Component getCustomizer (Object object) { Object o; try { - o = clazz.newInstance (); - } catch (InstantiationException e) { - if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("Lib::getCustomizer: exception = " + e); // NOI18N - - return null; - } catch (IllegalAccessException e) { + o = clazz.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException e) { if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("Lib::getCustomizer: exception = " + e); // NOI18N return null; @@ -141,12 +137,8 @@ public static Component getCustomizer (Class classClass, Object property, String } Object peo; try { - peo = clazz.newInstance (); - } catch (InstantiationException e) { - if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("Lib::getCustomizer: exception = " + e); // NOI18N - - return null; - } catch (IllegalAccessException e) { + peo = clazz.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException e) { if ( Util.THIS.isLoggable() ) /* then */ Util.THIS.debug ("Lib::getCustomizer: exception = " + e); // NOI18N return null; diff --git a/java/ant.debugger/test/unit/src/org/netbeans/modules/ant/debugger/StepTest.java b/java/ant.debugger/test/unit/src/org/netbeans/modules/ant/debugger/StepTest.java index 348b2d89c19a..f276275d8fb8 100644 --- a/java/ant.debugger/test/unit/src/org/netbeans/modules/ant/debugger/StepTest.java +++ b/java/ant.debugger/test/unit/src/org/netbeans/modules/ant/debugger/StepTest.java @@ -61,11 +61,11 @@ public void testStepOver () throws Exception { } public static final class Lkp extends ProxyLookup { - public Lkp() throws InstantiationException, IllegalAccessException, ClassNotFoundException { + public Lkp() throws ReflectiveOperationException { setLookups(new Lookup[] { Lookups.fixed(new Object[] { new IFL(), - Class.forName("org.netbeans.modules.masterfs.MasterURLMapper").newInstance(), + Class.forName("org.netbeans.modules.masterfs.MasterURLMapper").getDeclaredConstructor().newInstance(), new DebuggerAntLogger () }), }); diff --git a/java/dbschema/src/org/netbeans/modules/dbschema/migration/archiver/deserializer/XMLGraphDeserializer.java b/java/dbschema/src/org/netbeans/modules/dbschema/migration/archiver/deserializer/XMLGraphDeserializer.java index 909e9be0b147..183d67b6a8fa 100644 --- a/java/dbschema/src/org/netbeans/modules/dbschema/migration/archiver/deserializer/XMLGraphDeserializer.java +++ b/java/dbschema/src/org/netbeans/modules/dbschema/migration/archiver/deserializer/XMLGraphDeserializer.java @@ -23,6 +23,7 @@ import java.lang.reflect.Field; import java.lang.reflect.Array; +import java.lang.reflect.InvocationTargetException; import org.xml.sax.*; @@ -588,7 +589,7 @@ public void readObjectHeader(java.lang.String name, org.xml.sax.AttributeList if (WrapperClassHelper.isWrapperClass(lClass)) lObj = new WrapperClassHelper(lClass, lIDName); else - lObj = lClass.newInstance(); + lObj = lClass.getDeclaredConstructor().newInstance(); } catch (IllegalAccessException e1) { @@ -598,7 +599,7 @@ public void readObjectHeader(java.lang.String name, org.xml.sax.AttributeList SAXException useError = new SAXException(message); throw useError; } - catch (InstantiationException e2) + catch (InstantiationException | NoSuchMethodException | InvocationTargetException e2) { lObj = NewInstanceHelper.newInstance(lClassName, this.topObject()); @@ -688,7 +689,7 @@ else if (name.equals("ARRAY")) try { Class lArrayTypeClass = this.findClass(lArrayType); - lArray = lArrayTypeClass.newInstance(); + lArray = lArrayTypeClass.getDeclaredConstructor().newInstance(); } catch (ClassNotFoundException e1) { @@ -708,7 +709,7 @@ else if (name.equals("ARRAY")) SAXException accessError = new SAXException(message); throw accessError; } - catch (InstantiationException e3) + catch (InstantiationException | NoSuchMethodException | InvocationTargetException e3) { e3.printStackTrace(); //java.lang.String message = new String("Instantiation exception whilst trying to init new instance of " + lArrayType); @@ -822,11 +823,11 @@ else if (name.equals("NULLVALUE")) // does not declare the field anymore => ignore. this.pushObject(new Object()); else - this.pushObject(lField.getType().newInstance()); + this.pushObject(lField.getType().getDeclaredConstructor().newInstance()); this.State = new Integer(this.XGD_NEED_END_NULLVALUE); } - catch (InstantiationException e1) + catch (InstantiationException | NoSuchMethodException | InvocationTargetException e1) { e1.printStackTrace(); //java.lang.String message = new String("Could not init instance of " + lField.getType().getName()); diff --git a/java/dbschema/test/unit/src/org/netbeans/modules/dbschema/ColumnElementTest.java b/java/dbschema/test/unit/src/org/netbeans/modules/dbschema/ColumnElementTest.java index a11c03f48329..0350e1631349 100644 --- a/java/dbschema/test/unit/src/org/netbeans/modules/dbschema/ColumnElementTest.java +++ b/java/dbschema/test/unit/src/org/netbeans/modules/dbschema/ColumnElementTest.java @@ -137,7 +137,7 @@ private Connection getConnection() throws Exception { private Driver getDriver() throws Exception { URLClassLoader driverLoader = new URLClassLoader(new URL[] {new URL(jarpath)}); - return (Driver)Class.forName(driverClassName, true, driverLoader).newInstance(); + return (Driver)Class.forName(driverClassName, true, driverLoader).getDeclaredConstructor().newInstance(); } @Override diff --git a/java/form/src/org/netbeans/modules/form/CreationFactory.java b/java/form/src/org/netbeans/modules/form/CreationFactory.java index 4ec3811fdd1a..581f923d9437 100644 --- a/java/form/src/org/netbeans/modules/form/CreationFactory.java +++ b/java/form/src/org/netbeans/modules/form/CreationFactory.java @@ -152,7 +152,7 @@ public static Object createDefaultInstance(final Class cls) UIManager.put("ClassLoader", newCl); // NOI18N Object instance = cd != null ? cd.createDefaultInstance() : - cls.newInstance(); + cls.getDeclaredConstructor().newInstance(); if (cl == cl2) { // The original classloader (i.e., cl) was in look and feel defaults. // It remains there, we just have to remove the value that @@ -173,7 +173,7 @@ public static Object createInstance(Class cls) CreationDescriptor cd = CreationFactory.getDescriptor(cls); instance = cd != null ? cd.createDefaultInstance() : - cls.newInstance(); + cls.getDeclaredConstructor().newInstance(); initAfterCreation(instance); return instance; diff --git a/java/form/src/org/netbeans/modules/form/FormLAF.java b/java/form/src/org/netbeans/modules/form/FormLAF.java index 3ba23cf5bc73..01fb75b8f2ba 100644 --- a/java/form/src/org/netbeans/modules/form/FormLAF.java +++ b/java/form/src/org/netbeans/modules/form/FormLAF.java @@ -75,7 +75,7 @@ public static PreviewInfo initPreviewLaf(Class lafClass, ClassLoader formClassLo !MetalLookAndFeel.class.equals(lafClass) && (lafToTheme.get(MetalLookAndFeel.class) == null)) { lafToTheme.put(MetalLookAndFeel.class, MetalLookAndFeel.getCurrentTheme()); } - LookAndFeel previewLookAndFeel = (LookAndFeel)lafClass.newInstance(); + LookAndFeel previewLookAndFeel = (LookAndFeel)lafClass.getDeclaredConstructor().newInstance(); if (previewLafIsMetal) { MetalTheme theme = lafToTheme.get(lafClass); if (theme == null) { @@ -203,7 +203,7 @@ private static void initialize() throws Exception { } LookAndFeel original = laf; try { - original = laf.getClass().newInstance(); + original = laf.getClass().getDeclaredConstructor().newInstance(); } catch (Exception ex) { Logger.getLogger(FormLAF.class.getName()).log(Level.INFO, ex.getMessage(), ex); } diff --git a/java/form/src/org/netbeans/modules/form/FormPropertyEditorManager.java b/java/form/src/org/netbeans/modules/form/FormPropertyEditorManager.java index b03d46c9b02b..e64802001a37 100644 --- a/java/form/src/org/netbeans/modules/form/FormPropertyEditorManager.java +++ b/java/form/src/org/netbeans/modules/form/FormPropertyEditorManager.java @@ -304,7 +304,7 @@ private static boolean isComponentType(Class type) { private static PropertyEditor createEditorInstance(Class cls) { try { - return (PropertyEditor) cls.newInstance(); + return (PropertyEditor) cls.getDeclaredConstructor().newInstance(); } catch (Exception ex) { log(ex, "Error instantiating property editor: "+cls.getName()); // NOI18N } catch (LinkageError ex) { diff --git a/java/form/src/org/netbeans/modules/form/GandalfPersistenceManager.java b/java/form/src/org/netbeans/modules/form/GandalfPersistenceManager.java index 3066104a716a..4c1b0d0b7988 100644 --- a/java/form/src/org/netbeans/modules/form/GandalfPersistenceManager.java +++ b/java/form/src/org/netbeans/modules/form/GandalfPersistenceManager.java @@ -4606,8 +4606,7 @@ private void saveAuxValues(Map auxValues, StringBuffer buf, Strin private PropertyEditor createPropertyEditor(Class editorClass, Class propertyType, FormProperty property) - throws InstantiationException, - IllegalAccessException + throws ReflectiveOperationException { PropertyEditor ed = null; if (editorClass.equals(RADConnectionPropertyEditor.class)) { @@ -4623,7 +4622,7 @@ private PropertyEditor createPropertyEditor(Class editorClass, ed = RADProperty.createDefaultEnumEditor(propertyType); } } else { - ed = (PropertyEditor) editorClass.newInstance(); + ed = (PropertyEditor) editorClass.getDeclaredConstructor().newInstance(); } if (property != null) @@ -5575,10 +5574,7 @@ private Object getPropertyEditorOrValue(org.w3c.dom.Node node) { try { prEd = createPropertyEditor(editorClass, propertyType, null); } - catch (Exception ex) { - t = ex; - } - catch (LinkageError ex) { + catch (Exception | LinkageError ex) { t = ex; } if (t != null) { diff --git a/java/form/src/org/netbeans/modules/form/PersistenceManager.java b/java/form/src/org/netbeans/modules/form/PersistenceManager.java index 923b54837d85..2d0c2012ecda 100644 --- a/java/form/src/org/netbeans/modules/form/PersistenceManager.java +++ b/java/form/src/org/netbeans/modules/form/PersistenceManager.java @@ -103,7 +103,7 @@ public static Iterator getManagers() { String pmClassName = iter.next(); try { PersistenceManager manager = (PersistenceManager) - classLoader.loadClass(pmClassName).newInstance(); + classLoader.loadClass(pmClassName).getDeclaredConstructor().newInstance(); getManagersList().add(manager); } catch (Exception ex1) { diff --git a/java/form/src/org/netbeans/modules/form/PersistenceObjectRegistry.java b/java/form/src/org/netbeans/modules/form/PersistenceObjectRegistry.java index f864dca37a7d..468f8cb7bc01 100644 --- a/java/form/src/org/netbeans/modules/form/PersistenceObjectRegistry.java +++ b/java/form/src/org/netbeans/modules/form/PersistenceObjectRegistry.java @@ -58,9 +58,9 @@ public static void registerAlias(Class clazz, String alias) { } public static Object createInstance(String classname, FileObject form) - throws InstantiationException, IllegalAccessException, ClassNotFoundException + throws ReflectiveOperationException { - return loadClass(classname, form).newInstance(); + return loadClass(classname, form).getDeclaredConstructor().newInstance(); } public static Class loadClass(String name, FileObject form) diff --git a/java/form/src/org/netbeans/modules/form/RADComponentNode.java b/java/form/src/org/netbeans/modules/form/RADComponentNode.java index c41984800dd5..b78c2dccf35d 100644 --- a/java/form/src/org/netbeans/modules/form/RADComponentNode.java +++ b/java/form/src/org/netbeans/modules/form/RADComponentNode.java @@ -449,13 +449,8 @@ protected Component createCustomizer() { Object customizerObject; try { - customizerObject = customizerClass.newInstance(); - } - catch (InstantiationException e) { - ErrorManager.getDefault().notify(ErrorManager.WARNING, e); - return null; - } - catch (IllegalAccessException e) { + customizerObject = customizerClass.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException e) { ErrorManager.getDefault().notify(ErrorManager.WARNING, e); return null; } diff --git a/java/form/src/org/netbeans/modules/form/actions/TestAction.java b/java/form/src/org/netbeans/modules/form/actions/TestAction.java index 8fb9196fa2e2..fa72ceaa7cd3 100644 --- a/java/form/src/org/netbeans/modules/form/actions/TestAction.java +++ b/java/form/src/org/netbeans/modules/form/actions/TestAction.java @@ -330,7 +330,7 @@ public JPopupMenu getPopupMenu() { try { Class clazz = pitem.getComponentClass(); if ((clazz != null) && (LookAndFeel.class.isAssignableFrom(clazz))) { - LookAndFeel laf = (LookAndFeel)clazz.newInstance(); + LookAndFeel laf = (LookAndFeel)clazz.getDeclaredConstructor().newInstance(); supported = laf.isSupportedLookAndFeel(); if (supported && isSynthLAF && !lafName.equals(pitem.getComponentClassName()) && SynthLookAndFeel.class.isAssignableFrom(clazz)) { diff --git a/java/form/src/org/netbeans/modules/form/editors2/TableColumnModelEditor.java b/java/form/src/org/netbeans/modules/form/editors2/TableColumnModelEditor.java index 2553db5764fa..6e1f9370fd41 100644 --- a/java/form/src/org/netbeans/modules/form/editors2/TableColumnModelEditor.java +++ b/java/form/src/org/netbeans/modules/form/editors2/TableColumnModelEditor.java @@ -308,7 +308,7 @@ private void loadProperty(FormProperty property, Node node) { } else { Class propEdClass = PersistenceObjectRegistry.loadClass(propEdName, FormEditor.getFormDataObject(formModel).getFormFile()); - Object propEd = propEdClass.newInstance(); + Object propEd = propEdClass.getDeclaredConstructor().newInstance(); if (propEd instanceof XMLPropertyEditor) { xmlPropEd = (XMLPropertyEditor)propEd; if (propEd instanceof FormAwareEditor) { diff --git a/java/form/src/org/netbeans/modules/form/layoutsupport/AbstractLayoutSupport.java b/java/form/src/org/netbeans/modules/form/layoutsupport/AbstractLayoutSupport.java index b9a69f630b9f..744b57ca31b8 100644 --- a/java/form/src/org/netbeans/modules/form/layoutsupport/AbstractLayoutSupport.java +++ b/java/form/src/org/netbeans/modules/form/layoutsupport/AbstractLayoutSupport.java @@ -913,7 +913,7 @@ protected LayoutManager cloneLayoutInstance(Container container, */ protected AbstractLayoutSupport createLayoutSupportInstance() { try { - return (AbstractLayoutSupport) getClass().newInstance(); + return (AbstractLayoutSupport) getClass().getDeclaredConstructor().newInstance(); } catch (Exception ex) { // should not happen for AbstractLayoutSupport subclasses return null; diff --git a/java/form/src/org/netbeans/modules/form/layoutsupport/LayoutNode.java b/java/form/src/org/netbeans/modules/form/layoutsupport/LayoutNode.java index b9417e8969b0..31168b688480 100644 --- a/java/form/src/org/netbeans/modules/form/layoutsupport/LayoutNode.java +++ b/java/form/src/org/netbeans/modules/form/layoutsupport/LayoutNode.java @@ -118,13 +118,9 @@ protected Component createCustomizer() { // create bean customizer for layout manager Object customizerObject; try { - customizerObject = customizerClass.newInstance(); + customizerObject = customizerClass.getDeclaredConstructor().newInstance(); } - catch (InstantiationException e) { - ErrorManager.getDefault().notify(ErrorManager.WARNING, e); - return null; - } - catch (IllegalAccessException e) { + catch (ReflectiveOperationException e) { ErrorManager.getDefault().notify(ErrorManager.WARNING, e); return null; } diff --git a/java/form/src/org/netbeans/modules/form/layoutsupport/LayoutSupportRegistry.java b/java/form/src/org/netbeans/modules/form/layoutsupport/LayoutSupportRegistry.java index 2c4e5f5fd555..a4dbc55fc85e 100644 --- a/java/form/src/org/netbeans/modules/form/layoutsupport/LayoutSupportRegistry.java +++ b/java/form/src/org/netbeans/modules/form/layoutsupport/LayoutSupportRegistry.java @@ -97,22 +97,18 @@ public static void registerSupportForLayout( // creation methods public LayoutSupportDelegate createSupportForContainer(Class containerClass) - throws ClassNotFoundException, - InstantiationException, - IllegalAccessException + throws ReflectiveOperationException { String delegateClassName = getContainersMap().get(containerClass.getName()); if (delegateClassName == null) { return createLayoutSupportForSuperClass(getContainersMap(), containerClass); } else { - return (LayoutSupportDelegate) loadClass(delegateClassName).newInstance(); + return (LayoutSupportDelegate) loadClass(delegateClassName).getDeclaredConstructor().newInstance(); } } public LayoutSupportDelegate createSupportForLayout(Class layoutClass) - throws ClassNotFoundException, - InstantiationException, - IllegalAccessException + throws ReflectiveOperationException { String layoutClassName = layoutClass.getName(); String delegateClassName = getLayoutsMap().get(layoutClassName); @@ -125,7 +121,7 @@ public LayoutSupportDelegate createSupportForLayout(Class layoutClass) if (DEFAULT_SUPPORT.equals(delegateClassName)) { return new DefaultLayoutSupport(layoutClass); } else if (delegateClassName != null) { - return (LayoutSupportDelegate) loadClass(delegateClassName).newInstance(); + return (LayoutSupportDelegate) loadClass(delegateClassName).getDeclaredConstructor().newInstance(); } else { return null; } @@ -133,9 +129,9 @@ public LayoutSupportDelegate createSupportForLayout(Class layoutClass) public static LayoutSupportDelegate createSupportInstance( Class layoutDelegateClass) - throws InstantiationException, IllegalAccessException + throws ReflectiveOperationException { - return (LayoutSupportDelegate) layoutDelegateClass.newInstance(); + return (LayoutSupportDelegate) layoutDelegateClass.getDeclaredConstructor().newInstance(); } // ----------- @@ -155,7 +151,7 @@ private static boolean isUsableCustomLayoutClass(Class layoutClass) { } private LayoutSupportDelegate createLayoutSupportForSuperClass(Map map, Class subClass) - throws ClassNotFoundException, InstantiationException, IllegalAccessException { + throws ReflectiveOperationException { // We don't ask if the loaded registered class is assignable from 'subClass' // because it would not work for custom classes when the project classloader changes. for (Map.Entry en : map.entrySet()) { @@ -166,7 +162,7 @@ private LayoutSupportDelegate createLayoutSupportForSuperClass(Map computeFixes(CompilationInfo info, int pos, TreePath path) t } protected List computeFixes(CompilationInfo info, String diagnosticCode, int pos, TreePath path) throws Exception { - if (ruleToInvoke != null) return ruleToInvoke.newInstance().run(info, diagnosticCode, pos, path, null); + if (ruleToInvoke != null) return ruleToInvoke.getDeclaredConstructor().newInstance().run(info, diagnosticCode, pos, path, null); return computeFixes(info, pos, path); } @@ -325,7 +325,7 @@ protected void performFixTest(String fileName, String code, int pos, String fixC } protected Set getSupportedErrorKeys() throws Exception { - if (ruleToInvoke != null) return ruleToInvoke.newInstance().getCodes(); + if (ruleToInvoke != null) return ruleToInvoke.getDeclaredConstructor().newInstance().getCodes(); return null; } diff --git a/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/jrtfs/NBJRTFileSystem.java b/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/jrtfs/NBJRTFileSystem.java index 3f28daa43531..0c7a423c2677 100644 --- a/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/jrtfs/NBJRTFileSystem.java +++ b/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/platformdefinition/jrtfs/NBJRTFileSystem.java @@ -245,7 +245,7 @@ private R writeOp(Class clz) throws E { try { e = clz.getDeclaredConstructor(String.class).newInstance(message); } catch (NoSuchMethodException nsm) { - e = clz.newInstance(); + e = clz.getDeclaredConstructor().newInstance(); } } catch (ReflectiveOperationException roe) { throw new IllegalStateException(message); diff --git a/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/queries/QueriesCache.java b/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/queries/QueriesCache.java index 8c660331b490..fa84b442bbbe 100644 --- a/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/queries/QueriesCache.java +++ b/java/java.j2seplatform/src/org/netbeans/modules/java/j2seplatform/queries/QueriesCache.java @@ -36,7 +36,6 @@ import javax.swing.event.ChangeListener; import org.netbeans.api.annotations.common.NonNull; import org.netbeans.api.java.queries.JavadocForBinaryQuery; -import org.netbeans.api.java.queries.SourceForBinaryQuery; import org.netbeans.spi.java.queries.SourceForBinaryQueryImplementation2; import org.openide.filesystems.FileObject; import org.openide.filesystems.FileUtil; @@ -93,12 +92,10 @@ void updateRoot(final URL binaryRoot, final URL... rootsToAttach) { } if (currentMapping == null) { try { - currentMapping = clazz.newInstance(); + currentMapping = clazz.getDeclaredConstructor().newInstance(); currentRoots.put(binaryRoot, currentMapping); - } catch (InstantiationException ie) { + } catch (ReflectiveOperationException ie) { Exceptions.printStackTrace(ie); - } catch (IllegalAccessException iae) { - Exceptions.printStackTrace(iae); } } } @@ -131,19 +128,13 @@ private Map loadRoots() { } } for (Map.Entry> e : bindings.entrySet()) { - final T instance = clazz.newInstance(); + final T instance = clazz.getDeclaredConstructor().newInstance(); instance.update(e.getValue()); result.put(e.getKey(), instance); } } - } catch (BackingStoreException bse) { + } catch (BackingStoreException | MalformedURLException | ReflectiveOperationException bse) { Exceptions.printStackTrace(bse); - } catch (MalformedURLException mue) { - Exceptions.printStackTrace(mue); - } catch (InstantiationException ie) { - Exceptions.printStackTrace(ie); - } catch (IllegalAccessException iae) { - Exceptions.printStackTrace(iae); } cache = result; } diff --git a/java/java.source.base/src/org/netbeans/modules/java/source/indexing/APTUtils.java b/java/java.source.base/src/org/netbeans/modules/java/source/indexing/APTUtils.java index a437bf320e6b..2aa6f9657cb3 100644 --- a/java/java.source.base/src/org/netbeans/modules/java/source/indexing/APTUtils.java +++ b/java/java.source.base/src/org/netbeans/modules/java/source/indexing/APTUtils.java @@ -381,7 +381,7 @@ private Collection lookupProcessors(ClassLoader cl, boolean onScan, b for (String name : processorNames) { try { Class clazz = Class.forName(name, true, cl); - Object instance = clazz.newInstance(); + Object instance = clazz.getDeclaredConstructor().newInstance(); if (instance instanceof Processor) { result.add(new ErrorToleratingProcessor((Processor) instance)); } diff --git a/java/java.source/src/org/netbeans/modules/java/ui/CategorySupport.java b/java/java.source/src/org/netbeans/modules/java/ui/CategorySupport.java index 1e9b5e93b08d..c0f9258eea26 100644 --- a/java/java.source/src/org/netbeans/modules/java/ui/CategorySupport.java +++ b/java/java.source/src/org/netbeans/modules/java/ui/CategorySupport.java @@ -319,7 +319,7 @@ public Factory(String id, Class panelClass, String previewText public PreferencesCustomizer create(Preferences preferences) { try { - CategorySupport categorySupport = new CategorySupport(preferences, id, panelClass.newInstance(), previewText, forcedOptions); + CategorySupport categorySupport = new CategorySupport(preferences, id, panelClass.getDeclaredConstructor().newInstance(), previewText, forcedOptions); if (categorySupport.panel instanceof Runnable) ((Runnable)categorySupport.panel).run(); return categorySupport; diff --git a/java/lib.jshell.agent/agentsrc/org/netbeans/lib/jshell/agent/AgentWorker.java b/java/lib.jshell.agent/agentsrc/org/netbeans/lib/jshell/agent/AgentWorker.java index a822ac5bba6a..ac69f903fa44 100644 --- a/java/lib.jshell.agent/agentsrc/org/netbeans/lib/jshell/agent/AgentWorker.java +++ b/java/lib.jshell.agent/agentsrc/org/netbeans/lib/jshell/agent/AgentWorker.java @@ -149,12 +149,8 @@ private Executor findExecutor() { } else if (o instanceof String) { try { Class executorClazz = Class.forName((String)o); - return (Executor)executorClazz.newInstance(); - } catch (ClassNotFoundException ex) { - LOG.log(Level.SEVERE, null, ex); - } catch (InstantiationException ex) { - LOG.log(Level.SEVERE, null, ex); - } catch (IllegalAccessException ex) { + return (Executor)executorClazz.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException ex) { LOG.log(Level.SEVERE, null, ex); } } diff --git a/java/maven/test/unit/src/org/netbeans/modules/maven/newproject/simplewizard/EnsureJavaFXPresent.java b/java/maven/test/unit/src/org/netbeans/modules/maven/newproject/simplewizard/EnsureJavaFXPresent.java index 225018a1af4b..e2d73d65d5d0 100644 --- a/java/maven/test/unit/src/org/netbeans/modules/maven/newproject/simplewizard/EnsureJavaFXPresent.java +++ b/java/maven/test/unit/src/org/netbeans/modules/maven/newproject/simplewizard/EnsureJavaFXPresent.java @@ -25,7 +25,7 @@ class EnsureJavaFXPresent { static { Throwable t; try { - Object p = Class.forName("javafx.embed.swing.JFXPanel").newInstance(); + Object p = Class.forName("javafx.embed.swing.JFXPanel").getDeclaredConstructor().newInstance(); assertNotNull("Allocated", p); t = null; } catch (Throwable err) { diff --git a/java/performance/src/org/netbeans/modules/performance/Inst.java b/java/performance/src/org/netbeans/modules/performance/Inst.java index 8ec428c97cec..cf4c27180116 100644 --- a/java/performance/src/org/netbeans/modules/performance/Inst.java +++ b/java/performance/src/org/netbeans/modules/performance/Inst.java @@ -33,7 +33,7 @@ public void restored() { if (value != null) { try { Class c = Thread.currentThread().getContextClassLoader().loadClass(value); - Object run = c.newInstance(); + Object run = c.getDeclaredConstructor().newInstance(); ((Runnable)run).run(); } catch (Exception ex) { throw new IllegalStateException(ex); diff --git a/java/performance/test/qa-functional/src/org/netbeans/test/ide/PerfCountingSecurityManager.java b/java/performance/test/qa-functional/src/org/netbeans/test/ide/PerfCountingSecurityManager.java index ac6a13581db9..dcd3b28cead8 100644 --- a/java/performance/test/qa-functional/src/org/netbeans/test/ide/PerfCountingSecurityManager.java +++ b/java/performance/test/qa-functional/src/org/netbeans/test/ide/PerfCountingSecurityManager.java @@ -161,7 +161,7 @@ public void checkPermission(Permission p) { try { ClassLoader l = Thread.currentThread().getContextClassLoader(); Class manClass = Class.forName("org.netbeans.TopSecurityManager", false, l); - man = (SecurityManager) manClass.newInstance(); + man = (SecurityManager) manClass.getDeclaredConstructor().newInstance(); } catch (Exception ex) { throw new IllegalStateException(ex); } diff --git a/java/performance/test/unit/src/org/netbeans/performance/scalability/AWTThreadFreeTest.java b/java/performance/test/unit/src/org/netbeans/performance/scalability/AWTThreadFreeTest.java index 13286b79750e..b97e6de58855 100644 --- a/java/performance/test/unit/src/org/netbeans/performance/scalability/AWTThreadFreeTest.java +++ b/java/performance/test/unit/src/org/netbeans/performance/scalability/AWTThreadFreeTest.java @@ -130,7 +130,7 @@ public static void assertAWT(String msg, File dump) throws Exception { try { if (dump != null) { Class type = Class.forName("org.netbeans.lib.profiler.results.cpu.StackTraceSnapshotBuilder"); - Object builder = type.newInstance(); + Object builder = type.getDeclaredConstructor().newInstance(); long base = System.currentTimeMillis(); long time = base; for (StackTraceElement[] arr : traces) { diff --git a/java/performance/test/unit/src/org/netbeans/performance/scalability/TabSwitchSpeedTest.java b/java/performance/test/unit/src/org/netbeans/performance/scalability/TabSwitchSpeedTest.java index c811632ae386..1492d879502f 100644 --- a/java/performance/test/unit/src/org/netbeans/performance/scalability/TabSwitchSpeedTest.java +++ b/java/performance/test/unit/src/org/netbeans/performance/scalability/TabSwitchSpeedTest.java @@ -140,7 +140,7 @@ public void testAllPlatform() throws Exception { final void activateComponent(TopComponent tc) { if (map == null) { try { - Object o = Class.forName("org.netbeans.performance.scalability.Calls").newInstance(); + Object o = Class.forName("org.netbeans.performance.scalability.Calls").getDeclaredConstructor().newInstance(); @SuppressWarnings("unchecked") Map m = (Map)o; map = m; diff --git a/java/whitelist/src/org/netbeans/spi/whitelist/support/WhiteListImplementationBuilder.java b/java/whitelist/src/org/netbeans/spi/whitelist/support/WhiteListImplementationBuilder.java index ccf8b058968a..263d44b8ee2a 100644 --- a/java/whitelist/src/org/netbeans/spi/whitelist/support/WhiteListImplementationBuilder.java +++ b/java/whitelist/src/org/netbeans/spi/whitelist/support/WhiteListImplementationBuilder.java @@ -354,12 +354,8 @@ private static final class Model { private Model() { try { - names = (Names) Class.forName(System.getProperty("WhiteListBuilder.names", DEF_NAMES)).newInstance(); //NOI18N - } catch (InstantiationException ex) { - throw new IllegalStateException("Cannot instantiate names", ex); //NOI18N - } catch (IllegalAccessException ex) { - throw new IllegalStateException("Cannot instantiate names", ex); //NOI18N - } catch (ClassNotFoundException ex) { + names = (Names) Class.forName(System.getProperty("WhiteListBuilder.names", DEF_NAMES)).getDeclaredConstructor().newInstance(); //NOI18N + } catch (ReflectiveOperationException ex) { throw new IllegalStateException("Cannot instantiate names", ex); //NOI18N } checkedPkgs = Union2.createFirst(new StringBuilder()); diff --git a/java/xml.tools.java/src/org/netbeans/modules/xml/tools/java/generator/SAXGeneratorAbstractPanel.java b/java/xml.tools.java/src/org/netbeans/modules/xml/tools/java/generator/SAXGeneratorAbstractPanel.java index 54c46155dab5..20af481bff23 100644 --- a/java/xml.tools.java/src/org/netbeans/modules/xml/tools/java/generator/SAXGeneratorAbstractPanel.java +++ b/java/xml.tools.java/src/org/netbeans/modules/xml/tools/java/generator/SAXGeneratorAbstractPanel.java @@ -86,13 +86,11 @@ private SAXGeneratorAbstractPanel getPeer() { // object properly, client need to call setIndex and setBean if (bean == null) throw new IllegalStateException(); if (index == null) throw new IllegalStateException(); - peer = (SAXGeneratorAbstractPanel) peerClass.newInstance(); + peer = (SAXGeneratorAbstractPanel) peerClass.getDeclaredConstructor().newInstance(); peer.step = this; peer.setObject(bean); peer.putClientProperty(WizardDescriptor.PROP_CONTENT_SELECTED_INDEX, index); // NOI18N - } catch (InstantiationException ex) { - throw new IllegalStateException(); - } catch (IllegalAccessException ex) { + } catch (ReflectiveOperationException ex) { throw new IllegalStateException(); } } diff --git a/nb/o.n.upgrader/src/org/netbeans/upgrade/systemoptions/SettingsRecognizer.java b/nb/o.n.upgrader/src/org/netbeans/upgrade/systemoptions/SettingsRecognizer.java index 4040ebdc7dd4..b9836c8a094e 100644 --- a/nb/o.n.upgrader/src/org/netbeans/upgrade/systemoptions/SettingsRecognizer.java +++ b/nb/o.n.upgrader/src/org/netbeans/upgrade/systemoptions/SettingsRecognizer.java @@ -311,7 +311,7 @@ public Object instanceCreate() throws java.io.IOException, ClassNotFoundExceptio } } else { try { - inst = clazz.newInstance(); + inst = clazz.getDeclaredConstructor().newInstance(); } catch (Exception ex) { IOException ioe = new IOException(); ErrorManager emgr = ErrorManager.getDefault(); diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java b/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java index 853aac8b0233..cba8a55286a0 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/indent/FmtOptions.java @@ -635,8 +635,8 @@ public Factory(String id, Class panelClass, String previewText @Override public PreferencesCustomizer create(Preferences preferences) { try { - return new CategorySupport(preferences, id, panelClass.newInstance(), previewText, forcedOptions); - } catch (InstantiationException | IllegalAccessException e) { + return new CategorySupport(preferences, id, panelClass.getDeclaredConstructor().newInstance(), previewText, forcedOptions); + } catch (ReflectiveOperationException e) { LOGGER.log(Level.WARNING, "Exception during creating formatter customiezer", e); return null; } diff --git a/platform/api.io/src/org/netbeans/api/io/IOProvider.java b/platform/api.io/src/org/netbeans/api/io/IOProvider.java index d72a80d980bc..37ad0dcd4e3c 100644 --- a/platform/api.io/src/org/netbeans/api/io/IOProvider.java +++ b/platform/api.io/src/org/netbeans/api/io/IOProvider.java @@ -120,7 +120,7 @@ private static InputOutputProvider getBridging(String methodName, if (cl != null) { try { Class c = Class.forName(className, true, cl); - Object instance = c.newInstance(); + Object instance = c.getDeclaredConstructor().newInstance(); Method m = c.getDeclaredMethod(methodName, paramTypes); Object result = m.invoke(instance, params); if (result instanceof InputOutputProvider) { diff --git a/platform/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoUsesSwingTest.java b/platform/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoUsesSwingTest.java index b9070daf898d..794457fad57c 100644 --- a/platform/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoUsesSwingTest.java +++ b/platform/core.netigso/test/unit/src/org/netbeans/core/netigso/NetigsoUsesSwingTest.java @@ -68,7 +68,7 @@ public void testCanReferenceJFrame() throws Exception { m1 = mgr.create(simpleModule, null, false, false, false); mgr.enable(Collections.singleton(m1)); Class c = m1.getClassLoader().loadClass("org.barwing.Main"); - Runnable r = (Runnable)c.newInstance(); + Runnable r = (Runnable)c.getDeclaredConstructor().newInstance(); r.run(); } finally { mgr.mutexPrivileged().exitWriteAccess(); diff --git a/platform/core.osgi/src/org/netbeans/core/osgi/Activator.java b/platform/core.osgi/src/org/netbeans/core/osgi/Activator.java index 856f447e8d63..8f6583e244de 100644 --- a/platform/core.osgi/src/org/netbeans/core/osgi/Activator.java +++ b/platform/core.osgi/src/org/netbeans/core/osgi/Activator.java @@ -315,7 +315,7 @@ private void registerUrlProtocolHandlers(final Bundle bundle) { class Svc extends AbstractURLStreamHandlerService { public @Override URLConnection openConnection(final URL u) throws IOException { try { - URLStreamHandler handler = (URLStreamHandler) bundle.loadClass(fqn).newInstance(); + URLStreamHandler handler = (URLStreamHandler) bundle.loadClass(fqn).getDeclaredConstructor().newInstance(); Method openConnection = URLStreamHandler.class.getDeclaredMethod("openConnection", URL.class); openConnection.setAccessible(true); return (URLConnection) openConnection.invoke(handler, u); diff --git a/platform/core.startup.base/src/org/netbeans/core/startup/layers/SystemFileSystem.java b/platform/core.startup.base/src/org/netbeans/core/startup/layers/SystemFileSystem.java index d10d56c59f51..1fa57ee30275 100644 --- a/platform/core.startup.base/src/org/netbeans/core/startup/layers/SystemFileSystem.java +++ b/platform/core.startup.base/src/org/netbeans/core/startup/layers/SystemFileSystem.java @@ -185,7 +185,7 @@ static SystemFileSystem create (File userDir, File homeDir, File[] extradirs) if (customFSClass != null) { try { Class clazz = Class.forName(customFSClass); - Object instance = clazz.newInstance(); + Object instance = clazz.getDeclaredConstructor().newInstance(); user = (FileSystem)instance; } catch (Exception x) { ModuleLayeredFileSystem.err.log( diff --git a/platform/core.startup/src/org/netbeans/core/startup/ManifestSection.java b/platform/core.startup/src/org/netbeans/core/startup/ManifestSection.java index 1ce3f02976b8..fb91fb830018 100644 --- a/platform/core.startup/src/org/netbeans/core/startup/ManifestSection.java +++ b/platform/core.startup/src/org/netbeans/core/startup/ManifestSection.java @@ -175,7 +175,7 @@ protected final Object createInstance() throws Exception { if (SharedClassObject.class.isAssignableFrom(clazz)) { return SharedClassObject.findObject(clazz.asSubclass(SharedClassObject.class), true); } else { - return clazz.newInstance(); + return clazz.getDeclaredConstructor().newInstance(); } } } diff --git a/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java b/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java index 67de8f6fb7b6..8d5e5668d0c3 100644 --- a/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java +++ b/platform/core.startup/test/unit/src/org/netbeans/core/startup/layers/CountingSecurityManager.java @@ -167,7 +167,7 @@ public void checkPermission(Permission p) { try { ClassLoader l = Thread.currentThread().getContextClassLoader(); Class manClass = Class.forName("org.netbeans.TopSecurityManager", false, l); - man = (SecurityManager) manClass.newInstance(); + man = (SecurityManager) manClass.getDeclaredConstructor().newInstance(); } catch (Exception ex) { throw new IllegalStateException(ex); } diff --git a/platform/core.windows/src/org/netbeans/core/windows/options/LafPanel.java b/platform/core.windows/src/org/netbeans/core/windows/options/LafPanel.java index c7725da837dd..4ecff34c30a3 100644 --- a/platform/core.windows/src/org/netbeans/core/windows/options/LafPanel.java +++ b/platform/core.windows/src/org/netbeans/core/windows/options/LafPanel.java @@ -276,7 +276,7 @@ private boolean isChangeEditorColorsPossible() { cl = LafPanel.class.getClassLoader(); try { Class klz = cl.loadClass( COLOR_MODEL_CLASS_NAME ); - Object colorModel = klz.newInstance(); + Object colorModel = klz.getDeclaredConstructor().newInstance(); Method m = klz.getDeclaredMethod( "getCurrentProfile", new Class[0] ); //NOI18N Object res = m.invoke( colorModel, new Object[0] ); return res != null && !preferredProfile.equals( res ); @@ -296,7 +296,7 @@ private void switchEditorColorsProfile() { cl = LafPanel.class.getClassLoader(); try { Class klz = cl.loadClass( COLOR_MODEL_CLASS_NAME ); - Object colorModel = klz.newInstance(); + Object colorModel = klz.getDeclaredConstructor().newInstance(); Method m = klz.getDeclaredMethod( "getAnnotations", String.class ); //NOI18N Object annotations = m.invoke( colorModel, preferredProfile ); m = klz.getDeclaredMethod( "setAnnotations", String.class, Collection.class ); //NOI18N @@ -349,7 +349,7 @@ private String getPreferredColorProfile() { try { Class klazz = loader.loadClass( className ); - LookAndFeel laf = ( LookAndFeel ) klazz.newInstance(); + LookAndFeel laf = ( LookAndFeel ) klazz.getDeclaredConstructor().newInstance(); return laf.getDefaults().getString( "nb.preferred.color.profile" ); //NOI18N } catch( Exception e ) { //ignore diff --git a/platform/core.windows/src/org/netbeans/core/windows/view/ui/toolbars/ToolbarContainer.java b/platform/core.windows/src/org/netbeans/core/windows/view/ui/toolbars/ToolbarContainer.java index 97a53056dcb1..ae4482d4a808 100644 --- a/platform/core.windows/src/org/netbeans/core/windows/view/ui/toolbars/ToolbarContainer.java +++ b/platform/core.windows/src/org/netbeans/core/windows/view/ui/toolbars/ToolbarContainer.java @@ -258,7 +258,7 @@ private JComponent createDragger() { if( null != className ) { try { Class klzz = Lookup.getDefault().lookup( ClassLoader.class ).loadClass( className ); - Object inst = klzz.newInstance(); + Object inst = klzz.getDeclaredConstructor().newInstance(); if( inst instanceof JComponent ) { JComponent dragarea = ( JComponent ) inst; dragarea.setCursor( Cursor.getPredefinedCursor(Cursor.MOVE_CURSOR) ); diff --git a/platform/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookup.java b/platform/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookup.java index d720879621b6..e5642d0d50b3 100644 --- a/platform/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookup.java +++ b/platform/editor.mimelookup.impl/src/org/netbeans/modules/editor/mimelookup/impl/SwitchLookup.java @@ -102,11 +102,8 @@ public Class annotationType() { if (loc.instanceProviderClass() != null && loc.instanceProviderClass() != InstanceProvider.class) { try { // Get a lookup for the new instance provider - lookup = getLookupForProvider(paths, loc.instanceProviderClass().newInstance()); - } catch (InstantiationException ex) { - Exceptions.printStackTrace(ex); - lookup = Lookup.EMPTY; - } catch (IllegalAccessException ex) { + lookup = getLookupForProvider(paths, loc.instanceProviderClass().getDeclaredConstructor().newInstance()); + } catch (ReflectiveOperationException ex) { Exceptions.printStackTrace(ex); lookup = Lookup.EMPTY; } diff --git a/platform/editor.mimelookup/src/org/netbeans/modules/editor/mimelookup/CreateRegistrationProcessor.java b/platform/editor.mimelookup/src/org/netbeans/modules/editor/mimelookup/CreateRegistrationProcessor.java index bf65fef12981..a7febe65e5d5 100644 --- a/platform/editor.mimelookup/src/org/netbeans/modules/editor/mimelookup/CreateRegistrationProcessor.java +++ b/platform/editor.mimelookup/src/org/netbeans/modules/editor/mimelookup/CreateRegistrationProcessor.java @@ -277,7 +277,7 @@ private Iterable completeMimePath( l = CreateRegistrationProcessor.class.getClassLoader(); } try { - COMPLETIONS = (Processor)Class.forName(pathCompletions, true, l).newInstance(); + COMPLETIONS = (Processor)Class.forName(pathCompletions, true, l).getDeclaredConstructor().newInstance(); } catch (Exception ex) { Exceptions.printStackTrace(ex); // no completions, OK diff --git a/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/AgentTest.java b/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/AgentTest.java index e47fca0dd11b..046cd1b360b0 100644 --- a/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/AgentTest.java +++ b/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/AgentTest.java @@ -59,7 +59,7 @@ public void testAgentClassRedefinesHello() throws Exception { Module m = mgr.create(agent, null, false, false, false); try { mgr.enable(m); - Callable c = (Callable) m.getClassLoader().loadClass("org.agent.HelloWorld").newInstance(); + Callable c = (Callable) m.getClassLoader().loadClass("org.agent.HelloWorld").getDeclaredConstructor().newInstance(); assertEquals("Bytecode has been patched", "Ahoj World!", c.call()); } finally { mgr.disable(m); diff --git a/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/CountingSecurityManager.java b/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/CountingSecurityManager.java index ca5d0d73525d..608d1d936dbe 100644 --- a/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/CountingSecurityManager.java +++ b/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/CountingSecurityManager.java @@ -162,7 +162,7 @@ public void checkPermission(Permission p) { try { ClassLoader l = Thread.currentThread().getContextClassLoader(); Class manClass = Class.forName("org.netbeans.TopSecurityManager", false, l); - man = (SecurityManager) manClass.newInstance(); + man = (SecurityManager) manClass.getDeclaredConstructor().newInstance(); } catch (Exception ex) { throw new IllegalStateException(ex); } diff --git a/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/NetigsoUsesSwingTest.java b/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/NetigsoUsesSwingTest.java index 66ff1ba6069f..96c6f9100515 100644 --- a/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/NetigsoUsesSwingTest.java +++ b/platform/netbinox/test/unit/src/org/netbeans/modules/netbinox/NetigsoUsesSwingTest.java @@ -76,7 +76,7 @@ public void testCanReferenceJFrame() throws Exception { m1 = mgr.create(simpleModule, null, false, false, false); mgr.enable(Collections.singleton(m1)); Class c = m1.getClassLoader().loadClass("org.barwing.Main"); - Runnable r = (Runnable)c.newInstance(); + Runnable r = (Runnable)c.getDeclaredConstructor().newInstance(); r.run(); } finally { mgr.mutexPrivileged().exitWriteAccess(); diff --git a/platform/o.n.bootstrap/test/unit/src/org/netbeans/AgentTest.java b/platform/o.n.bootstrap/test/unit/src/org/netbeans/AgentTest.java index ebc581d4deeb..3e92196ad472 100644 --- a/platform/o.n.bootstrap/test/unit/src/org/netbeans/AgentTest.java +++ b/platform/o.n.bootstrap/test/unit/src/org/netbeans/AgentTest.java @@ -40,7 +40,7 @@ public void testAgentClassRedefinesHello() throws Exception { Module m = mgr.create(jar, null, false, false, false); try { mgr.enable(m); - Callable c = (Callable) m.getClassLoader().loadClass("org.agent.HelloWorld").newInstance(); + Callable c = (Callable) m.getClassLoader().loadClass("org.agent.HelloWorld").getDeclaredConstructor().newInstance(); assertEquals("Bytecode has been patched", "Ahoj World!", c.call()); } finally { mgr.disable(m); diff --git a/platform/o.n.bootstrap/test/unit/src/org/netbeans/ModuleManagerTest.java b/platform/o.n.bootstrap/test/unit/src/org/netbeans/ModuleManagerTest.java index d60864328e7f..a37f613cf495 100644 --- a/platform/o.n.bootstrap/test/unit/src/org/netbeans/ModuleManagerTest.java +++ b/platform/o.n.bootstrap/test/unit/src/org/netbeans/ModuleManagerTest.java @@ -27,6 +27,7 @@ import java.lang.ref.WeakReference; import java.lang.reflect.Field; import java.lang.reflect.Method; +import java.lang.reflect.InvocationTargetException; import java.net.URL; import java.net.URLClassLoader; import java.net.URLConnection; @@ -168,7 +169,7 @@ public void testSimpleInstallation() throws Exception { ), installer.args); Class somethingelse = Class.forName("org.bar.SomethingElse", true, m2.getClassLoader()); Method somemethod = somethingelse.getMethod("message"); - assertEquals("hello", somemethod.invoke(somethingelse.newInstance())); + assertEquals("hello", somemethod.invoke(somethingelse.getDeclaredConstructor().newInstance())); installer.clear(); List toDisable = mgr.simulateDisable(Collections.singleton(m1)); assertEquals("correct result of simulateDisable", Arrays.asList(m2, m1), toDisable); @@ -242,7 +243,7 @@ public void testInstallAutoload() throws Exception { ), installer.args); Class somethingelse = Class.forName("org.bar.SomethingElse", true, m2.getClassLoader()); Method somemethod = somethingelse.getMethod("message"); - assertEquals("hello", somemethod.invoke(somethingelse.newInstance())); + assertEquals("hello", somemethod.invoke(somethingelse.getDeclaredConstructor().newInstance())); // Now try turning off m2 and make sure m1 goes away as well. assertEquals("correct result of simulateDisable", Arrays.asList(m2, m1), mgr.simulateDisable(Collections.singleton(m2))); installer.clear(); @@ -302,7 +303,7 @@ public void testInstallEager() throws Exception { ), installer.args); Class somethingelse = Class.forName("org.bar.SomethingElse", true, m2.getClassLoader()); Method somemethod = somethingelse.getMethod("message"); - assertEquals("hello", somemethod.invoke(somethingelse.newInstance())); + assertEquals("hello", somemethod.invoke(somethingelse.getDeclaredConstructor().newInstance())); // Now try turning off m1 and make sure m2 goes away quietly. assertEquals("correct result of simulateDisable", Arrays.asList(m2, m1), mgr.simulateDisable(Collections.singleton(m1))); installer.clear(); @@ -349,7 +350,7 @@ public void testEagerPlusAutoload() throws Exception { ), installer.args); Class somethingelseagain = Class.forName("org.baz.SomethingElseAgain", true, m3.getClassLoader()); Method somemethod = somethingelseagain.getMethod("doit"); - assertEquals("hello", somemethod.invoke(somethingelseagain.newInstance())); + assertEquals("hello", somemethod.invoke(somethingelseagain.getDeclaredConstructor().newInstance())); assertEquals("correct result of simulateDisable", Arrays.asList(m3, m2, m1), mgr.simulateDisable(Collections.singleton(m2))); installer.clear(); mgr.disable(Collections.singleton(m2)); @@ -658,7 +659,7 @@ public void testPackageLoading() throws Exception { Module m = mgr.create(new File(jars, "depends-on-lib-undecl.jar"), null, false, false, false); mgr.enable(m); Class c = m.getClassLoader().loadClass("org.dol.User"); - Object o = c.newInstance(); + Object o = c.getDeclaredConstructor().newInstance(); Field f = c.getField("val"); assertEquals(42, f.getInt(o)); mgr.disable(m); @@ -892,7 +893,7 @@ public void testModulePatches() throws Exception { mgr.enable(m); Class c = m.getClassLoader().loadClass("pkg.subpkg.A"); Field f = c.getField("val"); - Object o = c.newInstance(); + Object o = c.getDeclaredConstructor().newInstance(); assertEquals(25, f.getInt(o)); } finally { mgr.mutexPrivileged().exitWriteAccess(); @@ -2066,8 +2067,8 @@ public void testPackageExports() throws Exception { Module m2 = mgr.create(new File(jars, "uses-api-simple-dep.jar"), null, false, false, false); mgr.enable(m1); mgr.enable(m2); - m2.getClassLoader().loadClass("usesapi.UsesPublicClass").newInstance(); - m2.getClassLoader().loadClass("usesapi.UsesImplClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesPublicClass").getDeclaredConstructor().newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesImplClass").getDeclaredConstructor().newInstance(); mgr.disable(m2); mgr.disable(m1); mgr.delete(m2); @@ -2077,13 +2078,17 @@ public void testPackageExports() throws Exception { mgr.enable(m1); mgr.enable(m2); try { - m2.getClassLoader().loadClass("usesapi.UsesPublicClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesPublicClass").getDeclaredConstructor().newInstance(); fail(); - } catch (NoClassDefFoundError e) {} + } catch (InvocationTargetException e) { + assertTrue(e.getCause() instanceof NoClassDefFoundError); + } try { - m2.getClassLoader().loadClass("usesapi.UsesImplClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesImplClass").getDeclaredConstructor().newInstance(); fail(); - } catch (NoClassDefFoundError e) {} + } catch (InvocationTargetException e) { + assertTrue(e.getCause() instanceof NoClassDefFoundError); + } assertNotNull(mgr.getClassLoader().getResource("usesapi/UsesImplClass.class")); assertNotNull(mgr.getClassLoader().getResource("org/netbeans/api/foo/PublicClass.class")); assertNotNull(mgr.getClassLoader().getResource("org/netbeans/modules/foo/ImplClass.class")); @@ -2096,13 +2101,17 @@ public void testPackageExports() throws Exception { mgr.enable(m1); mgr.enable(m2); try { - m2.getClassLoader().loadClass("usesapi.UsesPublicClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesPublicClass").getDeclaredConstructor().newInstance(); fail(); - } catch (NoClassDefFoundError e) {} + } catch (InvocationTargetException e) { + assertTrue(e.getCause() instanceof NoClassDefFoundError); + } try { - m2.getClassLoader().loadClass("usesapi.UsesImplClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesImplClass").getDeclaredConstructor().newInstance(); fail(); - } catch (NoClassDefFoundError e) {} + } catch (InvocationTargetException e) { + assertTrue(e.getCause() instanceof NoClassDefFoundError); + } mgr.disable(m2); mgr.disable(m1); mgr.delete(m2); @@ -2111,8 +2120,8 @@ public void testPackageExports() throws Exception { m2 = mgr.create(new File(jars, "uses-api-impl-dep.jar"), null, false, false, false); mgr.enable(m1); mgr.enable(m2); - m2.getClassLoader().loadClass("usesapi.UsesPublicClass").newInstance(); - m2.getClassLoader().loadClass("usesapi.UsesImplClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesPublicClass").getDeclaredConstructor().newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesImplClass").getDeclaredConstructor().newInstance(); mgr.disable(m2); mgr.disable(m1); mgr.delete(m2); @@ -2123,11 +2132,13 @@ public void testPackageExports() throws Exception { mgr.enable(m1); assertEquals("uses-api-simple-dep.jar can be enabled", Collections.EMPTY_SET, m2.getProblems()); mgr.enable(m2); - m2.getClassLoader().loadClass("usesapi.UsesPublicClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesPublicClass").getDeclaredConstructor().newInstance(); try { - m2.getClassLoader().loadClass("usesapi.UsesImplClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesImplClass").getDeclaredConstructor().newInstance(); fail(); - } catch (NoClassDefFoundError e) {} + } catch (InvocationTargetException e) { + assertTrue(e.getCause() instanceof NoClassDefFoundError); + } mgr.disable(m2); mgr.disable(m1); mgr.delete(m2); @@ -2136,11 +2147,13 @@ public void testPackageExports() throws Exception { m2 = mgr.create(new File(jars, "uses-api-spec-dep.jar"), null, false, false, false); mgr.enable(m1); mgr.enable(m2); - m2.getClassLoader().loadClass("usesapi.UsesPublicClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesPublicClass").getDeclaredConstructor().newInstance(); try { - m2.getClassLoader().loadClass("usesapi.UsesImplClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesImplClass").getDeclaredConstructor().newInstance(); fail(); - } catch (NoClassDefFoundError e) {} + } catch (InvocationTargetException e) { + assertTrue(e.getCause() instanceof NoClassDefFoundError); + } mgr.disable(m2); mgr.disable(m1); mgr.delete(m2); @@ -2149,8 +2162,8 @@ public void testPackageExports() throws Exception { m2 = mgr.create(new File(jars, "uses-api-impl-dep.jar"), null, false, false, false); mgr.enable(m1); mgr.enable(m2); - m2.getClassLoader().loadClass("usesapi.UsesPublicClass").newInstance(); - m2.getClassLoader().loadClass("usesapi.UsesImplClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesPublicClass").getDeclaredConstructor().newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesImplClass").getDeclaredConstructor().newInstance(); mgr.disable(m2); mgr.disable(m1); mgr.delete(m2); @@ -2182,15 +2195,17 @@ public void testIndirectPackageExports() throws Exception { assertEquals("uses-and-exports-api.jar had no problems", Collections.EMPTY_SET, m2.getProblems()); assertEquals("uses-api-transitively.jar had no problems", Collections.EMPTY_SET, m3.getProblems()); assertEquals("uses-api-directly.jar had no problems", Collections.EMPTY_SET, m4.getProblems()); - mgr.enable(new HashSet(Arrays.asList(m1, m2, m3, m4))); - m4.getClassLoader().loadClass("usesapitrans.UsesDirectAPI").newInstance(); - m4.getClassLoader().loadClass("usesapitrans.UsesIndirectAPI").newInstance(); - m3.getClassLoader().loadClass("usesapitrans.UsesDirectAPI").newInstance(); + mgr.enable(new HashSet<>(Arrays.asList(m1, m2, m3, m4))); + m4.getClassLoader().loadClass("usesapitrans.UsesDirectAPI").getDeclaredConstructor().newInstance(); + m4.getClassLoader().loadClass("usesapitrans.UsesIndirectAPI").getDeclaredConstructor().newInstance(); + m3.getClassLoader().loadClass("usesapitrans.UsesDirectAPI").getDeclaredConstructor().newInstance(); try { - m3.getClassLoader().loadClass("usesapitrans.UsesIndirectAPI").newInstance(); + m3.getClassLoader().loadClass("usesapitrans.UsesIndirectAPI").getDeclaredConstructor().newInstance(); fail("Should not be able to use a transitive API class with no direct dependency"); - } catch (NoClassDefFoundError e) {} - mgr.disable(new HashSet(Arrays.asList(m1, m2, m3, m4))); + } catch (InvocationTargetException e) { + assertTrue(e.getCause() instanceof NoClassDefFoundError); + } + mgr.disable(new HashSet<>(Arrays.asList(m1, m2, m3, m4))); mgr.delete(m4); mgr.delete(m3); mgr.delete(m2); @@ -2215,34 +2230,34 @@ public void testPublicPackagesCanBeExportedToSelectedFriendsOnlyIssue54123 () th assertEquals("uses-api-directly.jar had no problems", Collections.EMPTY_SET, m4.getProblems()); assertEquals("uses-api-impl-dep-for-friends.jar had no problems", Collections.EMPTY_SET, m5.getProblems()); mgr.enable(new HashSet(Arrays.asList(m1, m2, m3, m4, m5))); - m2.getClassLoader().loadClass("usesapi.UsesPublicClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesPublicClass").getDeclaredConstructor().newInstance(); try { - m2.getClassLoader().loadClass("usesapi.UsesImplClass").newInstance(); + m2.getClassLoader().loadClass("usesapi.UsesImplClass").getDeclaredConstructor().newInstance(); fail ("Even friends modules cannot access implementation classes"); - } catch (NoClassDefFoundError ex) { - // ok + } catch (InvocationTargetException ex) { + assertTrue(ex.getCause() instanceof NoClassDefFoundError); } try { - m4.getClassLoader().loadClass("usesapi.UsesPublicClass").newInstance(); + m4.getClassLoader().loadClass("usesapi.UsesPublicClass").getDeclaredConstructor().newInstance(); fail ("m4 is not friend and should not be allowed to load the class"); - } catch (NoClassDefFoundError ex) { - // ok + } catch (InvocationTargetException ex) { + assertTrue(ex.getCause() instanceof NoClassDefFoundError); } try { - m4.getClassLoader().loadClass("usesapi.UsesImplClass").newInstance(); + m4.getClassLoader().loadClass("usesapi.UsesImplClass").getDeclaredConstructor().newInstance(); fail ("m4 is not friend and should not be allowed to load the implementation either"); - } catch (NoClassDefFoundError ex) { - // ok + } catch (InvocationTargetException ex) { + assertTrue(ex.getCause() instanceof NoClassDefFoundError); } try { - m5.getClassLoader().loadClass("usesapi.UsesPublicClass").newInstance(); - } catch (NoClassDefFoundError e) { + m5.getClassLoader().loadClass("usesapi.UsesPublicClass").getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException e) { fail("m5 has an implementation dependency and has not been allowed to load the public class"); } try { - m5.getClassLoader().loadClass("usesapi.UsesImplClass").newInstance(); - } catch (NoClassDefFoundError e) { + m5.getClassLoader().loadClass("usesapi.UsesImplClass").getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException e) { fail("m5 has an implementation dependency and has not been allowed to load the imlpementation class"); } diff --git a/platform/o.n.swing.plaf/src/org/netbeans/swing/plaf/Startup.java b/platform/o.n.swing.plaf/src/org/netbeans/swing/plaf/Startup.java index 8ab286991a4f..3e5f56e655a5 100644 --- a/platform/o.n.swing.plaf/src/org/netbeans/swing/plaf/Startup.java +++ b/platform/o.n.swing.plaf/src/org/netbeans/swing/plaf/Startup.java @@ -158,8 +158,8 @@ private LFInstanceOrName getLookAndFeel() { LookAndFeel lf = UIManager.getLookAndFeel(); if (uiClass != lf.getClass()) { try { - lf = (LookAndFeel) uiClass.newInstance(); - } catch (IllegalAccessException | InstantiationException ex) { + lf = (LookAndFeel) uiClass.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException ex) { return new LFInstanceOrName(uiClass.getName()); } } @@ -385,7 +385,7 @@ private LFCustoms findCustoms () { } try { Class klazz = UIUtils.classForName( uiClassName ); - Object inst = klazz.newInstance(); + Object inst = klazz.getDeclaredConstructor().newInstance(); if( inst instanceof LFCustoms ) return ( LFCustoms ) inst; } catch( ClassNotFoundException e ) { @@ -417,7 +417,7 @@ private LFCustoms findDefaultCustoms() { return new GtkLFCustoms(); } else { try { - return (LFCustoms) UIUtils.classForName(FORCED_CUSTOMS).newInstance(); + return (LFCustoms) UIUtils.classForName(FORCED_CUSTOMS).getDeclaredConstructor().newInstance(); } catch (Exception e) { System.err.println("UI customizations class not found: " //NOI18N + FORCED_CUSTOMS); //NOI18N diff --git a/platform/openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java b/platform/openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java index 04c61c415f7b..ab64edfcef7b 100644 --- a/platform/openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java +++ b/platform/openide.awt/src/org/netbeans/modules/openide/awt/ActionProcessor.java @@ -127,7 +127,7 @@ public Iterable getCompletions(Element element, Annotation l = ActionProcessor.class.getClassLoader(); } try { - COMPLETIONS = (Processor)Class.forName(pathCompletions, true, l).newInstance(); + COMPLETIONS = (Processor)Class.forName(pathCompletions, true, l).getDeclaredConstructor().newInstance(); } catch (Exception ex) { Exceptions.printStackTrace(ex); // no completions, OK diff --git a/platform/openide.execution/test/unit/src/org/openide/execution/NbClassLoaderTest.java b/platform/openide.execution/test/unit/src/org/openide/execution/NbClassLoaderTest.java index 989b5763c78a..433fc00093c0 100644 --- a/platform/openide.execution/test/unit/src/org/openide/execution/NbClassLoaderTest.java +++ b/platform/openide.execution/test/unit/src/org/openide/execution/NbClassLoaderTest.java @@ -72,7 +72,7 @@ public void testUsingNbfsProtocol() throws Exception { Class c = cl.loadClass("org.openide.execution.NbClassLoaderTest$User"); assertEquals(cl, c.getClassLoader()); try { - c.newInstance(); + c.getDeclaredConstructor().newInstance(); } catch (ExceptionInInitializerError eiie) { Throwable t = eiie.getException(); if (t instanceof IllegalStateException) { diff --git a/platform/openide.explorer/src/org/openide/explorer/propertysheet/IndexedPropertyEditor.java b/platform/openide.explorer/src/org/openide/explorer/propertysheet/IndexedPropertyEditor.java index 6e2ae38043d4..1df6b95f158d 100644 --- a/platform/openide.explorer/src/org/openide/explorer/propertysheet/IndexedPropertyEditor.java +++ b/platform/openide.explorer/src/org/openide/explorer/propertysheet/IndexedPropertyEditor.java @@ -376,7 +376,7 @@ private Object defaultValue() { } } else { try { - value = getConvertedType().newInstance(); + value = getConvertedType().getDeclaredConstructor().newInstance(); } catch (Exception x) { // ignore any exception - if this fails just // leave null as the value diff --git a/platform/openide.explorer/src/org/openide/explorer/propertysheet/ModelProperty.java b/platform/openide.explorer/src/org/openide/explorer/propertysheet/ModelProperty.java index c3e999d62b13..565735adf822 100644 --- a/platform/openide.explorer/src/org/openide/explorer/propertysheet/ModelProperty.java +++ b/platform/openide.explorer/src/org/openide/explorer/propertysheet/ModelProperty.java @@ -349,7 +349,7 @@ public PropertyEditor getPropertyEditor() { //overrides getPropertyEditorClass() try { //System.err.println(getDisplayName() + "Returning editor class specified property editor - " + edClass); - return (PropertyEditor) edClass.newInstance(); + return (PropertyEditor) edClass.getDeclaredConstructor().newInstance(); } catch (Exception e) { //fall through } diff --git a/platform/openide.explorer/src/org/openide/explorer/propertysheet/RendererFactory.java b/platform/openide.explorer/src/org/openide/explorer/propertysheet/RendererFactory.java index 60db44922a6d..b44fdc089037 100644 --- a/platform/openide.explorer/src/org/openide/explorer/propertysheet/RendererFactory.java +++ b/platform/openide.explorer/src/org/openide/explorer/propertysheet/RendererFactory.java @@ -283,7 +283,7 @@ private PropertyEditor preparePropertyEditor(PropertyModel pm, PropertyEnv env) if (c != null) { try { - result = (PropertyEditor) c.newInstance(); + result = (PropertyEditor) c.getDeclaredConstructor().newInstance(); //Check the values first Object mdlValue = pm.getValue(); diff --git a/platform/openide.loaders/src/org/openide/loaders/XMLDataObject.java b/platform/openide.loaders/src/org/openide/loaders/XMLDataObject.java index 51845241ddc3..bda8047559f1 100644 --- a/platform/openide.loaders/src/org/openide/loaders/XMLDataObject.java +++ b/platform/openide.loaders/src/org/openide/loaders/XMLDataObject.java @@ -24,7 +24,6 @@ import java.lang.ref.*; import java.lang.reflect.*; import java.net.URL; -import java.nio.charset.StandardCharsets; import java.util.*; import java.util.logging.*; import javax.xml.parsers.DocumentBuilder; @@ -1243,7 +1242,7 @@ public synchronized Object getInstance () { if (Processor.class.isAssignableFrom (next)) { // the class implements Processor interface, so use // default constructor to construct instance - obj = next.newInstance (); + obj = next.getDeclaredConstructor().newInstance (); Processor proc = (Processor) obj; proc.attachTo (xmlDataObject); return obj; @@ -1269,11 +1268,7 @@ public synchronized Object getInstance () { } } throw new InternalError ("XMLDataObject processor class " + next + " invalid"); // NOI18N - } catch (InvocationTargetException e) { - xmlDataObject.notifyEx (e); - } catch (InstantiationException e) { - xmlDataObject.notifyEx(e); - } catch (IllegalAccessException e) { + } catch (ReflectiveOperationException e) { xmlDataObject.notifyEx(e); } diff --git a/platform/openide.nodes/src/org/openide/nodes/BeanNode.java b/platform/openide.nodes/src/org/openide/nodes/BeanNode.java index 919e67681f6c..ad1b4dd1f34d 100644 --- a/platform/openide.nodes/src/org/openide/nodes/BeanNode.java +++ b/platform/openide.nodes/src/org/openide/nodes/BeanNode.java @@ -383,14 +383,9 @@ public java.awt.Component getCustomizer() { Object o; try { - o = clazz.newInstance(); - } catch (InstantiationException e) { + o = clazz.getDeclaredConstructor().newInstance(); + } catch (ReflectiveOperationException e) { NodeOp.exception(e); - - return null; - } catch (IllegalAccessException e) { - NodeOp.exception(e); - return null; } diff --git a/platform/openide.nodes/src/org/openide/nodes/TMUtil.java b/platform/openide.nodes/src/org/openide/nodes/TMUtil.java index 294002ed9003..26fd8466cc72 100644 --- a/platform/openide.nodes/src/org/openide/nodes/TMUtil.java +++ b/platform/openide.nodes/src/org/openide/nodes/TMUtil.java @@ -19,6 +19,7 @@ package org.openide.nodes; +import java.lang.reflect.InvocationTargetException; import java.util.Hashtable; import org.openide.util.Mutex; @@ -159,7 +160,7 @@ public Void run() { /** Executes algorithm of given name. * @param name the name of algorithm - * @return true iff successfule + * @return true if successful */ private static boolean exec(String name) { Object obj = algorithms.get(name); @@ -167,20 +168,14 @@ private static boolean exec(String name) { if (obj == null) { try { Class c = Class.forName("org.openide.nodes.TMUtil$" + name); // NOI18N - obj = c.newInstance(); - } catch (ClassNotFoundException ex) { + obj = c.getDeclaredConstructor().newInstance(); + } catch (ClassNotFoundException | InvocationTargetException | IllegalAccessException ex) { obj = ex; NodeOp.exception(ex); - } catch (InstantiationException ex) { + } catch (InstantiationException | NoSuchMethodException | NoClassDefFoundError ex) { // that is ok, we should not be able to create an // instance if some classes are missing obj = ex; - } catch (IllegalAccessException ex) { - obj = ex; - NodeOp.exception(ex); - } catch (NoClassDefFoundError ex) { - // that is ok, some classes need not be found - obj = ex; } algorithms.put(name, obj); @@ -308,7 +303,7 @@ public void run() { nodeRenderer = loadClass("org.openide.explorer.view.NodeRenderer"); // NOI18N } - TALK.set(nodeRenderer.newInstance()); + TALK.set(nodeRenderer.getDeclaredConstructor().newInstance()); } catch (Exception ex) { throw new IllegalStateException(ex.getMessage()); } diff --git a/platform/openide.util.lookup/src/org/openide/util/Lookup.java b/platform/openide.util.lookup/src/org/openide/util/Lookup.java index 5c053c724f01..684fd87fd472 100644 --- a/platform/openide.util.lookup/src/org/openide/util/Lookup.java +++ b/platform/openide.util.lookup/src/org/openide/util/Lookup.java @@ -122,7 +122,7 @@ public static synchronized Lookup getDefault() { LOG.log(Level.FINER, "Searching in classloader {0}", l); try { if (className != null) { - Object o = Class.forName(className, true, l).newInstance(); + Object o = Class.forName(className, true, l).getDeclaredConstructor().newInstance(); defaultLookup = (Lookup)o; // set the global global Lookuo GlobalLookup.setSystemLookup(defaultLookup); diff --git a/platform/openide.util.lookup/src/org/openide/util/lookup/MetaInfServicesLookup.java b/platform/openide.util.lookup/src/org/openide/util/lookup/MetaInfServicesLookup.java index bfe00b034f47..f701548de10b 100644 --- a/platform/openide.util.lookup/src/org/openide/util/lookup/MetaInfServicesLookup.java +++ b/platform/openide.util.lookup/src/org/openide/util/lookup/MetaInfServicesLookup.java @@ -58,7 +58,7 @@ static synchronized Executor getRP() { if (res == null) { try { Class seek = Class.forName("org.openide.util.RequestProcessor"); - res = (Executor)seek.newInstance(); + res = (Executor)seek.getDeclaredConstructor().newInstance(); } catch (Throwable t) { try { res = Executors.newSingleThreadExecutor(); diff --git a/platform/openide.util.lookup/test/unit/src/org/openide/util/lookup/AbstractLookupBaseHid.java b/platform/openide.util.lookup/test/unit/src/org/openide/util/lookup/AbstractLookupBaseHid.java index abe390ac7a30..6641e7d5122a 100644 --- a/platform/openide.util.lookup/test/unit/src/org/openide/util/lookup/AbstractLookupBaseHid.java +++ b/platform/openide.util.lookup/test/unit/src/org/openide/util/lookup/AbstractLookupBaseHid.java @@ -1307,7 +1307,7 @@ private void doTwoSerializedClasses (boolean queryBeforeSerialization, boolean u loader = new CL (); c = loader.loadClass (Garbage.class.getName ()); - Object theInstance = c.newInstance (); + Object theInstance = c.getDeclaredConstructor().newInstance (); ic.addPair (new SerialPair (theInstance)); diff --git a/platform/openide.util.ui/test/unit/src/org/netbeans/modules/openide/util/NbBundleProcessorTest.java b/platform/openide.util.ui/test/unit/src/org/netbeans/modules/openide/util/NbBundleProcessorTest.java index 84bcbc383645..b2d7ec3745aa 100644 --- a/platform/openide.util.ui/test/unit/src/org/netbeans/modules/openide/util/NbBundleProcessorTest.java +++ b/platform/openide.util.ui/test/unit/src/org/netbeans/modules/openide/util/NbBundleProcessorTest.java @@ -209,18 +209,18 @@ public void testIncrementalCompilation() throws Exception { assertTrue(AnnotationProcessorTestUtils.runJavac(src, null, dest, null, null)); assertTrue(AnnotationProcessorTestUtils.runJavac(src, null, dest, null, null)); ClassLoader l = new URLClassLoader(new URL[] {Utilities.toURI(dest).toURL()}); - assertEquals("v1", l.loadClass("p.C1").newInstance().toString()); - assertEquals("v2", l.loadClass("p.C2").newInstance().toString()); + assertEquals("v1", l.loadClass("p.C1").getDeclaredConstructor().newInstance().toString()); + assertEquals("v2", l.loadClass("p.C2").getDeclaredConstructor().newInstance().toString()); AnnotationProcessorTestUtils.makeSource(src, "p.C1", "@org.openide.util.NbBundle.Messages(\"k1=v3\")", "public class C1 {public @Override String toString() {return Bundle.k1();}}"); assertTrue(AnnotationProcessorTestUtils.runJavac(src, "C1.java", dest, null, null)); l = new URLClassLoader(new URL[] {Utilities.toURI(dest).toURL()}); - assertEquals("v3", l.loadClass("p.C1").newInstance().toString()); - assertEquals("v2", l.loadClass("p.C2").newInstance().toString()); + assertEquals("v3", l.loadClass("p.C1").getDeclaredConstructor().newInstance().toString()); + assertEquals("v2", l.loadClass("p.C2").getDeclaredConstructor().newInstance().toString()); AnnotationProcessorTestUtils.makeSource(src, "p.C1", "@org.openide.util.NbBundle.Messages(\"k3=v4\")", "public class C1 {public @Override String toString() {return Bundle.k3();}}"); assertTrue(AnnotationProcessorTestUtils.runJavac(src, "C1.java", dest, null, null)); l = new URLClassLoader(new URL[] {Utilities.toURI(dest).toURL()}); - assertEquals("v4", l.loadClass("p.C1").newInstance().toString()); - assertEquals("v2", l.loadClass("p.C2").newInstance().toString()); + assertEquals("v4", l.loadClass("p.C1").getDeclaredConstructor().newInstance().toString()); + assertEquals("v2", l.loadClass("p.C2").getDeclaredConstructor().newInstance().toString()); } public void testIncrementalCompilationWithBrokenClassFiles() throws Exception { @@ -230,16 +230,16 @@ public void testIncrementalCompilationWithBrokenClassFiles() throws Exception { assertTrue(AnnotationProcessorTestUtils.runJavac(src, null, dest, null, null)); assertTrue(AnnotationProcessorTestUtils.runJavac(src, null, dest, null, null)); ClassLoader l = new URLClassLoader(new URL[] {Utilities.toURI(dest).toURL()}); - assertEquals("v1", l.loadClass("p.C1").newInstance().toString()); - assertEquals("v2", l.loadClass("p.C2").newInstance().toString()); + assertEquals("v1", l.loadClass("p.C1").getDeclaredConstructor().newInstance().toString()); + assertEquals("v2", l.loadClass("p.C2").getDeclaredConstructor().newInstance().toString()); assertTrue(new File(dest, "p/C3.class").delete()); assertTrue(new File(dest, "p/C3$1.class").delete()); assertTrue(new File(dest, "p/C3$1$1.class").isFile()); AnnotationProcessorTestUtils.makeSource(src, "p.C1", "@org.openide.util.NbBundle.Messages(\"k1=v3\")", "public class C1 {public @Override String toString() {return Bundle.k1();}}"); assertTrue(AnnotationProcessorTestUtils.runJavac(src, "C1.java", dest, null, null)); l = new URLClassLoader(new URL[] {Utilities.toURI(dest).toURL()}); - assertEquals("v3", l.loadClass("p.C1").newInstance().toString()); - assertEquals("v2", l.loadClass("p.C2").newInstance().toString()); + assertEquals("v3", l.loadClass("p.C1").getDeclaredConstructor().newInstance().toString()); + assertEquals("v2", l.loadClass("p.C2").getDeclaredConstructor().newInstance().toString()); } public void testIncrementalCompilationWithPackageInfo() throws Exception { @@ -248,11 +248,11 @@ public void testIncrementalCompilationWithPackageInfo() throws Exception { assertTrue(AnnotationProcessorTestUtils.runJavac(src, null, dest, null, null)); assertTrue(AnnotationProcessorTestUtils.runJavac(src, null, dest, null, null)); ClassLoader l = new URLClassLoader(new URL[] {Utilities.toURI(dest).toURL()}); - assertEquals("v1v2", l.loadClass("p.C").newInstance().toString()); + assertEquals("v1v2", l.loadClass("p.C").getDeclaredConstructor().newInstance().toString()); assertTrue(new File(dest, "p/C.class").delete()); assertTrue(AnnotationProcessorTestUtils.runJavac(src, "C.java", dest, null, null)); l = new URLClassLoader(new URL[] {Utilities.toURI(dest).toURL()}); - assertEquals("v1v2", l.loadClass("p.C").newInstance().toString()); + assertEquals("v1v2", l.loadClass("p.C").getDeclaredConstructor().newInstance().toString()); } public void testComments() throws Exception { diff --git a/platform/openide.util/src/org/openide/util/NbBundle.java b/platform/openide.util/src/org/openide/util/NbBundle.java index e66b3fc11044..b3235ddadf05 100644 --- a/platform/openide.util/src/org/openide/util/NbBundle.java +++ b/platform/openide.util/src/org/openide/util/NbBundle.java @@ -602,7 +602,7 @@ private static ResourceBundle loadBundleClass( for (String suffix : suffixes) { try { Class c = Class.forName(name + suffix, true, l).asSubclass(ResourceBundle.class); - ResourceBundle b = c.newInstance(); + ResourceBundle b = c.getDeclaredConstructor().newInstance(); if (master == null) { master = b; diff --git a/platform/sendopts/src/org/netbeans/api/sendopts/CommandLine.java b/platform/sendopts/src/org/netbeans/api/sendopts/CommandLine.java index 314402281e7c..5c5ac6e57a11 100644 --- a/platform/sendopts/src/org/netbeans/api/sendopts/CommandLine.java +++ b/platform/sendopts/src/org/netbeans/api/sendopts/CommandLine.java @@ -93,7 +93,7 @@ public static CommandLine create(Object... instances) { } private static CommandLine createImpl(Object[] instances) { - List arr = new ArrayList(); + List arr = new ArrayList<>(); for (Object o : instances) { Class c; Object instance; @@ -107,12 +107,10 @@ private static CommandLine createImpl(Object[] instances) { if (OptionProcessor.class.isAssignableFrom(c)) { try { if (instance == null) { - instance = c.newInstance(); + instance = c.getDeclaredConstructor().newInstance(); } arr.add((OptionProcessor) instance); - } catch (InstantiationException ex) { - throw new IllegalStateException(ex); - } catch (IllegalAccessException ex) { + } catch (ReflectiveOperationException ex) { throw new IllegalStateException(ex); } } else { diff --git a/platform/sendopts/src/org/netbeans/modules/sendopts/DefaultProcessor.java b/platform/sendopts/src/org/netbeans/modules/sendopts/DefaultProcessor.java index f1928b5fcefe..4e2e1ecc523c 100644 --- a/platform/sendopts/src/org/netbeans/modules/sendopts/DefaultProcessor.java +++ b/platform/sendopts/src/org/netbeans/modules/sendopts/DefaultProcessor.java @@ -156,7 +156,7 @@ protected void process(Env env, Map optionValues) throws Comma Object inst; if (instance == null) { realClazz = Class.forName(clazz, true, l); - inst = realClazz.newInstance(); + inst = realClazz.getDeclaredConstructor().newInstance(); } else { realClazz = instance.getClass(); inst = instance; diff --git a/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/formatter/FmtOptions.java b/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/formatter/FmtOptions.java index 6a21b86a36cc..8780ab37a8dc 100644 --- a/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/formatter/FmtOptions.java +++ b/webcommon/javascript2.editor/src/org/netbeans/modules/javascript2/editor/formatter/FmtOptions.java @@ -634,8 +634,8 @@ public Factory(String mimeType, String id, Class panelClass, @Override public PreferencesCustomizer create(Preferences preferences) { try { - return new CategorySupport(mimeType, provider, preferences, id, panelClass.newInstance(), previewText, forcedOptions); - } catch (RuntimeException | IllegalAccessException | InstantiationException e) { + return new CategorySupport(mimeType, provider, preferences, id, panelClass.getDeclaredConstructor().newInstance(), previewText, forcedOptions); + } catch (RuntimeException | ReflectiveOperationException e) { LOGGER.log(Level.WARNING, "Exception during creating formatter customiezer", e); return null; } diff --git a/webcommon/libs.graaljs/test/unit/src/org/netbeans/libs/graaljs/GraalJSTest2.java b/webcommon/libs.graaljs/test/unit/src/org/netbeans/libs/graaljs/GraalJSTest2.java index 5a8b6ff3bd1c..b93e78f76024 100644 --- a/webcommon/libs.graaljs/test/unit/src/org/netbeans/libs/graaljs/GraalJSTest2.java +++ b/webcommon/libs.graaljs/test/unit/src/org/netbeans/libs/graaljs/GraalJSTest2.java @@ -127,7 +127,7 @@ public void testDirectEvaluationOfGraalJS() throws Exception { // the test code itself HAS to use the module system to load appropriate Engine. URL u = getClass().getProtectionDomain().getCodeSource().getLocation(); ClassLoader ldr2 = new URLClassLoader(new URL[] { u }, ldr); - Callable c = (Callable)ldr2.loadClass(getClass().getName() + "$T").newInstance(); + Callable c = (Callable)ldr2.loadClass(getClass().getName() + "$T").getDeclaredConstructor().newInstance(); c.call(); } From a8efe63c517d4dc7d91c33f6e98fbc5ae037cce3 Mon Sep 17 00:00:00 2001 From: Michael Bien Date: Wed, 14 Feb 2024 07:07:02 +0100 Subject: [PATCH 05/12] Prefer list.sort(comp) over Collections.sort(list, comp) - more fluent/direct - one less import in many cases --- .../project/layers/LayerUtilsTest.java | 2 +- .../j2ee/common/DatasourceUIHelper.java | 3 +-- .../mdb/MessageDestinationUiSupport.java | 2 +- .../entries/DataSourceReferencePanel.form | 2 +- .../entries/DataSourceReferencePanel.java | 3 +-- .../entries/SendJMSMessageUiSupport.java | 2 +- .../j2ee/ejbverification/HintTestBase.java | 2 +- .../test/j2ee/hints/EntityRelations.java | 5 ++--- .../ide/editors/ui/SortableDDTableModel.java | 2 +- .../netbeans/modules/web/el/ELTestBase.java | 2 +- .../jsf/editor/actions/NamespaceProcessor.java | 3 +-- .../JsfAttributesCompletionHelper.java | 3 +-- .../graph/layout/GridGraphLayoutUtility.java | 3 +-- .../graph/layout/SceneElementComparator.java | 2 +- .../modules/web/jsf/JsfTemplateUtils.java | 3 +-- .../wizards/JSFConfigurationPanelVisual.java | 2 +- .../web/project/ui/ConfFilesNodeFactory.java | 2 +- .../websvc/core/jaxws/nodes/JaxWsChildren.java | 8 ++------ .../websvc/core/jaxws/nodes/PortChildren.java | 3 +-- .../modules/ws/qaf/editor/HintsTests.java | 4 ++-- .../websvc/rest/nodes/HttpMethodsChildren.java | 7 +------ .../SubResourceLocatorsChildrenFactory.java | 3 +-- .../ide/ergonomics/CommonServersBase.java | 4 ++-- .../CustomActionRegistrationSupport.java | 3 +-- .../modules/gradle/api/execute/RunUtils.java | 2 +- .../gradle/execute/navigator/TasksPanel.java | 5 ++--- .../api/completion/GroovyCCTestBase.java | 3 +-- .../src/org/netbeans/api/debugger/Lookup.java | 2 +- .../bridge/nodes/BugtrackingRootNode.java | 4 +--- .../tasks/dashboard/TaskContainerNode.java | 2 +- .../ui/search/QuickSearchPopup.java | 2 +- .../netbeans/modules/analysis/ui/Nodes.java | 8 ++++---- .../modules/csl/editor/SyncDocumentRegion.java | 3 +-- .../editor/overridden/IsOverriddenPopup.java | 3 +-- .../hints/infrastructure/GsfHintsManager.java | 2 +- .../csl/navigation/ClassMemberFilters.java | 2 +- .../csl/navigation/ElementScanningTask.java | 4 ++-- .../csl/spi/support/ModificationResult.java | 2 +- .../modules/csl/api/test/CslTestBase.java | 14 +++++++------- .../css/editor/module/CssModuleSupport.java | 2 +- .../modules/css/visual/RuleEditorNode.java | 8 ++++---- .../modules/db/sql/history/SQLHistory.java | 2 +- .../modules/db/dataview/meta/DBTable.java | 6 ++---- .../db/dataview/output/DataViewDBTable.java | 2 +- .../celleditor/ClobFieldTableCellEditor.java | 2 +- .../modules/db/mysql/nodes/ServerNode.java | 4 +--- .../editor/ui/actions/ConnectionAction.java | 3 +-- .../explorer/support/DatabaseExplorerUIs.java | 3 +-- .../db/util/DatabaseExplorerInternalUIs.java | 11 +++++------ .../modules/diff/builtin/ContextualPatch.java | 2 +- .../api/execution/IOTabsController.java | 3 +-- .../api/util/RemoteMeasurements.java | 5 ++--- .../test/NativeExecutionBaseTestSuite.java | 3 +-- .../docker/ui/build2/BuildInstanceVisual.java | 3 +-- .../docker/ui/node/DockerChildFactory.java | 3 +-- .../ui/node/DockerContainersChildFactory.java | 3 +-- .../ui/node/DockerImagesChildFactory.java | 3 +-- .../lib/editor/bookmarks/api/BookmarkList.java | 2 +- .../editor/bookmarks/BookmarkManager.java | 6 +++--- .../editor/bookmarks/FileBookmarks.java | 3 +-- .../CodeTemplateManagerOperation.java | 6 +++--- .../codetemplates/SyncDocumentRegion.java | 3 +-- .../storage/ui/CodeTemplatesModel.java | 3 +-- .../editor/completion/CompletionImpl.java | 2 +- .../editor/fold/ui/CaretFoldExpanderImpl.java | 2 +- .../editor/fold/ui/FoldOptionsPanel.java | 4 +--- .../modules/editor/fold/FoldOperationImpl.java | 5 ++--- .../modules/editor/indent/TaskHandler.java | 2 +- .../editor/lib2/view/EditorViewFactory.java | 2 +- .../spi/editor/highlighting/ZOrder.java | 3 +-- .../editor/macros/storage/ui/MacrosModel.java | 2 +- .../storage/keybindings/KeyMapsStorage.java | 3 +-- .../base/ExplicitProcessParameters.java | 2 +- .../ui/repository/RepositoryBrowserPanel.java | 4 ++-- .../repository/RevisionDialogController.java | 4 ++-- .../html/editor/hints/HtmlHintsProvider.java | 2 +- .../netbeans/modules/jumpto/common/Models.java | 2 +- .../jumpto/quicksearch/GoToSymbolWorker.java | 3 +-- .../jumpto/quicksearch/GoToTypeWorker.java | 2 +- .../languages/database/DatabaseContext.java | 10 +++++----- .../refactoring/ModificationResult.java | 2 +- .../ui/diff/ExportDiffChangesAction.java | 2 +- .../mercurial/ui/diff/MultiDiffPanel.java | 2 +- .../swing/dirchooser/DirectoryNode.java | 7 +++---- .../options/colors/AnnotationsPanel.java | 5 ++--- .../options/colors/HighlightingPanel.java | 4 ++-- .../completion/CodeCompletionOptionsPanel.java | 7 ++----- .../modules/parsing/api/Embedding.java | 3 +-- .../modules/parsing/impl/SourceCache.java | 2 +- .../parsing/impl/indexing/IndexerCache.java | 4 ++-- .../impl/indexing/RepositoryUpdater2Test.java | 2 +- .../impl/indexing/RepositoryUpdaterTest.java | 12 ++++++------ .../impl/ProjectModificationResultImpl.java | 2 +- .../impl/TextDocumentEditProcessor.java | 3 +-- .../project/libraries/LibraryChooserGUI.java | 2 +- .../modules/project/ui/BrowseFolders.java | 2 +- .../project/ui/ProjectChooserAccessory.java | 2 +- .../modules/project/ui/ProjectsRootNode.java | 2 +- .../modules/properties/BundleStructure.java | 7 +++---- .../modules/refactoring/spi/ui/ScopePanel.java | 3 +-- .../server/ui/manager/ServerManagerPanel.java | 4 +--- .../modules/server/ui/node/RootNode.java | 3 +-- .../modules/spellchecker/DictionaryImpl.java | 6 +++--- .../options/SpellcheckerOptionsPanel.java | 9 ++------- .../debugger/ui/actions/ConnectorPanel.java | 5 +---- .../netbeans/modules/editor/hints/FixData.java | 3 +-- .../subversion/ui/diff/ExportDiffAction.java | 2 +- .../ui/history/RepositoryRevision.java | 4 ++-- .../modules/subversion/util/SvnUtils.java | 2 +- .../modules/team/ide/PatchContextChooser.java | 3 +-- .../versioning/core/ProjectMenuItem.java | 2 +- .../versioning/core/VersioningMainMenu.java | 2 +- .../versioning/util/ProjectUtilities.java | 2 +- .../modules/web/browser/api/WebBrowsers.java | 2 +- .../modules/web/common/ui/ImportantFiles.java | 2 +- .../modules/web/indent/api/LexUtilities.java | 3 +-- .../indent/api/support/AbstractIndenter.java | 5 ++--- .../modules/xml/dtd/grammar/DTDGrammar.java | 2 +- .../modules/xml/xdm/diff/DiffFinder.java | 6 ++---- .../modules/beans/PatternAnalyser.java | 7 +++---- .../jdbcimpl/wizard/SortedListModel.java | 4 ++-- .../modules/dbschema/nodes/TableChildren.java | 2 +- .../jpda/projects/SourcePathProviderImpl.java | 2 +- .../modules/form/BindingCustomizer.java | 4 ++-- .../modules/form/ConnectionCustomEditor.form | 2 +- .../modules/form/ConnectionCustomEditor.java | 3 +-- .../form/GandalfPersistenceManager.java | 2 +- .../org/netbeans/modules/form/HandleLayer.java | 3 +-- .../modules/form/JavaCodeGenerator.java | 2 +- .../netbeans/modules/form/MethodPicker.java | 2 +- .../modules/form/ParametersPicker.java | 2 +- .../netbeans/modules/form/PropertyPicker.java | 2 +- .../modules/form/actions/EncloseAction.java | 3 +-- .../form/layoutdesign/LayoutAligner.java | 2 +- .../support/SwingLayoutCodeGenerator.java | 2 +- .../modules/form/wizard/ConnectionPanel2.java | 4 ++-- .../java/classpath/GradleSourcesImpl.java | 2 +- .../modules/i18n/form/I18nServiceImpl.java | 2 +- .../unit/PersistenceCfgProperties.java | 3 +-- .../wizard/fromdb/DBSchemaFileList.java | 2 +- .../library/PersistenceLibrarySupport.java | 5 ++--- .../common/project/ProjectConfigurations.java | 2 +- .../project/ui/MultiModuleNodeFactory.java | 4 ++-- .../ui/customizer/MainClassChooser.form | 2 +- .../ui/customizer/MainClassChooser.java | 5 ++--- .../common/classpath/ModuleClassPathsTest.java | 7 ++----- .../base/javadoc/JavadocImportsTest.java | 12 ++++++------ .../java/editor/codegen/ui/ElementNode.java | 5 ++--- .../java/editor/imports/ClipboardHandler.java | 2 +- .../editor/overridden/IsOverriddenPopup.form | 6 +++++- .../editor/overridden/IsOverriddenPopup.java | 3 +-- .../java/editor/rename/SyncDocumentRegion.java | 3 +-- .../semantic/MarkOccurrencesHighlighter.java | 2 +- .../occurrences/MarkOccurrencesTest.java | 4 +--- .../editor/completion/CompletionTestBase.java | 3 +-- .../java/editor/imports/UnusedImportsTest.java | 8 +------- .../java/freeform/ui/SourceFoldersPanel.java | 5 ++--- .../java/hints/spiimpl/options/HintsPanel.java | 5 ++--- .../AbstractApplyHintsRefactoringPlugin.java | 2 +- .../modules/java/hints/OrganizeImports.java | 3 +-- .../hints/bugs/ComparatorParameterNotUsed.java | 3 +-- .../infrastructure/JavaErrorProvider.java | 2 +- .../hints/introduce/IntroduceMethodFix.java | 2 +- .../hints/infrastructure/HintsTestBase.java | 3 +-- .../modules/java/mx/project/CoreSuiteTest.java | 7 ++----- .../java/navigation/ClassMemberFilters.java | 2 +- .../java/openjdk/jtreg/TagOrderHint.java | 3 +-- .../openjdk/project/ConfigurationImpl.java | 2 +- .../java/platform/ui/PlatformsCustomizer.java | 2 +- .../modules/java/project/ui/FixPlatform.java | 2 +- .../JavadocAndSourceRootDetectionTest.java | 6 ++---- .../api/java/source/GeneratorUtilities.java | 2 +- .../netbeans/api/java/source/WorkingCopy.java | 4 ++-- .../java/source/save/DiffUtilities.java | 8 +------- .../java/source/usages/BinaryAnalyser.java | 3 +-- .../api/java/source/gen/ImportFormatTest.java | 2 +- .../source/support/ProfileSupportTest.java | 2 +- .../api/java/source/ui/ElementHeadersTest.java | 3 +-- .../java/source/ui/JavaTypeProviderTest.java | 3 +-- .../modules/javadoc/search/IndexSearch.java | 2 +- .../modules/maven/codegen/NewPluginPanel.java | 3 +-- .../maven/navigator/POMModelVisitor.java | 11 ++++------- .../junit/ui/MavenJUnitTestMethodNode.java | 3 +-- .../modules/maven/api/PluginPropertyUtils.java | 2 +- .../maven/newproject/ChooseArchetypePanel.java | 5 ++--- .../maven/nodes/AddDependencyPanel.java | 4 ++-- .../modules/maven/nodes/DependenciesNode.java | 2 +- .../MavenDependenciesImplementationTest.java | 2 +- .../EncapsulateFieldRefactoringPlugin.java | 2 +- .../java/plugins/FindUsagesVisitor.java | 6 +----- .../java/ui/EncapsulateFieldPanel.java | 2 +- .../java/ui/ExtractInterfacePanel.java | 2 +- .../java/ui/ExtractSuperclassPanel.java | 3 +-- .../refactoring/java/ui/MoveClassPanel.java | 2 +- .../refactoring/java/ui/MoveMembersPanel.java | 4 ++-- .../java/ui/SyncDocumentRegion.java | 7 ++----- .../test/refactoring/ModifyingRefactoring.java | 2 +- .../editor/completion/impl/ClassCompleter.java | 3 +-- .../javafx2/editor/FXMLCompletionTestBase.java | 8 +------- .../project/JFXProjectConfigurations.java | 4 ++-- .../pluginimporter/ImportManager.java | 4 ++-- .../welcome/content/CombinationRSSFeed.java | 3 +-- .../php/api/ui/options/FrameworksPanel.java | 3 +-- .../AnalysisOptionsPanelController.java | 3 +-- .../php/editor/actions/FixUsesPerformer.java | 2 +- .../php/editor/actions/ImportDataCreator.java | 2 +- .../php/editor/csl/NavigatorScanner.java | 2 +- .../editor/model/impl/FunctionScopeImpl.java | 2 +- .../php/editor/csl/PhpNavigatorTestBase.java | 6 +++--- .../modules/php/nette2/ConfigurationFiles.java | 2 +- .../php/project/PhpConfigurationProvider.java | 2 +- .../project/connections/RemoteConnections.java | 2 +- .../connections/sync/SyncController.java | 4 ++-- .../connections/ui/RemoteConnectionsPanel.java | 4 ++-- .../ui/transfer/tree/TransferSelector.form | 2 +- .../ui/transfer/tree/TransferSelector.java | 5 ++--- .../php/project/ui/actions/RemoteCommand.java | 3 +-- .../customizer/CompositePanelProviderImpl.java | 2 +- .../ui/customizer/CustomizerTesting.java | 3 +-- .../php/symfony/ConfigurationFiles.java | 2 +- .../php/symfony2/ConfigurationFiles.java | 2 +- .../modules/php/zend/ConfigurationFiles.java | 2 +- .../modules/php/zend2/ConfigurationFiles.java | 2 +- .../modules/search/SearchScopeList.java | 4 +--- .../visual/graph/layout/GridGraphLayout.java | 2 +- .../graph/layout/HierarchicalLayout.java | 8 ++++---- .../autoupdate/services/UpdateUnitImpl.java | 2 +- .../autoupdate/ui/SettingsTableModel.java | 3 +-- .../autoupdate/ui/UnitCategoryTableModel.java | 4 ++-- .../ui/wizards/OperationDescriptionStep.java | 2 +- .../autoupdate/ui/wizards/OperationPanel.java | 3 +-- .../core/network/utils/IpAddressUtils.java | 3 +-- .../core/network/utils/LocalAddressUtils.java | 2 +- .../org/netbeans/core/osgi/OSGiProcess.java | 3 +-- .../startup/layers/BinaryCacheManager.java | 2 +- .../filetypes/FileAssociationsModel.java | 2 +- .../filetypes/FileAssociationsPanel.java | 3 +-- .../src/org/netbeans/core/windows/Central.java | 2 +- .../org/netbeans/core/windows/LazyLoader.java | 2 +- .../core/windows/model/DefaultModeModel.java | 4 ++-- .../core/windows/view/dnd/KeyboardDnd.java | 3 +-- .../modules/javahelp/JavaHelpQuery.java | 3 +-- .../swing/etable/ColumnSelectionPanel.java | 14 +++++++------- .../src/org/netbeans/swing/etable/ETable.java | 2 +- .../org/netbeans/swing/outline/Outline.java | 4 +--- .../openide/explorer/view/TreeTableView.java | 6 ++---- .../openide/filesystems/FileFilterSupport.java | 5 ++--- .../src/org/openide/loaders/FolderList.java | 2 +- .../openide/loaders/FolderComparatorTest.java | 3 +-- .../src/org/openide/nodes/Children.java | 2 +- .../src/org/openide/nodes/NodeLookup.java | 2 +- .../openide/util/lookup/InheritanceTree.java | 2 +- .../util/ServiceProviderProcessorTest.java | 2 +- .../modules/options/advanced/Model.java | 3 +-- .../modules/print/provider/ComponentPanel.java | 4 +--- .../profiler/ui/swing/ProfilerColumnModel.java | 3 +-- .../lib/profiler/heap/HprofGCRoots.java | 2 +- .../profiler/instrumentation/ClassManager.java | 4 ++-- .../modules/profiler/api/ProjectUtilities.java | 16 +++------------- .../heapwalk/ClassesListController.java | 2 +- .../heapwalk/InstancesListController.java | 3 +-- .../heapwalk/memorylint/RuleRegistry.java | 18 +++--------------- .../ppoints/LoadGenProfilingPoint.java | 9 +-------- .../ppoints/ProfilingPointsManager.java | 2 +- .../snaptracer/impl/TracerSupportImpl.java | 3 +-- .../modules/profiler/ResultsManager.java | 7 ++----- .../rust/cargo/impl/CargoTOMLParser.java | 3 +-- .../modules/cordova/project/PluginsPanel.java | 3 +-- .../bower/ui/libraries/DependenciesPanel.java | 2 +- .../javascript/cdnjs/ui/SelectionPanel.java | 5 ++--- .../javascript/karma/util/FileUtils.java | 2 +- .../nodejs/ui/libraries/DependenciesPanel.java | 2 +- .../javascript/nodejs/util/FileUtils.java | 2 +- .../editor/formatter/FormatContext.java | 3 +-- .../editor/parser/JsErrorManager.java | 2 +- .../javascript2/extdoc/ExtDocModelTest.java | 4 ++-- .../javascript2/jsdoc/JsDocModelTest.java | 4 ++-- .../modules/javascript2/model/api/Model.java | 4 ++-- .../javascript2/sdoc/SDocModelTest.java | 4 ++-- .../remotefiles/RemoteFilesNode.java | 3 +-- .../webkit/knockout/KnockoutChildFactory.java | 3 +-- .../debugger/locals/VariablesModel.java | 3 +-- 282 files changed, 398 insertions(+), 597 deletions(-) diff --git a/apisupport/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/layers/LayerUtilsTest.java b/apisupport/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/layers/LayerUtilsTest.java index ef8b3c6f3754..ac08b16304db 100644 --- a/apisupport/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/layers/LayerUtilsTest.java +++ b/apisupport/apisupport.ant/test/unit/src/org/netbeans/modules/apisupport/project/layers/LayerUtilsTest.java @@ -141,7 +141,7 @@ public boolean accept(File dir, String name) { } })); System.out.println("Loading external cache from " + cacheDir + ", " + files.size() + " files"); - Collections.sort(files, new Comparator() { + files.sort(new Comparator() { public int compare(File f1, File f2) { return - f1.getName().compareTo(f2.getName()); } diff --git a/enterprise/j2ee.common/src/org/netbeans/modules/j2ee/common/DatasourceUIHelper.java b/enterprise/j2ee.common/src/org/netbeans/modules/j2ee/common/DatasourceUIHelper.java index affc750c5bc0..310f224015e9 100644 --- a/enterprise/j2ee.common/src/org/netbeans/modules/j2ee/common/DatasourceUIHelper.java +++ b/enterprise/j2ee.common/src/org/netbeans/modules/j2ee/common/DatasourceUIHelper.java @@ -30,7 +30,6 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.LinkedList; @@ -608,7 +607,7 @@ private static List getDatasources(final J2eeModuleProvider provider datasources.addAll(serverDatasources); ArrayList sortedDatasources = new ArrayList(datasources); - Collections.sort(sortedDatasources, new DatasourceComparator()); + sortedDatasources.sort(new DatasourceComparator()); return sortedDatasources; } diff --git a/enterprise/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/mdb/MessageDestinationUiSupport.java b/enterprise/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/mdb/MessageDestinationUiSupport.java index bc3642ec5160..61db0f69f5af 100644 --- a/enterprise/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/mdb/MessageDestinationUiSupport.java +++ b/enterprise/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ejb/wizard/mdb/MessageDestinationUiSupport.java @@ -121,7 +121,7 @@ public static void populateDestinations(final Set destinatio comboBox.setRenderer(new MessageDestinationListCellRenderer()); List sortedDestinations = new ArrayList(destinations); - Collections.sort(sortedDestinations, new MessageDestinationComparator()); + sortedDestinations.sort(new MessageDestinationComparator()); comboBox.removeAllItems(); for (MessageDestination d : sortedDestinations) { diff --git a/enterprise/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entries/DataSourceReferencePanel.form b/enterprise/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entries/DataSourceReferencePanel.form index 487b3e3897e4..42eda6660b68 100644 --- a/enterprise/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entries/DataSourceReferencePanel.form +++ b/enterprise/j2ee.ejbcore/src/org/netbeans/modules/j2ee/ejbcore/ui/logicalview/entries/DataSourceReferencePanel.form @@ -1,4 +1,4 @@ - + -
+ + + + + diff --git a/java/java.editor/src/org/netbeans/modules/java/editor/overridden/IsOverriddenPopup.java b/java/java.editor/src/org/netbeans/modules/java/editor/overridden/IsOverriddenPopup.java index 7daa69e607aa..6c10dd7127e4 100644 --- a/java/java.editor/src/org/netbeans/modules/java/editor/overridden/IsOverriddenPopup.java +++ b/java/java.editor/src/org/netbeans/modules/java/editor/overridden/IsOverriddenPopup.java @@ -26,7 +26,6 @@ import java.awt.event.FocusListener; import java.awt.event.KeyEvent; import java.awt.event.MouseEvent; -import java.util.Collections; import java.util.Comparator; import java.util.List; import javax.swing.DefaultListCellRenderer; @@ -53,7 +52,7 @@ public IsOverriddenPopup(String caption, List declarations) this.caption = caption; this.declarations = declarations; - Collections.sort(declarations, new Comparator() { + declarations.sort(new Comparator() { public int compare(ElementDescription o1, ElementDescription o2) { if (o1.isOverridden() == o2.isOverridden()) { return o1.getDisplayName().compareTo(o2.getDisplayName()); diff --git a/java/java.editor/src/org/netbeans/modules/java/editor/rename/SyncDocumentRegion.java b/java/java.editor/src/org/netbeans/modules/java/editor/rename/SyncDocumentRegion.java index af7be5f6a324..5b6fcd849ee9 100644 --- a/java/java.editor/src/org/netbeans/modules/java/editor/rename/SyncDocumentRegion.java +++ b/java/java.editor/src/org/netbeans/modules/java/editor/rename/SyncDocumentRegion.java @@ -20,7 +20,6 @@ package org.netbeans.modules.java.editor.rename; import java.util.ArrayList; -import java.util.Collections; import java.util.List; import javax.swing.text.BadLocationException; import javax.swing.text.Document; @@ -64,7 +63,7 @@ public SyncDocumentRegion(Document doc, List re sortedRegions = regions; } else { sortedRegions = new ArrayList(regions); - Collections.sort(sortedRegions, PositionRegion.getComparator()); + sortedRegions.sort(PositionRegion.getComparator()); } } diff --git a/java/java.editor/src/org/netbeans/modules/java/editor/semantic/MarkOccurrencesHighlighter.java b/java/java.editor/src/org/netbeans/modules/java/editor/semantic/MarkOccurrencesHighlighter.java index df13ade8e4b1..0a36776247ec 100644 --- a/java/java.editor/src/org/netbeans/modules/java/editor/semantic/MarkOccurrencesHighlighter.java +++ b/java/java.editor/src/org/netbeans/modules/java/editor/semantic/MarkOccurrencesHighlighter.java @@ -106,7 +106,7 @@ protected void process(CompilationInfo info, Document doc, SchedulerEvent event) bag = new ArrayList(); } - Collections.sort(bag, new Comparator() { + bag.sort(new Comparator() { public int compare(int[] o1, int[] o2) { return o1[0] - o2[0]; } diff --git a/java/java.editor/test/qa-functional/src/org/netbeans/test/java/editor/occurrences/MarkOccurrencesTest.java b/java/java.editor/test/qa-functional/src/org/netbeans/test/java/editor/occurrences/MarkOccurrencesTest.java index f1b970f6f0b3..fb813eeab5fa 100644 --- a/java/java.editor/test/qa-functional/src/org/netbeans/test/java/editor/occurrences/MarkOccurrencesTest.java +++ b/java/java.editor/test/qa-functional/src/org/netbeans/test/java/editor/occurrences/MarkOccurrencesTest.java @@ -41,10 +41,8 @@ import org.netbeans.api.java.source.JavaSource; import org.netbeans.api.java.source.JavaSource.Phase; import org.netbeans.api.java.source.support.CaretAwareJavaSourceTaskFactory; -import org.netbeans.jemmy.EventTool; import org.netbeans.junit.NbModuleSuite; import org.netbeans.junit.NbTestCase; -import org.netbeans.junit.RandomlyFails; import org.netbeans.modules.java.editor.base.options.MarkOccurencesSettingsNames; import org.netbeans.modules.java.editor.base.semantic.MarkOccurrencesHighlighterBase; import org.netbeans.modules.java.editor.options.MarkOccurencesSettings; @@ -317,7 +315,7 @@ private void setAndCheck(int pos,SimpleMark[] marks) throws IOException { if(foundMarks==null) { ref = ""; } else { - Collections.sort(foundMarks, new Comparator(){ + foundMarks.sort(new Comparator(){ public int compare(int[] o1, int[] o2) { if(o1[0] items = JavaCompletionProvider.query(s, CompletionProvider.COMPLETION_QUERY_TYPE, caretPos + textToInsertLength, caretPos + textToInsertLength); - Collections.sort(items, CompletionItemComparator.BY_PRIORITY); + items.sort(CompletionItemComparator.BY_PRIORITY); assertNotNull(goldenFileName); diff --git a/java/java.editor/test/unit/src/org/netbeans/modules/java/editor/imports/UnusedImportsTest.java b/java/java.editor/test/unit/src/org/netbeans/modules/java/editor/imports/UnusedImportsTest.java index 63187a978e14..01d448ca44f3 100644 --- a/java/java.editor/test/unit/src/org/netbeans/modules/java/editor/imports/UnusedImportsTest.java +++ b/java/java.editor/test/unit/src/org/netbeans/modules/java/editor/imports/UnusedImportsTest.java @@ -30,8 +30,6 @@ import java.io.OutputStream; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; -import java.util.Comparator; import java.util.List; import java.util.concurrent.atomic.AtomicBoolean; import java.util.regex.Pattern; @@ -690,11 +688,7 @@ public void run(CompilationController parameter) throws IOException { } }, true); - Collections.sort(realSpans, new Comparator() { - @Override public int compare(int[] o1, int[] o2) { - return o1[0] - o2[0]; - } - }); + realSpans.sort((int[] o1, int[] o2) -> o1[0] - o2[0]); int[][] goldenSpansArray = goldenSpans.toArray(new int[0][]); int[][] realSpansArray = realSpans.toArray(new int[0][]); diff --git a/java/java.freeform/src/org/netbeans/modules/java/freeform/ui/SourceFoldersPanel.java b/java/java.freeform/src/org/netbeans/modules/java/freeform/ui/SourceFoldersPanel.java index 040a5747a798..a3f5b0cb4301 100644 --- a/java/java.freeform/src/org/netbeans/modules/java/freeform/ui/SourceFoldersPanel.java +++ b/java/java.freeform/src/org/netbeans/modules/java/freeform/ui/SourceFoldersPanel.java @@ -28,7 +28,6 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; @@ -893,8 +892,8 @@ private void updateModel(List srcFolders) { } if (notEmpty) { FolderComparator comparator = new FolderComparator(); - Collections.sort(finalSourceFolders, comparator); - Collections.sort(finalTestFolders, comparator); + finalSourceFolders.sort(comparator); + finalTestFolders.sort(comparator); for (SourceFolder sf : finalSourceFolders) { model.addSourceFolder(sf, false); } diff --git a/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/options/HintsPanel.java b/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/options/HintsPanel.java index 02dd3991330a..7e74a831299b 100644 --- a/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/options/HintsPanel.java +++ b/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/options/HintsPanel.java @@ -35,7 +35,6 @@ import java.io.IOException; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.IdentityHashMap; @@ -1209,7 +1208,7 @@ private DefaultTreeModel constructTM(Collection metadata TreePath currentPath = category2Node.get(cat); DefaultMutableTreeNode node = (DefaultMutableTreeNode) currentPath.getLastPathComponent(); - Collections.sort(cat.subCategories, new Comparator() { + cat.subCategories.sort(new Comparator() { @Override public int compare(HintCategory o1, HintCategory o2) { return HintsPanel.compare(o1.displayName, o2.displayName); } @@ -1224,7 +1223,7 @@ private DefaultTreeModel constructTM(Collection metadata hints.addAll(cat.subCategories); - Collections.sort(cat.hints, new Comparator() { + cat.hints.sort(new Comparator() { @Override public int compare(HintMetadata o1, HintMetadata o2) { return o1.displayName.compareTo(o2.displayName); } diff --git a/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/refactoring/AbstractApplyHintsRefactoringPlugin.java b/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/refactoring/AbstractApplyHintsRefactoringPlugin.java index ca1196af20ee..5f798abbff70 100644 --- a/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/refactoring/AbstractApplyHintsRefactoringPlugin.java +++ b/java/java.hints.ui/src/org/netbeans/modules/java/hints/spiimpl/refactoring/AbstractApplyHintsRefactoringPlugin.java @@ -152,7 +152,7 @@ protected Collection performApplyPattern(Iterable changes : file2Changes.values()) { - Collections.sort(changes, new Comparator() { + changes.sort(new Comparator() { @Override public int compare(RefactoringElementImplementation o1, RefactoringElementImplementation o2) { return o1.getPosition().getBegin().getOffset() - o2.getPosition().getBegin().getOffset(); } diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java b/java/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java index 9bbc56f0f022..3f89bb551319 100644 --- a/java/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java +++ b/java/java.hints/src/org/netbeans/modules/java/hints/OrganizeImports.java @@ -48,7 +48,6 @@ import com.sun.source.util.TreePath; import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner; import com.sun.source.util.Trees; -import com.sun.tools.javac.code.Scope; import com.sun.tools.javac.code.Symbol; import com.sun.tools.javac.tree.JCTree.JCCompilationUnit; import com.sun.tools.javac.util.Name; @@ -204,7 +203,7 @@ public static void doOrganizeImports(WorkingCopy copy, Set addImports, return; } if (!imps.isEmpty()) { - Collections.sort(imps, new Comparator() { + imps.sort(new Comparator() { private CodeStyle.ImportGroups groups = cs.getImportGroups(); diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java b/java/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java index 374e6838eefe..ae96d5343582 100644 --- a/java/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java +++ b/java/java.hints/src/org/netbeans/modules/java/hints/bugs/ComparatorParameterNotUsed.java @@ -26,7 +26,6 @@ import org.netbeans.api.java.source.support.ErrorAwareTreePathScanner; import java.text.Collator; import java.util.ArrayList; -import java.util.Collections; import java.util.HashSet; import java.util.List; import java.util.Set; @@ -119,7 +118,7 @@ public static List run(HintContext ctx) { List ll = new ArrayList(v.unusedVars); List res = new ArrayList<>(ll.size()); - Collections.sort(ll, Collator.getInstance()); + ll.sort(Collator.getInstance()); for (VariableElement ve : ll) { Tree vt = ve.getSimpleName() == par1.getName() ? par1 : par2; res.add( diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java b/java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java index f332ca7c82cb..c8725dce9fdb 100644 --- a/java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java +++ b/java/java.hints/src/org/netbeans/modules/java/hints/infrastructure/JavaErrorProvider.java @@ -315,7 +315,7 @@ protected void performRewrite(JavaFix.TransformationContext ctx) throws Exceptio private static List sortFixes(Collection fixes) { List result = new ArrayList(fixes); - Collections.sort(result, new FixComparator()); + result.sort(new FixComparator()); return result; } diff --git a/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceMethodFix.java b/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceMethodFix.java index 0a50a91b146a..e92d0eee4126 100644 --- a/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceMethodFix.java +++ b/java/java.hints/src/org/netbeans/modules/java/hints/introduce/IntroduceMethodFix.java @@ -839,7 +839,7 @@ public void run(ResultIterator resultIterator) throws Exception { } Pattern p = Pattern.createPatternWithRemappableVariables(statementsPaths, parameters, true); List occurrences = new ArrayList(Matcher.create(copy).setSearchRoot(pathToClass).setCancel(new AtomicBoolean()).match(p)); - Collections.sort(occurrences, new OccurrencePositionComparator(copy.getCompilationUnit(), copy.getTrees().getSourcePositions())); + occurrences.sort(new OccurrencePositionComparator(copy.getCompilationUnit(), copy.getTrees().getSourcePositions())); for (Occurrence desc :occurrences ) { TreePath firstLeaf = desc.getOccurrenceRoot(); if (!isDuplicateValid(firstLeaf)) { diff --git a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/HintsTestBase.java b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/HintsTestBase.java index 8233a68783c8..c2c621f89113 100644 --- a/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/HintsTestBase.java +++ b/java/java.hints/test/unit/src/org/netbeans/modules/java/hints/infrastructure/HintsTestBase.java @@ -31,7 +31,6 @@ import java.io.Writer; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.LinkedHashSet; import java.util.LinkedList; @@ -311,7 +310,7 @@ private List sortFixes(Collection fixes) { } } - Collections.sort(sortableFixes, new FixComparator()); + sortableFixes.sort(new FixComparator()); List result = new ArrayList(); diff --git a/java/java.mx.project/test/unit/src/org/netbeans/modules/java/mx/project/CoreSuiteTest.java b/java/java.mx.project/test/unit/src/org/netbeans/modules/java/mx/project/CoreSuiteTest.java index 2be0bdb1ac50..b190de1c005f 100644 --- a/java/java.mx.project/test/unit/src/org/netbeans/modules/java/mx/project/CoreSuiteTest.java +++ b/java/java.mx.project/test/unit/src/org/netbeans/modules/java/mx/project/CoreSuiteTest.java @@ -25,7 +25,6 @@ import java.net.URL; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.Map; import org.junit.Assume; @@ -115,10 +114,8 @@ private static void dump(StringBuilder sb, String indent, Object obj) throws Sec } private static Iterable sortMethods(Method[] methods) { - List arr = new ArrayList(Arrays.asList(methods)); - Collections.sort(arr, (o1, o2) -> { - return o1.getName().compareTo(o2.getName()); - }); + List arr = new ArrayList<>(Arrays.asList(methods)); + arr.sort((o1, o2) -> o1.getName().compareTo(o2.getName())); return arr; } } diff --git a/java/java.navigation/src/org/netbeans/modules/java/navigation/ClassMemberFilters.java b/java/java.navigation/src/org/netbeans/modules/java/navigation/ClassMemberFilters.java index 7a2d2a9e38a0..45c62a46ab44 100644 --- a/java/java.navigation/src/org/netbeans/modules/java/navigation/ClassMemberFilters.java +++ b/java/java.navigation/src/org/netbeans/modules/java/navigation/ClassMemberFilters.java @@ -93,7 +93,7 @@ public Collection filter( Collection origina result.add(description); } - Collections.sort( result, isNaturalSort() ? Description.POSITION_COMPARATOR : Description.ALPHA_COMPARATOR ); + result.sort(isNaturalSort() ? Description.POSITION_COMPARATOR : Description.ALPHA_COMPARATOR ); return result; } diff --git a/java/java.openjdk.project/src/org/netbeans/modules/java/openjdk/jtreg/TagOrderHint.java b/java/java.openjdk.project/src/org/netbeans/modules/java/openjdk/jtreg/TagOrderHint.java index 1f2462b9ebe8..91eb767f45ca 100644 --- a/java/java.openjdk.project/src/org/netbeans/modules/java/openjdk/jtreg/TagOrderHint.java +++ b/java/java.openjdk.project/src/org/netbeans/modules/java/openjdk/jtreg/TagOrderHint.java @@ -19,7 +19,6 @@ package org.netbeans.modules.java.openjdk.jtreg; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -60,7 +59,7 @@ public static ErrorDescription computeWarning(HintContext ctx) { private static List sortTags(Result tags) { List sorted = new ArrayList<>(tags.getTags()); - Collections.sort(sorted, new Comparator() { + sorted.sort(new Comparator() { @Override public int compare(Tag o1, Tag o2) { int pos1 = TagParser.RECOMMENDED_TAGS_ORDER.indexOf(o1.getName()); int pos2 = TagParser.RECOMMENDED_TAGS_ORDER.indexOf(o2.getName()); diff --git a/java/java.openjdk.project/src/org/netbeans/modules/java/openjdk/project/ConfigurationImpl.java b/java/java.openjdk.project/src/org/netbeans/modules/java/openjdk/project/ConfigurationImpl.java index 7db7d4c13790..635fa4895a2c 100644 --- a/java/java.openjdk.project/src/org/netbeans/modules/java/openjdk/project/ConfigurationImpl.java +++ b/java/java.openjdk.project/src/org/netbeans/modules/java/openjdk/project/ConfigurationImpl.java @@ -175,7 +175,7 @@ private synchronized void updateConfigurations() { newConfigurations.add(0, newActive); } - Collections.sort(newConfigurations, new Comparator() { + newConfigurations.sort(new Comparator() { @Override public int compare(ConfigurationImpl o1, ConfigurationImpl o2) { return o1.getLocation().getName().compareTo(o2.getLocation().getName()); } diff --git a/java/java.platform.ui/src/org/netbeans/modules/java/platform/ui/PlatformsCustomizer.java b/java/java.platform.ui/src/org/netbeans/modules/java/platform/ui/PlatformsCustomizer.java index 47ffd0df3f7e..d8b84fc7a9e7 100644 --- a/java/java.platform.ui/src/org/netbeans/modules/java/platform/ui/PlatformsCustomizer.java +++ b/java/java.platform.ui/src/org/netbeans/modules/java/platform/ui/PlatformsCustomizer.java @@ -552,7 +552,7 @@ public List getPlatform () { if (changed) { //SortedSet can't be used, there can be platforms with the same //display name - Collections.sort(platforms, new PlatformNodeComparator()); + platforms.sort(new PlatformNodeComparator()); changed = false; } return Collections.unmodifiableList (this.platforms); diff --git a/java/java.project.ui/src/org/netbeans/modules/java/project/ui/FixPlatform.java b/java/java.project.ui/src/org/netbeans/modules/java/project/ui/FixPlatform.java index ab96870f9337..3232e893f404 100644 --- a/java/java.project.ui/src/org/netbeans/modules/java/project/ui/FixPlatform.java +++ b/java/java.project.ui/src/org/netbeans/modules/java/project/ui/FixPlatform.java @@ -311,7 +311,7 @@ private void init () { toSelect = broken; newPlatfs.add(broken); } - Collections.sort(newPlatfs, (p1,p2) -> { + newPlatfs.sort((p1,p2) -> { if (p1 == broken) { return -1; } diff --git a/java/java.project/test/unit/src/org/netbeans/spi/java/project/support/JavadocAndSourceRootDetectionTest.java b/java/java.project/test/unit/src/org/netbeans/spi/java/project/support/JavadocAndSourceRootDetectionTest.java index baac170c0b21..ca37cb4d22fa 100644 --- a/java/java.project/test/unit/src/org/netbeans/spi/java/project/support/JavadocAndSourceRootDetectionTest.java +++ b/java/java.project/test/unit/src/org/netbeans/spi/java/project/support/JavadocAndSourceRootDetectionTest.java @@ -20,14 +20,12 @@ package org.netbeans.spi.java.project.support; import java.io.File; -import java.io.FileOutputStream; import java.io.IOException; import java.net.URL; import java.nio.charset.Charset; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.Set; @@ -146,8 +144,8 @@ public int compare(FileObject o1, FileObject o2) { return o1.getNameExt().compareToIgnoreCase(o2.getNameExt()); } }; - Collections.sort(expected,c); - Collections.sort(result,c); + expected.sort(c); + result.sort(c); assertEquals (expected.toString(), result.toString()); } diff --git a/java/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java b/java/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java index 02ecc97368bd..7aac23e9ae57 100644 --- a/java/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java +++ b/java/java.source.base/src/org/netbeans/api/java/source/GeneratorUtilities.java @@ -1331,7 +1331,7 @@ private CompilationUnitTree addImports(CompilationUnitTree cut, List tag2Span, Collection textC return; } List orderedDiffs = new ArrayList<>(textChanges); - Collections.sort(orderedDiffs, new Comparator() { + orderedDiffs.sort(new Comparator() { @Override public int compare(Diff o1, Diff o2) { return o1.getPos() - o2.getPos(); @@ -959,7 +959,7 @@ public int compare(Diff o1, Diff o2) { }); List spans = new ArrayList<>(tag2Span.values()); - Collections.sort(spans, new Comparator() { + spans.sort(new Comparator() { @Override public int compare(int[] o1, int[] o2) { return o1[0] - o2[0]; diff --git a/java/java.source.base/src/org/netbeans/modules/java/source/save/DiffUtilities.java b/java/java.source.base/src/org/netbeans/modules/java/source/save/DiffUtilities.java index e92594a2df79..858ecab07bc4 100644 --- a/java/java.source.base/src/org/netbeans/modules/java/source/save/DiffUtilities.java +++ b/java/java.source.base/src/org/netbeans/modules/java/source/save/DiffUtilities.java @@ -20,8 +20,6 @@ import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; -import java.util.Comparator; import java.util.LinkedList; import java.util.List; import java.util.Map; @@ -59,11 +57,7 @@ public static List diff(String origContent, String newContent, int offset, } public static List diff2ModificationResultDifference(FileObject fo, PositionConverter converter, Map userInfo, String content, List diffs, Source src) throws IOException, BadLocationException { - Collections.sort(diffs, new Comparator() { - public int compare(Diff o1, Diff o2) { - return o1.getPos() - o2.getPos(); - } - }); + diffs.sort((Diff o1, Diff o2) -> o1.getPos() - o2.getPos()); Rewriter out = new Rewriter(fo, converter, userInfo, src); char[] buf = content.toCharArray(); diff --git a/java/java.source.base/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java b/java/java.source.base/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java index 6500315dd173..765f7724bcb8 100644 --- a/java/java.source.base/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java +++ b/java/java.source.base/src/org/netbeans/modules/java/source/usages/BinaryAnalyser.java @@ -39,7 +39,6 @@ import java.nio.file.Path; import java.nio.file.StandardOpenOption; import java.nio.file.attribute.BasicFileAttributes; -import java.nio.file.attribute.FileTime; import java.util.ArrayList; import java.util.Arrays; import java.util.Collection; @@ -1186,7 +1185,7 @@ private RootProcessor() { protected final boolean execute(Predicate accept) throws IOException { final boolean res = executeImpl(accept); if (res) { - Collections.sort(result, COMPARATOR); + result.sort(COMPARATOR); } return res; } diff --git a/java/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ImportFormatTest.java b/java/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ImportFormatTest.java index eb32b6201077..bb1ea8534b1c 100644 --- a/java/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ImportFormatTest.java +++ b/java/java.source.base/test/unit/src/org/netbeans/api/java/source/gen/ImportFormatTest.java @@ -399,7 +399,7 @@ public void run(WorkingCopy workingCopy) throws IOException { List imports = new ArrayList(cut.getImports()); ImportTree oneImport = imports.remove(4); imports.add(4, make.Import(make.Identifier("java.util.Collection"), false)); - Collections.sort(imports, new Comparator() { + imports.sort(new Comparator() { public int compare(Object o1, Object o2) { if (o1 == o2) { return 0; diff --git a/java/java.source.base/test/unit/src/org/netbeans/api/java/source/support/ProfileSupportTest.java b/java/java.source.base/test/unit/src/org/netbeans/api/java/source/support/ProfileSupportTest.java index 5854d03f1d92..be538fa18bb9 100644 --- a/java/java.source.base/test/unit/src/org/netbeans/api/java/source/support/ProfileSupportTest.java +++ b/java/java.source.base/test/unit/src/org/netbeans/api/java/source/support/ProfileSupportTest.java @@ -186,7 +186,7 @@ private void assertEquals( v.getRequiredProfile())); } for (List,SourceLevelQuery.Profile>> l : resM.values()) { - Collections.sort(l, new Comparator,SourceLevelQuery.Profile>>() { + l.sort(new Comparator,SourceLevelQuery.Profile>>() { @Override public int compare( Pair, SourceLevelQuery.Profile> o1, diff --git a/java/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java b/java/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java index 75ebd78a6df9..27c8f35f7875 100644 --- a/java/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java +++ b/java/java.sourceui/test/unit/src/org/netbeans/api/java/source/ui/ElementHeadersTest.java @@ -28,7 +28,6 @@ import java.nio.file.Files; import java.nio.file.Path; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.List; import java.util.concurrent.Callable; @@ -305,7 +304,7 @@ public boolean accept(Element e, TypeMirror type) { private List sortChildren(StructureElement parent) { List ch = new ArrayList<>(parent.getChildren()); - Collections.sort(ch, new Comparator() { + ch.sort(new Comparator() { @Override public int compare(StructureElement o1, StructureElement o2) { return o1.getSelectionStartOffset() - o2.getSelectionStartOffset(); diff --git a/java/java.sourceui/test/unit/src/org/netbeans/modules/java/source/ui/JavaTypeProviderTest.java b/java/java.sourceui/test/unit/src/org/netbeans/modules/java/source/ui/JavaTypeProviderTest.java index d2bd00113c46..ce7f1ba577fa 100644 --- a/java/java.sourceui/test/unit/src/org/netbeans/modules/java/source/ui/JavaTypeProviderTest.java +++ b/java/java.sourceui/test/unit/src/org/netbeans/modules/java/source/ui/JavaTypeProviderTest.java @@ -34,7 +34,6 @@ import org.netbeans.junit.MockServices; import org.netbeans.junit.NbTestCase; import org.netbeans.modules.java.source.parsing.FileObjects; -import org.netbeans.modules.java.source.ui.JavaTypeProvider; import org.netbeans.modules.java.source.usages.IndexUtil; import org.netbeans.modules.parsing.api.indexing.IndexingManager; import org.netbeans.spi.java.classpath.ClassPathFactory; @@ -230,7 +229,7 @@ private void assertComputeTypeNames(String[][] expectedResults, String searchTex assertEquals(expectedResults.length, results.size()); //sort to make the result test run reproducable - Collections.sort(results, new Comparator() { + results.sort(new Comparator() { @Override public int compare(TypeDescriptor o1, TypeDescriptor o2) { int compareValue = o1.getSimpleName().compareToIgnoreCase(o2.getSimpleName()); diff --git a/java/javadoc/src/org/netbeans/modules/javadoc/search/IndexSearch.java b/java/javadoc/src/org/netbeans/modules/javadoc/search/IndexSearch.java index 497573b07963..42e2ac30fc62 100644 --- a/java/javadoc/src/org/netbeans/modules/javadoc/search/IndexSearch.java +++ b/java/javadoc/src/org/netbeans/modules/javadoc/search/IndexSearch.java @@ -747,7 +747,7 @@ private void mirrorMRUStrings() { DefaultListModel generateModel( java.util.Comparator comp ) { DefaultListModel model = new DefaultListModel(); - java.util.Collections.sort( results, comp ); + results.sort(comp); String pckg = null; diff --git a/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewPluginPanel.java b/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewPluginPanel.java index 6d6814a6e77b..571145c17cf3 100644 --- a/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewPluginPanel.java +++ b/java/maven.grammar/src/org/netbeans/modules/maven/codegen/NewPluginPanel.java @@ -31,7 +31,6 @@ import java.beans.PropertyChangeEvent; import java.beans.PropertyChangeListener; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.Enumeration; import java.util.HashMap; @@ -214,7 +213,7 @@ public void run() { } final List keyList = new ArrayList(map.keySet()); // sort specially using our comparator, see compare method - Collections.sort(keyList, NewPluginPanel.this); + keyList.sort(NewPluginPanel.this); SwingUtilities.invokeLater(new Runnable() { diff --git a/java/maven.grammar/src/org/netbeans/modules/maven/navigator/POMModelVisitor.java b/java/maven.grammar/src/org/netbeans/modules/maven/navigator/POMModelVisitor.java index 215d098c375c..75652fc93620 100644 --- a/java/maven.grammar/src/org/netbeans/modules/maven/navigator/POMModelVisitor.java +++ b/java/maven.grammar/src/org/netbeans/modules/maven/navigator/POMModelVisitor.java @@ -27,7 +27,6 @@ import java.lang.reflect.Method; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.LinkedHashMap; @@ -1654,9 +1653,8 @@ private void setKeysImpl() { this.keys = toSet; //keys is the unsorted, natural order stuff.. if (configuration.isSortLists()) { - toSet = new ArrayList(); - toSet.addAll(keys); - Collections.sort(toSet, lkpComparator); + toSet = new ArrayList<>(keys); + toSet.sort(lkpComparator); } setKeys(toSet); } @@ -1671,9 +1669,8 @@ public void propertyChange(PropertyChangeEvent evt) { public void resort() { if (keys != null) { if (configuration.isSortLists()) { - ArrayList toSet = new ArrayList(); - toSet.addAll(keys); - Collections.sort(toSet, lkpComparator); + ArrayList toSet = new ArrayList<>(keys); + toSet.sort(lkpComparator); setKeys(toSet); } else { setKeys(keys); diff --git a/java/maven.junit.ui/src/org/netbeans/modules/maven/junit/ui/MavenJUnitTestMethodNode.java b/java/maven.junit.ui/src/org/netbeans/modules/maven/junit/ui/MavenJUnitTestMethodNode.java index 797f833ae0df..13dd7c8bc1a2 100644 --- a/java/maven.junit.ui/src/org/netbeans/modules/maven/junit/ui/MavenJUnitTestMethodNode.java +++ b/java/maven.junit.ui/src/org/netbeans/modules/maven/junit/ui/MavenJUnitTestMethodNode.java @@ -21,7 +21,6 @@ import java.util.ArrayList; import java.util.Arrays; -import java.util.Collections; import java.util.List; import java.util.logging.Level; import java.util.logging.Logger; @@ -112,7 +111,7 @@ public Action[] getActions(boolean context) { } } - Collections.sort(actions, (a, b) -> { + actions.sort((a, b) -> { String aName = (String)a.getValue(Action.NAME); String bName = (String)b.getValue(Action.NAME); if(aName == null) { diff --git a/java/maven/src/org/netbeans/modules/maven/api/PluginPropertyUtils.java b/java/maven/src/org/netbeans/modules/maven/api/PluginPropertyUtils.java index 45a9e1bc2fef..d28868147d39 100644 --- a/java/maven/src/org/netbeans/modules/maven/api/PluginPropertyUtils.java +++ b/java/maven/src/org/netbeans/modules/maven/api/PluginPropertyUtils.java @@ -592,7 +592,7 @@ public Properties build(Xpp3Dom conf, ExpressionEvaluator eval) { exes.add(exe); } } - Collections.sort(exes, new Comparator() { + exes.sort(new Comparator() { @Override public int compare(PluginExecution e1, PluginExecution e2) { return e2.getPriority() - e1.getPriority(); } diff --git a/java/maven/src/org/netbeans/modules/maven/newproject/ChooseArchetypePanel.java b/java/maven/src/org/netbeans/modules/maven/newproject/ChooseArchetypePanel.java index 8c8181e1aa79..47990b46a034 100644 --- a/java/maven/src/org/netbeans/modules/maven/newproject/ChooseArchetypePanel.java +++ b/java/maven/src/org/netbeans/modules/maven/newproject/ChooseArchetypePanel.java @@ -22,7 +22,6 @@ import java.awt.Component; import java.awt.EventQueue; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.HashSet; import java.util.List; @@ -99,7 +98,7 @@ public void addNotify() { for (ArchetypeProvider provider : Lookup.getDefault().lookupAll(ArchetypeProvider.class)) { final List added = provider.getArchetypes(); LOG.log(Level.FINE, "{0} -> {1}", new Object[] {provider, added}); - Collections.sort(added, new Comparator() { + added.sort(new Comparator() { @Override public int compare(Archetype o1, Archetype o2) { int c = o1.getArtifactId().compareTo(o2.getArtifactId()); @@ -153,7 +152,7 @@ private void updateList() { } filtered.add(a); } - Collections.sort(filtered, new Comparator() { + filtered.sort(new Comparator() { @Override public int compare(Archetype o1, Archetype o2) { diff --git a/java/maven/src/org/netbeans/modules/maven/nodes/AddDependencyPanel.java b/java/maven/src/org/netbeans/modules/maven/nodes/AddDependencyPanel.java index b165b7eda447..12bd655602d7 100644 --- a/java/maven/src/org/netbeans/modules/maven/nodes/AddDependencyPanel.java +++ b/java/maven/src/org/netbeans/modules/maven/nodes/AddDependencyPanel.java @@ -828,7 +828,7 @@ private static List getDependenciesFromDM(MavenProject project, Proj break; } } - Collections.sort(result, new Comparator() { + result.sort(new Comparator() { @Override public int compare(Dependency o1, Dependency o2) { @@ -1276,7 +1276,7 @@ void updateResults(List infos, final boolean partial) { final List keyList = new ArrayList(map.keySet()); // sort specially using our comparator, see compare method - Collections.sort(keyList, QueryPanel.this); + keyList.sort(QueryPanel.this); SwingUtilities.invokeLater(new Runnable() { @Override diff --git a/java/maven/src/org/netbeans/modules/maven/nodes/DependenciesNode.java b/java/maven/src/org/netbeans/modules/maven/nodes/DependenciesNode.java index d6304a41175c..7be5b0003f52 100644 --- a/java/maven/src/org/netbeans/modules/maven/nodes/DependenciesNode.java +++ b/java/maven/src/org/netbeans/modules/maven/nodes/DependenciesNode.java @@ -209,7 +209,7 @@ Collection list(boolean longLiving) { } //#200927 do not use comparator in treeset, comparator not equivalent to equals/hashcode ArrayList l = new ArrayList<>(lst); - Collections.sort(l, new DependenciesComparator()); + l.sort(new DependenciesComparator()); return l; } diff --git a/java/maven/test/unit/src/org/netbeans/modules/maven/queries/MavenDependenciesImplementationTest.java b/java/maven/test/unit/src/org/netbeans/modules/maven/queries/MavenDependenciesImplementationTest.java index f6529356fbca..9e098cb5a24c 100644 --- a/java/maven/test/unit/src/org/netbeans/modules/maven/queries/MavenDependenciesImplementationTest.java +++ b/java/maven/test/unit/src/org/netbeans/modules/maven/queries/MavenDependenciesImplementationTest.java @@ -315,7 +315,7 @@ static void printDependencyTree(Dependency from, int levels, StringBuilder sb) { sb.append("\n"); int index = 0; List sorted = new ArrayList<>(from.getChildren()); - Collections.sort(sorted, (d1, d2) -> { + sorted.sort((d1, d2) -> { return d1.getArtifact().toString().compareToIgnoreCase(d2.getArtifact().toString()); }); for (Dependency c : sorted) { diff --git a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/EncapsulateFieldRefactoringPlugin.java b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/EncapsulateFieldRefactoringPlugin.java index 16fa6e321403..f8537ddfb180 100644 --- a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/EncapsulateFieldRefactoringPlugin.java +++ b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/EncapsulateFieldRefactoringPlugin.java @@ -584,7 +584,7 @@ public Tree visitClass(ClassTree node, Element field) { if (!newMembers.isEmpty()) { if (sortBy == SortBy.ALPHABETICALLY) { - Collections.sort(newMembers, new SortMethodsByNameComparator()); + newMembers.sort(new SortMethodsByNameComparator()); } if (insertPoint < 0) { if(insertPoint > Integer.MIN_VALUE) { diff --git a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java index 335102d64dd0..2db46bad250f 100644 --- a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java +++ b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/plugins/FindUsagesVisitor.java @@ -26,12 +26,9 @@ import java.io.IOException; import java.util.*; import java.util.concurrent.atomic.AtomicBoolean; -import java.util.logging.Level; -import java.util.logging.Logger; import javax.lang.model.element.*; import javax.lang.model.type.TypeKind; import javax.lang.model.type.TypeMirror; -import javax.lang.model.util.ElementFilter; import org.netbeans.api.java.lexer.JavaTokenId; import org.netbeans.api.java.source.ClasspathInfo.PathKind; import org.netbeans.api.java.source.CompilationController; @@ -44,7 +41,6 @@ import org.netbeans.modules.refactoring.java.spi.JavaWhereUsedFilters; import org.netbeans.modules.refactoring.java.spi.ToPhaseException; import org.openide.ErrorManager; -import org.openide.filesystems.FileObject; import org.openide.util.Exceptions; /** @@ -343,7 +339,7 @@ protected void addUsage(TreePath tp) { public Collection getElements() { if(findInComments) { // the elements need to be sorted. Comments are searched for the whole file at once. - Collections.sort(elements, new Comparator() { + elements.sort(new Comparator() { @Override public int compare(WhereUsedElement o1, WhereUsedElement o2) { diff --git a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/EncapsulateFieldPanel.java b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/EncapsulateFieldPanel.java index 50e35ede8ab2..404466136e1d 100644 --- a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/EncapsulateFieldPanel.java +++ b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/EncapsulateFieldPanel.java @@ -533,7 +533,7 @@ private static String getString(String key) { private static & Comparator> void initEnumCombo(JComboBox combo, E defValue) { Vector enumList = new Vector(EnumSet.allOf(defValue.getDeclaringClass())); - Collections.sort(enumList, defValue); + enumList.sort(defValue); combo.setModel(new DefaultComboBoxModel(enumList)); combo.setSelectedItem(defValue); } diff --git a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractInterfacePanel.java b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractInterfacePanel.java index ca7bebb0a907..d18342adf669 100644 --- a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractInterfacePanel.java +++ b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractInterfacePanel.java @@ -416,7 +416,7 @@ private void initializeInTransaction(CompilationController javac, TreePathHandle // the members are collected // now, create a tree map (to sort them) and create the table data - Collections.sort(result, new Comparator() { + result.sort(new Comparator() { @Override public int compare(Object o1, Object o2) { ExtractInterfaceInfo i1 = (ExtractInterfaceInfo) o1; diff --git a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractSuperclassPanel.java b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractSuperclassPanel.java index 05f8d40d2ba7..d58b020a6ad0 100644 --- a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractSuperclassPanel.java +++ b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/ExtractSuperclassPanel.java @@ -27,7 +27,6 @@ import java.awt.event.ActionListener; import java.io.IOException; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.List; import javax.lang.model.element.Element; @@ -411,7 +410,7 @@ private void initializeInTransaction(CompilationController javac, TreePathHandle // the members are collected // now, create a tree map (to sort them) and create the table data - Collections.sort(result, new Comparator>() { + result.sort(new Comparator>() { @Override public int compare(MemberInfo mi1, MemberInfo mi2) { int result = mi1.getGroup().compareTo(mi2.getGroup()); diff --git a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveClassPanel.java b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveClassPanel.java index b76d152db0ed..6130711b1126 100644 --- a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveClassPanel.java +++ b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveClassPanel.java @@ -534,7 +534,7 @@ public void run(CompilationController parameter) throws Exception { } catch (IOException ex) { Exceptions.printStackTrace(ex); } - Collections.sort(items, new Comparator() { + items.sort(new Comparator() { private Comparator COLLATOR = Collator.getInstance(); @Override diff --git a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java index c4c77bf9aaec..a57d507d7036 100644 --- a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java +++ b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/MoveMembersPanel.java @@ -331,7 +331,7 @@ public void run(CompilationController parameter) throws Exception { } catch (IOException ex) { Exceptions.printStackTrace(ex); } - Collections.sort(items, new Comparator() { + items.sort(new Comparator() { private Comparator COLLATOR = Collator.getInstance(); @Override @@ -415,7 +415,7 @@ public Collection filter(Collection original) { } result.add(description); } - Collections.sort(result, isNaturalSort() ? Description.POSITION_COMPARATOR : Description.ALPHA_COMPARATOR); + result.sort(isNaturalSort() ? Description.POSITION_COMPARATOR : Description.ALPHA_COMPARATOR); if(warn) { if(this.label == null && outlineView1.isValid()) { final JLayeredPane layeredPaneAbove = JLayeredPane.getLayeredPaneAbove(outlineView1); diff --git a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/SyncDocumentRegion.java b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/SyncDocumentRegion.java index 8a2ed8c73cad..edf80acee5bf 100644 --- a/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/SyncDocumentRegion.java +++ b/java/refactoring.java/src/org/netbeans/modules/refactoring/java/ui/SyncDocumentRegion.java @@ -20,13 +20,10 @@ package org.netbeans.modules.refactoring.java.ui; import java.util.ArrayList; -import java.util.Collections; import java.util.LinkedList; import java.util.List; -import java.util.Set; import javax.swing.text.BadLocationException; import javax.swing.text.Document; -import javax.swing.text.Position; import org.netbeans.lib.editor.util.CharSequenceUtilities; import org.netbeans.lib.editor.util.swing.DocumentUtilities; import org.netbeans.lib.editor.util.swing.MutablePositionRegion; @@ -64,7 +61,7 @@ public SyncDocumentRegion(Document doc, List re sortedRegions = regions; } else { sortedRegions = new ArrayList<>(regions); - Collections.sort(sortedRegions, PositionRegion.getComparator()); + sortedRegions.sort(PositionRegion.getComparator()); } this.oldVal = getFirstRegionText(); } @@ -78,7 +75,7 @@ public void updateRegions(List regions) { sortedRegions = regions; } else { sortedRegions = new ArrayList<>(regions); - Collections.sort(sortedRegions, PositionRegion.getComparator()); + sortedRegions.sort(PositionRegion.getComparator()); } int j = 0; for (int i = 0; i < this.regions.size();) { diff --git a/java/refactoring.java/test/qa-functional/src/org/netbeans/modules/test/refactoring/ModifyingRefactoring.java b/java/refactoring.java/test/qa-functional/src/org/netbeans/modules/test/refactoring/ModifyingRefactoring.java index a7a2e56a43c2..6b5a5c75f15c 100644 --- a/java/refactoring.java/test/qa-functional/src/org/netbeans/modules/test/refactoring/ModifyingRefactoring.java +++ b/java/refactoring.java/test/qa-functional/src/org/netbeans/modules/test/refactoring/ModifyingRefactoring.java @@ -65,7 +65,7 @@ private void getFiles(File dir, List res) { public void refModifiedFiles(Set modifiedFiles) { List l = new LinkedList(modifiedFiles); - Collections.sort(l, new Comparator() { + l.sort(new Comparator() { @Override public int compare(FileObject o1, FileObject o2) { return o1.getName().compareTo(o2.getName()); diff --git a/javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/impl/ClassCompleter.java b/javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/impl/ClassCompleter.java index 615e19fb845f..c5476c6385c3 100644 --- a/javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/impl/ClassCompleter.java +++ b/javafx/javafx2.editor/src/org/netbeans/modules/javafx2/editor/completion/impl/ClassCompleter.java @@ -48,7 +48,6 @@ import org.netbeans.modules.javafx2.editor.completion.beans.FxDefinitionKind; import org.netbeans.modules.javafx2.editor.completion.beans.FxProperty; import org.netbeans.modules.javafx2.editor.completion.model.FxClassUtils; -import org.netbeans.modules.javafx2.editor.completion.model.FxInstance; import org.netbeans.modules.javafx2.editor.completion.model.FxNode; import org.netbeans.modules.javafx2.editor.completion.model.ImportDecl; import org.netbeans.spi.editor.completion.CompletionItem; @@ -369,7 +368,7 @@ private CompletionItem createItem(ElementHandle handle, int priorit private List createItems(Collection> elems, int priority) { List> sorted = new ArrayList>(elems); - Collections.sort(sorted, CLASS_SORTER); + sorted.sort(CLASS_SORTER); List items = new ArrayList(); for (ElementHandle tel : sorted) { CompletionItem item = createItem(tel, priority); diff --git a/javafx/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java b/javafx/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java index da11e988d3b4..d6102597cbe2 100644 --- a/javafx/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java +++ b/javafx/javafx2.editor/test/unit/src/org/netbeans/modules/javafx2/editor/FXMLCompletionTestBase.java @@ -28,7 +28,6 @@ import java.util.regex.Pattern; import javax.swing.JEditorPane; import javax.swing.text.Document; -import org.netbeans.ModuleManager; import org.netbeans.api.editor.mimelookup.MimePath; import org.netbeans.api.java.classpath.ClassPath; import org.netbeans.api.java.source.ClasspathInfo; @@ -39,11 +38,8 @@ import org.netbeans.api.java.source.gen.WhitespaceIgnoringDiff; import org.netbeans.api.lexer.Language; import org.netbeans.api.xml.lexer.XMLTokenId; -import org.netbeans.core.ModuleActions; -import org.netbeans.core.startup.ModuleLifecycleManager; import org.netbeans.junit.NbTestCase; import org.netbeans.modules.editor.completion.CompletionItemComparator; -import org.netbeans.modules.editor.java.Utilities; import org.netbeans.modules.java.JavaDataLoader; import org.netbeans.modules.java.source.indexing.TransactionContext; import org.netbeans.modules.java.source.parsing.JavacParserFactory; @@ -66,8 +62,6 @@ import org.openide.cookies.EditorCookie; import org.openide.filesystems.*; import org.openide.loaders.DataObject; -import org.openide.modules.ModuleInfo; -import org.openide.modules.ModuleInstall; import org.openide.util.Lookup; import org.openide.util.SharedClassObject; import org.openide.util.lookup.Lookups; @@ -288,7 +282,7 @@ protected void performTest(String source, int caretPos, int charsDelete, int car doc.insertString(caretPos, textToInsert, null); Source s = Source.create(doc); List items = performQuery(s, queryType, caretPos + textToInsertLength, caretPos + textToInsertLength, doc); - Collections.sort(items, CompletionItemComparator.BY_PRIORITY); + items.sort(CompletionItemComparator.BY_PRIORITY); File output = new File(getWorkDir(), getName() + ".out"); Writer out = new FileWriter(output); diff --git a/javafx/javafx2.project/src/org/netbeans/modules/javafx2/project/JFXProjectConfigurations.java b/javafx/javafx2.project/src/org/netbeans/modules/javafx2/project/JFXProjectConfigurations.java index eb9a63f7e7b5..6bb7230d3b96 100644 --- a/javafx/javafx2.project/src/org/netbeans/modules/javafx2/project/JFXProjectConfigurations.java +++ b/javafx/javafx2.project/src/org/netbeans/modules/javafx2/project/JFXProjectConfigurations.java @@ -2833,7 +2833,7 @@ public String toString() { sb.append(":"); // NOI18N List keys = new ArrayList(); keys.addAll(APP_MULTIPROPS.keySet()); - Collections.sort(keys, new Comparator() { + keys.sort(new Comparator() { @Override public int compare(String o1, String o2) { if(o1 == null) { @@ -2857,7 +2857,7 @@ public int compare(String o1, String o2) { sb.append(configName); sb.append("}"); // NOI18N List> configList = new ArrayList>(APP_MULTIPROPS.get(configName)); - Collections.sort(configList, new Comparator>() { + configList.sort(new Comparator>() { @Override public int compare(Map o1, Map o2) { String n1 = getEntryName(o1); diff --git a/nb/autoupdate.pluginimporter/src/org/netbeans/modules/autoupdate/pluginimporter/ImportManager.java b/nb/autoupdate.pluginimporter/src/org/netbeans/modules/autoupdate/pluginimporter/ImportManager.java index 6ca5216a479e..039a16971529 100644 --- a/nb/autoupdate.pluginimporter/src/org/netbeans/modules/autoupdate/pluginimporter/ImportManager.java +++ b/nb/autoupdate.pluginimporter/src/org/netbeans/modules/autoupdate/pluginimporter/ImportManager.java @@ -92,7 +92,7 @@ public PluginImporter getPluginImporter() { private void initialize() { toInstall = new ArrayList (importer.getPluginsAvailableToInstall ()); - Collections.sort (toInstall, new Comparator () { + toInstall.sort (new Comparator () { @Override public int compare (UpdateElement o1, UpdateElement o2) { return o1.getDisplayName ().compareTo (o2.getDisplayName ()); @@ -101,7 +101,7 @@ public int compare (UpdateElement o1, UpdateElement o2) { checkedToInstall = new ArrayList (Collections.nCopies (importer.getPluginsAvailableToInstall ().size (), Boolean.TRUE)); toImport = new ArrayList (importer.getPluginsToImport ()); - Collections.sort (toImport, new Comparator () { + toImport.sort (new Comparator () { @Override public int compare (UpdateElement o1, UpdateElement o2) { return o1.getDisplayName ().compareTo (o2.getDisplayName ()); diff --git a/nb/welcome/src/org/netbeans/modules/welcome/content/CombinationRSSFeed.java b/nb/welcome/src/org/netbeans/modules/welcome/content/CombinationRSSFeed.java index b0bdf54712d2..540d004c6168 100644 --- a/nb/welcome/src/org/netbeans/modules/welcome/content/CombinationRSSFeed.java +++ b/nb/welcome/src/org/netbeans/modules/welcome/content/CombinationRSSFeed.java @@ -26,7 +26,6 @@ import java.text.ParseException; import java.text.SimpleDateFormat; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.Date; import java.util.List; @@ -85,7 +84,7 @@ protected List buildItemList() throws SAXException, ParserConfiguratio } private ArrayList sortNodes( ArrayList res ) { - Collections.sort( res, new DateFeedItemComparator() ); + res.sort(new DateFeedItemComparator()); return res; } diff --git a/php/php.api.phpmodule/src/org/netbeans/modules/php/api/ui/options/FrameworksPanel.java b/php/php.api.phpmodule/src/org/netbeans/modules/php/api/ui/options/FrameworksPanel.java index 7c5673cca800..8bd76786e1f5 100644 --- a/php/php.api.phpmodule/src/org/netbeans/modules/php/api/ui/options/FrameworksPanel.java +++ b/php/php.api.phpmodule/src/org/netbeans/modules/php/api/ui/options/FrameworksPanel.java @@ -25,7 +25,6 @@ import java.beans.PropertyChangeListener; import java.text.Collator; import java.util.ArrayList; -import java.util.Collections; import java.util.Comparator; import java.util.Enumeration; import java.util.HashMap; @@ -93,7 +92,7 @@ public void propertyChange(PropertyChangeEvent evt) { private void sortOptions(List options) { final Collator collator = Collator.getInstance(); - Collections.sort(options, new Comparator() { + options.sort(new Comparator() { @Override public int compare(AdvancedOption o1, AdvancedOption o2) { return collator.compare(o1.getDisplayName(), o2.getDisplayName()); diff --git a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/AnalysisOptionsPanelController.java b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/AnalysisOptionsPanelController.java index be5501490297..e1ae70cd94c9 100644 --- a/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/AnalysisOptionsPanelController.java +++ b/php/php.code.analysis/src/org/netbeans/modules/php/analysis/ui/options/AnalysisOptionsPanelController.java @@ -24,7 +24,6 @@ import java.text.Collator; import java.util.ArrayList; import java.util.Collection; -import java.util.Collections; import java.util.Comparator; import java.util.List; import javax.swing.JComponent; @@ -180,7 +179,7 @@ private Collection getCategoryPanels() { categoryPanels = new ArrayList<>(AnalysisCategoryPanels.getCategoryPanels()); // sort them by name final Collator collator = Collator.getInstance(); - Collections.sort(categoryPanels, new Comparator() { + categoryPanels.sort(new Comparator() { @Override public int compare(AnalysisCategoryPanel o1, AnalysisCategoryPanel o2) { return collator.compare(o1.getCategoryName(), o2.getCategoryName()); diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java b/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java index 265ace02ff2b..0562f98d53a3 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/actions/FixUsesPerformer.java @@ -318,7 +318,7 @@ private Map getTypeOrderPriorities(List useParts } private void sort(List useParts, final Map typePriorities) { - Collections.sort(useParts, (u1, u2) -> { + useParts.sort((u1, u2) -> { int result = 0; Integer p1 = typePriorities.get(u1.getType()); Integer p2 = typePriorities.get(u2.getType()); diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/actions/ImportDataCreator.java b/php/php.editor/src/org/netbeans/modules/php/editor/actions/ImportDataCreator.java index 6d9b1eb00278..f8f79da26cab 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/actions/ImportDataCreator.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/actions/ImportDataCreator.java @@ -64,7 +64,7 @@ public class ImportDataCreator { private static Collection sortFQElements(final Collection filteredFQElements) { final List sortedFQElements = new ArrayList<>(filteredFQElements); - Collections.sort(sortedFQElements, new FQElementsComparator()); + sortedFQElements.sort(new FQElementsComparator()); return sortedFQElements; } diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/csl/NavigatorScanner.java b/php/php.editor/src/org/netbeans/modules/php/editor/csl/NavigatorScanner.java index 077bbd5f6be9..4e74cec77909 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/csl/NavigatorScanner.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/csl/NavigatorScanner.java @@ -355,7 +355,7 @@ protected void appendInterfaces(Collection interfaes, protected void appendUsedTraits(Collection usedTraits, HtmlFormatter formatter) { boolean first = true; List traits = new ArrayList<>(usedTraits); - Collections.sort(traits, TRAIT_SCOPE_COMPARATOR); + traits.sort(TRAIT_SCOPE_COMPARATOR); for (TraitScope traitScope : traits) { if (!first) { formatter.appendText(", "); //NOI18N diff --git a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/FunctionScopeImpl.java b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/FunctionScopeImpl.java index 51bead55cd9c..145413592ae4 100644 --- a/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/FunctionScopeImpl.java +++ b/php/php.editor/src/org/netbeans/modules/php/editor/model/impl/FunctionScopeImpl.java @@ -410,7 +410,7 @@ private int getLastValidMethodOffset() { int result = getOffset(); List elements = ModelUtils.getElements(this, true); if (elements != null && !elements.isEmpty()) { - Collections.sort(elements, new ModelElementsPositionComparator()); + elements.sort(new ModelElementsPositionComparator()); result = elements.get(0).getNameRange().getEnd(); } return result; diff --git a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/PhpNavigatorTestBase.java b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/PhpNavigatorTestBase.java index d82ea076e73c..8aec1e7f0c91 100644 --- a/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/PhpNavigatorTestBase.java +++ b/php/php.editor/test/unit/src/org/netbeans/modules/php/editor/csl/PhpNavigatorTestBase.java @@ -93,10 +93,10 @@ public void run(ResultIterator resultIterator) throws Exception { } } - Collections.sort(result, STRUCTURE_ITEM_COMPARATOR); + result.sort(STRUCTURE_ITEM_COMPARATOR); for (StructureItem structureItem : result) { - Collections.sort(structureItem.getNestedItems(), STRUCTURE_ITEM_COMPARATOR); + structureItem.getNestedItems().sort(STRUCTURE_ITEM_COMPARATOR); sb.append(printStructureItem(structureItem, 0)); sb.append("\n"); } @@ -120,7 +120,7 @@ private String printStructureItem(StructureItem structureItem, int indent) { HtmlFormatter formatter = new TestHtmlFormatter(); sb.append(structureItem.getHtml(formatter)); List nestedItems = structureItem.getNestedItems(); - Collections.sort(nestedItems, STRUCTURE_ITEM_COMPARATOR); + nestedItems.sort(STRUCTURE_ITEM_COMPARATOR); for (StructureItem item : nestedItems) { sb.append("\n"); sb.append(printStructureItem(item, indent + 1)); diff --git a/php/php.nette2/src/org/netbeans/modules/php/nette2/ConfigurationFiles.java b/php/php.nette2/src/org/netbeans/modules/php/nette2/ConfigurationFiles.java index bd39153605b1..b48a8a8cfe06 100644 --- a/php/php.nette2/src/org/netbeans/modules/php/nette2/ConfigurationFiles.java +++ b/php/php.nette2/src/org/netbeans/modules/php/nette2/ConfigurationFiles.java @@ -78,7 +78,7 @@ public Collection getFiles() { configFiles.add(new FileInfo(child)); } } - Collections.sort(configFiles, FileInfo.COMPARATOR); + configFiles.sort(FileInfo.COMPARATOR); files.addAll(configFiles); } return files; diff --git a/php/php.project/src/org/netbeans/modules/php/project/PhpConfigurationProvider.java b/php/php.project/src/org/netbeans/modules/php/project/PhpConfigurationProvider.java index a3fd2cda001e..35d54bc2d83e 100644 --- a/php/php.project/src/org/netbeans/modules/php/project/PhpConfigurationProvider.java +++ b/php/php.project/src/org/netbeans/modules/php/project/PhpConfigurationProvider.java @@ -209,7 +209,7 @@ public Collection getConfigurations() { calculateConfigs(); List l = new ArrayList<>(); l.addAll(configs.values()); - Collections.sort(l, new Comparator() { + l.sort(new Comparator() { Collator c = Collator.getInstance(); diff --git a/php/php.project/src/org/netbeans/modules/php/project/connections/RemoteConnections.java b/php/php.project/src/org/netbeans/modules/php/project/connections/RemoteConnections.java index 1af5317218b2..37792ca52ee6 100644 --- a/php/php.project/src/org/netbeans/modules/php/project/connections/RemoteConnections.java +++ b/php/php.project/src/org/netbeans/modules/php/project/connections/RemoteConnections.java @@ -253,7 +253,7 @@ private List getConfigurations() { } configs.add(cfg); } - Collections.sort(configs, ConfigManager.getConfigurationComparator()); + configs.sort(ConfigManager.getConfigurationComparator()); return configs; } diff --git a/php/php.project/src/org/netbeans/modules/php/project/connections/sync/SyncController.java b/php/php.project/src/org/netbeans/modules/php/project/connections/sync/SyncController.java index 97bdede5ce43..a5a098ce747b 100644 --- a/php/php.project/src/org/netbeans/modules/php/project/connections/sync/SyncController.java +++ b/php/php.project/src/org/netbeans/modules/php/project/connections/sync/SyncController.java @@ -237,9 +237,9 @@ void disconnect() { private SyncItems pairItems(Set remoteFiles, Set localFiles) { List remoteFilesSorted = new ArrayList<>(remoteFiles); - Collections.sort(remoteFilesSorted, TransferFile.TRANSFER_FILE_COMPARATOR); + remoteFilesSorted.sort(TransferFile.TRANSFER_FILE_COMPARATOR); List localFilesSorted = new ArrayList<>(localFiles); - Collections.sort(localFilesSorted, TransferFile.TRANSFER_FILE_COMPARATOR); + localFilesSorted.sort(TransferFile.TRANSFER_FILE_COMPARATOR); removeProjectRoot(remoteFilesSorted); removeProjectRoot(localFilesSorted); diff --git a/php/php.project/src/org/netbeans/modules/php/project/connections/ui/RemoteConnectionsPanel.java b/php/php.project/src/org/netbeans/modules/php/project/connections/ui/RemoteConnectionsPanel.java index a77cc7139924..d295ff7cf3c2 100644 --- a/php/php.project/src/org/netbeans/modules/php/project/connections/ui/RemoteConnectionsPanel.java +++ b/php/php.project/src/org/netbeans/modules/php/project/connections/ui/RemoteConnectionsPanel.java @@ -748,7 +748,7 @@ public boolean addElement(Configuration configuration) { if (!data.add(configuration)) { return false; } - Collections.sort(data, ConfigManager.getConfigurationComparator()); + data.sort(ConfigManager.getConfigurationComparator()); int idx = indexOf(configuration); fireIntervalAdded(this, idx, idx); return true; @@ -781,7 +781,7 @@ public void setElements(List configurations) { } if (configurations.size() > 0) { data.addAll(configurations); - Collections.sort(data, ConfigManager.getConfigurationComparator()); + data.sort(ConfigManager.getConfigurationComparator()); fireIntervalAdded(this, 0, data.size() - 1); } } diff --git a/php/php.project/src/org/netbeans/modules/php/project/connections/ui/transfer/tree/TransferSelector.form b/php/php.project/src/org/netbeans/modules/php/project/connections/ui/transfer/tree/TransferSelector.form index bba0ed1bd143..9547e645ce0d 100644 --- a/php/php.project/src/org/netbeans/modules/php/project/connections/ui/transfer/tree/TransferSelector.form +++ b/php/php.project/src/org/netbeans/modules/php/project/connections/ui/transfer/tree/TransferSelector.form @@ -1,4 +1,4 @@ - +