8028415: TreeMaker.Literal(Object) creates invalid JCLiterals when passed a Character

JCLiteral for char must contain an Integer, not the provided Character.

Reviewed-by: jjg
This commit is contained in:
Jan Lahoda 2013-12-17 10:58:21 +01:00
parent 8ebb81fb7a
commit 92c25244aa
2 changed files with 9 additions and 3 deletions

View File

@ -757,7 +757,7 @@ public class TreeMaker implements JCTree.Factory {
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).

View File

@ -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 @@ public class MakeLiteralTest {
+ 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) {