# \[macro\]Generating java problem

**URL:** <https://community.haxe.org/t/macro-generating-java-problem/2153>\
**Category:** Haxe\
**Tags:** macro, haxe-java\
**Created:** [November 20, 2019, 11:20am UTC](https://community.haxe.org/t/macro-generating-java-problem/2153 "2019-11-20T11:20:15Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![alex\_dja](https://community.haxe.org/user_avatar/community.haxe.org/alex_dja/32/294_2.png) [@alex\_dja](https://community.haxe.org/u/alex_dja)\
**Post date:** [November 20, 2019, 11:20am UTC](https://community.haxe.org/t/macro-generating-java-problem/2153/1 "2019-11-20T11:20:15Z")

</div>

I have the extern type in haxe:

```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>`?

---

<div class="post-metadata">

**Author:** ![ibilon](https://community.haxe.org/user_avatar/community.haxe.org/ibilon/32/13_2.png) [@ibilon](https://community.haxe.org/u/ibilon)\
**Post date:** [November 20, 2019, 11:36am UTC](https://community.haxe.org/t/macro-generating-java-problem/2153/2 "2019-11-20T11:36:23Z")

</div>

You can create a class like this:

```haxe
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.

---

<div class="post-metadata">

**Author:** ![alex\_dja](https://community.haxe.org/user_avatar/community.haxe.org/alex_dja/32/294_2.png) [@alex\_dja](https://community.haxe.org/u/alex_dja)\
**Post date:** [November 20, 2019, 12:19pm UTC](https://community.haxe.org/t/macro-generating-java-problem/2153/3 "2019-11-20T12:19:42Z")

</div>

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

```haxe
typedef SomeStruct = 
{
  list: Array<SomeType>
}

```

and interface to be built:

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

```

result I want achieve in java:

```haxe
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?

---

<div class="post-metadata">

**Author:** ![ibilon](https://community.haxe.org/user_avatar/community.haxe.org/ibilon/32/13_2.png) [@ibilon](https://community.haxe.org/u/ibilon)\
**Post date:** [November 26, 2019, 1:39pm UTC](https://community.haxe.org/t/macro-generating-java-problem/2153/4 "2019-11-26T13:39:16Z")

</div>

I don’t think that’s currently possible, you could open an [issue on github](https://github.com/HaxeFoundation/haxe/issues) and ask for a field meta that would make the generator output such construct.
