Skip to content

Commit 60e58a2

Browse files
committed
Polishing
1 parent 8eac870 commit 60e58a2

File tree

3 files changed

+39
-43
lines changed

3 files changed

+39
-43
lines changed

spring-beans/src/main/java/org/springframework/beans/factory/support/DefaultSingletonBeanRegistry.java

+1-1
Original file line numberDiff line numberDiff line change
@@ -379,7 +379,7 @@ public void registerContainedBean(String containedBeanName, String containingBea
379379
return;
380380
}
381381

382-
// No entry yet -> fully synchronized manipulation of the dependentBeans Set
382+
// No entry yet -> fully synchronized manipulation of the containedBeans Set
383383
synchronized (this.containedBeanMap) {
384384
containedBeans = this.containedBeanMap.get(containingBeanName);
385385
if (containedBeans == null) {

spring-core/src/main/java/org/springframework/core/io/support/PropertiesLoaderSupport.java

+3-3
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*
2-
* Copyright 2002-2013 the original author or authors.
2+
* Copyright 2002-2014 the original author or authors.
33
*
44
* Licensed under the Apache License, Version 2.0 (the "License");
55
* you may not use this file except in compliance with the License.
@@ -66,7 +66,7 @@ public void setProperties(Properties properties) {
6666
* Set local properties, e.g. via the "props" tag in XML bean definitions,
6767
* allowing for merging multiple properties sets into one.
6868
*/
69-
public void setPropertiesArray(Properties[] propertiesArray) {
69+
public void setPropertiesArray(Properties... propertiesArray) {
7070
this.localProperties = propertiesArray;
7171
}
7272

@@ -88,7 +88,7 @@ public void setLocation(Resource location) {
8888
* Hence, make sure that the most specific files are the last
8989
* ones in the given list of locations.
9090
*/
91-
public void setLocations(Resource[] locations) {
91+
public void setLocations(Resource... locations) {
9292
this.locations = locations;
9393
}
9494

spring-expression/src/main/java/org/springframework/expression/spel/ast/Indexer.java

+35-39
Original file line numberDiff line numberDiff line change
@@ -179,98 +179,93 @@ else if (targetObject instanceof String) {
179179
@Override
180180
public boolean isCompilable() {
181181
if (this.indexedType == IndexedType.array) {
182-
return exitTypeDescriptor != null;
182+
return (this.exitTypeDescriptor != null);
183183
}
184184
else if (this.indexedType == IndexedType.list) {
185185
return this.children[0].isCompilable();
186186
}
187187
else if (this.indexedType == IndexedType.map) {
188-
if (this.children[0] instanceof PropertyOrFieldReference) {
189-
// Only the name will be used, so that is OK
190-
return true;
191-
}
192-
else {
193-
return this.children[0].isCompilable();
194-
}
188+
return (this.children[0] instanceof PropertyOrFieldReference || this.children[0].isCompilable());
195189
}
196190
else if (this.indexedType == IndexedType.object) {
197191
// If the string name is changing the accessor is clearly going to change (so compilation is not possible)
198192
if (this.cachedReadAccessor != null &&
199193
(this.cachedReadAccessor instanceof ReflectivePropertyAccessor.OptimalPropertyAccessor) &&
200194
(getChild(0) instanceof StringLiteral)) {
201195
return true;
202-
};
196+
}
203197
}
204198
return false;
205199
}
206200

207201
@Override
208202
public void generateCode(MethodVisitor mv, CodeFlow codeflow) {
209-
String s = codeflow.lastDescriptor();
210-
211-
if (s == null) {
212-
// stack is empty, should use context object
203+
String descriptor = codeflow.lastDescriptor();
204+
if (descriptor == null) {
205+
// Stack is empty, should use context object
213206
codeflow.loadTarget(mv);
214207
}
215208

216209
if (this.indexedType == IndexedType.array) {
217-
if ("I".equals(exitTypeDescriptor)) {
210+
if ("I".equals(this.exitTypeDescriptor)) {
218211
mv.visitTypeInsn(CHECKCAST,"[I");
219212
SpelNodeImpl index = this.children[0];
220213
codeflow.enterCompilationScope();
221214
index.generateCode(mv, codeflow);
222215
codeflow.exitCompilationScope();
223216
mv.visitInsn(IALOAD);
224217
}
225-
else if ("D".equals(exitTypeDescriptor)) {
226-
mv.visitTypeInsn(CHECKCAST,"[D");
218+
else if ("D".equals(this.exitTypeDescriptor)) {
219+
mv.visitTypeInsn(CHECKCAST, "[D");
227220
SpelNodeImpl index = this.children[0];
228221
codeflow.enterCompilationScope();
229222
index.generateCode(mv, codeflow);
230223
mv.visitInsn(DALOAD);
231224
}
232-
else if ("J".equals(exitTypeDescriptor)) {
233-
mv.visitTypeInsn(CHECKCAST,"[J");
225+
else if ("J".equals(this.exitTypeDescriptor)) {
226+
mv.visitTypeInsn(CHECKCAST, "[J");
234227
SpelNodeImpl index = this.children[0];
235228
codeflow.enterCompilationScope();
236229
index.generateCode(mv, codeflow);
237230
codeflow.exitCompilationScope();
238231
mv.visitInsn(LALOAD);
239232
}
240-
else if ("F".equals(exitTypeDescriptor)) {
241-
mv.visitTypeInsn(CHECKCAST,"[F");
233+
else if ("F".equals(this.exitTypeDescriptor)) {
234+
mv.visitTypeInsn(CHECKCAST, "[F");
242235
SpelNodeImpl index = this.children[0];
243236
codeflow.enterCompilationScope();
244237
index.generateCode(mv, codeflow);
245238
codeflow.exitCompilationScope();
246239
mv.visitInsn(FALOAD);
247240
}
248-
else if ("S".equals(exitTypeDescriptor)) {
249-
mv.visitTypeInsn(CHECKCAST,"[S");
241+
else if ("S".equals(this.exitTypeDescriptor)) {
242+
mv.visitTypeInsn(CHECKCAST, "[S");
250243
SpelNodeImpl index = this.children[0];
251244
codeflow.enterCompilationScope();
252245
index.generateCode(mv, codeflow);
253246
codeflow.exitCompilationScope();
254247
mv.visitInsn(SALOAD);
255248
}
256-
else if ("B".equals(exitTypeDescriptor)) {
257-
mv.visitTypeInsn(CHECKCAST,"[B");
249+
else if ("B".equals(this.exitTypeDescriptor)) {
250+
mv.visitTypeInsn(CHECKCAST, "[B");
258251
SpelNodeImpl index = this.children[0];
259252
codeflow.enterCompilationScope();
260253
index.generateCode(mv, codeflow);
261254
codeflow.exitCompilationScope();
262255
mv.visitInsn(BALOAD);
263256
}
264-
else if ("C".equals(exitTypeDescriptor)) {
265-
mv.visitTypeInsn(CHECKCAST,"[C");
257+
else if ("C".equals(this.exitTypeDescriptor)) {
258+
mv.visitTypeInsn(CHECKCAST, "[C");
266259
SpelNodeImpl index = this.children[0];
267260
codeflow.enterCompilationScope();
268261
index.generateCode(mv, codeflow);
269262
codeflow.exitCompilationScope();
270263
mv.visitInsn(CALOAD);
271264
}
272265
else {
273-
mv.visitTypeInsn(CHECKCAST,"["+exitTypeDescriptor+(CodeFlow.isPrimitiveArray(exitTypeDescriptor)?"":";"));//depthPlusOne(exitTypeDescriptor)+"Ljava/lang/Object;");
266+
mv.visitTypeInsn(CHECKCAST, "["+ this.exitTypeDescriptor +
267+
(CodeFlow.isPrimitiveArray(this.exitTypeDescriptor) ? "" : ";"));
268+
//depthPlusOne(exitTypeDescriptor)+"Ljava/lang/Object;");
274269
SpelNodeImpl index = this.children[0];
275270
codeflow.enterCompilationScope();
276271
index.generateCode(mv, codeflow);
@@ -279,15 +274,15 @@ else if ("C".equals(exitTypeDescriptor)) {
279274
}
280275
}
281276
else if (this.indexedType == IndexedType.list) {
282-
mv.visitTypeInsn(CHECKCAST,"java/util/List");
277+
mv.visitTypeInsn(CHECKCAST, "java/util/List");
283278
codeflow.enterCompilationScope();
284279
this.children[0].generateCode(mv, codeflow);
285280
codeflow.exitCompilationScope();
286-
mv.visitMethodInsn(INVOKEINTERFACE,"java/util/List","get","(I)Ljava/lang/Object;", true);
287-
CodeFlow.insertCheckCast(mv,exitTypeDescriptor);
281+
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/List", "get", "(I)Ljava/lang/Object;", true);
282+
CodeFlow.insertCheckCast(mv, this.exitTypeDescriptor);
288283
}
289284
else if (this.indexedType == IndexedType.map) {
290-
mv.visitTypeInsn(CHECKCAST,"java/util/Map");
285+
mv.visitTypeInsn(CHECKCAST, "java/util/Map");
291286
// Special case when the key is an unquoted string literal that will be parsed as
292287
// a property/field reference
293288
if ((this.children[0] instanceof PropertyOrFieldReference)) {
@@ -300,16 +295,14 @@ else if (this.indexedType == IndexedType.map) {
300295
this.children[0].generateCode(mv, codeflow);
301296
codeflow.exitCompilationScope();
302297
}
303-
mv.visitMethodInsn(INVOKEINTERFACE,"java/util/Map","get","(Ljava/lang/Object;)Ljava/lang/Object;", true);
304-
CodeFlow.insertCheckCast(mv,exitTypeDescriptor);
298+
mv.visitMethodInsn(INVOKEINTERFACE, "java/util/Map", "get", "(Ljava/lang/Object;)Ljava/lang/Object;", true);
299+
CodeFlow.insertCheckCast(mv, this.exitTypeDescriptor);
305300
}
306301
else if (this.indexedType == IndexedType.object) {
307302
ReflectivePropertyAccessor.OptimalPropertyAccessor accessor =
308-
(ReflectivePropertyAccessor.OptimalPropertyAccessor)this.cachedReadAccessor;
303+
(ReflectivePropertyAccessor.OptimalPropertyAccessor) this.cachedReadAccessor;
309304
Member member = accessor.member;
310305
boolean isStatic = Modifier.isStatic(member.getModifiers());
311-
312-
String descriptor = codeflow.lastDescriptor();
313306
String memberDeclaringClassSlashedDescriptor = member.getDeclaringClass().getName().replace('.','/');
314307
if (!isStatic) {
315308
if (descriptor == null) {
@@ -320,13 +313,16 @@ else if (this.indexedType == IndexedType.object) {
320313
}
321314
}
322315
if (member instanceof Field) {
323-
mv.visitFieldInsn(isStatic?GETSTATIC:GETFIELD,memberDeclaringClassSlashedDescriptor,member.getName(),CodeFlow.toJVMDescriptor(((Field) member).getType()));
316+
mv.visitFieldInsn(isStatic ? GETSTATIC : GETFIELD, memberDeclaringClassSlashedDescriptor,
317+
member.getName(), CodeFlow.toJVMDescriptor(((Field) member).getType()));
324318
}
325319
else {
326-
mv.visitMethodInsn(isStatic?INVOKESTATIC:INVOKEVIRTUAL, memberDeclaringClassSlashedDescriptor, member.getName(),CodeFlow.createSignatureDescriptor((Method)member),false);
320+
mv.visitMethodInsn(isStatic? INVOKESTATIC : INVOKEVIRTUAL, memberDeclaringClassSlashedDescriptor,
321+
member.getName(), CodeFlow.createSignatureDescriptor((Method) member), false);
327322
}
328323
}
329-
codeflow.pushDescriptor(exitTypeDescriptor);
324+
325+
codeflow.pushDescriptor(this.exitTypeDescriptor);
330326
}
331327

332328
@Override

0 commit comments

Comments
 (0)