Java Code Examples for org.springframework.expression.spel.support.ReflectiveConstructorExecutor#getConstructor()

The following examples show how to use org.springframework.expression.spel.support.ReflectiveConstructorExecutor#getConstructor() . 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 File: ConstructorReference.java    From spring-analysis-note with 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 File: ConstructorReference.java    From spring-analysis-note with 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 File: ConstructorReference.java    From java-technology-stack with 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 File: ConstructorReference.java    From java-technology-stack with 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 File: ConstructorReference.java    From lams with 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
Source File: ConstructorReference.java    From spring4-understanding with Apache License 2.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 7
Source File: ConstructorReference.java    From lams with 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
Source File: ConstructorReference.java    From spring4-understanding with Apache License 2.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);
}