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 2a5992ff8f81998931a47b3bdf104e4f623a8f95
Author: Gary David Gregory (Code signing key) <[email protected]>
AuthorDate: Sat Jun 22 09:35:11 2024 -0400

    Fix SpotBugs DM_DEFAULT_ENCODING in JasminVisitor
---
 src/changes/changes.xml         | 1 +
 src/examples/JasminVisitor.java | 5 ++++-
 2 files changed, 5 insertions(+), 1 deletion(-)

diff --git a/src/changes/changes.xml b/src/changes/changes.xml
index da301fb4..3485b1b0 100644
--- a/src/changes/changes.xml
+++ b/src/changes/changes.xml
@@ -67,6 +67,7 @@ The <action> type attribute can be add,update,fix,remove.
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Fix SpotBugs RV_RETURN_VALUE_IGNORED_BAD_PRACTICE in 
JasminVisitor.</action>
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">SpotBugs checks should ignore code generated by JavaCC.</action>
       <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Fix SpotBugs URF_UNREAD_FIELD in ClassDumper.</action>
+      <action                  type="update" dev="ggregory" due-to="Gary 
Gregory">Fix SpotBugs DM_DEFAULT_ENCODING in JasminVisitor.</action>
       <!-- ADD --> 
       <action                  type="update" dev="ggregory" due-to="nbauma109, 
Gary Gregory, Mark Roberts">Add accessors to model and unit tests, Javadoc 
#183.</action>
       <!-- UPDATE -->
diff --git a/src/examples/JasminVisitor.java b/src/examples/JasminVisitor.java
index 03c2fe52..d17a3528 100644
--- a/src/examples/JasminVisitor.java
+++ b/src/examples/JasminVisitor.java
@@ -15,10 +15,13 @@
  *  limitations under the License.
  */
 
+import java.io.BufferedWriter;
 import java.io.File;
 import java.io.FileOutputStream;
 import java.io.OutputStream;
+import java.io.OutputStreamWriter;
 import java.io.PrintWriter;
+import java.nio.charset.StandardCharsets;
 import java.util.Date;
 import java.util.Hashtable;
 import java.util.StringTokenizer;
@@ -99,7 +102,7 @@ public class JasminVisitor extends 
org.apache.bcel.classfile.EmptyVisitor {
 
     public JasminVisitor(final JavaClass clazz, final OutputStream out) {
         this.javaClass = clazz;
-        this.printWriter = new PrintWriter(out);
+        this.printWriter = new PrintWriter(new BufferedWriter(new 
OutputStreamWriter(out, StandardCharsets.UTF_8)), false);
         this.className = clazz.getClassName();
         this.cp = new ConstantPoolGen(clazz.getConstantPool());
     }

Reply via email to