Hi,
I have a question. I need to create an alias for java Consumer. So I came up with:
TGIS_PvlModalResult = enum ( None, OK, Cancel, Abort ) of Integer ;
TGIS_Proc = public Consumer<TGIS_PvlModalResult > ;
TGIS_PvlModalProc = class
private
FProc : TGIS_Proc ;
public
property Proc : TGIS_Proc
read FProc
write FProc ;
end;
It’s implemented like this later on:
proc := TGIS_PvlModalProc.Create ;
proc.Proc := new interface TGIS_Proc(
accept := method( _modal_result : TGIS_PvlModalResult )
begin
writeLn( _modal_result ) ;
end
)
But whenever I try to use it I get an Internal error, NullReferanceException (E0).
proc.Proc.accept(TGIS_PvlModalResult.OK) ;
Any idea what would cause it?
mh
(marc hoffman)
September 13, 2021, 3:32pm
2
Damian,
an internal error is always a compiler bug, by definition, so whether oyour code is coprehct or not, this should not happen/ 'll try to repros wit your snippets, but if yu could send us a full test case, that would greatly help!
Update : reproduced: consoleapplication10 1.bugreport.zip (7.3 KB)
bugs://E25332 was closed as fixed.
@mh is there any chance to get a daily private build ?
mh
(marc hoffman)
September 14, 2021, 1:08pm
6
I started one with Water now. If you just need VS, lemme know and I can upload one immediately.
@mh Still some issue happens even in your test project, would really appreciate some help on this one
:
bugs://E25332 was reopened.
mh
(marc hoffman)
September 27, 2021, 12:48pm
11
my apologies; we’ll have another look.
Strangly it works for String for Example
1 Like
bugs://E25332 was closed as fixed.
Ok @mh it works withing small project now. But for some strange reason in our big solution we still get this:
Exception in thread "AWT-EventQueue-0" java.lang.VerifyError: (class: tatukgis/jdk/T_scrollablePanel, method: $doCustomSize$b__0 signature: (I)V) Register 0 contains wrong type
It is the same code as in the small sample:
/// <summary>
/// Result type of TGIS_PvlModalForm
/// </summary>
TGIS_PvlModalResult = {$IFDEF JAVA}enum{$ENDIF} ( None, OK, Cancel, Abort ) {$IFDEF JAVA}of Integer{$ENDIF} ;
TGIS_Proc =
{$IFDEF DCC}
TProc<TGIS_PvlModalResult>
{$ENDIF}
{$IFDEF CLR}
Action<TGIS_PvlModalResult>
{$ENDIF}
{$IFDEF JAVA}
java.util.function.Consumer<TGIS_PvlModalResult>
{$ENDIF}
;
and then
function T_scrollablePanel.doCustomSize(
_sender : TObject ;
_e : TGIS_ComboBoxHelperCustomEventArgs
) : String ;
var
dlg : tatukgis.jdk.pvl.TGIS_ControlSizeForm ;
frm : tatukgis.jdk.pvl.TGIS_ControlFieldFactor ;
val : String ;
begin
Result := '' ;
if _e.Value = GIS_PARAMTXT_TYPE_FIELD then begin
frm := tatukgis.jdk.pvl.TGIS_ControlFieldFactor.Create( Self ) ;
frm.FillFields( oParentWindow.MVC.FieldNames ) ;
frm.FillUnits( tatukgis.jdk.pvl.TGIS_FieldFactorUnitsType.Size ) ;
var proc : TGIS_Proc := new interface TGIS_Proc(
accept := method( _modal_result : TGIS_PvlModalResult )
begin
writeLn( _modal_result ) ;
end
);
proc.accept( TGIS_PvlModalResult.OK ) ;
end
else
if _e.Value = GIS_PARAMTXT_TYPE_CUSTOM then begin
dlg := tatukgis.jdk.pvl.TGIS_ControlSizeForm.Create( Self ) ;
try
dlg.FillUnits( False ) ;
// Result := dlg.Execute( oParentWindow.pOnHelp ) ;
finally
FreeObject( dlg ) ;
end ;
end;
end ;
When i try to create object which contains this function i get that error.
Update:
It shouldnt matter but declaraction of TGIS_Proc and TGIS_PvlModalResult are in different file than the function itself.
mh
(marc hoffman)
October 6, 2021, 1:44pm
15
Hmm. any chance w ecan get a tets case that reproduces this? (i assume the small testcase does not give the java.lang.VerifyError?)
Yeah small one doesnt reproduce that i will try to get some demo of that behaviour.
1 Like
@mh ok so i found whats causing it. Just add this to uses of the existing test case.
remobjects.elements.rtl.*
1 Like
bugs://E25332 was reopened.
bugs://E25332 was closed as fixed.
ck
(Carlo Kok)
October 11, 2021, 7:53pm
20
Wow this is an interesting bug. Fixed now I hope.
1 Like