Delphi Java Bridge - 如何实例化 class 并在其上调用方法

Delphi Java Bridge - how to instance a class and call a method on it

我正尝试在我的 Delphi 项目中为 Android 使用 .jar 文件。遗憾的是,网上并没有资料说清楚这一点。

我按照 Embarcadero 在他们关于使用 Java2OP 的文档中所写的那样创建了 Bridge,并且我得到了 .pas 文件。我只想知道,如何使用界面JPrintUtilClass?我不知道这个文件是如何工作的,也不知道如何使用它。

这是 .pas 文件:

unit SdkPrint;

interface

uses
  Androidapi.JNIBridge,
  Androidapi.JNI.Bluetooth,
  Androidapi.JNI.GraphicsContentViewText,
  Androidapi.JNI.JavaTypes;

type
// ===== Forward declarations =====

  Jprint_sdk_BuildConfig = interface;//com.example.print_sdk.BuildConfig
  JEscUtils = interface;//com.example.print_sdk.EscUtils
  JEscUtils_1 = interface;//com.example.print_sdk.EscUtils
  JSerialManager_OnDataReceiveListener = interface;//com.example.print_sdk.SerialManager$OnDataReceiveListener
  JPrintUtil = interface;//com.example.print_sdk.PrintUtil
  JPrintUtil_1 = interface;//com.example.print_sdk.PrintUtil
  JPrintUtil_Singleton = interface;//com.example.print_sdk.PrintUtil$Singleton
  JSerialManager = interface;//com.example.print_sdk.SerialManager
  JSerialManager_1 = interface;//com.example.print_sdk.SerialManager
  JSerialManager_ReadThread = interface;//com.example.print_sdk.SerialManager$ReadThread
  JSerialManager_Singleton = interface;//com.example.print_sdk.SerialManager$Singleton
  JALIGN_MODE = interface;//com.example.print_sdk.enums.ALIGN_MODE
  JBARCODE_1D_TYPE = interface;//com.example.print_sdk.enums.BARCODE_1D_TYPE
  JFONT_ID = interface;//com.example.print_sdk.enums.FONT_ID
  JMODE_ENLARGE = interface;//com.example.print_sdk.enums.MODE_ENLARGE
  JOnPrintEventListener = interface;//com.example.print_sdk.interfaces.OnPrintEventListener
  JBitmapToByteUtils = interface;//com.example.print_sdk.util.BitmapToByteUtils
  JBitmapToByteUtils_1 = interface;//com.example.print_sdk.util.BitmapToByteUtils
  JBitmapToByteUtils_PAlign = interface;//com.example.print_sdk.util.BitmapToByteUtils$PAlign
  JByteUtils = interface;//com.example.print_sdk.util.ByteUtils
  JSerialPort = interface;//com.lcserial.www.SerialPort
  JSerialPortFinder = interface;//com.lcserial.www.SerialPortFinder
  JSerialPortFinder_Driver = interface;//com.lcserial.www.SerialPortFinder$Driver
  JSerialPortTool = interface;//com.lcserial.www.SerialPortTool
  JVector = interface;//java.util.Vector

// ===== Interface declarations =====

  Jprint_sdk_BuildConfigClass = interface(JObjectClass)
    ['{4AF7C67A-A9C7-4D40-AC55-59A00B9F9037}']
    {class} function _GetBUILD_TYPE: JString; cdecl;
    {class} function _GetDEBUG: Boolean; cdecl;
    {class} function _GetLIBRARY_PACKAGE_NAME: JString; cdecl;
    {class} function init: Jprint_sdk_BuildConfig; cdecl;//Deprecated
    {class} property BUILD_TYPE: JString read _GetBUILD_TYPE;
    {class} property DEBUG: Boolean read _GetDEBUG;
    {class} property LIBRARY_PACKAGE_NAME: JString read _GetLIBRARY_PACKAGE_NAME;
  end;

  [JavaSignature('com/example/print_sdk/BuildConfig')]
  Jprint_sdk_BuildConfig = interface(JObject)
    ['{3EF30B8F-3139-41C1-A3E1-97FEA126AAEE}']
  end;
  TJprint_sdk_BuildConfig = class(TJavaGenericImport<Jprint_sdk_BuildConfigClass, Jprint_sdk_BuildConfig>) end;

  JEscUtilsClass = interface(JObjectClass)
    ['{9E23270C-7339-4000-B628-36F5AB13F947}']
    {class} function esc_barcode_1D_print(P1: JString; P2: JBARCODE_1D_TYPE): Integer; cdecl;//Deprecated
    {class} function esc_barcode_2D_print(P1: Integer; P2: Integer; P3: Integer; P4: JALIGN_MODE; P5: JString): Integer; cdecl;//Deprecated
    {class} function esc_barcode_height(P1: Integer): Integer; cdecl;//Deprecated
    {class} function esc_barcode_width(P1: Integer): Integer; cdecl;//Deprecated
    {class} procedure esc_buffer_clear; cdecl;//Deprecated
    {class} function esc_char_bold(P1: Boolean): Integer; cdecl;//Deprecated
    {class} function esc_char_enlarge(P1: JMODE_ENLARGE): Integer; cdecl;//Deprecated
    {class} function esc_char_font(P1: JFONT_ID): Integer; cdecl;//Deprecated
    {class} function esc_default_print: Integer; cdecl;//Deprecated
    {class} function esc_enable_mark(P1: Boolean): Integer; cdecl;//Deprecated
    {class} function esc_enter_print: Integer; cdecl;//Deprecated
    {class} function esc_exit_unicode: Integer; cdecl;//Deprecated
    {class} function esc_feature_list: Integer; cdecl;//Deprecated
    {class} function esc_feed_paper(P1: Boolean; P2: Integer): Integer; cdecl;//Deprecated
    {class} function esc_init_print: Integer; cdecl;//Deprecated
    {class} function esc_length_get: Integer; cdecl;//Deprecated
    {class} function esc_lib_version: Integer; cdecl;//Deprecated
    {class} function esc_main_mark: Integer; cdecl;//Deprecated
    {class} function esc_no_paper_print_status(P1: Byte): Integer; cdecl;//Deprecated
    {class} function esc_open_one_vote_one_control(P1: Integer): Integer; cdecl;//Deprecated
    {class} function esc_print_align(P1: JALIGN_MODE): Integer; cdecl;//Deprecated
    {class} function esc_print_hri: Integer; cdecl;//Deprecated
    {class} function esc_print_languageList: Integer; cdecl;//Deprecated
    {class} function esc_print_left_margin(P1: SmallInt): Integer; cdecl;//Deprecated
    {class} function esc_print_line_space(P1: Boolean; P2: Byte): Integer; cdecl;//Deprecated
    {class} function esc_print_state: Integer; cdecl;//Deprecated
    {class} function esc_psam_info(P1: Integer): Integer; cdecl;//Deprecated
    {class} function esc_psam_send(P1: Integer; P2: TJavaArray<Byte>; P3: Integer): Integer; cdecl;//Deprecated
    {class} function esc_select_sensor_stop_print: Integer; cdecl;//Deprecated
    {class} function esc_set_black(P1: Integer; P2: Integer): Integer; cdecl;//Deprecated
    {class} function esc_set_concentration(P1: Integer): Integer; cdecl;//Deprecated
    {class} function esc_set_encode(P1: Byte): Integer; cdecl;//Deprecated
    {class} function esc_set_language(P1: Byte): Integer; cdecl;//Deprecated
    {class} function esc_set_sn(P1: TJavaArray<Byte>): Integer; cdecl;//Deprecated
    {class} function esc_set_sn_end: Integer; cdecl;//Deprecated
    {class} function esc_test: Integer; cdecl;//Deprecated
    {class} function esc_text_print(P1: JString): Integer; cdecl;//Deprecated
    {class} function getEscBuffer: TJavaArray<Byte>; cdecl;//Deprecated
    {class} function init(P1: Integer): JEscUtils; cdecl;//Deprecated
  end;

  [JavaSignature('com/example/print_sdk/EscUtils')]
  JEscUtils = interface(JObject)
    ['{154063F4-5B7B-4A21-9B2B-2CA70F9D0861}']
  end;
  TJEscUtils = class(TJavaGenericImport<JEscUtilsClass, JEscUtils>) end;

  JEscUtils_1Class = interface(JObjectClass)
    ['{CCEFF579-0236-4ED3-97C8-4BDFCE28377C}']
  end;

  [JavaSignature('com/example/print_sdk/EscUtils')]
  JEscUtils_1 = interface(JObject)
    ['{263CB672-7EE1-4F22-9E10-16D8DDA2F77E}']
  end;
  TJEscUtils_1 = class(TJavaGenericImport<JEscUtils_1Class, JEscUtils_1>) end;

  JSerialManager_OnDataReceiveListenerClass = interface(IJavaClass)
    ['{A1E769AF-2EBA-4A18-9B09-2B5F75D3116E}']
    {class} procedure onDataReceive(P1: TJavaArray<Byte>; P2: Integer); cdecl;//Deprecated
  end;

  [JavaSignature('com/example/print_sdk/SerialManager$OnDataReceiveListener')]
  JSerialManager_OnDataReceiveListener = interface(IJavaInstance)
    ['{4CE95D9C-BC11-43A8-8D64-C9908138973A}']
  end;
  TJSerialManager_OnDataReceiveListener = class(TJavaGenericImport<JSerialManager_OnDataReceiveListenerClass, JSerialManager_OnDataReceiveListener>) end;

  JPrintUtilClass = interface(JSerialManager_OnDataReceiveListenerClass)
    ['{197C02F8-45F1-4961-B34E-E714AD84E558}']
    {class} function _GetWIDTH_PIXEL: Integer; cdecl;
    {class} function _Getcheck_paper: Boolean; cdecl;
    {class} procedure _Setcheck_paper(Value: Boolean); cdecl;
    {class} procedure closeDev; cdecl;//Deprecated
    {class} function esc_text_print(P1: JString): Integer; cdecl;//Deprecated
    {class} procedure exitUnicode; cdecl;//Deprecated
    {class} function getClient: JPrintUtil; cdecl;//Deprecated
    {class} function getGbk(P1: JString): TJavaArray<Byte>; cdecl;//Deprecated
    {class} function getInstance: JPrintUtil; cdecl;//Deprecated
    {class} function getOffset(P1: JString): Integer; cdecl;//Deprecated
    {class} procedure getTemperature; cdecl;//Deprecated
    {class} procedure getVersion; cdecl;//Deprecated
    {class} function init: JPrintUtil; cdecl;//Deprecated
    {class} procedure initPrinter; cdecl;//Deprecated
    {class} procedure initSDK; cdecl;//Deprecated
    {class} function isChinese(P1: JString): Boolean; cdecl; overload;//Deprecated
    {class} function isChinese(P1: Char): Boolean; cdecl; overload;//Deprecated
    {class} procedure onDataReceive(P1: TJavaArray<Byte>; P2: Integer); cdecl;//Deprecated
    {class} procedure print(P1: TJavaArray<Byte>); cdecl;//Deprecated
    {class} procedure printAlignment(P1: JALIGN_MODE); cdecl;//Deprecated
    {class} procedure printAutoEnableMark(P1: Boolean); cdecl;//Deprecated
    {class} procedure printBackPaper(P1: Integer); cdecl;//Deprecated
    {class} procedure printBarcode(P1: JString; P2: Integer; P3: Integer); cdecl; overload;//Deprecated
    {class} procedure printBarcode(P1: JString; P2: JBARCODE_1D_TYPE; P3: Integer; P4: Integer); cdecl; overload;//Deprecated
    {class} procedure printBarcode2(P1: JBitmap); cdecl;//Deprecated
    {class} procedure printBitmap(P1: JBitmap); cdecl;//Deprecated
    {class} procedure printBitmap2(P1: JBitmap); cdecl;//Deprecated
    {class} procedure printConcentration(P1: Integer); cdecl;//Deprecated
    {class} procedure printDashLine; cdecl;//Deprecated
    {class} procedure printEnableCertificate(P1: Boolean); cdecl;//Deprecated
    {class} procedure printEnableMark(P1: Boolean); cdecl;//Deprecated
    {class} procedure printEncode(P1: Integer); cdecl;//Deprecated
    {class} procedure printEndNumber; cdecl;//Deprecated
    {class} procedure printFeatureList; cdecl;//Deprecated
    {class} procedure printFontSize(P1: JMODE_ENLARGE); cdecl;//Deprecated
    {class} procedure printFourColumn(P1: JString; P2: JString; P3: JString; P4: JString); cdecl;//Deprecated
    {class} procedure printGoToNextMark; cdecl;//Deprecated
    {class} procedure printImage(P1: JBitmap); cdecl;//Deprecated
    {class} procedure printLanguage(P1: Integer); cdecl;//Deprecated
    {class} procedure printLargeText(P1: JString); cdecl;//Deprecated
    {class} procedure printLine; cdecl; overload;//Deprecated
    {class} procedure printLine(P1: Integer); cdecl; overload;//Deprecated
    {class} procedure printMarginLeft(P1: Integer); cdecl;//Deprecated
    {class} procedure printNoBarcodeText; cdecl;//Deprecated
    {class} procedure printQR(P1: JBitmap); cdecl;//Deprecated
    {class} procedure printQR2(P1: Integer; P2: Integer; P3: Integer; P4: JALIGN_MODE; P5: JString); cdecl;//Deprecated
    {class} procedure printStartNumber(P1: Integer); cdecl;//Deprecated
    {class} procedure printState; cdecl;//Deprecated
    {class} procedure printTabSpace(P1: Integer); cdecl;//Deprecated
    {class} procedure printText(P1: JString); cdecl;//Deprecated
    {class} procedure printTextBold(P1: Boolean); cdecl;//Deprecated
    {class} procedure printThicken(P1: Boolean); cdecl;//Deprecated
    {class} procedure printThreeColumn(P1: JString; P2: JString; P3: JString); cdecl;//Deprecated
    {class} procedure printTwoColumn(P1: JString; P2: JString); cdecl;//Deprecated
    {class} procedure printUnderscore(P1: Integer); cdecl;//Deprecated
    {class} procedure resetPrint; cdecl;//Deprecated
    {class} function resetPsam(P1: Integer; P2: TJavaArray<Byte>): Integer; cdecl;//Deprecated
    {class} function sendApdu(P1: Integer; P2: JString; P3: TJavaArray<Byte>): Integer; cdecl;//Deprecated
    {class} procedure setEncoding(P1: JString); cdecl;//Deprecated
    {class} function setLocation(P1: Integer): TJavaArray<Byte>; cdecl;//Deprecated
    {class} procedure setPrintDefLineSpacing; cdecl;//Deprecated
    {class} procedure setPrintEventListener(P1: JOnPrintEventListener); cdecl;//Deprecated
    {class} procedure setPrintLineSpacing(P1: Byte); cdecl;//Deprecated
    {class} procedure setPrintSpeed(P1: Integer); cdecl;//Deprecated
    {class} procedure setSocket(P1: JBluetoothSocket; P2: JString); cdecl;//Deprecated
    {class} procedure showBarcodeHRI(P1: Boolean); cdecl;//Deprecated
    {class} procedure sleep(P1: Integer); cdecl;//Deprecated
    {class} property WIDTH_PIXEL: Integer read _GetWIDTH_PIXEL;
    {class} property check_paper: Boolean read _Getcheck_paper write _Setcheck_paper;
  end;

  [JavaSignature('com/example/print_sdk/PrintUtil')]
  JPrintUtil = interface(JSerialManager_OnDataReceiveListener)
    ['{F62A814D-3547-4B21-905D-C9624753E306}']
  end;
  TJPrintUtil = class(TJavaGenericImport<JPrintUtilClass, JPrintUtil>) end;

  JPrintUtil_1Class = interface(JRunnableClass)
    ['{8FD0FAD7-0D4A-4242-87DB-3E30B5FB2909}']
    {class} function _Getthis: JPrintUtil; cdecl;
    {class} function _Getvalsize: Integer; cdecl;
    {class} function init(P1: JPrintUtil; P2: TJavaArray<Byte>; P3: Integer): JPrintUtil_1; cdecl;//Deprecated
    {class} procedure run; cdecl;//Deprecated
    {class} property this: JPrintUtil read _Getthis;
    {class} property valsize: Integer read _Getvalsize;
  end;

  [JavaSignature('com/example/print_sdk/PrintUtil')]
  JPrintUtil_1 = interface(JRunnable)
    ['{5E560D8E-9C5D-4F73-92D2-0543822C26C2}']
  end;
  TJPrintUtil_1 = class(TJavaGenericImport<JPrintUtil_1Class, JPrintUtil_1>) end;

  JPrintUtil_SingletonClass = interface(JEnumClass)
    ['{8A00925F-0E6C-4820-BA88-D8A9FAA4D66B}']
    {class} function _GetINSTANCE: JPrintUtil_Singleton; cdecl;
    {class} function valueOf(P1: JString): JPrintUtil_Singleton; cdecl;//Deprecated
    {class} function values: TJavaObjectArray<JPrintUtil_Singleton>; cdecl;//Deprecated
    {class} property INSTANCE: JPrintUtil_Singleton read _GetINSTANCE;
  end;

  [JavaSignature('com/example/print_sdk/PrintUtil$Singleton')]
  JPrintUtil_Singleton = interface(JEnum)
    ['{F8B01F89-4515-4C9E-80AA-AD23F4756141}']
  end;
  TJPrintUtil_Singleton = class(TJavaGenericImport<JPrintUtil_SingletonClass, JPrintUtil_Singleton>) end;

  JSerialManagerClass = interface(JObjectClass)
    ['{93E1233C-BFD5-4A4F-AEF8-81AD41133888}']
    {class} function _GetBAUTRATE: Integer; cdecl;
    {class} function _GetPATH: JString; cdecl;
    {class} function _Getextvcc: JString; cdecl;
    {class} procedure _Setextvcc(Value: JString); cdecl;
    {class} function _GetmOutputStream: JOutputStream; cdecl;
    {class} procedure _SetmOutputStream(Value: JOutputStream); cdecl;
    {class} function _GetmSerialPort: JSerialPort; cdecl;
    {class} procedure _SetmSerialPort(Value: JSerialPort); cdecl;
    {class} function _GetserialPortTool: JSerialPortTool; cdecl;
    {class} procedure _SetserialPortTool(Value: JSerialPortTool); cdecl;
    {class} function _GetsetSam: JString; cdecl;
    {class} procedure _SetsetSam(Value: JString); cdecl;
    {class} function Bytes2HexString(P1: TJavaArray<Byte>): JString; cdecl;//Deprecated
    {class} procedure close; cdecl;//Deprecated
    {class} function escCommand(P1: TJavaArray<Byte>): Boolean; cdecl; overload;//Deprecated
    {class} function escCommand(P1: JString): Boolean; cdecl; overload;//Deprecated
    {class} function escCommand(P1: TJavaArray<Byte>; P2: Integer): Boolean; cdecl; overload;//Deprecated
    {class} function getClient: JSerialManager; cdecl;//Deprecated
    {class} function getInputStream: JInputStream; cdecl;//Deprecated
    {class} function getOutputStream: JOutputStream; cdecl;//Deprecated
    {class} function init: JSerialManager; cdecl;//Deprecated
    {class} function open: Boolean; cdecl;//Deprecated
    {class} function receivePsam(P1: TJavaArray<Byte>; P2: Int64): Integer; cdecl;//Deprecated
    {class} procedure setOnDataReceiveListener(P1: JSerialManager_OnDataReceiveListener); cdecl;//Deprecated
    {class} procedure startReadThread; cdecl;//Deprecated
    {class} property BAUTRATE: Integer read _GetBAUTRATE;
    {class} property PATH: JString read _GetPATH;
    {class} property extvcc: JString read _Getextvcc write _Setextvcc;
    {class} property mOutputStream: JOutputStream read _GetmOutputStream write _SetmOutputStream;
    {class} property mSerialPort: JSerialPort read _GetmSerialPort write _SetmSerialPort;
    {class} property serialPortTool: JSerialPortTool read _GetserialPortTool write _SetserialPortTool;
    {class} property setSam: JString read _GetsetSam write _SetsetSam;
  end;

  [JavaSignature('com/example/print_sdk/SerialManager')]
  JSerialManager = interface(JObject)
    ['{DCBA525F-7998-455B-92E3-BAAA93D6F749}']
  end;
  TJSerialManager = class(TJavaGenericImport<JSerialManagerClass, JSerialManager>) end;

  JSerialManager_1Class = interface(JObjectClass)
    ['{DBE7BCE2-AE43-4DC9-BC96-8C0292D0696C}']
  end;

  [JavaSignature('com/example/print_sdk/SerialManager')]
  JSerialManager_1 = interface(JObject)
    ['{B2EB9959-6F2D-413C-9CAD-971E08400A3E}']
  end;
  TJSerialManager_1 = class(TJavaGenericImport<JSerialManager_1Class, JSerialManager_1>) end;

  JSerialManager_ReadThreadClass = interface(JThreadClass)
    ['{F130A205-F0BE-4DF5-A4BB-E089587F5944}']
    {class} function init(P1: JSerialManager; P2: JSerialManager_1): JSerialManager_ReadThread; cdecl;//Deprecated
    {class} procedure run; cdecl;//Deprecated
  end;

  [JavaSignature('com/example/print_sdk/SerialManager$ReadThread')]
  JSerialManager_ReadThread = interface(JThread)
    ['{8B080BC4-4080-47ED-9D86-D0C87F833EF4}']
  end;
  TJSerialManager_ReadThread = class(TJavaGenericImport<JSerialManager_ReadThreadClass, JSerialManager_ReadThread>) end;

  JSerialManager_SingletonClass = interface(JEnumClass)
    ['{04AFBD2A-5EC3-4896-B143-D540D3FB8985}']
    {class} function _GetINSTANCE: JSerialManager_Singleton; cdecl;
    {class} function valueOf(P1: JString): JSerialManager_Singleton; cdecl;//Deprecated
    {class} function values: TJavaObjectArray<JSerialManager_Singleton>; cdecl;//Deprecated
    {class} property INSTANCE: JSerialManager_Singleton read _GetINSTANCE;
  end;

  [JavaSignature('com/example/print_sdk/SerialManager$Singleton')]
  JSerialManager_Singleton = interface(JEnum)
    ['{3F2E8946-1CF2-4295-A93F-FBA4F91E66DD}']
  end;
  TJSerialManager_Singleton = class(TJavaGenericImport<JSerialManager_SingletonClass, JSerialManager_Singleton>) end;

  JALIGN_MODEClass = interface(JEnumClass)
    ['{DD57EF9B-D9BD-4800-B9E0-8DCF6CB20C6C}']
    {class} function _GetALIGN_CENTER: JALIGN_MODE; cdecl;
    {class} function _GetALIGN_LEFT: JALIGN_MODE; cdecl;
    {class} function _GetALIGN_RIGHT: JALIGN_MODE; cdecl;
    {class} function &Get: Integer; cdecl;//Deprecated
    {class} function valueOf(P1: JString): JALIGN_MODE; cdecl;//Deprecated
    {class} function values: TJavaObjectArray<JALIGN_MODE>; cdecl;//Deprecated
    {class} property ALIGN_CENTER: JALIGN_MODE read _GetALIGN_CENTER;
    {class} property ALIGN_LEFT: JALIGN_MODE read _GetALIGN_LEFT;
    {class} property ALIGN_RIGHT: JALIGN_MODE read _GetALIGN_RIGHT;
  end;

  [JavaSignature('com/example/print_sdk/enums/ALIGN_MODE')]
  JALIGN_MODE = interface(JEnum)
    ['{2E72216B-8E1A-4FB0-9A18-112C0077FE14}']
  end;
  TJALIGN_MODE = class(TJavaGenericImport<JALIGN_MODEClass, JALIGN_MODE>) end;

  JBARCODE_1D_TYPEClass = interface(JEnumClass)
    ['{964C5000-043A-4EC1-B98A-FEEBCE464B69}']
    {class} function _GetCODE128: JBARCODE_1D_TYPE; cdecl;
    {class} function _GetCODE39: JBARCODE_1D_TYPE; cdecl;
    {class} function _GetCODE93: JBARCODE_1D_TYPE; cdecl;
    {class} function _GetEAN13: JBARCODE_1D_TYPE; cdecl;
    {class} function _GetEAN8: JBARCODE_1D_TYPE; cdecl;
    {class} function _GetITF25: JBARCODE_1D_TYPE; cdecl;
    {class} function _GetUPCA: JBARCODE_1D_TYPE; cdecl;
    {class} function _GetUPCE: JBARCODE_1D_TYPE; cdecl;
    {class} function &Get: Integer; cdecl;//Deprecated
    {class} function valueOf(P1: JString): JBARCODE_1D_TYPE; cdecl;//Deprecated
    {class} function values: TJavaObjectArray<JBARCODE_1D_TYPE>; cdecl;//Deprecated
    {class} property CODE128: JBARCODE_1D_TYPE read _GetCODE128;
    {class} property CODE39: JBARCODE_1D_TYPE read _GetCODE39;
    {class} property CODE93: JBARCODE_1D_TYPE read _GetCODE93;
    {class} property EAN13: JBARCODE_1D_TYPE read _GetEAN13;
    {class} property EAN8: JBARCODE_1D_TYPE read _GetEAN8;
    {class} property ITF25: JBARCODE_1D_TYPE read _GetITF25;
    {class} property UPCA: JBARCODE_1D_TYPE read _GetUPCA;
    {class} property UPCE: JBARCODE_1D_TYPE read _GetUPCE;
  end;

  [JavaSignature('com/example/print_sdk/enums/BARCODE_1D_TYPE')]
  JBARCODE_1D_TYPE = interface(JEnum)
    ['{71202FD9-B725-4FDF-8E31-2FFAB7C47186}']
  end;
  TJBARCODE_1D_TYPE = class(TJavaGenericImport<JBARCODE_1D_TYPEClass, JBARCODE_1D_TYPE>) end;

  JFONT_IDClass = interface(JEnumClass)
    ['{FFC9C28D-7FFD-4B8B-9BD6-AF5B94E03F74}']
    {class} function _GetFONT_ASCII_12x24: JFONT_ID; cdecl;
    {class} function _GetFONT_ASCII_9x17: JFONT_ID; cdecl;
    {class} function &Get: Integer; cdecl;//Deprecated
    {class} function valueOf(P1: JString): JFONT_ID; cdecl;//Deprecated
    {class} function values: TJavaObjectArray<JFONT_ID>; cdecl;//Deprecated
    {class} property FONT_ASCII_12x24: JFONT_ID read _GetFONT_ASCII_12x24;
    {class} property FONT_ASCII_9x17: JFONT_ID read _GetFONT_ASCII_9x17;
  end;

  [JavaSignature('com/example/print_sdk/enums/FONT_ID')]
  JFONT_ID = interface(JEnum)
    ['{E952A2D8-831D-45C0-9856-1B5DE9E11C81}']
  end;
  TJFONT_ID = class(TJavaGenericImport<JFONT_IDClass, JFONT_ID>) end;

  JSerialPortToolClass = interface(JObjectClass)
    ['{18F19FB3-9A40-422C-B9AD-F04076C51CCE}']
    {class} function _GetmSerialPortFinder: JSerialPortFinder; cdecl;
    {class} procedure closeSerialPort; cdecl;//Deprecated
    {class} function getSerialPort(P1: JString; P2: Integer): JSerialPort; cdecl;//Deprecated
    {class} function init: JSerialPortTool; cdecl;//Deprecated
    {class} property mSerialPortFinder: JSerialPortFinder read _GetmSerialPortFinder;
  end;

  [JavaSignature('com/lcserial/www/SerialPortTool')]
  JSerialPortTool = interface(JObject)
    ['{01A9F76E-F9DA-41FB-99F3-5A11D273A5D4}']
  end;
  TJSerialPortTool = class(TJavaGenericImport<JSerialPortToolClass, JSerialPortTool>) end;

  JVectorClass = interface(JAbstractListClass)
    ['{AF3067AC-4EA6-496A-9A93-E5D96BDDDECD}']
    {class} function init: JVector; cdecl; overload;//Deprecated
    {class} function init(capacity: Integer): JVector; cdecl; overload;//Deprecated
    {class} function init(capacity: Integer; capacityIncrement: Integer): JVector; cdecl; overload;//Deprecated
    {class} function init(collection: JCollection): JVector; cdecl; overload;//Deprecated
    {class} procedure add(location: Integer; object_: JObject); cdecl; overload;
    {class} function add(object_: JObject): Boolean; cdecl; overload;
    {class} function addAll(location: Integer; collection: JCollection): Boolean; cdecl; overload;
    {class} procedure clear; cdecl;
    {class} function clone: JObject; cdecl;
    {class} function &contains(object_: JObject): Boolean; cdecl;
    {class} function elements: JEnumeration; cdecl;//Deprecated
    {class} procedure ensureCapacity(minimumCapacity: Integer); cdecl;//Deprecated
    {class} function hashCode: Integer; cdecl;//Deprecated
    {class} function indexOf(object_: JObject): Integer; cdecl; overload;//Deprecated
    {class} function indexOf(object_: JObject; location: Integer): Integer; cdecl; overload;//Deprecated
    {class} function lastIndexOf(object_: JObject): Integer; cdecl; overload;//Deprecated
    {class} function lastIndexOf(object_: JObject; location: Integer): Integer; cdecl; overload;//Deprecated
    {class} function remove(location: Integer): JObject; cdecl; overload;//Deprecated
    {class} function removeElement(object_: JObject): Boolean; cdecl;//Deprecated
    {class} procedure removeElementAt(location: Integer); cdecl;//Deprecated
    {class} function retainAll(collection: JCollection): Boolean; cdecl;//Deprecated
    {class} function size: Integer; cdecl;
    {class} function subList(start: Integer; end_: Integer): JList; cdecl;
    {class} function toArray: TJavaObjectArray<JObject>; cdecl; overload;
  end;
 overload;
    function toString: JString; cdecl;
    procedure trimToSize; cdecl;
  end;
  TJVector = class(TJavaGenericImport<JVectorClass, JVector>) end;

implementation

procedure RegisterTypes;
begin
  TRegTypes.RegisterType('SdkPrint.Jprint_sdk_BuildConfig', TypeInfo(SdkPrint.Jprint_sdk_BuildConfig));
  TRegTypes.RegisterType('SdkPrint.JEscUtils', TypeInfo(SdkPrint.JEscUtils));
  TRegTypes.RegisterType('SdkPrint.JEscUtils_1', TypeInfo(SdkPrint.JEscUtils_1));
  TRegTypes.RegisterType('SdkPrint.JSerialManager_OnDataReceiveListener', TypeInfo(SdkPrint.JSerialManager_OnDataReceiveListener));
  TRegTypes.RegisterType('SdkPrint.JPrintUtil', TypeInfo(SdkPrint.JPrintUtil));
  TRegTypes.RegisterType('SdkPrint.JPrintUtil_1', TypeInfo(SdkPrint.JPrintUtil_1));
  TRegTypes.RegisterType('SdkPrint.JPrintUtil_Singleton', TypeInfo(SdkPrint.JPrintUtil_Singleton));
  TRegTypes.RegisterType('SdkPrint.JSerialManager', TypeInfo(SdkPrint.JSerialManager));
  TRegTypes.RegisterType('SdkPrint.JSerialManager_1', TypeInfo(SdkPrint.JSerialManager_1));
  TRegTypes.RegisterType('SdkPrint.JSerialManager_ReadThread', TypeInfo(SdkPrint.JSerialManager_ReadThread));
  TRegTypes.RegisterType('SdkPrint.JSerialManager_Singleton', TypeInfo(SdkPrint.JSerialManager_Singleton));
  TRegTypes.RegisterType('SdkPrint.JALIGN_MODE', TypeInfo(SdkPrint.JALIGN_MODE));
  TRegTypes.RegisterType('SdkPrint.JBARCODE_1D_TYPE', TypeInfo(SdkPrint.JBARCODE_1D_TYPE));
  TRegTypes.RegisterType('SdkPrint.JFONT_ID', TypeInfo(SdkPrint.JFONT_ID));
  TRegTypes.RegisterType('SdkPrint.JMODE_ENLARGE', TypeInfo(SdkPrint.JMODE_ENLARGE));
  TRegTypes.RegisterType('SdkPrint.JOnPrintEventListener', TypeInfo(SdkPrint.JOnPrintEventListener));
  TRegTypes.RegisterType('SdkPrint.JBitmapToByteUtils', TypeInfo(SdkPrint.JBitmapToByteUtils));
  TRegTypes.RegisterType('SdkPrint.JBitmapToByteUtils_1', TypeInfo(SdkPrint.JBitmapToByteUtils_1));
  TRegTypes.RegisterType('SdkPrint.JBitmapToByteUtils_PAlign', TypeInfo(SdkPrint.JBitmapToByteUtils_PAlign));
  TRegTypes.RegisterType('SdkPrint.JByteUtils', TypeInfo(SdkPrint.JByteUtils));
  TRegTypes.RegisterType('SdkPrint.JSerialPort', TypeInfo(SdkPrint.JSerialPort));
  TRegTypes.RegisterType('SdkPrint.JSerialPortFinder', TypeInfo(SdkPrint.JSerialPortFinder));
  TRegTypes.RegisterType('SdkPrint.JSerialPortFinder_Driver', TypeInfo(SdkPrint.JSerialPortFinder_Driver));
  TRegTypes.RegisterType('SdkPrint.JSerialPortTool', TypeInfo(SdkPrint.JSerialPortTool));
  TRegTypes.RegisterType('SdkPrint.JVector', TypeInfo(SdkPrint.JVector));
end;

initialization
  RegisterTypes;
end.

JPrintUtilClass接口是用来表示JavaPrintUtilclass的静态methods/properties,而JPrintUtil接口是意在表示非静态实例 methods/properties。您需要使用生成的 TJPrintUtil Delphi 包装器 class 的 JavaClass 属性 才能访问 Java PrintUtilclass,例如:

uses
  SdkPrint;

TJPrintUtil.JavaClass.useSomeMemberHere;
...

根据您最近的评论,您从 SDK 文档中提供的示例的 正确 翻译在 Delphi:

中看起来像这样
uses
  ..., SdkPrint;

var
  pUtil: JPrintUtil;
begin
  try
    pUtil := TJPrintUtil.JavaClass.getClient;
    pUtil.printState;
    pUtil.printAlignment(TJALIGN_MODE.JavaClass.ALIGN_LEFT);
    pUtil.printTextBold(false);
    pUtil.printTwoColumn(StringToJString('Time: '), StringToJString('2021-05-09 15:50:41'));
    pUtil.printTwoColumn(StringToJString('order number:'), StringToJString('1'));
    pUtil.printText(StringToJString('unit price'));
    pUtil.printThreeColumn(StringToJString('iphoneXII'), StringToJString('1'), StringToJString('4999.00'));
    pUtil.printThreeColumn(StringToJString('MAC PRO'), StringToJString('1'), StringToJString('4999.00'));
    pUtil.printTwoColumn(StringToJString('order amount:'), StringToJString('9998.00'));
    pUtil.printEndNumber;
  except
  end;
end;

但是,这在您的情况下不起作用,因为这些 PrintUtil 方法中的大多数都是非静态实例方法,但是 Java2OP 生成的 Delphi 代码您提供的是将它们全部视为静态 class 方法。这意味着 Java2OP 没有正确导入 JAR。这实际上是一个已知问题,请参阅以下错误报告:

RSP-15473: Java2Op emits erroneous code

RSP-21462: Java2OP outputting Class declarations instead of procedures

RSP-24029: Regression in Java2OP so that instance methods are treated as class methods

因此,您将不得不手动更正生成的代码中的错误,以便从 JPrintUtilClass 接口中移动 非静态实例 methods/properties到 JPrintUtil 接口(并且可能对同一单元中的许多其他接口执行相同的操作)。那么上面的代码应该可以工作了。