src/jdk.jdeps/share/classes/com/sun/tools/javap/ConstantWriter.java
changeset 47875 93bba74ed8a3
parent 47216 71c04702a3d5
child 48826 c4d9d1b08e2e
--- a/src/jdk.jdeps/share/classes/com/sun/tools/javap/ConstantWriter.java	Tue Nov 21 10:26:45 2017 +0100
+++ b/src/jdk.jdeps/share/classes/com/sun/tools/javap/ConstantWriter.java	Tue Nov 21 13:06:43 2017 -0800
@@ -1,5 +1,5 @@
 /*
- * Copyright (c) 2007, 2016, Oracle and/or its affiliates. All rights reserved.
+ * Copyright (c) 2007, 2017, Oracle and/or its affiliates. All rights reserved.
  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
  *
  * This code is free software; you can redistribute it and/or modify it
@@ -253,6 +253,38 @@
         }
     }
 
+    String booleanValue(int constant_pool_index) {
+        ClassFile classFile = classWriter.getClassFile();
+        try {
+            CPInfo info = classFile.constant_pool.get(constant_pool_index);
+            if (info instanceof CONSTANT_Integer_info) {
+                int value = ((CONSTANT_Integer_info) info).value;
+               switch (value) {
+                   case 0: return "false";
+                   case 1: return "true";
+               }
+            }
+            return "#" + constant_pool_index;
+        } catch (ConstantPool.InvalidIndex e) {
+            return report(e);
+        }
+    }
+
+    String charValue(int constant_pool_index) {
+        ClassFile classFile = classWriter.getClassFile();
+        try {
+            CPInfo info = classFile.constant_pool.get(constant_pool_index);
+            if (info instanceof CONSTANT_Integer_info) {
+                int value = ((CONSTANT_Integer_info) info).value;
+                return String.valueOf((char) value);
+            } else {
+                return "#" + constant_pool_index;
+            }
+        } catch (ConstantPool.InvalidIndex e) {
+            return report(e);
+        }
+    }
+
     String stringValue(int constant_pool_index) {
         ClassFile classFile = classWriter.getClassFile();
         try {