generics not supported

F

focode

i am writing the following code in my midlet (j2me program), and
trying to run it , it shows the following error:


C:\Documents and Settings\rohit\My Documents\NetBeansProjects
\arrayconcatination\src\arrayconcatination.java:103: generics are not
supported in -source 1.3
(use -source 5 or higher to enable generics)
Vector<String[]> v = new Vector<String[]>();
1 error

i am using netbeans to compile this program , please guide me to
eliminate the problem .

thanks and regards
Arunesh
 
F

focode

i am writing the following code in my midlet (j2me program), and
trying to run it , it shows the following error:

C:\Documents and Settings\rohit\My Documents\NetBeansProjects
\arrayconcatination\src\arrayconcatination.java:103: generics are not
supported in -source 1.3
(use -source 5 or higher to enable generics)
                Vector<String[]> v = new Vector<String[]>();
1 error

i am using netbeans 6.7 and java 6 to compile this program , please guide me to
eliminate the problem .
 
G

gold

i am writing the following code in my midlet (j2me program), and
trying to run it , it shows the following error:

C:\Documents and Settings\rohit\My Documents\NetBeansProjects
\arrayconcatination\src\arrayconcatination.java:103: generics are not
supported in -source 1.3
(use -source 5 or higher to enable generics)
                Vector<String[]> v = new Vector<String[]>();
1 error

i am using netbeans to compile this program , please guide me to
eliminate the problem .

thanks and regards
Arunesh

Hi !!!

The Vector is not allowed in J2ME Environment... For more
more information please refer J2ME Spec...
 
F

focode

i am writing the following code in my midlet (j2me program), and
trying to run it , it shows the following error:
C:\Documents and Settings\rohit\My Documents\NetBeansProjects
\arrayconcatination\src\arrayconcatination.java:103: generics are not
supported in -source 1.3
(use -source 5 or higher to enable generics)
                Vector<String[]> v = new Vector<String[]>();
1 error
i am using netbeans to compile this program , please guide me to
eliminate the problem .
thanks and regards
Arunesh

Hi !!!

          The Vector is not allowed in J2ME Environment... For more
more information please refer J2ME Spec...

i am using Vector in my j2me program how can you say that it is not
allowed here ...

thanks
focode
 
A

Alexander Schölling

focode said:
i am writing the following code in my midlet (j2me program), and
trying to run it , it shows the following error:
C:\Documents and Settings\rohit\My Documents\NetBeansProjects
\arrayconcatination\src\arrayconcatination.java:103: generics are not
supported in -source 1.3
(use -source 5 or higher to enable generics)
                Vector<String[]> v = new Vector<String[]>();
1 error
i am using netbeans to compile this program , please guide me to
eliminate the problem .
thanks and regards
Arunesh

Hi !!!

          The Vector is not allowed in J2ME Environment... For more
more information please refer J2ME Spec...

i am using Vector in my j2me program how can you say that it is not
allowed here ...

thanks
focode

Hi,

the error message does not state that Vector is no allowed,
Vector<String> is what triggered the error. Use

Vector v=new Vector();

instead and do the appropriate typecasts/checks when accessing.

Yours,

Alexander
 
L

Lew

focode said:
i [sic] am using Vector in my j2me program how can you say that it is not
allowed here ...
the error message does not state that Vector is no allowed,
Vector<String> is what triggered the error. Use

Vector v=new Vector();

instead and do the appropriate typecasts/checks when accessing.

J2ME is not yet up to Java 5, ergo it does not have generics.
 
T

Tom Anderson

the error message does not state that Vector is no allowed,
Vector<String> is what triggered the error. Use

Vector v=new Vector();

instead and do the appropriate typecasts/checks when accessing.

Has anyone figured out a way to use generics in J2ME? Something like using
the java 1.5 language, but the J2ME libraries? It all goes via bytecode,
so it should be possible, right? It would be really, really nice to have
generics when doing J2ME development. Or so my friend who is a J2ME
developer tells me.

tom
 
D

Daniel Pitts

Tom said:
Has anyone figured out a way to use generics in J2ME? Something like
using the java 1.5 language, but the J2ME libraries? It all goes via
bytecode, so it should be possible, right? It would be really, really
nice to have generics when doing J2ME development. Or so my friend who
is a J2ME developer tells me.

tom
Class file formats have changed significantly between 1.3 and 1.5, so
unfortunately you can't compile 1.5 source into 1.3 bytecode.
 
J

Joshua Cranmer

Class file formats have changed significantly between 1.3 and 1.5, so
unfortunately you can't compile 1.5 source into 1.3 bytecode.

The only changes I'm aware of in the actual bytecode itself (ignoring
the new attributes and flags, as a VM can and would easily ignore those)
are the ldc instruction supporting a ClassInfo and invokedynamic, the
latter of which is not usable from Java.
 
J

Jim Janney

Tom Anderson said:
Has anyone figured out a way to use generics in J2ME? Something like
using the java 1.5 language, but the J2ME libraries? It all goes via
bytecode, so it should be possible, right? It would be really, really
nice to have generics when doing J2ME development. Or so my friend who
is a J2ME developer tells me.

tom

I have no experience with it (or with J2ME) but here's something that claims to do this.

http://www.j2mepolish.org/cms/leftsection/documentation/programming/programming-java5.html
 
T

Tom Anderson

The only changes I'm aware of in the actual bytecode itself (ignoring
the new attributes and flags, as a VM can and would easily ignore those)
are the ldc instruction supporting a ClassInfo and invokedynamic, the
latter of which is not usable from Java.

And the former of which was supported by earlier Sun JVMs, despite not
being in the spec. I have no idea if that extends to their mobile JVMs,
though, nor to any vendor mobile JVMs.

The ClassInfo ldc is fairly easily rewritten into a String ldc followed by
a Class.forName call, although given that J2ME doesn't (?) have the
version of forName which avoids initialising a class, this would change
the semantics in a subtle but strictly incorrect way. There is a more
convoluted trick for loading a class without initialising it discovered by
the Jikes team, but i think that would also be easy enough to rewrite ldc
calls to.

Other than that, things like generics and autoboxing vanish at
compile-time, so they should Just Work.

tom
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,769
Messages
2,569,582
Members
45,070
Latest member
BiogenixGummies

Latest Threads

Top