Mercurial > hg > truffle
comparison c1x4hotspotsrc/HotSpotVM/src/com/sun/hotspot/c1x/HotSpotField.java @ 2057:89bf01e6b049
Treat C1XOptions fields as final.
author | Thomas Wuerthinger <wuerthinger@ssw.jku.at> |
---|---|
date | Fri, 14 Jan 2011 16:29:42 +0100 |
parents | 99ad52189524 |
children | f21664b3dd1c 569d3fe7d65c |
comparison
equal
deleted
inserted
replaced
2056:b7f06f504206 | 2057:89bf01e6b049 |
---|---|
19 * Company, Ltd. | 19 * Company, Ltd. |
20 */ | 20 */ |
21 | 21 |
22 package com.sun.hotspot.c1x; | 22 package com.sun.hotspot.c1x; |
23 | 23 |
24 import java.lang.reflect.*; | |
25 | |
26 import com.sun.c1x.*; | |
24 import com.sun.cri.ci.CiConstant; | 27 import com.sun.cri.ci.CiConstant; |
25 import com.sun.cri.ci.CiKind; | 28 import com.sun.cri.ci.CiKind; |
26 import com.sun.cri.ri.RiField; | 29 import com.sun.cri.ri.RiField; |
27 import com.sun.cri.ri.RiType; | 30 import com.sun.cri.ri.RiType; |
28 | 31 |
53 } | 56 } |
54 | 57 |
55 @Override | 58 @Override |
56 public CiConstant constantValue(Object object) { | 59 public CiConstant constantValue(Object object) { |
57 if (object == null) { | 60 if (object == null) { |
61 if (constant == null && holder.isResolved() && holder.javaClass() == C1XOptions.class) { | |
62 Field f; | |
63 try { | |
64 f = C1XOptions.class.getField(name); | |
65 } catch (SecurityException e1) { | |
66 return null; | |
67 } catch (NoSuchFieldException e1) { | |
68 return null; | |
69 } | |
70 f.setAccessible(true); | |
71 if (Modifier.isStatic(f.getModifiers())) { | |
72 CiKind kind = CiKind.fromJavaClass(f.getType()); | |
73 Object value; | |
74 try { | |
75 value = f.get(null); | |
76 } catch (IllegalArgumentException e) { | |
77 return null; | |
78 } catch (IllegalAccessException e) { | |
79 return null; | |
80 } | |
81 constant = CiConstant.forBoxed(kind, value); | |
82 } | |
83 } | |
84 | |
58 // Constant part only valid for static fields. | 85 // Constant part only valid for static fields. |
59 return constant; | 86 return constant; |
60 } | 87 } |
61 return null; | 88 return null; |
62 } | 89 } |