Java Code Examples for org.springframework.expression.spel.support.ReflectiveConstructorExecutor

The following examples show how to use org.springframework.expression.spel.support.ReflectiveConstructorExecutor. These examples are extracted from open source projects. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source Project: spring-analysis-note   Source File: ConstructorReference.java    License: MIT License 6 votes vote down vote up
@Override
public boolean isCompilable() {
	if (!(this.cachedExecutor instanceof ReflectiveConstructorExecutor) ||
		this.exitTypeDescriptor == null) {
		return false;
	}

	if (getChildCount() > 1) {
		for (int c = 1, max = getChildCount();c < max; c++) {
			if (!this.children[c].isCompilable()) {
				return false;
			}
		}
	}

	ReflectiveConstructorExecutor executor = (ReflectiveConstructorExecutor) this.cachedExecutor;
	if (executor == null) {
		return false;
	}
	Constructor<?> constructor = executor.getConstructor();
	return (Modifier.isPublic(constructor.getModifiers()) &&
			Modifier.isPublic(constructor.getDeclaringClass().getModifiers()));
}
 
Example 2
Source Project: spring-analysis-note   Source File: ConstructorReference.java    License: MIT License 6 votes vote down vote up
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
	ReflectiveConstructorExecutor executor = ((ReflectiveConstructorExecutor) this.cachedExecutor);
	Assert.state(executor != null, "No cached executor");

	Constructor<?> constructor = executor.getConstructor();
	String classDesc = constructor.getDeclaringClass().getName().replace('.', '/');
	mv.visitTypeInsn(NEW, classDesc);
	mv.visitInsn(DUP);

	// children[0] is the type of the constructor, don't want to include that in argument processing
	SpelNodeImpl[] arguments = new SpelNodeImpl[this.children.length - 1];
	System.arraycopy(this.children, 1, arguments, 0, this.children.length - 1);
	generateCodeForArguments(mv, cf, constructor, arguments);
	mv.visitMethodInsn(INVOKESPECIAL, classDesc, "<init>", CodeFlow.createSignatureDescriptor(constructor), false);
	cf.pushDescriptor(this.exitTypeDescriptor);
}
 
Example 3
Source Project: java-technology-stack   Source File: ConstructorReference.java    License: MIT License 6 votes vote down vote up
@Override
public boolean isCompilable() {
	if (!(this.cachedExecutor instanceof ReflectiveConstructorExecutor) ||
		this.exitTypeDescriptor == null) {
		return false;
	}

	if (getChildCount() > 1) {
		for (int c = 1, max = getChildCount();c < max; c++) {
			if (!this.children[c].isCompilable()) {
				return false;
			}
		}
	}

	ReflectiveConstructorExecutor executor = (ReflectiveConstructorExecutor) this.cachedExecutor;
	if (executor == null) {
		return false;
	}
	Constructor<?> constructor = executor.getConstructor();
	return (Modifier.isPublic(constructor.getModifiers()) &&
			Modifier.isPublic(constructor.getDeclaringClass().getModifiers()));
}
 
Example 4
Source Project: java-technology-stack   Source File: ConstructorReference.java    License: MIT License 6 votes vote down vote up
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
	ReflectiveConstructorExecutor executor = ((ReflectiveConstructorExecutor) this.cachedExecutor);
	Assert.state(executor != null, "No cached executor");

	Constructor<?> constructor = executor.getConstructor();
	String classDesc = constructor.getDeclaringClass().getName().replace('.', '/');
	mv.visitTypeInsn(NEW, classDesc);
	mv.visitInsn(DUP);

	// children[0] is the type of the constructor, don't want to include that in argument processing
	SpelNodeImpl[] arguments = new SpelNodeImpl[this.children.length - 1];
	System.arraycopy(this.children, 1, arguments, 0, this.children.length - 1);
	generateCodeForArguments(mv, cf, constructor, arguments);
	mv.visitMethodInsn(INVOKESPECIAL, classDesc, "<init>", CodeFlow.createSignatureDescriptor(constructor), false);
	cf.pushDescriptor(this.exitTypeDescriptor);
}
 
Example 5
Source Project: lams   Source File: ConstructorReference.java    License: GNU General Public License v2.0 6 votes vote down vote up
@Override
public boolean isCompilable() {
	if (!(this.cachedExecutor instanceof ReflectiveConstructorExecutor) || 
		this.exitTypeDescriptor == null) {
		return false;
	}

	if (getChildCount() > 1) {
		for (int c = 1, max = getChildCount();c < max; c++) {
			if (!this.children[c].isCompilable()) {
				return false;
			}
		}
	}

	ReflectiveConstructorExecutor executor = (ReflectiveConstructorExecutor) this.cachedExecutor;
	Constructor<?> constructor = executor.getConstructor();
	return (Modifier.isPublic(constructor.getModifiers()) &&
			Modifier.isPublic(constructor.getDeclaringClass().getModifiers()));
}
 
Example 6
@Override
public boolean isCompilable() {
	if (!(this.cachedExecutor instanceof ReflectiveConstructorExecutor) || 
		this.exitTypeDescriptor == null) {
		return false;
	}

	if (getChildCount() > 1) {
		for (int c = 1, max = getChildCount();c < max; c++) {
			if (!this.children[c].isCompilable()) {
				return false;
			}
		}
	}

	ReflectiveConstructorExecutor executor = (ReflectiveConstructorExecutor) this.cachedExecutor;
	Constructor<?> constructor = executor.getConstructor();
	return (Modifier.isPublic(constructor.getModifiers()) &&
			Modifier.isPublic(constructor.getDeclaringClass().getModifiers()));
}
 
Example 7
Source Project: lams   Source File: ConstructorReference.java    License: GNU General Public License v2.0 5 votes vote down vote up
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
	ReflectiveConstructorExecutor executor = ((ReflectiveConstructorExecutor) this.cachedExecutor);
	Constructor<?> constructor = executor.getConstructor();		
	String classDesc = constructor.getDeclaringClass().getName().replace('.', '/');
	mv.visitTypeInsn(NEW, classDesc);
	mv.visitInsn(DUP);
	// children[0] is the type of the constructor, don't want to include that in argument processing
	SpelNodeImpl[] arguments = new SpelNodeImpl[children.length - 1];
	System.arraycopy(children, 1, arguments, 0, children.length - 1);
	generateCodeForArguments(mv, cf, constructor, arguments);	
	mv.visitMethodInsn(INVOKESPECIAL, classDesc, "<init>", CodeFlow.createSignatureDescriptor(constructor), false);
	cf.pushDescriptor(this.exitTypeDescriptor);
}
 
Example 8
@Override
public void generateCode(MethodVisitor mv, CodeFlow cf) {
	ReflectiveConstructorExecutor executor = ((ReflectiveConstructorExecutor) this.cachedExecutor);
	Constructor<?> constructor = executor.getConstructor();		
	String classDesc = constructor.getDeclaringClass().getName().replace('.', '/');
	mv.visitTypeInsn(NEW, classDesc);
	mv.visitInsn(DUP);
	// children[0] is the type of the constructor, don't want to include that in argument processing
	SpelNodeImpl[] arguments = new SpelNodeImpl[children.length - 1];
	System.arraycopy(children, 1, arguments, 0, children.length - 1);
	generateCodeForArguments(mv, cf, constructor, arguments);	
	mv.visitMethodInsn(INVOKESPECIAL, classDesc, "<init>", CodeFlow.createSignatureDescriptor(constructor), false);
	cf.pushDescriptor(this.exitTypeDescriptor);
}