|
1 | 1 | /*
|
2 |
| - * Copyright 2002-2014 the original author or authors. |
| 2 | + * Copyright 2002-2015 the original author or authors. |
3 | 3 | *
|
4 | 4 | * Licensed under the Apache License, Version 2.0 (the "License");
|
5 | 5 | * you may not use this file except in compliance with the License.
|
@@ -80,8 +80,9 @@ public ValueRef getValueRef(ExpressionState state) throws EvaluationException {
|
80 | 80 | public TypedValue getValueInternal(ExpressionState state) throws EvaluationException {
|
81 | 81 | TypedValue tv = getValueInternal(state.getActiveContextObject(), state.getEvaluationContext(),
|
82 | 82 | state.getConfiguration().isAutoGrowNullReferences());
|
83 |
| - if (this.cachedReadAccessor instanceof CompilablePropertyAccessor) { |
84 |
| - CompilablePropertyAccessor accessor = (CompilablePropertyAccessor) this.cachedReadAccessor; |
| 83 | + PropertyAccessor accessorToUse = this.cachedReadAccessor; |
| 84 | + if (accessorToUse instanceof CompilablePropertyAccessor) { |
| 85 | + CompilablePropertyAccessor accessor = (CompilablePropertyAccessor) accessorToUse; |
85 | 86 | this.exitTypeDescriptor = CodeFlow.toDescriptor(accessor.getPropertyType());
|
86 | 87 | }
|
87 | 88 | return tv;
|
@@ -338,13 +339,18 @@ else if (clazz.isAssignableFrom(targetType)) {
|
338 | 339 |
|
339 | 340 | @Override
|
340 | 341 | public boolean isCompilable() {
|
341 |
| - return (this.cachedReadAccessor instanceof CompilablePropertyAccessor && |
342 |
| - ((CompilablePropertyAccessor) this.cachedReadAccessor).isCompilable()); |
| 342 | + PropertyAccessor accessorToUse = this.cachedReadAccessor; |
| 343 | + return (accessorToUse instanceof CompilablePropertyAccessor && |
| 344 | + ((CompilablePropertyAccessor) accessorToUse).isCompilable()); |
343 | 345 | }
|
344 | 346 |
|
345 | 347 | @Override
|
346 | 348 | public void generateCode(MethodVisitor mv, CodeFlow cf) {
|
347 |
| - ((CompilablePropertyAccessor) this.cachedReadAccessor).generateCode(this.name, mv, cf); |
| 349 | + PropertyAccessor accessorToUse = this.cachedReadAccessor; |
| 350 | + if (!(accessorToUse instanceof CompilablePropertyAccessor)) { |
| 351 | + throw new IllegalStateException("Property accessor is not compilable: " + accessorToUse); |
| 352 | + } |
| 353 | + ((CompilablePropertyAccessor) accessorToUse).generateCode(this.name, mv, cf); |
348 | 354 | cf.pushDescriptor(this.exitTypeDescriptor);
|
349 | 355 | }
|
350 | 356 |
|
|
0 commit comments