hxjava
hxjava copied to clipboard
Error: unreported exception must be caught or declared to be thrown
If we override / @:overload native method marked throws ServletException, IOException we need this meta too. Ok, using @:throws("java.io.IOException, javax.servlet.ServletException") under the our method declaration. Everything is fine but now we will get the same exception for a different method:
Generated java-code:
public java.lang.Object __hx_invokeField(java.lang.String field, haxe.root.Array dynargs)
{
{
boolean __temp_executeDef37 = true;
switch (field.hashCode())
{
case 95730379:
{
if (field.equals("doGet"))
{
__temp_executeDef37 = false;
this.doGet(((javax.servlet.http.HttpServletRequest) (dynargs.__get(0)) ), ((javax.servlet.http.HttpServletResponse) (dynargs.__get(1)) ));
}
break;
}
}
if (__temp_executeDef37)
{
return ((haxe.lang.Function) (this.__hx_getField(field, true, false, false)) ).__hx_invokeDynamic(dynargs);
}
}
return null;
}
This is because there is clearly calling a method this.doGet marked with the throws.
I was update Haxe-compiller to latest nightly build and YES, fixed. Thx!
This is the new __hx_invokeField method:
public java.lang.Object __hx_invokeField(java.lang.String field, haxe.root.Array dynargs)
{
{
boolean __temp_executeDef37 = true;
switch (field.hashCode())
{
case 95730379:
{
if (field.equals("doGet"))
{
__temp_executeDef37 = false;
return haxe.lang.Runtime.slowCallField(this, field, dynargs);
}
break;
}
}
if (__temp_executeDef37)
{
return ((haxe.lang.Function) (this.__hx_getField(field, true, false, false)) ).__hx_invokeDynamic(dynargs);
}
else
{
throw null;
}
}
}