Mercurial > hg > release > icedtea6-1.11
view patches/openjdk/4111861-static_fields.patch @ 2938:d667440f2973
Add 2013/10/15 security fixes.
2013-10-29 Andrew John Hughes <gnu.andrew@redhat.com>
* patches/ecj/bootver.patch:
Removed as unapplied & incorporated in other patches.
* Makefile.am:
(SECURITY_PATCHES): Add security update.
* NEWS: Updated.
* patches/jtreg-LastErrorString.patch,
* patches/openjdk/7196533-timezone_bottleneck.patch,
* patches/openjdk/8010727-empty_logger_name.patch,
* patches/openjdk/8010939-logmanager_deadlock.patch,
* patches/openjdk/8012617-arrayindexoutofbounds_linebreakmeasurer.patch,
* patches/openjdk/8014718-remove_logging_suntoolkit.patch:
Regenerated.
* patches/nss-config.patch: Fix path to java.security.
* patches/openjdk/4075303-javap_update.patch,
* patches/openjdk/4111861-static_fields.patch,
* patches/openjdk/4501661-disallow_mixing.patch,
* patches/openjdk/4884240-javap_additional_option.patch,
* patches/openjdk/6708729-javap_makefile_update.patch,
* patches/openjdk/6715767-javap_crash.patch,
* patches/openjdk/6819246-javap_instruction_decoding.patch,
* patches/openjdk/6824493-experimental.patch,
* patches/openjdk/6841419-classfile_iterator.patch,
* patches/openjdk/6841420-classfile_methods.patch,
* patches/openjdk/6843013-missing_experimental.patch,
* patches/openjdk/6852856-javap_subclasses.patch,
* patches/openjdk/6867671-javap_whitespace.patch,
* patches/openjdk/6868539-constant_pool_tags.patch,
* patches/openjdk/6902264-fix_indentation.patch,
* patches/openjdk/6954275-big_xml_signatures.patch,
* patches/openjdk/7146431-java.security_files.patch,
* patches/openjdk/8000450-restrict_access.patch,
* patches/openjdk/8002070-remove_logger_stack_search.patch,
* patches/openjdk/8003992-embedded_nulls.patch,
* patches/openjdk/8004188-rename_java.security.patch,
* patches/openjdk/8006882-jmockit.patch,
* patches/openjdk/8006900-new_date_time.patch,
* patches/openjdk/8008589-better_mbean_permission_validation.patch,
* patches/openjdk/8010118-caller_sensitive.patch,
* patches/openjdk/8011071-better_crypto_provider_handling.patch,
* patches/openjdk/8011081-improve_jhat.patch,
* patches/openjdk/8011139-revise_checking_getenclosingclass.patch,
* patches/openjdk/8011157-improve_corba_portability-jdk.patch,
* patches/openjdk/8011157-improve_corba_portability.patch,
* patches/openjdk/8011990-logger_test_urls.patch,
* patches/openjdk/8012071-better_bean_building.patch,
* patches/openjdk/8012147-improve_tool.patch,
* patches/openjdk/8012243-serial_regression.patch,
* patches/openjdk/8012277-improve_dataflavour.patch,
* patches/openjdk/8012425-transform_transformfactory.patch,
* patches/openjdk/8012453-runtime.exec.patch,
* patches/openjdk/8013380-logger_stack_walk_glassfish.patch,
* patches/openjdk/8013503-improve_stream_factories.patch,
* patches/openjdk/8013506-better_pack200.patch,
* patches/openjdk/8013510-augment_image_writing.patch,
* patches/openjdk/8013514-improve_cmap_stability.patch,
* patches/openjdk/8013739-better_ldap_resource_management.patch,
* patches/openjdk/8013744-better_tabling.patch,
* patches/openjdk/8013827-createtempfile_hang.patch,
* patches/openjdk/8014085-better_serialization.patch,
* patches/openjdk/8014093-improve_image_parsing.patch,
* patches/openjdk/8014102-improve_image_conversion.patch,
* patches/openjdk/8014341-better_kerberos_service.patch,
* patches/openjdk/8014349-getdeclaredclass_fix.patch,
* patches/openjdk/8014530-better_dsp.patch,
* patches/openjdk/8014534-better_profiling.patch,
* patches/openjdk/8014745-logger_stack_walk_switch.patch,
* patches/openjdk/8014987-augment_serialization.patch,
* patches/openjdk/8015144-performance_regression.patch,
* patches/openjdk/8015614-update_build.patch,
* patches/openjdk/8015731-auth_improvements.patch,
* patches/openjdk/8015743-address_internet_addresses.patch,
* patches/openjdk/8015965-typo_in_property_name.patch,
* patches/openjdk/8015978-incorrect_transformation.patch,
* patches/openjdk/8016256-finalization_final.patch,
* patches/openjdk/8016357-update_hs_diagnostic_class.patch,
* patches/openjdk/8016653-ignoreable_characters.patch,
* patches/openjdk/8016675-robust_javadoc.patch,
* patches/openjdk/8017196-ensure_proxies_are_handled_appropriately-jdk.patch,
* patches/openjdk/8017196-ensure_proxies_are_handled_appropriately.patch,
* patches/openjdk/8017287-better_resource_disposal.patch,
* patches/openjdk/8017291-cast_proxies_aside.patch,
* patches/openjdk/8017298-better_xml_support.patch,
* patches/openjdk/8017300-improve_interface_implementation.patch,
* patches/openjdk/8017505-better_client_service.patch,
* patches/openjdk/8017566-backout_part_of_8000450.patch,
* patches/openjdk/8019292-better_attribute_value_exceptions.patch,
* patches/openjdk/8019584-invalid_notification_fix.patch,
* patches/openjdk/8019617-better_view_of_objects.patch,
* patches/openjdk/8019969-inet6_test_case_fix.patch,
* patches/openjdk/8019979-better_access_test.patch,
* patches/openjdk/8020293-jvm_crash.patch,
* patches/openjdk/8021290-signature_validation.patch,
* patches/openjdk/8021355-splashscreen_regression.patch,
* patches/openjdk/8021366-jaxp_test_fix-01.patch,
* patches/openjdk/8021577-bean_serialization_fix.patch,
* patches/openjdk/8021933-jaxp_test_fix-02.patch,
* patches/openjdk/8021969-jnlp_load_failure.patch,
* patches/openjdk/8022661-writeobject_flush.patch,
* patches/openjdk/8022682-supporting_xom.patch,
* patches/openjdk/8022940-enhance_corba_translations.patch,
* patches/openjdk/8023683-enhance_class_file_parsing.patch,
* patches/openjdk/8023964-ignore_test.patch,
* patches/openjdk/8024914-swapped_usage.patch,
* patches/openjdk/8025128-createtempfile_absolute_prefix.patch,
* patches/openjdk/oj6-19-fix_8010118_test_cases.patch,
* patches/openjdk/oj6-20-merge.patch,
* patches/openjdk/oj6-21-overrides.patch: Added.
author | Andrew John Hughes <gnu.andrew@redhat.com> |
---|---|
date | Thu, 31 Oct 2013 00:22:07 +0000 |
parents | |
children |
line wrap: on
line source
# HG changeset patch # User jjg # Date 1217887742 25200 # Mon Aug 04 15:09:02 2008 -0700 # Node ID 6134c146043a3e9dd12ee73ca32ce56ac1c95e3a # Parent 17dfaebe23044c48bcd5ed0730ce2358543ac459 4111861: static final field contents are not displayed Reviewed-by: ksrini diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/ClassWriter.java --- openjdk/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Tue May 19 11:43:50 2009 -0700 +++ openjdk/langtools/src/share/classes/com/sun/tools/javap/ClassWriter.java Mon Aug 04 15:09:02 2008 -0700 @@ -35,6 +35,7 @@ import com.sun.tools.classfile.Code_attribute; import com.sun.tools.classfile.ConstantPool; import com.sun.tools.classfile.ConstantPoolException; +import com.sun.tools.classfile.ConstantValue_attribute; import com.sun.tools.classfile.Descriptor; import com.sun.tools.classfile.DescriptorException; import com.sun.tools.classfile.Exceptions_attribute; @@ -189,6 +190,14 @@ } print(" "); print(getFieldName(f)); + if (options.showConstants && !options.compat) { // BUG 4111861 print static final field contents + Attribute a = f.attributes.get(Attribute.ConstantValue); + if (a instanceof ConstantValue_attribute) { + print(" = "); + ConstantValue_attribute cv = (ConstantValue_attribute) a; + print(getConstantValue(f.descriptor, cv.constantvalue_index)); + } + } print(";"); println(); @@ -485,6 +494,81 @@ } } + /** + * Get the value of an entry in the constant pool as a Java constant. + * Characters and booleans are represented by CONSTANT_Intgere entries. + * Character and string values are processed to escape characters outside + * the basic printable ASCII set. + * @param d the descriptor, giving the expected type of the constant + * @param index the index of the value in the constant pool + * @return a printable string containing the value of the constant. + */ + String getConstantValue(Descriptor d, int index) { + try { + ConstantPool.CPInfo cpInfo = constant_pool.get(index); + + switch (cpInfo.getTag()) { + case ConstantPool.CONSTANT_Integer: { + ConstantPool.CONSTANT_Integer_info info = + (ConstantPool.CONSTANT_Integer_info) cpInfo; + String t = d.getValue(constant_pool); + if (t.equals("C")) { // character + return getConstantCharValue((char) info.value); + } else if (t.equals("Z")) { // boolean + return String.valueOf(info.value == 1); + } else { // other: assume integer + return String.valueOf(info.value); + } + } + + case ConstantPool.CONSTANT_String: { + ConstantPool.CONSTANT_String_info info = + (ConstantPool.CONSTANT_String_info) cpInfo; + return getConstantStringValue(info.getString()); + } + + default: + return constantWriter.stringValue(cpInfo); + } + } catch (ConstantPoolException e) { + return "#" + index; + } + } + + private String getConstantCharValue(char c) { + StringBuilder sb = new StringBuilder(); + sb.append('\''); + sb.append(esc(c, '\'')); + sb.append('\''); + return sb.toString(); + } + + private String getConstantStringValue(String s) { + StringBuilder sb = new StringBuilder(); + sb.append("\""); + for (int i = 0; i < s.length(); i++) { + sb.append(esc(s.charAt(i), '"')); + } + sb.append("\""); + return sb.toString(); + } + + private String esc(char c, char quote) { + if (32 <= c && c <= 126 && c != quote) + return String.valueOf(c); + else switch (c) { + case '\b': return "\\b"; + case '\n': return "\\n"; + case '\t': return "\\t"; + case '\f': return "\\f"; + case '\r': return "\\r"; + case '\\': return "\\\\"; + case '\'': return "\\'"; + case '\"': return "\\\""; + default: return String.format("\\u%04x", (int) c); + } + } + private Options options; private AttributeWriter attrWriter; private CodeWriter codeWriter; diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/JavapTask.java --- openjdk/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Tue May 19 11:43:50 2009 -0700 +++ openjdk/langtools/src/share/classes/com/sun/tools/javap/JavapTask.java Mon Aug 04 15:09:02 2008 -0700 @@ -222,6 +222,12 @@ void process(JavapTask task, String opt, String arg) { task.options.ignoreSymbolFile = true; } + }, + + new Option(false, "-constants") { + void process(JavapTask task, String opt, String arg) { + task.options.showConstants = true; + } } }; diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/Options.java --- openjdk/langtools/src/share/classes/com/sun/tools/javap/Options.java Tue May 19 11:43:50 2009 -0700 +++ openjdk/langtools/src/share/classes/com/sun/tools/javap/Options.java Mon Aug 04 15:09:02 2008 -0700 @@ -77,6 +77,7 @@ public boolean showDisassembled; public boolean showInternalSignatures; public boolean showAllAttrs; + public boolean showConstants; public boolean compat; // bug-for-bug compatibility mode with old javap public boolean jsr277; diff -r 17dfaebe2304 -r 6134c146043a src/share/classes/com/sun/tools/javap/resources/javap.properties --- openjdk/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Tue May 19 11:43:50 2009 -0700 +++ openjdk/langtools/src/share/classes/com/sun/tools/javap/resources/javap.properties Mon Aug 04 15:09:02 2008 -0700 @@ -58,5 +58,9 @@ main.opt.bootclasspath=\ \ -bootclasspath <path> Override location of bootstrap class files +main.opt.constants=\ +\ -constants Show static final constants + + diff -r 17dfaebe2304 -r 6134c146043a test/tools/javap/4111861/A.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ openjdk/langtools/test/tools/javap/4111861/A.java Mon Aug 04 15:09:02 2008 -0700 @@ -0,0 +1,14 @@ +class A { + public static final int i = 42; + public static final boolean b = true; + public static final float f = 1.0f; + public static final double d = 1.0d; + public static final short s = 1; + public static final long l = 1l; + public static final char cA = 'A'; + public static final char c0 = '\u0000'; + public static final char cn = '\n'; + public static final char cq1 = '\''; + public static final char cq2 = '"'; + public static final java.lang.String t1 = "abc \u0000 \f\n\r\t'\""; +} diff -r 17dfaebe2304 -r 6134c146043a test/tools/javap/4111861/T4111861.java --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ openjdk/langtools/test/tools/javap/4111861/T4111861.java Mon Aug 04 15:09:02 2008 -0700 @@ -0,0 +1,101 @@ +/* + * Copyright 2008 Sun Microsystems, Inc. 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 + * under the terms of the GNU General Public License version 2 only, as + * published by the Free Software Foundation. + * + * This code is distributed in the hope that it will be useful, but WITHOUT + * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or + * FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License + * version 2 for more details (a copy is included in the LICENSE file that + * accompanied this code). + * + * You should have received a copy of the GNU General Public License version + * 2 along with this work; if not, write to the Free Software Foundation, + * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. + * + * Please contact Sun Microsystems, Inc., 4150 Network Circle, Santa Clara, + * CA 95054 USA or visit www.sun.com if you need additional information or + * have any questions. + */ + +import java.io.*; + +/* + * @test + * @bug 4111861 + * @summary static final field contents are not displayed + */ +public class T4111861 { + public static void main(String... args) throws Exception { + new T4111861().run(); + } + + void run() throws Exception { + File testSrc = new File(System.getProperty("test.src", ".")); + File a_java = new File(testSrc, "A.java"); + javac("-d", ".", a_java.getPath()); + + String out = javap("-classpath", ".", "-constants", "A"); + + String a = read(a_java); + + if (!filter(out).equals(filter(read(a_java)))) { + System.out.println(out); + throw new Exception("unexpected output"); + } + } + + String javac(String... args) throws Exception { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = com.sun.tools.javac.Main.compile(args, pw); + if (rc != 0) + throw new Exception("javac failed, rc=" + rc); + return sw.toString(); + } + + String javap(String... args) throws Exception { + StringWriter sw = new StringWriter(); + PrintWriter pw = new PrintWriter(sw); + int rc = com.sun.tools.javap.Main.run(args, pw); + if (rc != 0) + throw new Exception("javap failed, rc=" + rc); + return sw.toString(); + } + + String read(File f) throws IOException { + StringBuilder sb = new StringBuilder(); + BufferedReader in = new BufferedReader(new FileReader(f)); + try { + String line; + while ((line = in.readLine()) != null) { + sb.append(line); + sb.append('\n'); + } + } finally { + in.close(); + } + return sb.toString(); + } + + // return those lines beginning "public static final" + String filter(String s) throws IOException { + StringBuilder sb = new StringBuilder(); + BufferedReader in = new BufferedReader(new StringReader(s)); + try { + String line; + while ((line = in.readLine()) != null) { + if (line.indexOf("public static final") > 0) { + sb.append(line); + sb.append('\n'); + } + } + } finally { + in.close(); + } + return sb.toString(); + } +}