aboutsummaryrefslogtreecommitdiffstats
path: root/src/main/javassist/expr/MethodCall.java
diff options
context:
space:
mode:
authorchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2003-04-23 17:08:37 +0000
committerchiba <chiba@30ef5769-5b8d-40dd-aea6-55b5d6557bb3>2003-04-23 17:08:37 +0000
commitcdeddfd6fc34a06734f9fa525cf5c7437a6c8fb6 (patch)
tree0471a4d9b985b11969ecd6f521f660e3d468f1d1 /src/main/javassist/expr/MethodCall.java
parentfb431982111b03608b888953f7ed8ba7e98f421c (diff)
downloadjavassist-cdeddfd6fc34a06734f9fa525cf5c7437a6c8fb6.tar.gz
javassist-cdeddfd6fc34a06734f9fa525cf5c7437a6c8fb6.zip
Changed the copyright notices and removed tab characters.
git-svn-id: http://anonsvn.jboss.org/repos/javassist/trunk@9 30ef5769-5b8d-40dd-aea6-55b5d6557bb3
Diffstat (limited to 'src/main/javassist/expr/MethodCall.java')
-rw-r--r--src/main/javassist/expr/MethodCall.java211
1 files changed, 100 insertions, 111 deletions
diff --git a/src/main/javassist/expr/MethodCall.java b/src/main/javassist/expr/MethodCall.java
index 747380b4..e0801659 100644
--- a/src/main/javassist/expr/MethodCall.java
+++ b/src/main/javassist/expr/MethodCall.java
@@ -1,28 +1,17 @@
/*
- * This file is part of the Javassist toolkit.
+ * Javassist, a Java-bytecode translator toolkit.
+ * Copyright (C) 1999-2003 Shigeru Chiba. All Rights Reserved.
*
- * The contents of this file are subject to the Mozilla Public License
- * Version 1.1 (the "License"); you may not use this file except in
- * compliance with the License. You may obtain a copy of the License at
- * either http://www.mozilla.org/MPL/.
+ * This library is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU Lesser General Public
+ * License as published by the Free Software Foundation; either
+ * version 2.1 of the License, or (at your option) any later version.
*
- * Software distributed under the License is distributed on an "AS IS"
- * basis, WITHOUT WARRANTY OF ANY KIND, either express or implied. See
- * the License for the specific language governing rights and limitations
- * under the License.
- *
- * The Original Code is Javassist.
- *
- * The Initial Developer of the Original Code is Shigeru Chiba. Portions
- * created by Shigeru Chiba are Copyright (C) 1999-2003 Shigeru Chiba.
- * All Rights Reserved.
- *
- * Contributor(s):
- *
- * The development of this software is supported in part by the PRESTO
- * program (Sakigake Kenkyu 21) of Japan Science and Technology Corporation.
+ * This library is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
+ * Lesser General Public License for more details.
*/
-
package javassist.expr;
import javassist.*;
@@ -37,19 +26,19 @@ public class MethodCall extends Expr {
* Undocumented constructor. Do not use; internal-use only.
*/
MethodCall(int pos, CodeIterator i, CtClass declaring, MethodInfo m) {
- super(pos, i, declaring, m);
+ super(pos, i, declaring, m);
}
private int getNameAndType(ConstPool cp) {
- String cname;
- int pos = currentPos;
- int c = iterator.byteAt(pos);
- int index = iterator.u16bitAt(pos + 1);
-
- if (c == INVOKEINTERFACE)
- return cp.getInterfaceMethodrefNameAndType(index);
- else
- return cp.getMethodrefNameAndType(index);
+ String cname;
+ int pos = currentPos;
+ int c = iterator.byteAt(pos);
+ int index = iterator.u16bitAt(pos + 1);
+
+ if (c == INVOKEINTERFACE)
+ return cp.getInterfaceMethodrefNameAndType(index);
+ else
+ return cp.getMethodrefNameAndType(index);
}
/**
@@ -62,19 +51,19 @@ public class MethodCall extends Expr {
* Returns the line number of the source line containing the
* method call.
*
- * @return -1 if this information is not available.
+ * @return -1 if this information is not available.
*/
public int getLineNumber() {
- return super.getLineNumber();
+ return super.getLineNumber();
}
/**
* Returns the source file containing the method call.
*
- * @return null if this information is not available.
+ * @return null if this information is not available.
*/
public String getFileName() {
- return super.getFileName();
+ return super.getFileName();
}
/**
@@ -82,7 +71,7 @@ public class MethodCall extends Expr {
* which the method is called on.
*/
private CtClass getCtClass() throws NotFoundException {
- return thisClass.getClassPool().get(getClassName());
+ return thisClass.getClassPool().get(getClassName());
}
/**
@@ -90,41 +79,41 @@ public class MethodCall extends Expr {
* which the method is called on.
*/
public String getClassName() {
- String cname;
+ String cname;
- ConstPool cp = getConstPool();
- int pos = currentPos;
- int c = iterator.byteAt(pos);
- int index = iterator.u16bitAt(pos + 1);
+ ConstPool cp = getConstPool();
+ int pos = currentPos;
+ int c = iterator.byteAt(pos);
+ int index = iterator.u16bitAt(pos + 1);
- if (c == INVOKEINTERFACE)
- cname = cp.getInterfaceMethodrefClassName(index);
- else
- cname = cp.getMethodrefClassName(index);
+ if (c == INVOKEINTERFACE)
+ cname = cp.getInterfaceMethodrefClassName(index);
+ else
+ cname = cp.getMethodrefClassName(index);
- return cname;
+ return cname;
}
/**
* Returns the name of the called method.
*/
public String getMethodName() {
- ConstPool cp = getConstPool();
- int nt = getNameAndType(cp);
- return cp.getUtf8Info(cp.getNameAndTypeName(nt));
+ ConstPool cp = getConstPool();
+ int nt = getNameAndType(cp);
+ return cp.getUtf8Info(cp.getNameAndTypeName(nt));
}
/**
* Returns the called method.
*/
public CtMethod getMethod() throws NotFoundException {
- return getCtClass().getMethod(getMethodName(), getMethodDesc());
+ return getCtClass().getMethod(getMethodName(), getMethodDesc());
}
private String getMethodDesc() {
- ConstPool cp = getConstPool();
- int nt = getNameAndType(cp);
- return cp.getUtf8Info(cp.getNameAndTypeDescriptor(nt));
+ ConstPool cp = getConstPool();
+ int nt = getNameAndType(cp);
+ return cp.getUtf8Info(cp.getNameAndTypeDescriptor(nt));
}
/**
@@ -134,15 +123,15 @@ public class MethodCall extends Expr {
* the throws declaration allows the method to throw.
*/
public CtClass[] mayThrow() {
- return super.mayThrow();
+ return super.mayThrow();
}
/*
* Returns the parameter types of the called method.
public CtClass[] getParameterTypes() throws NotFoundException {
- return Descriptor.getParameterTypes(getMethodDesc(),
- thisClass.getClassPool());
+ return Descriptor.getParameterTypes(getMethodDesc(),
+ thisClass.getClassPool());
}
*/
@@ -150,8 +139,8 @@ public class MethodCall extends Expr {
* Returns the return type of the called method.
public CtClass getReturnType() throws NotFoundException {
- return Descriptor.getReturnType(getMethodDesc(),
- thisClass.getClassPool());
+ return Descriptor.getReturnType(getMethodDesc(),
+ thisClass.getClassPool());
}
*/
@@ -161,60 +150,60 @@ public class MethodCall extends Expr {
*
* <p>$0 is available even if the called method is static.
*
- * @param statement a Java statement.
+ * @param statement a Java statement.
*/
public void replace(String statement) throws CannotCompileException {
- ConstPool constPool = getConstPool();
- int pos = currentPos;
- int index = iterator.u16bitAt(pos + 1);
-
- String classname, methodname, signature;
- int opcodeSize;
- int c = iterator.byteAt(pos);
- if (c == INVOKEINTERFACE) {
- opcodeSize = 5;
- classname = constPool.getInterfaceMethodrefClassName(index);
- methodname = constPool.getInterfaceMethodrefName(index);
- signature = constPool.getInterfaceMethodrefType(index);
- }
- else if (c == INVOKESTATIC
- || c == INVOKESPECIAL || c == INVOKEVIRTUAL) {
- opcodeSize = 3;
- classname = constPool.getMethodrefClassName(index);
- methodname = constPool.getMethodrefName(index);
- signature = constPool.getMethodrefType(index);
- }
- else
- throw new CannotCompileException("not method invocation");
-
- Javac jc = new Javac(thisClass);
- ClassPool cp = thisClass.getClassPool();
- CodeAttribute ca = iterator.get();
- try {
- CtClass[] params = Descriptor.getParameterTypes(signature, cp);
- CtClass retType = Descriptor.getReturnType(signature, cp);
- int paramVar = ca.getMaxLocals();
- jc.recordParams(classname, params,
- true, paramVar, withinStatic());
- int retVar = jc.recordReturnType(retType, true);
- jc.recordProceed(Javac.param0Name, methodname);
-
- /* Is $_ included in the source code?
- */
- checkResultValue(retType, statement);
-
- Bytecode bytecode = jc.getBytecode();
- storeStack(params, c == INVOKESTATIC, paramVar, bytecode);
- jc.compileStmnt(statement);
- if (retType != CtClass.voidType)
- bytecode.addLoad(retVar, retType);
-
- replace0(pos, bytecode, opcodeSize);
- }
- catch (CompileError e) { throw new CannotCompileException(e); }
- catch (NotFoundException e) { throw new CannotCompileException(e); }
- catch (BadBytecode e) {
- throw new CannotCompileException("broken method");
- }
+ ConstPool constPool = getConstPool();
+ int pos = currentPos;
+ int index = iterator.u16bitAt(pos + 1);
+
+ String classname, methodname, signature;
+ int opcodeSize;
+ int c = iterator.byteAt(pos);
+ if (c == INVOKEINTERFACE) {
+ opcodeSize = 5;
+ classname = constPool.getInterfaceMethodrefClassName(index);
+ methodname = constPool.getInterfaceMethodrefName(index);
+ signature = constPool.getInterfaceMethodrefType(index);
+ }
+ else if (c == INVOKESTATIC
+ || c == INVOKESPECIAL || c == INVOKEVIRTUAL) {
+ opcodeSize = 3;
+ classname = constPool.getMethodrefClassName(index);
+ methodname = constPool.getMethodrefName(index);
+ signature = constPool.getMethodrefType(index);
+ }
+ else
+ throw new CannotCompileException("not method invocation");
+
+ Javac jc = new Javac(thisClass);
+ ClassPool cp = thisClass.getClassPool();
+ CodeAttribute ca = iterator.get();
+ try {
+ CtClass[] params = Descriptor.getParameterTypes(signature, cp);
+ CtClass retType = Descriptor.getReturnType(signature, cp);
+ int paramVar = ca.getMaxLocals();
+ jc.recordParams(classname, params,
+ true, paramVar, withinStatic());
+ int retVar = jc.recordReturnType(retType, true);
+ jc.recordProceed(Javac.param0Name, methodname);
+
+ /* Is $_ included in the source code?
+ */
+ checkResultValue(retType, statement);
+
+ Bytecode bytecode = jc.getBytecode();
+ storeStack(params, c == INVOKESTATIC, paramVar, bytecode);
+ jc.compileStmnt(statement);
+ if (retType != CtClass.voidType)
+ bytecode.addLoad(retVar, retType);
+
+ replace0(pos, bytecode, opcodeSize);
+ }
+ catch (CompileError e) { throw new CannotCompileException(e); }
+ catch (NotFoundException e) { throw new CannotCompileException(e); }
+ catch (BadBytecode e) {
+ throw new CannotCompileException("broken method");
+ }
}
}