| 2125 | |
| 2126 | |
| 2127 | static class StaticMethodExpr extends MethodExpr{ |
| 2128 | //final String className; |
| 2129 | public final Class c; |
| 2130 | public final String methodName; |
| 2131 | public final IPersistentVector args; |
| 2132 | public final String source; |
| 2133 | public final int line; |
| 2134 | public final int column; |
| 2135 | public final java.lang.reflect.Method method; |
| 2136 | public final Symbol tag; |
| 2137 | public final boolean tailPosition; |
| 2138 | final static Method forNameMethod = Method.getMethod("Class classForName(String)"); |
| 2139 | final static Method invokeStaticMethodMethod = |
| 2140 | Method.getMethod("Object invokeStaticMethod(Class,String,Object[])"); |
| 2141 | final static Keyword warnOnBoxedKeyword = Keyword.intern("warn-on-boxed"); |
| 2142 | Class jc; |
| 2143 | |
| 2144 | public StaticMethodExpr(String source, int line, int column, Symbol tag, Class c, |
| 2145 | String methodName, java.lang.reflect.Method preferredMethod, IPersistentVector args, boolean tailPosition) |
| 2146 | { |
| 2147 | checkMethodArity(preferredMethod, RT.count(args)); |
| 2148 | |
| 2149 | this.c = c; |
| 2150 | this.methodName = methodName; |
| 2151 | this.args = args; |
| 2152 | this.source = source; |
| 2153 | this.line = line; |
| 2154 | this.column = column; |
| 2155 | this.tag = tag; |
| 2156 | this.tailPosition = tailPosition; |
| 2157 | this.method = preferredMethod; |
| 2158 | |
| 2159 | if(method != null && warnOnBoxedKeyword.equals(RT.UNCHECKED_MATH.deref()) && isBoxedMath(method)) |
| 2160 | { |
| 2161 | RT.errPrintWriter() |
| 2162 | .format("Boxed math warning, %s:%d:%d - call: %s.\n", |
| 2163 | SOURCE_PATH.deref(), line, column, method.toString()); |
| 2164 | } |
| 2165 | } |
| 2166 | |
| 2167 | public StaticMethodExpr(String source, int line, int column, Symbol tag, Class c, |
| 2168 | String methodName, IPersistentVector args, boolean tailPosition) |
| 2169 | { |
| 2170 | this.c = c; |
| 2171 | this.methodName = methodName; |
| 2172 | this.args = args; |
| 2173 | this.source = source; |
| 2174 | this.line = line; |
| 2175 | this.column = column; |
| 2176 | this.tag = tag; |
| 2177 | this.tailPosition = tailPosition; |
| 2178 | |
| 2179 | List methods = Reflector.getMethods(c, args.count(), methodName, true); |
| 2180 | if(methods.isEmpty()) |
| 2181 | throw new IllegalArgumentException("No matching method " + methodName + " found taking " |
| 2182 | + args.count() + " args for " + c); |
| 2183 | |
| 2184 | int methodidx = 0; |