[fpc-pascal] Re: Some questions regarding jvmbackend port

Jonas Maebe jonas.maebe at elis.ugent.be
Mon Jan 9 00:21:27 CET 2012


On 09 Jan 2012, at 00:12, leledumbo wrote:

> Since the title is still valid, I'd like ask about the usage of java
> collections in generic style. For instance java.util.ArrayList. How can I
> construct JUArrayList with Integer constraint as in Java?
> 
> e.g.: ArrayList<Integer> a = new ArrayList<Integer>;

Java-style generics are a Java-language-level feature (they work via type-erasure at the language level) that does not exist in FPC. The FPC JVM port enables compiling Pascal code into Java bytecode. It does not add Java language features to the Object Pascal language (except to the extent required for interoperability with Java bytecode).

You simply have to use them like in the Java language before JDK 1.5: by typecasting the return values (which are JLObject) into JLInteger.


Jonas


More information about the fpc-pascal mailing list