# HG changeset patch # User jlahoda # Date 1387274301 -3600 # Node ID 3c8d86bf756b95ab4173bd5f676019d2afd90ed8 # Parent f9f06fcca59deae934d266a2c7af142b45bd7fb3 8028415: TreeMaker.Literal(Object) creates invalid JCLiterals when passed a Character. Summary: JCLiteral for char must contain an Integer, not the provided Character. Reviewed-by: jjg diff -r f9f06fcca59d -r 3c8d86bf756b langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java --- a/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Tue Dec 17 10:55:59 2013 +0100 +++ b/langtools/src/share/classes/com/sun/tools/javac/tree/TreeMaker.java Tue Dec 17 10:58:21 2013 +0100 @@ -757,7 +757,7 @@ setType(syms.byteType.constType(value)); } else if (value instanceof Character) { int v = (int) (((Character) value).toString().charAt(0)); - result = Literal(CHAR, value). + result = Literal(CHAR, v). setType(syms.charType.constType(v)); } else if (value instanceof Double) { result = Literal(DOUBLE, value). diff -r f9f06fcca59d -r 3c8d86bf756b langtools/test/tools/javac/tree/MakeLiteralTest.java --- a/langtools/test/tools/javac/tree/MakeLiteralTest.java Tue Dec 17 10:55:59 2013 +0100 +++ b/langtools/test/tools/javac/tree/MakeLiteralTest.java Tue Dec 17 10:58:21 2013 +0100 @@ -1,5 +1,5 @@ /* - * Copyright (c) 2010, 2012, Oracle and/or its affiliates. All rights reserved. + * Copyright (c) 2010, 2013, 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 @@ -23,7 +23,7 @@ /* * @test - * @bug 6504896 + * @bug 6504896 8028415 * @summary TreeMaker.Literal(Object) does not support Booleans */ @@ -76,6 +76,12 @@ + l.type.constValue().getClass() + " " + l.type.constValue() + ": expected:" + constValue.getClass() + " " + constValue); } + if (l.getValue().getClass() != value.getClass() + || !value.equals(l.getValue())) { + error("unexpected const value: " + + l.getValue().getClass() + " " + l.type.constValue() + + ": expected:" + value.getClass() + " " + value); + } } void error(String msg) {