equal
deleted
inserted
replaced
959 public Object getConstantValue() { // Mirror API |
959 public Object getConstantValue() { // Mirror API |
960 return Constants.decode(getConstValue(), type); |
960 return Constants.decode(getConstValue(), type); |
961 } |
961 } |
962 |
962 |
963 public void setLazyConstValue(final Env<AttrContext> env, |
963 public void setLazyConstValue(final Env<AttrContext> env, |
964 final Log log, |
|
965 final Attr attr, |
964 final Attr attr, |
966 final JCTree.JCExpression initializer) |
965 final JCTree.JCExpression initializer) |
967 { |
966 { |
968 setData(new Callable<Object>() { |
967 setData(new Callable<Object>() { |
969 public Object call() { |
968 public Object call() { |
970 JavaFileObject source = log.useSource(env.toplevel.sourcefile); |
969 return attr.attribLazyConstantValue(env, initializer, type); |
971 try { |
|
972 Type itype = attr.attribExpr(initializer, env, type); |
|
973 if (itype.constValue() != null) |
|
974 return attr.coerce(itype, type).constValue(); |
|
975 else |
|
976 return null; |
|
977 } finally { |
|
978 log.useSource(source); |
|
979 } |
|
980 } |
970 } |
981 }); |
971 }); |
982 } |
972 } |
983 |
973 |
984 /** |
974 /** |
1008 Callable<?> eval = (Callable<?>)data; |
998 Callable<?> eval = (Callable<?>)data; |
1009 data = null; // to make sure we don't evaluate this twice. |
999 data = null; // to make sure we don't evaluate this twice. |
1010 try { |
1000 try { |
1011 data = eval.call(); |
1001 data = eval.call(); |
1012 } catch (Exception ex) { |
1002 } catch (Exception ex) { |
|
1003 ex.printStackTrace(); |
1013 throw new AssertionError(ex); |
1004 throw new AssertionError(ex); |
1014 } |
1005 } |
1015 } |
1006 } |
1016 return data; |
1007 return data; |
1017 } |
1008 } |