Polishing
This commit is contained in:
parent
c52484ed68
commit
7387475deb
|
@ -274,7 +274,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
|||
if (requiredConstructor != null) {
|
||||
throw new BeanCreationException(beanName,
|
||||
"Invalid autowire-marked constructor: " + candidate +
|
||||
". Found another constructor with 'required' Autowired annotation: " +
|
||||
". Found constructor with 'required' Autowired annotation already: " +
|
||||
requiredConstructor);
|
||||
}
|
||||
if (candidate.getParameterTypes().length == 0) {
|
||||
|
@ -286,7 +286,7 @@ public class AutowiredAnnotationBeanPostProcessor extends InstantiationAwareBean
|
|||
if (!candidates.isEmpty()) {
|
||||
throw new BeanCreationException(beanName,
|
||||
"Invalid autowire-marked constructors: " + candidates +
|
||||
". Found another constructor with 'required' Autowired annotation: " +
|
||||
". Found constructor with 'required' Autowired annotation: " +
|
||||
candidate);
|
||||
}
|
||||
requiredConstructor = candidate;
|
||||
|
|
|
@ -13,6 +13,7 @@
|
|||
* See the License for the specific language governing permissions and
|
||||
* limitations under the License.
|
||||
*/
|
||||
|
||||
package org.springframework.expression.spel.standard;
|
||||
|
||||
import java.io.File;
|
||||
|
@ -77,7 +78,7 @@ public class SpelCompiler implements Opcodes {
|
|||
// The child ClassLoader used to load the compiled expression classes
|
||||
private final ChildClassLoader ccl;
|
||||
|
||||
// counter suffix for generated classes within this SpelCompiler instance
|
||||
// Counter suffix for generated classes within this SpelCompiler instance
|
||||
private final AtomicInteger suffixId = new AtomicInteger(1);
|
||||
|
||||
|
||||
|
@ -131,8 +132,7 @@ public class SpelCompiler implements Opcodes {
|
|||
// Create class outline 'spel/ExNNN extends org.springframework.expression.spel.CompiledExpression'
|
||||
String clazzName = "spel/Ex" + getNextSuffix();
|
||||
ClassWriter cw = new ClassWriter(ClassWriter.COMPUTE_MAXS|ClassWriter.COMPUTE_FRAMES);
|
||||
cw.visit(V1_5, ACC_PUBLIC, clazzName, null,
|
||||
"org/springframework/expression/spel/CompiledExpression", null);
|
||||
cw.visit(V1_5, ACC_PUBLIC, clazzName, null, "org/springframework/expression/spel/CompiledExpression", null);
|
||||
|
||||
// Create default constructor
|
||||
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
|
||||
|
@ -199,8 +199,8 @@ public class SpelCompiler implements Opcodes {
|
|||
}
|
||||
|
||||
/**
|
||||
* Request to revert to the interpreter for expression evaluation. Any compiled form
|
||||
* is discarded but can be recreated by later recompiling again.
|
||||
* Request to revert to the interpreter for expression evaluation.
|
||||
* Any compiled form is discarded but can be recreated by later recompiling again.
|
||||
* @param expression the expression
|
||||
*/
|
||||
public static void revertToInterpreted(Expression expression) {
|
||||
|
|
|
@ -77,6 +77,7 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
|||
|
||||
private InvokerPair lastReadInvokerPair;
|
||||
|
||||
|
||||
/**
|
||||
* Returns {@code null} which means this is a general purpose accessor.
|
||||
*/
|
||||
|
@ -662,7 +663,8 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
|||
@Override
|
||||
public boolean isCompilable() {
|
||||
// If non public must continue to use reflection
|
||||
if (!Modifier.isPublic(member.getModifiers()) || !Modifier.isPublic(member.getDeclaringClass().getModifiers())) {
|
||||
if (!Modifier.isPublic(this.member.getModifiers()) ||
|
||||
!Modifier.isPublic(this.member.getDeclaringClass().getModifiers())) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -670,19 +672,19 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
|||
|
||||
@Override
|
||||
public Class<?> getPropertyType() {
|
||||
if (member instanceof Field) {
|
||||
return ((Field) member).getType();
|
||||
if (this.member instanceof Field) {
|
||||
return ((Field) this.member).getType();
|
||||
}
|
||||
else {
|
||||
return ((Method) member).getReturnType();
|
||||
return ((Method) this.member).getReturnType();
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void generateCode(String propertyName, MethodVisitor mv, CodeFlow codeflow) {
|
||||
boolean isStatic = Modifier.isStatic(member.getModifiers());
|
||||
boolean isStatic = Modifier.isStatic(this.member.getModifiers());
|
||||
String descriptor = codeflow.lastDescriptor();
|
||||
String memberDeclaringClassSlashedDescriptor = member.getDeclaringClass().getName().replace('.','/');
|
||||
String memberDeclaringClassSlashedDescriptor = this.member.getDeclaringClass().getName().replace('.', '/');
|
||||
if (!isStatic) {
|
||||
if (descriptor == null) {
|
||||
codeflow.loadTarget(mv);
|
||||
|
@ -691,16 +693,15 @@ public class ReflectivePropertyAccessor implements PropertyAccessor {
|
|||
mv.visitTypeInsn(CHECKCAST, memberDeclaringClassSlashedDescriptor);
|
||||
}
|
||||
}
|
||||
if (member instanceof Field) {
|
||||
if (this.member instanceof Field) {
|
||||
mv.visitFieldInsn(isStatic ? GETSTATIC : GETFIELD, memberDeclaringClassSlashedDescriptor,
|
||||
member.getName(), CodeFlow.toJVMDescriptor(((Field) member).getType()));
|
||||
this.member.getName(), CodeFlow.toJVMDescriptor(((Field) this.member).getType()));
|
||||
}
|
||||
else {
|
||||
mv.visitMethodInsn(isStatic ? INVOKESTATIC : INVOKEVIRTUAL, memberDeclaringClassSlashedDescriptor,
|
||||
member.getName(), CodeFlow.createSignatureDescriptor((Method) member),false);
|
||||
this.member.getName(), CodeFlow.createSignatureDescriptor((Method) this.member),false);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue