You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@commons.apache.org by gg...@apache.org on 2022/11/19 21:25:18 UTC
[commons-bcel] branch master updated (f9c93865 -> 8b3e1751)
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a change to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
from f9c93865 Remove old comment
new ae494539 Better internal name
new 8b3e1751 org.apache.bcel.util.ClassPath hashCode() and equals() don't match.
The 2 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
Summary of changes:
src/changes/changes.xml | 1 +
src/main/java/org/apache/bcel/util/ClassPath.java | 33 ++++++++++++-----------
2 files changed, 19 insertions(+), 15 deletions(-)
[commons-bcel] 01/02: Better internal name
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
commit ae4945393246a599e3a53b1c2b2684f7100f217c
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Sat Nov 19 16:20:28 2022 -0500
Better internal name
---
src/main/java/org/apache/bcel/util/ClassPath.java | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/src/main/java/org/apache/bcel/util/ClassPath.java b/src/main/java/org/apache/bcel/util/ClassPath.java
index f8f1c854..de8aa568 100644
--- a/src/main/java/org/apache/bcel/util/ClassPath.java
+++ b/src/main/java/org/apache/bcel/util/ClassPath.java
@@ -517,7 +517,7 @@ public class ClassPath implements Closeable {
return name.replace('.', '/');
}
- private final String classPath;
+ private final String classPathString;
private final ClassPath parent;
@@ -534,11 +534,11 @@ public class ClassPath implements Closeable {
}
@SuppressWarnings("resource")
- public ClassPath(final ClassPath parent, final String classPath) {
+ public ClassPath(final ClassPath parent, final String classPathString) {
this.parent = parent;
- this.classPath = classPath;
+ this.classPathString = classPathString;
this.paths = new ArrayList<>();
- for (final StringTokenizer tokenizer = new StringTokenizer(classPath, File.pathSeparator); tokenizer.hasMoreTokens();) {
+ for (final StringTokenizer tokenizer = new StringTokenizer(classPathString, File.pathSeparator); tokenizer.hasMoreTokens();) {
final String path = tokenizer.nextToken();
if (!path.isEmpty()) {
final File file = new File(path);
@@ -583,7 +583,7 @@ public class ClassPath implements Closeable {
public boolean equals(final Object o) {
if (o instanceof ClassPath) {
final ClassPath cp = (ClassPath) o;
- return classPath.equals(cp.toString());
+ return classPathString.equals(cp.toString());
}
return false;
}
@@ -768,9 +768,9 @@ public class ClassPath implements Closeable {
@Override
public int hashCode() {
if (parent != null) {
- return classPath.hashCode() + parent.hashCode();
+ return classPathString.hashCode() + parent.hashCode();
}
- return classPath.hashCode();
+ return classPathString.hashCode();
}
/**
@@ -779,8 +779,8 @@ public class ClassPath implements Closeable {
@Override
public String toString() {
if (parent != null) {
- return parent + File.pathSeparator + classPath;
+ return parent + File.pathSeparator + classPathString;
}
- return classPath;
+ return classPathString;
}
}
[commons-bcel] 02/02: org.apache.bcel.util.ClassPath hashCode() and equals() don't match.
Posted by gg...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
ggregory pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/commons-bcel.git
commit 8b3e1751c6dcdf5cf82f312692df27fb9d714fbd
Author: Gary David Gregory (Code signing key) <gg...@apache.org>
AuthorDate: Sat Nov 19 16:25:14 2022 -0500
org.apache.bcel.util.ClassPath hashCode() and equals() don't match.
---
src/changes/changes.xml | 1 +
src/main/java/org/apache/bcel/util/ClassPath.java | 21 ++++++++++++---------
2 files changed, 13 insertions(+), 9 deletions(-)
diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index 9fab3684..4adb3858 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -91,6 +91,7 @@ The <action> type attribute can be add,update,fix,remove.
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.StackMapEntry.StackMapEntry(DataInput, ConstantPool) reads signed instead of unsigned shorts from its DataInput.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.StackMapType.StackMapType(DataInput, ConstantPool) reads signed instead of unsigned shorts from its DataInput.</action>
<action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.classfile.ConstantInvokeDynamic.ConstantInvokeDynamic(DataInput).</action>
+ <action type="fix" dev="ggregory" due-to="Gary Gregory">org.apache.bcel.util.ClassPath hashCode() and equals() don't match.</action>
<!-- UPDATE -->
<action type="update" dev="ggregory" due-to="Gary Gregory">Bump spotbugs-maven-plugin from 4.7.2.2 to 4.7.3.0 #167.</action>
<action type="update" dev="ggregory" due-to="Dependabot">Bump jmh.version from 1.35 to 1.36 #170.</action>
diff --git a/src/main/java/org/apache/bcel/util/ClassPath.java b/src/main/java/org/apache/bcel/util/ClassPath.java
index de8aa568..c6e36c6d 100644
--- a/src/main/java/org/apache/bcel/util/ClassPath.java
+++ b/src/main/java/org/apache/bcel/util/ClassPath.java
@@ -536,7 +536,7 @@ public class ClassPath implements Closeable {
@SuppressWarnings("resource")
public ClassPath(final ClassPath parent, final String classPathString) {
this.parent = parent;
- this.classPathString = classPathString;
+ this.classPathString = Objects.requireNonNull(classPathString, "classPathString");
this.paths = new ArrayList<>();
for (final StringTokenizer tokenizer = new StringTokenizer(classPathString, File.pathSeparator); tokenizer.hasMoreTokens();) {
final String path = tokenizer.nextToken();
@@ -580,12 +580,18 @@ public class ClassPath implements Closeable {
}
@Override
- public boolean equals(final Object o) {
- if (o instanceof ClassPath) {
- final ClassPath cp = (ClassPath) o;
- return classPathString.equals(cp.toString());
+ public boolean equals(Object obj) {
+ if (this == obj) {
+ return true;
}
- return false;
+ if (obj == null) {
+ return false;
+ }
+ if (getClass() != obj.getClass()) {
+ return false;
+ }
+ ClassPath other = (ClassPath) obj;
+ return Objects.equals(classPathString, other.classPathString);
}
/**
@@ -767,9 +773,6 @@ public class ClassPath implements Closeable {
@Override
public int hashCode() {
- if (parent != null) {
- return classPathString.hashCode() + parent.hashCode();
- }
return classPathString.hashCode();
}