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:
parent
8ebb81fb7a
commit
92c25244aa
@ -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).
|
||||
|
@ -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) {
|
||||
|
Loading…
Reference in New Issue
Block a user