Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix warnings due to usage of deprecated system APIs #3742

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2019 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -29,6 +29,8 @@
import java.io.InputStream;
import java.io.StringWriter;
import java.net.MalformedURLException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.nio.file.Paths;
import java.util.ArrayList;
Expand Down Expand Up @@ -1780,8 +1782,8 @@ public URL getLibraryIndexLocation() {
if (IClasspathAttribute.INDEX_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
String value = attrib.getValue();
try {
return new URL(value);
} catch (MalformedURLException e) {
return (new URI(value)).toURL();
} catch (MalformedURLException | URISyntaxException e) {
return null;
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2010 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -70,7 +70,7 @@ protected char getHandleMementoDelimiter() {
*/
@Override
public ImportDeclaration getImport(String importName) {
int index = importName.indexOf(".*"); ///$NON-NLS-1$
int index = importName.indexOf(".*"); //$NON-NLS-1$
boolean isOnDemand = index != -1;
if (isOnDemand) {
importName = importName.substring(0, index);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -23,9 +23,11 @@
import java.net.ProtocolException;
import java.net.SocketException;
import java.net.SocketTimeoutException;
import java.net.URI;
import java.net.URL;
import java.net.URLConnection;
import java.net.UnknownHostException;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.HashSet;
Expand Down Expand Up @@ -749,8 +751,8 @@ protected static URL getLibraryJavadocLocation(IClasspathEntry entry) throws Jav
if (IClasspathAttribute.JAVADOC_LOCATION_ATTRIBUTE_NAME.equals(attrib.getName())) {
String value = attrib.getValue();
try {
return new URL(value);
} catch (MalformedURLException e) {
return (new URI(value)).toURL();
} catch (MalformedURLException | URISyntaxException e) {
throw new JavaModelException(new JavaModelStatus(IJavaModelStatusConstants.CANNOT_RETRIEVE_ATTACHED_JAVADOC, value));
}
}
Expand Down Expand Up @@ -819,12 +821,12 @@ protected void validateAndCache(URL baseLoc, FileNotFoundException e) throws Jav
protected String getURLContents(URL baseLoc, String docUrlValue) throws JavaModelException {
InputStream stream = null;
JarURLConnection connection2 = null;
URL docUrl = null;
URI docUri = null;
URLConnection connection = null;
try {
redirect: for (int i= 0; i < 5; i++) { // avoid endless redirects...
docUrl = new URL(docUrlValue);
connection = docUrl.openConnection();
docUri = new URI(docUrlValue);
connection = docUri.toURL().openConnection();

int timeoutVal = 10000;
connection.setConnectTimeout(timeoutVal);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2020 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -577,6 +577,6 @@ public interface IJavaSearchConstants {
* in searches involving modules
* @since 3.14
*/
char[] ALL_UNNAMED = "ALL-UNNAMED".toCharArray(); ////$NON-NLS-1$
char[] ALL_UNNAMED = "ALL-UNNAMED".toCharArray(); //$NON-NLS-1$

}
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2018 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -22,7 +22,6 @@
import java.nio.file.NoSuchFileException;
import java.util.Enumeration;
import java.util.zip.ZipEntry;
import java.util.zip.ZipError;
import java.util.zip.ZipFile;
import org.eclipse.core.resources.IFile;
import org.eclipse.core.runtime.CoreException;
Expand Down Expand Up @@ -281,7 +280,7 @@ public boolean execute(IProgressMonitor progressMonitor) {
}
monitor.exitWrite(); // free write lock
}
} catch (IOException | ZipError e) {
} catch (IOException e) {
if (e instanceof NoSuchFileException) {
org.eclipse.jdt.internal.core.util.Util.log(Status.info("Can not index not existing zip " + this.containerPath)); //$NON-NLS-1$
} else if ("zip file is empty".equals(e.getMessage())) { //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2017 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -31,7 +31,7 @@ public interface IIndexConstants {
char[] MODULE_DECL= "moduleDecl".toCharArray(); //$NON-NLS-1$
char[] MODULE_REF= "moduleRef".toCharArray(); //$NON-NLS-1$
char[] OBJECT = "Object".toCharArray(); //$NON-NLS-1$
char[] MODULE_INFO = "module-info".toCharArray(); ////$NON-NLS-1$
char[] MODULE_INFO = "module-info".toCharArray(); //$NON-NLS-1$
char[][] COUNTS=
new char[][] { new char[] {'/', '0'}, new char[] {'/', '1'}, new char[] {'/', '2'}, new char[] {'/', '3'}, new char[] {'/', '4'},
new char[] {'/', '5'}, new char[] {'/', '6'}, new char[] {'/', '7'}, new char[] {'/', '8'}, new char[] {'/', '9'}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2022 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand All @@ -21,6 +21,7 @@
import java.io.FileNotFoundException;
import java.io.FileWriter;
import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.net.URL;
import java.util.*;
Expand Down Expand Up @@ -1309,7 +1310,12 @@ private void readIndexMap() {
String savedSignature = DiskIndex.SIGNATURE;
if (savedSignature.equals(new String(names[0]))) {
for (int i = 1, l = names.length-1 ; i < l ; i+=2) {
IndexLocation indexPath = IndexLocation.createIndexLocation(new URL(new String(names[i])));
IndexLocation indexPath = null;
try {
indexPath = IndexLocation.createIndexLocation((new URI(new String(names[i])).toURL()));
} catch (URISyntaxException e) {
// Ignore the null path and continue
}
if (indexPath == null) continue;
this.indexLocations.put(new Path(new String(names[i+1])), indexPath );
this.indexStates.put(indexPath, REUSE_STATE);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*******************************************************************************
* Copyright (c) 2000, 2022 IBM Corporation and others.
* Copyright (c) 2000, 2024 IBM Corporation and others.
*
* This program and the accompanying materials
* are made available under the terms of the Eclipse Public License 2.0
Expand Down Expand Up @@ -557,9 +557,6 @@ protected IStatus run(IProgressMonitor monitor) {
} catch (InterruptedException e) { // background indexing was interrupted
}
}
} catch (ThreadDeath e) {
// do not restart
throw e;
} catch (RuntimeException|Error e) {
if (getProcessingThread() != null) { // if not shutting down
// log exception
Expand Down
Loading