Polishing

This commit is contained in:
Juergen Hoeller
2018-09-17 14:39:54 +02:00
parent 702d533e6f
commit 5ca2c56cf0
10 changed files with 79 additions and 81 deletions

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2014 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -33,7 +33,7 @@ public class StringLiteral extends Literal {
public StringLiteral(String payload, int pos, String value) {
super(payload,pos);
super(payload, pos);
value = value.substring(1, value.length() - 1);
this.value = new TypedValue(value.replaceAll("''", "'").replaceAll("\"\"", "\""));
this.exitTypeDescriptor = "Ljava/lang/String";

View File

@@ -1,5 +1,5 @@
/*
* Copyright 2002-2017 the original author or authors.
* Copyright 2002-2018 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
@@ -132,9 +132,9 @@ public class SpelCompiler implements Opcodes {
@Nullable
private Class<? extends CompiledExpression> createExpressionClass(SpelNodeImpl expressionToCompile) {
// Create class outline 'spel/ExNNN extends org.springframework.expression.spel.CompiledExpression'
String clazzName = "spel/Ex" + getNextSuffix();
String className = "spel/Ex" + getNextSuffix();
ClassWriter cw = new ExpressionClassWriter();
cw.visit(V1_5, ACC_PUBLIC, clazzName, null, "org/springframework/expression/spel/CompiledExpression", null);
cw.visit(V1_5, ACC_PUBLIC, className, null, "org/springframework/expression/spel/CompiledExpression", null);
// Create default constructor
MethodVisitor mv = cw.visitMethod(ACC_PUBLIC, "<init>", "()V", null, null);
@@ -152,7 +152,7 @@ public class SpelCompiler implements Opcodes {
new String[ ]{"org/springframework/expression/EvaluationException"});
mv.visitCode();
CodeFlow cf = new CodeFlow(clazzName, cw);
CodeFlow cf = new CodeFlow(className, cw);
// Ask the expression AST to generate the body of the method
try {
@@ -181,7 +181,7 @@ public class SpelCompiler implements Opcodes {
byte[] data = cw.toByteArray();
// TODO need to make this conditionally occur based on a debug flag
// dump(expressionToCompile.toStringAST(), clazzName, data);
return loadClass(clazzName.replaceAll("/", "."), data);
return loadClass(className.replaceAll("/", "."), data);
}
/**
@@ -256,12 +256,12 @@ public class SpelCompiler implements Opcodes {
}
int getClassesDefinedCount() {
return classesDefinedCount;
return this.classesDefinedCount;
}
public Class<?> defineClass(String name, byte[] bytes) {
Class<?> clazz = super.defineClass(name, bytes, 0, bytes.length);
classesDefinedCount++;
this.classesDefinedCount++;
return clazz;
}
}