30
votes

When I try to access some class's method; eclipse gets that method but arguments inside that method are replaced by arg0, arg1, arg2...

Example:-

Suppose I have this method in some class named ReadFile.java

@Override
public int readXXX(int start, int end, String xxx) throws IOException {
    return 0;
}

When I try to access that method from an instance of class it shows me as follows:

readFile.readXXX(arg0, arg1, arg2);

It becomes hard to identify what I should pass in argument. The same thing also happens for java methods. i.e. when I implement interface all method under that will be generated but arguments in that methods are arg0, arg1.....

Is there any setting I can do prevent this?

I'm using Eclipse Galelio.

6
Please make sure that the source code for your libraries is available and configured in the project settings.Sebastian Zarnekow
@Sebastian: Yes they are configured.Harry Joy
In case someone ends up here trying to fix the same issue but with standard Java APIs, try increasing the "Timeout for fetching a parameter name from attached Javadoc (ms):" in preferences under Java > Editor > Content Assist > Advanced. This worked for me in Indigo on OS X.michiakig
@spacemanaki Also, the issue can be caused in standard Java APIs if you have your runtime environment set to a JRE not a JDK. In the former case, Eclipse spends time resolving online Javadocs rather than reading the JDK.Duncan Jones
@spacemanaki Your comment should appear as an answer. I had problem with the autocomplete when using javaFx 2.0, and your comment solved my issue. Everybody is talking about attaching the source when most of the times the case for me is the "Timeout fetching".C.L.S

6 Answers

18
votes

Eclipse can't work out the arguments because it can't find the source or javadoc attachments.

Make sure your source is attached.

To check, click on the method call readXXX and press F3 which should open the method declaration. If the source is not attached, Eclipse will say "Source not found" and will allow you to "Attach Source...".

4
votes

Anyone having the same issue, try performing a Project > Clean, this will delete the old class files, and Eclipse will recompile them in debug mode this time. Worked for me in Indigo 3.7.2

3
votes

The problem is that your class files lacks debug information embedded in them. JDT doesn't reparse the source files or the javadoc for dependencies, when building the AST for your project, so it doesn't have idea what the name of the parameter is, even when you are able to open the class and clearly see what are the method names.

In order to correct this, you need to recompile your class files with debug information enabled, which makes the class file considerably larger, but unless you are developing for memory-constraint devices, you should be fine.

1
votes

I solved this by going to preferences
Java / Content Assist
On this page under "Sorting and Filtering" I unchecked "Hide proposals not visible in the invocation context" now instead of seeing (arg0, arg1, arg2) etc in autocomplete I see (catalog, schemaPattern, tableNamePattern...)
I am using Spring Tools Suite 3.7.2 which runs on the Eclipse Mars 4.5.1 platform.

0
votes

for those like me who tried to apply one of our colleagues suggestions and unfortunately hasn't worked, please, give a try to check the option "Add variable attributes to generated class files (used by the debugger)" within Window -> Preferences -> Java + Compiler.

Once you've done that, try to build the project again.

Cheers.

0
votes

This link helped me to solve this problem.

1) Right click on your android.jar and select Properties.

enter image description here

2) Select Java Source Attachment. Enter the source directory location (you can also use External Folder… to browse to the directory) and click on “Apply“.

enter image description here

The code names match the following version numbers, along with API levels and NDK releases provided for convenience:

enter image description here