Welcome!

Welcome to the official BlackBerry Support Community Forums.

This is your resource to discuss support topics with your peers, and learn from each other.

inside custom component

Java Development

Reply
New Developer
Posts: 39
Registered: ‎10-13-2009
My Device: Not Specified

Re: Error starting xxx: Class 'xxx.xxx' ref member out of range

Reducing the number of variables means that you have reduce the number of class variables. You can have as many local vars in local functions inside the class as you wish to but this error applies only to the class level declaration of variables. For ex- if u need the Sapcer in a local component then declare it inside the inner class of that component and use it accordingly. Be very specific about declarig class level compoenets. I solved this problem by reducing class level vars only

Developer
Posts: 109
Registered: ‎03-13-2010
My Device: BlackBerry 8520 Curve Smartphone
My Carrier: -

Re: Error starting xxx: Class 'xxx.xxx' ref member out of range

Thanks Shubhra, for very presize and clear explaination. First I have installed application successfully on 8520 device. But while opening application it has given error ref out of range. To resolve this error, I tried to reduce the number of my class variables by the way you specified, also, I broke my large class into two, and move many class variables to another class. I managed to reduce more than 55 class level variables, and move more than 40 variables to another class.

 

Now, as I have reduced the variables, I want to test it again by installing it on the device. But installation is getting failed.

 

I got the error 907 Invalid JAR: control flow verification too large: commandAction

So, to resolve this error, I reduce the length of my commandAction() method by creating other methods and placing the code into them. So I think, this error is solved [not sure], as it is giving another error while installation, which is as follows:

 

907 Invalid JAR output file: <filename>-1.cod code section too large

 

Now, I am not getting the way or any clue to proceed further. Please guide me to sort out this. Thanks and Best Regards.

Developer
Posts: 109
Registered: ‎03-13-2010
My Device: BlackBerry 8520 Curve Smartphone
My Carrier: -

Re: Error starting xxx: Class 'xxx.xxx' ref member out of range

I have managed to resolve both the 907 Invalid JAR errors, and managed to install the midlet on the device 8520 successfully. But still at the time of starting the midlet, it is showing the same error i.e. 

Error starting <classname>: Class '<classname>.<variablename>' ref member out of range

 

In my main class which extends midlet, there are still more than 280 class level data members, but all these are of type Forms, StringItems, TextFields, Alerts, ChoiceGroups, Imageitems and Spacers.

 

As I am developing in NetBeans, when I add any item on any form, automatically it creates a code entry like

 

class variable

private Form loginForm;

 and, it also generates the getter method automatically as

 

public Form getLoginForm() {
if (loginForm == null) {
// write pre-init user code here
loginForm = new Form("Login", new Item[] { getUsernametextField(), getPasswordTextField() });
loginForm.addCommand(getOkCommand());
loginForm.setCommandListener(this);
// write post-init user code here
}
return loginForm;
}

 

In this way, I have added almost 280 class level variables. The error is pointing to the last declared variable.

 

now I found myself into deep trouble, please help me to sort out this issue. Please provide me suggestions and ways to further reduce the number of variables at class level.

 

I am eagerly waiting for your reply. Best Regards.

New Developer
Posts: 39
Registered: ‎10-13-2009
My Device: Not Specified

Re: Error starting xxx: Class 'xxx.xxx' ref member out of range

If you are not using the class level data members (Forms, StringItems, TextFields, Alerts, ChoiceGroups, Imageitems and Spacers) on the class level then can you change them to inner classes?

 

like

 

LabelField myLabel = new LabelField("some name", ..................) {

-------------------------------------

-------------------------------------

};

 

This way class level vars would reduce.

Developer
Posts: 109
Registered: ‎03-13-2010
My Device: BlackBerry 8520 Curve Smartphone
My Carrier: -

Re: Error starting xxx: Class 'xxx.xxx' ref member out of range

[ Edited ]

Thanks for the response Shubhra . Please can you specify it bit more? Actually I am not getting it properly what you are trying to explain. Instead of declaring class level data member as I mentioned in the code, declaring it inside the method itself. do you mean like that?

 

 

public Form getLoginForm() {
Form loginForm = new Form("Login", new Item[] { getUsernameTextField(), getPasswordTextField() });                                    
loginForm.addCommand(getOkCommand());
loginForm.setCommandListener(this);                                  
        return loginForm;
}

 

like this?

 

yes, it will reduce the class level data member, but in the commandAction(), it will not get the access to the loginForm variable. As, in the commandAction() method, I am doing like

 

 

public void commandAction(Command command, Displayable displayable) {
if (displayable == loginForm) {
if (command == okCommand) {
username = usernameTextextField.getString();
password = passwordTextField.getString();
}
}
else if (displayable == someOtherForm) {
---
---
---}
}

 You said you have already resolved this issue in the same way. But, I think I have not got your point,  please can you elaborate it more? It will be a great help to me. Thanks and Best Regards.