throw an error if a volatile field is encountered, since we don't yet support them properly

This commit is contained in:
Joel Dice 2008-12-18 16:32:18 -07:00
parent c479bccdb4
commit 5e727c8c5d
3 changed files with 23 additions and 0 deletions

View File

@ -2483,6 +2483,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
object field = resolveField(t, codePool(t, code), index - 1);
if (UNLIKELY(t->exception)) return;
if (throwIfVolatileField(t, field)) return;
Compiler::Operand* table;
@ -3363,6 +3364,7 @@ compile(MyThread* t, Frame* initialFrame, unsigned ip,
object field = resolveField(t, codePool(t, code), index - 1);
if (UNLIKELY(t->exception)) return;
if (throwIfVolatileField(t, field)) return;
object staticTable = 0;

View File

@ -1452,6 +1452,7 @@ interpret(Thread* t)
object field = resolveField(t, codePool(t, code), index - 1);
if (UNLIKELY(exception)) goto throw_;
if (throwIfVolatileField(t, field)) goto throw_;
pushField(t, popObject(t), field);
} else {
@ -1465,6 +1466,8 @@ interpret(Thread* t)
object field = resolveField(t, codePool(t, code), index - 1);
if (UNLIKELY(exception)) goto throw_;
if (throwIfVolatileField(t, field)) goto throw_;
PROTECT(t, field);
if (UNLIKELY(classInit(t, fieldClass(t, field), 3))) goto invoke;
@ -2396,6 +2399,7 @@ interpret(Thread* t)
object field = resolveField(t, codePool(t, code), index - 1);
if (UNLIKELY(exception)) goto throw_;
if (throwIfVolatileField(t, field)) goto throw_;
switch (fieldCode(t, field)) {
case ByteField:
@ -2461,6 +2465,8 @@ interpret(Thread* t)
object field = resolveField(t, codePool(t, code), index - 1);
if (UNLIKELY(exception)) goto throw_;
if (throwIfVolatileField(t, field)) goto throw_;
PROTECT(t, field);
if (UNLIKELY(classInit(t, fieldClass(t, field), 3))) goto invoke;

View File

@ -188,6 +188,21 @@ populateMultiArray(Thread* t, object array, int32_t* counts,
int
findLineNumber(Thread* t, object method, unsigned ip);
inline bool
throwIfVolatileField(Thread* t, object field)
{
if (fieldFlags(t, field) & ACC_VOLATILE) {
object message = makeString
(t, "volatile fields are not yet supported: %s.%s",
&byteArrayBody(t, className(t, fieldClass(t, field)), 0),
&byteArrayBody(t, fieldName(t, field), 0));
t->exception = makeNoSuchFieldError(t, message);
return true;
} else {
return false;
}
}
} // namespace vm
#endif//PROCESS_H