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

Replace "UTF8" with StandardCharsets.UTF_8 #532

Merged
merged 4 commits into from
Jul 2, 2024
Merged
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
2 changes: 1 addition & 1 deletion bundles/org.eclipse.equinox.p2.core/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %pluginName
Bundle-SymbolicName: org.eclipse.equinox.p2.core;singleton:=true
Bundle-Version: 2.12.0.qualifier
Bundle-Version: 2.12.100.qualifier
Bundle-Activator: org.eclipse.equinox.internal.p2.core.Activator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
package org.eclipse.equinox.internal.p2.core.helpers;

import java.io.*;
import java.nio.charset.StandardCharsets;

/**
* Copied from org.eclipse.ui.internal.wizards.datatransfer.TarInputStream.
Expand Down Expand Up @@ -188,14 +189,14 @@ TarEntry getNextEntryInternal() throws TarException, IOException {
while (pos < 100 && header[pos] != 0) {
pos++;
}
String name = new String(header, 0, pos, "UTF8"); //$NON-NLS-1$
String name = new String(header, 0, pos, StandardCharsets.UTF_8);
// Prepend the prefix here.
pos = 345;
if (header[pos] != 0) {
while (pos < 500 && header[pos] != 0) {
pos++;
}
String prefix = new String(header, 345, pos - 345, "UTF8"); //$NON-NLS-1$
String prefix = new String(header, 345, pos - 345, StandardCharsets.UTF_8);
name = prefix + "/" + name; //$NON-NLS-1$
}

Expand Down Expand Up @@ -290,7 +291,7 @@ public TarEntry getNextEntry() throws TarException, IOException {
while (pos < longNameData.length && longNameData[pos] != 0) {
pos++;
}
longLinkName = new String(longNameData, 0, pos, "UTF8"); //$NON-NLS-1$
longLinkName = new String(longNameData, 0, pos, StandardCharsets.UTF_8);
return getNextEntryInternal();
}
return entry;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,28 @@

package org.eclipse.equinox.p2.tests;

import java.io.*;
import java.util.*;
import org.eclipse.equinox.internal.p2.metadata.*;
import org.eclipse.equinox.p2.metadata.*;
import java.io.BufferedReader;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
import java.util.StringTokenizer;
import org.eclipse.equinox.internal.p2.metadata.IRequiredCapability;
import org.eclipse.equinox.internal.p2.metadata.InstallableUnit;
import org.eclipse.equinox.internal.p2.metadata.ProvidedCapability;
import org.eclipse.equinox.internal.p2.metadata.RequiredCapability;
import org.eclipse.equinox.p2.metadata.IInstallableUnit;
import org.eclipse.equinox.p2.metadata.IProvidedCapability;
import org.eclipse.equinox.p2.metadata.IRequirement;
import org.eclipse.equinox.p2.metadata.IUpdateDescriptor;
import org.eclipse.equinox.p2.metadata.MetadataFactory;
import org.eclipse.equinox.p2.metadata.MetadataFactory.InstallableUnitDescription;
import org.eclipse.equinox.p2.metadata.Version;
import org.eclipse.equinox.p2.metadata.VersionRange;

public class ReducedCUDFParser {

Expand Down Expand Up @@ -71,7 +88,7 @@ class Tuple {
public void parse(InputStream stream, boolean includeRecommends, String sumProperty) {
BufferedReader reader = null;
try {
reader = new BufferedReader(new InputStreamReader(stream, "UTF-8"));
reader = new BufferedReader(new InputStreamReader(stream, StandardCharsets.UTF_8));
String next = reader.readLine();
while (true) {

Expand Down
2 changes: 1 addition & 1 deletion bundles/org.eclipse.equinox.p2.ui/META-INF/MANIFEST.MF
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.equinox.p2.ui;singleton:=true
Bundle-Version: 2.8.400.qualifier
Bundle-Version: 2.8.500.qualifier
Bundle-Activator: org.eclipse.equinox.internal.p2.ui.ProvUIActivator
Bundle-Vendor: %providerName
Bundle-Localization: plugin
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@
import java.io.*;
import java.net.URI;
import java.net.URISyntaxException;
import java.nio.charset.StandardCharsets;
import java.util.Vector;
import javax.xml.parsers.*;
import org.eclipse.core.runtime.*;
Expand Down Expand Up @@ -128,7 +129,7 @@ private static void store(String fileName, Vector<MetadataRepositoryElement> boo
PrintWriter writer = null;
try {
fos = new FileOutputStream(fileName);
osw = new OutputStreamWriter(fos, "UTF8"); //$NON-NLS-1$
osw = new OutputStreamWriter(fos, StandardCharsets.UTF_8);
writer = new PrintWriter(osw);
writer.println("<?xml version=\"1.0\" encoding=\"UTF-8\"?>"); //$NON-NLS-1$
writer.println("<bookmarks>"); //$NON-NLS-1$
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ Manifest-Version: 1.0
Bundle-ManifestVersion: 2
Bundle-Name: %bundleName
Bundle-SymbolicName: org.eclipse.equinox.simpleconfigurator.manipulator;singleton:=true
Bundle-Version: 2.3.200.qualifier
Bundle-Version: 2.3.300.qualifier
Bundle-Localization: plugin
Bundle-ActivationPolicy: lazy
Import-Package: org.eclipse.equinox.frameworkadmin;version="[2.0.0,3.0.0)",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@

import java.io.*;
import java.net.URI;
import java.nio.charset.StandardCharsets;
import java.util.Arrays;
import org.eclipse.equinox.internal.frameworkadmin.equinox.Messages;
import org.eclipse.equinox.internal.frameworkadmin.utils.Utils;
Expand All @@ -27,7 +28,9 @@ public class SimpleConfiguratorManipulatorUtils {
private static final String VERSION_PREFIX = "#version="; //$NON-NLS-1$
private static final String VERSION_1 = "1"; //$NON-NLS-1$
private static final Version OLD_STYLE_SIMPLE_CONFIGURATOR_VERSION = new Version("1.0.100.v20081206"); //$NON-NLS-1$
private static final Version DEFAULT_ENCODING_CONFIGURATOR_VERSION = new Version("1.0.200.v20100503"); //$NON-NLS-1$ 3.6, after bug 289644
private static final Version DEFAULT_ENCODING_CONFIGURATOR_VERSION = new Version("1.0.200.v20100503"); //$NON-NLS-1$ 3.6,
// after bug
// 289644

public static void writeConfiguration(BundleInfo[] simpleInfos, File outputFile) throws IOException {
if (!Utils.createParentDir(outputFile)) {
Expand Down Expand Up @@ -72,7 +75,8 @@ public static void writeConfiguration(BundleInfo[] simpleInfos, OutputStream str
boolean oldStyle = false;
boolean utf8 = true;
for (BundleInfo simpleInfo : simpleInfos) {
if (SimpleConfiguratorManipulator.SERVICE_PROP_VALUE_CONFIGURATOR_SYMBOLICNAME.equals(simpleInfo.getSymbolicName())) {
if (SimpleConfiguratorManipulator.SERVICE_PROP_VALUE_CONFIGURATOR_SYMBOLICNAME
.equals(simpleInfo.getSymbolicName())) {
Version version = new Version(simpleInfo.getVersion());
if (version.compareTo(OLD_STYLE_SIMPLE_CONFIGURATOR_VERSION) < 0)
oldStyle = true;
Expand All @@ -83,8 +87,8 @@ public static void writeConfiguration(BundleInfo[] simpleInfos, OutputStream str
}

if (utf8) {
writer = new BufferedWriter(new OutputStreamWriter(stream, "UTF-8")); //$NON-NLS-1$
//encoding is expected to be the first line
writer = new BufferedWriter(new OutputStreamWriter(stream, StandardCharsets.UTF_8));
// encoding is expected to be the first line
writer.write(SimpleConfiguratorUtils.ENCODING_UTF8);
writer.newLine();
} else {
Expand Down Expand Up @@ -128,7 +132,8 @@ public static String createBundleLocation(URI location, boolean oldStyle) {
return scheme + ':' + location.getSchemeSpecificPart();
}

//encode comma characters because it is used as the segment delimiter in the bundle info file
// encode comma characters because it is used as the segment delimiter in the
// bundle info file
String result = location.toString();
int commaIndex = result.indexOf(',');
while (commaIndex != -1) {
Expand Down
2 changes: 1 addition & 1 deletion features/org.eclipse.equinox.p2.core.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.equinox.p2.core.feature"
label="%featureName"
version="1.7.200.qualifier"
version="1.7.300.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
2 changes: 1 addition & 1 deletion features/org.eclipse.equinox.p2.rcp.feature/feature.xml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
<feature
id="org.eclipse.equinox.p2.rcp.feature"
label="%featureName"
version="1.4.2400.qualifier"
version="1.4.2500.qualifier"
provider-name="%providerName"
license-feature="org.eclipse.license"
license-feature-version="0.0.0">
Expand Down
Loading