COMMUNITY

[macro]Generating java problem

I have the extern type in haxe:

package java.util;

@:native("java.util.List")
extern class List<T> {}

and contstruct ComplexType from it: var arrayComplexType = macro: java.util.List<$someType>;
Later in macro I can generate fields typed as java.util.List<SomeType> in java.
Is it possible to generate fields typed as java.util.List<? extends SomeType>?

You can create a class like this:

class SomeClass<T:SomeType> {
    var myfield:java.util.List<T>;
}

and the list type will need to extend SomeType so that the class can be constructed.

So if you generate the class it’s possible.

I have anon struct(used in javascript target code):

typedef SomeStruct = 
{
  list: Array<SomeType>
}

and interface to be built:

@:nativeGen
@:build(MacroBuilder.buildBasedOnStruct(SomeStruct))
interface SomeInterface
{
}

result I want achieve in java:

public interface SomeInterface
{
  java.util.List<? extends SomeType> getList();
}

I have success only with java.util.List<SomeType> getList();
But there are problems with a covariance on java side and I need ? extends thing. Maybe it is possible with a haxe postgenerating mechanism?

I don’t think that’s currently possible, you could open an issue on github and ask for a field meta that would make the generator output such construct.