Questions tagged [method-invocation]
132 questions
2
votes
4 answers
Method Local Inner Class
public class Test {
public static void main(String[] args) {
}
}
class Outer {
void aMethod() {
class MethodLocalInner {
void bMethod() {
System.out.println("Inside method-local bMethod");
…
Omnipotent
- 25,231
- 11
- 28
- 33
2
votes
2 answers
Why does it seem to call the wrong method?
Lets say I have two classes A and B . B inherits from A and B has the following methods:
public boolean equals(Object other) {
System.out.print("Object");
return true;
}
public boolean equals(A other){
System.out.print("A object");
…
bm1125
- 223
- 1
- 9
2
votes
1 answer
Exact overload resolution procedure - why f(1) call against f(int... arg) and f(long... arg) is not ambiguous?
I feel that these are applicable:
JLS 15.12.2.4. Phase 3: Identify Methods Applicable by Variable
Arity Invocation
JLS 15.12.2.5. Choosing the Most Specific Method
But JLS language is so complex that I cannot understand the point.
void…
Code Complete
- 2,664
- 1
- 10
- 28
2
votes
3 answers
Why can't I call this method via string?
Question from a Reflection newbie. I have a method in a Windows Form:
private void handleOrderCode()
{
//...do stuff
}
Which I am trying to call in the following manner:
Type t = this.GetType();
MethodInfo mi = t.GetMethod("handleOrderCode");
if…
One Monkey
- 693
- 2
- 9
- 23
2
votes
3 answers
Java invoke method using reflection
I am trying to invoke a method using reflection.
The method I am invoking is not static and in the same class I am invoking it from.
A simplified version of my code:
public class Test {
public static void main(String[] args) {
Test instance…
Jdv
- 883
- 7
- 28
2
votes
2 answers
Invoke Methods Dynamically on Java
At work, we have to generate a report for our client that changes its parameters several times during the week.
This report is generated from a single table on our database.
For example, imagine a table that has 100 columns and I have to generate a…
Victor Dinis
- 91
- 1
- 5
2
votes
1 answer
Can I create an object that receives arbitrary method invocation in python?
In python, can I create a Class that, when instantiated, can receive arbitrary method invocation? I have read this but couldn't put the pieces together
I guess it has something to do with the attribute lookup. For a class Foo:
class Foo(object):
…
user2829759
- 2,994
- 2
- 24
- 47
2
votes
1 answer
Why calling this function recursively does not throw a NullPointerException
My question comes from this thread.
Consider this code:
public class Test {
static Function fibLambda = null;
public static void main (String[] args) {
fibLambda = n -> n <= 2 ? 1 : fibLambda.apply(n - 1) +…
user2336315
- 14,237
- 9
- 37
- 63
2
votes
5 answers
Java performance issue
I've got a question related to java performance and method execution.
In my app there are a lot of place where I have to validate some parameter, so I've written a Validator class and put all the validation methods into it. Here is an…
Colby77
- 597
- 1
- 7
- 10
2
votes
3 answers
Can I check if a void method returned?
I just want to ask, if it is possible to check if a void method "cancelled" itself by calling return;?
For example in my main I call calculate(myArray);, which is defined as follows:
public static void calculate(Object[] array) {
if (array ==…
Frozn
- 509
- 1
- 10
- 16
2
votes
2 answers
invoke javax.el.MethodExpression from jsf component
I have a jsp tag which takes a javax.el.MethodExpression as attribute:
<%@ attribute name="action" required="true" type="javax.el.MethodExpression" rtexprvalue="true" %>
within the same tag I have:
link…
marcosbeirigo
- 10,238
- 6
- 37
- 56
2
votes
2 answers
Difference between this two uses of MethodInvoker
What exactly is the difference between this two uses of MethodInvoker:
1:
textBox1.Invoke(new MethodInvoker(b));
2:
textBox1.Invoke((MethodInvoker)delegate { b(); });
I only understand, that variant 2 allow me to call b() with parameters if i…
krokvskrok
- 197
- 2
- 10
2
votes
3 answers
Generic method invokation
If we have generic method
class SClass{
public static ArrayList listFactory(){ return new ArrayList(); }
}
we can define type-parameter T explicit when this method is calling.
SClass.>listFactory();//compile…
user2889159
2
votes
2 answers
Java HashMap/HashSet polymorphism
I have an inheritance chain in which Superclass have 3 immediate subclasses, Subclass1, Subclass2, Subclass3.
I have a:
HashMap>> map = new HashMap<>();
I want map to contain 3 hashmaps at integer…
user2651804
- 1,134
- 4
- 16
- 41
2
votes
1 answer
How to access MethodInvocation that is inside a VariableDeclarationStatement
I am checking for the invocation of a method using JDT and performing a check on its argument. I am using an AST Visitor class which visits MethodInvocation nodes and performs this operation. I use the below method in the Visitor class.
public…
Unni Kris
- 2,963
- 3
- 27
- 57