在 java 中覆盖 class 的静态块

Over riding the static block of a class in java

我正在尝试为某些设备扩展 driver 的功能。我不想更改 driver 的代码,但我想通过扩展 drivers.The driver class 的现有代码来添加功能 static 块 定义了大部分变量。我需要在 driver class 的静态块中添加更多变量,而不更改原始静态块(可能是继承或其他方式) driver class 是:

    package postilion.vfsc5000;


import java.io.PrintStream;
import java.util.Hashtable;
import postespos.core.message.Validator;
import postespos.core.message.stream.*;


public class VfSC5000Response extends StreamMessage
{
    public static class Field extends VfSC5000Request.Field
    {

        public static final String VERSION = "Application version";
        public static final String MTD = "Msg Type delimiter";
        public static final String TRACK_1 = "Track 1";
        public static final String TRACK_2 = "Track 2";
        public static final String TRACK_3 = "Track 3";
        public static final String RSP_CODE = "Response code";
        public static final String AID = "Application ID";
        public static final String PREF_NAME = "Preferred name";
        public static final String APP_LABEL = "Application label";
        public static final String CARDHOLDER_NAME = "Cardholder name";
        public static final String TRACK2_EQUIV = "Track 2 equivalent";
        public static final String PAN = "PAN";
        public static final String EXPIRY_DATE = "Expiry date";
        public static final String PAN_SEQUENCE = "PAN sequence number";
        public static final String AUTH_STATUS = "Authentication status";
        public static final String SIGN = "Sign";
        public static final String TVR = "TVR";
        public static final String TSI = "TSI";
        public static final String AUTH_RSP = "Authorisation response";
        public static final String CID = "Cryptogram information data";
        public static final String VALUE = "Value";
        public static final String VALUES = "Values";
        public static final String SCRIPT_RESULT = "Script result";
        public static final String SCRIPT_RESULTS = "Script results";
        public static final String OPERATION_STATUS = "Operation Status";
        public static final String ICC_PRESENCE = "ICC Presence";
        public static final String KEYPRESS = "Key pressed";
        public static final String FKI = "Function Key Indicator";
        public static final String PIN_LENGTH = "Pin Length";
        public static final String PIN_BLOCK_FORMAT = "Pin Block Format";
        public static final String PIN_BLOCK = "Pin Block";
        public static final String MK_ADDR_RSP = "MK present response";

        public Field()
        {
        }
    }

    public static class PacketRspCode
    {

        public static final String _00_SUCCESSFUL = "00";
        public static final String _01_INVALID_CMD = "01";
        public static final String _02_INVALID_DATA_FORMAT = "02";
        public static final String _03_MORE_PACKETS = "03";

    public static final String _04_PREV_STEP_MISSING = "04";
    public static final String _05_INVALID_CONFIG = "05";
    public static final String _06_TIMEOUT = "06";
    public static final String _07_TIMER_ERROR = "07";
    public static final String _08_CANCELLED = "08";
    public static final String _09_COMM_FAILURE = "09";
    public static final String _10_CHIP_RDR_FAILURE = "10";
    public static final String _20_USE_CHIP_READER = "20";
    public static final String _21_USE_MAG_STRIPE = "21";
    public static final String _22_CHIP_ERROR = "22";
    public static final String _23_CARD_REMOVED = "23";
    public static final String _24_CARD_BLOCKED = "24";
    public static final String _25_CARD_NOT_SUPPORTED = "25";
    public static final String _26_INVALID_APP = "26";
    public static final String _27_DO_ABSENT = "27";
    public static final String _28_DO_REPEAT = "28";
    public static final String _29_INVALID_PIN = "29";
    public static final String _30_PIN_LAST_CHANCE = "30";
    public static final String _31_PIN_RETRYLIMIT = "31";
    public static final String _32_TLVCOLLECTION_FULL = "32";
    public static final String _33_TLVFORMAT = "33";
    public static final String _34_INVALID_PDOL = "34";
    public static final String _35_INVALID_CDOL = "35";
    public static final String _36_INVALID_TDOL = "36";
    public static final String _37_INVALID_DDOL = "37";
    public static final String _38_INVALID_SDOL = "38";
    public static final String _39_AID_LIST_FULL = "39";
    public static final String _40_PSE_NOT_FOUND = "40";
    public static final String _41_ICC_DATA_MISSING = "41";
    public static final String _42_CANDIDATELIST_EMPTY = "42";
    public static final String _43_APDU_FORMAT = "43";
    public static final String _44_HASH_FAILED = "44";
    public static final String _45_BAD_TRACK2 = "45";
    public static final String _46_CERTIFICATE_EXPIRED = "46";
    public static final String _47_DIFF_AVN_ERR = "47";
    public static final String _48_SERVICE_NOT_ALLOWED = "48";
    public static final String _49_APP_NOTYET_EFFECTIVE = "49";
    public static final String _50_APP_EXPIRED = "50";
    public static final String _51_LOWER_LMT_EXCEED = "51";
    public static final String _52_UPPER_LMT_EXCEED = "52";
    public static final String _53_CVM_FAILED = "53";
    public static final String _54_UNRECOGNIZED_CVM = "54";
    public static final String _55_BAD_DATA_FORMAT = "55";
    public static final String _56_BAD_HASHALGO = "56";
    public static final String _57_BAD_IPKALGO = "57";
    public static final String _58_INVALID_LENGTH = "58";
    public static final String _59_TAG_NOTFOUND = "59";
    public static final String _60_INVALID_OFFSET = "60";
    public static final String _61_BAD_COMMAND = "61";
    public static final String _62_TAG_ALREADY_PRESENT = "62";
    public static final String _63_READ_RECORD_FAILED = "63";
    public static final String _64_EXPLICIT_SELEC_REQD = "64";
    public static final String _65_COND_NOT_SATISFIED = "65";
    public static final String _66_CSN_FAILURE = "66";
    public static final String _67_BAD_SLOT = "67";
    public static final String _68_BAD_LEN = "68";
    public static final String _69_NO_MEM = "69";
    public static final String _70_CAPK_ERROR = "70";
    public static final String _71_PIN_CONFIG_ERR = "71";
    public static final String _72_EST_TAB_ERR = "72";
    public static final String _73_MVT_TAB_ERR = "73";
    public static final String _74_SCRIPT_ERROR = "74";
    public static final String _75_LOG_ERROR = "75";
    public static final String _76_COMBINED_DDA_AC_GEN_REQD = "76";
    public static final String _77_COMBINED_DDA_AC_GEN_FAILED = "77";
    public static final String _78_CARD_INSERTED = "78";
    public static final String _97_UNRECOG_RETURN = "97";
    public static final String _98_UNEXPECTED_RETURN = "98";
    public static final String _99_FAIL = "99";

    public PacketRspCode()
    {
    }
}

public static class CtrlChar
{

    public static final char ETX = 3;
    public static final char FS = 28;

    public CtrlChar()
    {
    }
}

public static final class PacketType extends VfSC5000Request.PacketType
{

    public static final String _71_TRSFR_PIN_BLOCK = "71";
    public static final String _81_MSR_DATA = "81";

    public PacketType()
    {
    }
}


public VfSC5000Response()
{
    super(512, stream);
}

public static void main(String args[])
{
    try
    {
        VfSC5000ResponseModification vf_rsp = new VfSC5000ResponseModification();
        System.out.println(vf_rsp.describeStructure());
        vf_rsp.fromMsg("C2000008E5A1C24265C64788");
        System.out.println(vf_rsp);
        vf_rsp.fromMsg("C2000008E5A1C24265C6478800706010A03A4000000205070025800003010302003E0B0C0002084000122004EF482FC800400000090");
        System.out.println(vf_rsp);
        System.out.println(vf_rsp.getField("Response code"));
    }
    catch(Exception e)
    {
        e.printStackTrace();
    }
}

private static IStreamFormatter stream;
static final int MAX_LEN = 512;
protected static Hashtable pkt_rsp_code_ht;

static 
{
    StreamFormatterContainer msg = new StreamFormatterContainer();
    IStreamFormatter packet_type_2_byte = new StreamFormatterFieldFixed("Packet Type 2-byte", Validator.getAn(), 2);
    IStreamFormatter mtd = new StreamFormatterFieldFixed("Msg Type delimiter", ".");
    IStreamFormatter address = new StreamFormatterFieldFixed("Master Key Address", Validator.getN(), 1);
    IStreamFormatter key = new StreamFormatterFieldVar("Key", Validator.getHex(), 48, true);
    StreamFormatterContainer pkt_02 = new StreamFormatterContainer();
    pkt_02.add(address);
    pkt_02.add(key);
    StreamFormatterContainer pkt_04 = new StreamFormatterContainer();
    IStreamFormatter rsp = new StreamFormatterFieldFixed("MK present response", Validator.getAn(), 1);
    pkt_04.add(rsp);
    StreamFormatterContainer pkt_08 = new StreamFormatterContainer();
    pkt_08.add(rsp);
    StreamFormatterContainer pkt_13 = new StreamFormatterContainer();
    IStreamFormatter version = new StreamFormatterFieldFixed("Application version", Validator.getAns(), 32);
    pkt_13.add(version);
    StreamFormatterContainer pkt_71 = new StreamFormatterContainer();
    IStreamFormatter function_key_indicator = new StreamFormatterFieldFixed("Function Key Indicator", Validator.getN(), 1);
    IStreamFormatter pin_length = new StreamFormatterFieldFixed("Pin Length", Validator.getN(), 2);
    IStreamFormatter pin_block_format = new StreamFormatterFieldFixed("Pin Block Format", Validator.getN(), 2);
    IStreamFormatter pin_block = new StreamFormatterFieldVar("Pin Block", Validator.getHex(), 16, false);
    pkt_71.add(mtd);
    pkt_71.add(function_key_indicator);
    pkt_71.add(pin_length);
    pkt_71.add(pin_block_format);
    pkt_71.add(pin_block);
    StreamFormatterContainer pkt_72 = new StreamFormatterContainer();
    pkt_72.add(new StreamFormatterFieldFixed("Response code", Validator.getN(), 2));
    StreamFormatterContainer pkt_81 = new StreamFormatterContainer();
    IStreamFormatter track2 = new StreamFormatterFieldVar("Track 2", Validator.getAns(), 40, false, '4');
    IStreamFormatter track1 = new StreamFormatterFieldVar("Track 1", Validator.getAns(), 79, false, '4');
    IStreamFormatter track3 = new StreamFormatterFieldVar("Track 3", Validator.getAns(), 107, false, '4');
    pkt_81.add(mtd);
    pkt_81.add(track2);
    pkt_81.add(track1);
    pkt_81.add(track3);
    StreamFormatterContainer pkt_poll = new StreamFormatterContainer();
    Hashtable pkt_2_ht = new Hashtable();
    pkt_2_ht.put("02", pkt_02);
    pkt_2_ht.put("04", pkt_04);
    pkt_2_ht.put("08", pkt_08);
    pkt_2_ht.put("13", pkt_13);
    pkt_2_ht.put("81", pkt_81);
    pkt_2_ht.put("71", pkt_71);
    pkt_2_ht.put("72", pkt_72);
    pkt_2_ht.put("ZZ", pkt_poll);
    IStreamFormatter msg_pkt_2_select = new StreamFormatterCase("Packet Type 2-byte", pkt_2_ht, null);
    StreamFormatterContainer msg_2_byte = new StreamFormatterContainer();
    msg_2_byte.add(packet_type_2_byte);
    msg_2_byte.add(msg_pkt_2_select);
    IStreamFormatter packet_type_3_byte = new StreamFormatterFieldFixed("Packet Type 3-byte", Validator.getAn(), 3);
    IStreamFormatter rsp_code = new StreamFormatterFieldFixed("Response code", Validator.getN(), 2);
    StreamFormatterContainer no_rsp = new StreamFormatterContainer();
    no_rsp.add(rsp_code);
    StreamFormatterContainer pkt_c00 = new StreamFormatterContainer();
    IStreamFormatter aid = new VfStreamFormatterFieldVarHex("Application ID", Validator.getHex(), new VfLengthFormatter(3, 16), false);
    IStreamFormatter pref_name = new VfStreamFormatterFieldVarHex("Preferred name", Validator.getHex(), new VfLengthFormatter(3, 16), false);
    IStreamFormatter app_label = new VfStreamFormatterFieldVarHex("Application label", Validator.getHex(), new VfLengthFormatter(3, 16), false);
    StreamFormatterContainer c00_rsp = new StreamFormatterContainer();
    c00_rsp.add(rsp_code);
    c00_rsp.add(aid);
    c00_rsp.add(pref_name);
    c00_rsp.add(app_label);
    IStreamFormatter c00_peek = new StreamFormatterPeek(0, "00", null, c00_rsp, no_rsp, "Application ID", c00_rsp, no_rsp);
    pkt_c00.add(c00_peek);
    StreamFormatterContainer pkt_c01 = new StreamFormatterContainer();
    IStreamFormatter service_code = new VfStreamFormatterFieldVarHex("Service code", Validator.getHex(), new VfLengthFormatter(3, 3), false);
    IStreamFormatter cardholder_name = new VfStreamFormatterFieldVarHex("Cardholder name", Validator.getAns(), new VfLengthFormatter(3, 26), false);
    IStreamFormatter track2_equiv = new VfStreamFormatterFieldVarHex("Track 2 equivalent", Validator.getHex(), new VfLengthFormatter(3, 37), false);
    IStreamFormatter pan = new VfStreamFormatterFieldVarHex("PAN", Validator.getHex(), new VfLengthFormatter(3, 19), false);
    IStreamFormatter expiry_date = new VfStreamFormatterFieldVarHex("Expiry date", Validator.getHex(), new VfLengthFormatter(3, 4), false);
    IStreamFormatter pan_seq = new VfStreamFormatterFieldVarHex("PAN sequence number", Validator.getHex(), new VfLengthFormatter(3, 3), false);
    IStreamFormatter auth_status = new StreamFormatterFieldFixed("Authentication status", Validator.getN(), 1);
    StreamFormatterContainer c01_rsp = new StreamFormatterContainer();
    c01_rsp.add(rsp_code);
    c01_rsp.add(aid);
    c01_rsp.add(pref_name);
    c01_rsp.add(app_label);
    c01_rsp.add(service_code);
    c01_rsp.add(cardholder_name);
    c01_rsp.add(track2_equiv);
    c01_rsp.add(pan);
    c01_rsp.add(expiry_date);
    c01_rsp.add(pan_seq);
    c01_rsp.add(auth_status);
    IStreamFormatter c01_peek = new StreamFormatterPeek(0, "00", null, c01_rsp, no_rsp, "PAN", c01_rsp, no_rsp);
    pkt_c01.add(c01_peek);
    StreamFormatterContainer pkt_c02 = new StreamFormatterContainer();
    IStreamFormatter sign = new StreamFormatterFieldFixed("Sign", Validator.getN(), 1);
    IStreamFormatter tvr = new VfStreamFormatterFieldVarHex("TVR", Validator.getHex(), new VfLengthFormatter(3, 5), false);
    IStreamFormatter tsi = new VfStreamFormatterFieldVarHex("TSI", Validator.getHex(), new VfLengthFormatter(3, 16), false);
    StreamFormatterContainer c02_rsp = new StreamFormatterContainer();
    c02_rsp.add(rsp_code);
    c02_rsp.add(sign);
    c02_rsp.add(tvr);
    c02_rsp.add(tsi);
    IStreamFormatter c02_peek = new StreamFormatterPeek(0, "00", null, c02_rsp, no_rsp, "TVR", c02_rsp, no_rsp);
    pkt_c02.add(c02_peek);
    StreamFormatterContainer pkt_c03 = new StreamFormatterContainer();
    IStreamFormatter cid = new VfStreamFormatterFieldVarHex("Cryptogram information data", Validator.getHex(), new VfLengthFormatter(3, 1), false);
    IStreamFormatter auth_rsp = new VfStreamFormatterFieldVarHex("Authorisation response", Validator.getHex(), new VfLengthFormatter(3, 2), false);
    StreamFormatterContainer c03_rsp = new StreamFormatterContainer();
    c03_rsp.add(rsp_code);
    c03_rsp.add(cid);
    c03_rsp.add(auth_rsp);
    IStreamFormatter c03_peek = new StreamFormatterPeek(0, "00", null, c03_rsp, no_rsp, "Cryptogram information data", c03_rsp, no_rsp);
    pkt_c03.add(c03_peek);
    StreamFormatterContainer pkt_c04 = new StreamFormatterContainer();
    IStreamFormatter num_scripts = new StreamFormatterFieldFixed("Number of scripts", Validator.getN(), 2);
    IStreamFormatter script_result = new StreamFormatterFieldFixed("Script result", Validator.getAn(), 10);
    IStreamFormatter script_results = new StreamFormatterRepeat("Script results", 5, script_result);
    StreamFormatterContainer c04_rsp = new StreamFormatterContainer();
    c04_rsp.add(rsp_code);
    c04_rsp.add(cid);
    c04_rsp.add(auth_rsp);
    c04_rsp.add(num_scripts);
    c04_rsp.add(script_results);
    IStreamFormatter c04_peek = new StreamFormatterPeek(0, "00", null, c04_rsp, no_rsp, "Cryptogram information data", c04_rsp, no_rsp);
    pkt_c04.add(c04_peek);
    StreamFormatterContainer pkt_c11 = new StreamFormatterContainer();
    pkt_c11.add(rsp_code);
    StreamFormatterContainer pkt_c19 = new StreamFormatterContainer();
    pkt_c19.add(rsp_code);
    StreamFormatterContainer pkt_c20 = new StreamFormatterContainer();
    IStreamFormatter value = new VfStreamFormatterFieldVarHex("Value", Validator.getHex(), new VfLengthFormatter(3, 999), false);
    StreamFormatterContainer value_container = new StreamFormatterContainer();
    value_container.add(value);
    StreamFormatterRepeat values = new StreamFormatterRepeat("Values", 10, value_container);
    StreamFormatterContainer c20_rsp = new StreamFormatterContainer();
    pkt_c20.add(rsp_code);
    pkt_c20.add(values);
    StreamFormatterContainer pkt_c22 = new StreamFormatterContainer();
    pkt_c22.add(rsp_code);
    StreamFormatterContainer pkt_c23 = new StreamFormatterContainer();
    pkt_c23.add(rsp_code);
    StreamFormatterContainer pkt_c24 = new StreamFormatterContainer();
    StreamFormatterContainer c24_rsp = new StreamFormatterContainer();
    c24_rsp.add(rsp_code);
    c24_rsp.add(cid);
    c24_rsp.add(auth_rsp);
    IStreamFormatter c24_peek = new StreamFormatterPeek(0, "00", null, c24_rsp, no_rsp, "Cryptogram information data", c24_rsp, no_rsp);
    pkt_c24.add(c24_peek);
    StreamFormatterContainer pkt_c25 = new StreamFormatterContainer();
    pkt_c25.add(rsp_code);
    StreamFormatterContainer pkt_c26 = new StreamFormatterContainer();
    IStreamFormatter key_press = new StreamFormatterFieldFixed("Key pressed", Validator.getAn(), 2);
    StreamFormatterContainer c26_rsp = new StreamFormatterContainer();
    c26_rsp.add(rsp_code);
    c26_rsp.add(key_press);
    IStreamFormatter c26_peek = new StreamFormatterPeek(0, "00", null, c26_rsp, no_rsp, "Key pressed", c26_rsp, no_rsp);
    pkt_c26.add(c26_peek);
    StreamFormatterContainer pkt_i02 = new StreamFormatterContainer();
    IStreamFormatter operation_status = new StreamFormatterFieldFixed("Operation Status", Validator.getN(), 1);
    pkt_i02.add(operation_status);
    StreamFormatterContainer pkt_i05 = new StreamFormatterContainer();
    IStreamFormatter presence_result = new StreamFormatterFieldFixed("ICC Presence", Validator.getN(), 1);
    pkt_i05.add(presence_result);
    StreamFormatterContainer pkt_d03 = new StreamFormatterContainer();
    pkt_d03.add(new StreamFormatterFieldFixed("Response code", Validator.getN(), 2));
    pkt_d03.add(new StreamFormatterFieldFixed("number of fields", Validator.getN(), 3));
    pkt_d03.add(new StreamFormatterFieldFixed("length", Validator.getN(), 3));
    pkt_d03.add(new StreamFormatterFieldVar("fields", Validator.getAns(), 497, true));
    StreamFormatterContainer pkt_d04 = new StreamFormatterContainer();
    pkt_d04.add(new StreamFormatterFieldFixed("Response code", Validator.getN(), 2));
    pkt_d04.add(new StreamFormatterFieldFixed("record number", Validator.getN(), 3));
    StreamFormatterContainer pkt_d05 = new StreamFormatterContainer();
    pkt_d05.add(new StreamFormatterFieldFixed("Response code", Validator.getN(), 2));
    StreamFormatterContainer pkt_d06 = new StreamFormatterContainer();
    pkt_d06.add(new StreamFormatterFieldFixed("Response code", Validator.getN(), 2));
    Hashtable pkt_3_ht = new Hashtable();
    pkt_3_ht.put("C00", pkt_c00);
    pkt_3_ht.put("C01", pkt_c01);
    pkt_3_ht.put("C02", pkt_c02);
    pkt_3_ht.put("C03", pkt_c03);
    pkt_3_ht.put("C04", pkt_c04);
    pkt_3_ht.put("C11", pkt_c11);
    pkt_3_ht.put("C19", pkt_c19);
    pkt_3_ht.put("C20", pkt_c20);
    pkt_3_ht.put("C22", pkt_c22);
    pkt_3_ht.put("C23", pkt_c23);
    pkt_3_ht.put("C24", pkt_c24);
    pkt_3_ht.put("C25", pkt_c25);
    pkt_3_ht.put("C26", pkt_c26);
    pkt_3_ht.put("I02", pkt_i02);
    pkt_3_ht.put("I05", pkt_i05);
    pkt_3_ht.put("D03", pkt_d03);
    pkt_3_ht.put("D04", pkt_d04);
    pkt_3_ht.put("D06", pkt_d06);
    IStreamFormatter msg_pkt_3_select = new StreamFormatterCase("Packet Type 3-byte", pkt_3_ht, null);
    StreamFormatterContainer msg_3_byte = new StreamFormatterContainer();
    msg_3_byte.add(packet_type_3_byte);
    msg_3_byte.add(msg_pkt_3_select);
    IStreamFormatter c_msg_select = new StreamFormatterPeek(0, "C", null, msg_3_byte, msg_2_byte, "Packet Type 3-byte", msg_3_byte, msg_2_byte);
    IStreamFormatter i_msg_select = new StreamFormatterPeek(0, "I", null, msg_3_byte, c_msg_select, "Packet Type 3-byte", msg_3_byte, c_msg_select);
    IStreamFormatter d_msg_select = new StreamFormatterPeek(0, "D", null, msg_3_byte, i_msg_select, "Packet Type 3-byte", msg_3_byte, i_msg_select);
    msg.add(d_msg_select);
    stream = msg;
    pkt_rsp_code_ht = new Hashtable();
    pkt_rsp_code_ht.put("00", "OPERATION SUCCESSFUL");
    pkt_rsp_code_ht.put("01", "INVALID COMMAND CODE");
    pkt_rsp_code_ht.put("02", "INVALID DATA FORMAT");
    pkt_rsp_code_ht.put("03", "RESPONSE HAS MORE PACKETS");
    pkt_rsp_code_ht.put("04", "PREVIOUS STEP MISSING");
    pkt_rsp_code_ht.put("05", "INVALID_CONFIG");
    pkt_rsp_code_ht.put("06", "TIMEOUT");
    pkt_rsp_code_ht.put("07", "TIMER_ERROR");
    pkt_rsp_code_ht.put("08", "CANCELLED");
    pkt_rsp_code_ht.put("09", "COMM_FAILURE");
    pkt_rsp_code_ht.put("10", "CHIP_RDR_FAILURE");
    pkt_rsp_code_ht.put("20", "USE_CHIP_READER");
    pkt_rsp_code_ht.put("21", "USE_MAG_STRIPE");
    pkt_rsp_code_ht.put("22", "CHIP_ERROR");
    pkt_rsp_code_ht.put("23", "CARD_REMOVED");
    pkt_rsp_code_ht.put("24", "CARD_BLOCKED");
    pkt_rsp_code_ht.put("25", "CARD_NOT_SUPPORTED");
    pkt_rsp_code_ht.put("26", "INVALID_APP");
    pkt_rsp_code_ht.put("27", "DO_ABSENT");
    pkt_rsp_code_ht.put("28", "DO_REPEAT");
    pkt_rsp_code_ht.put("29", "INVALID_PIN");
    pkt_rsp_code_ht.put("30", "PIN_LAST_CHANCE");
    pkt_rsp_code_ht.put("31", "PIN_RETRYLIMIT");
    pkt_rsp_code_ht.put("32", "TLVCOLLECTION_FULL");
    pkt_rsp_code_ht.put("33", "TLVFORMAT");
    pkt_rsp_code_ht.put("34", "INVALID_PDOL");
    pkt_rsp_code_ht.put("35", "INVALID_CDOL");
    pkt_rsp_code_ht.put("36", "INVALID_TDOL");
    pkt_rsp_code_ht.put("37", "INVALID_DDOL");
    pkt_rsp_code_ht.put("38", "INVALID_SDOL");
    pkt_rsp_code_ht.put("39", "AID_LIST_FULL");
    pkt_rsp_code_ht.put("40", "PSE_NOT_FOUND");
    pkt_rsp_code_ht.put("41", "ICC_DATA_MISSING");
    pkt_rsp_code_ht.put("42", "CANDIDATELIST_EMPTY");
    pkt_rsp_code_ht.put("43", "APDU_FORMAT");
    pkt_rsp_code_ht.put("44", "HASH_FAILED");
    pkt_rsp_code_ht.put("45", "BAD_TRACK2");
    pkt_rsp_code_ht.put("46", "CERTIFICATE_EXPIRED");
    pkt_rsp_code_ht.put("47", "DIFF_AVN_ERR");
    pkt_rsp_code_ht.put("48", "SERVICE_NOT_ALLOWED");
    pkt_rsp_code_ht.put("49", "APP_NOTYET_EFFECTIVE");
    pkt_rsp_code_ht.put("50", "APP_EXPIRED");
    pkt_rsp_code_ht.put("51", "LOWER_LMT_EXCEED");
    pkt_rsp_code_ht.put("52", "UPPER_LMT_EXCEED");
    pkt_rsp_code_ht.put("53", "CVM_FAILED");
    pkt_rsp_code_ht.put("54", "UNRECOGNIZED_CVM");
    pkt_rsp_code_ht.put("55", "BAD_DATA_FORMAT");
    pkt_rsp_code_ht.put("56", "BAD_HASHALGO");
    pkt_rsp_code_ht.put("57", "BAD_IPKALGO");
    pkt_rsp_code_ht.put("58", "INVALID_LENGTH");
    pkt_rsp_code_ht.put("59", "TAG_NOTFOUND");
    pkt_rsp_code_ht.put("60", "INVALID_OFFSET");
    pkt_rsp_code_ht.put("61", "BAD_COMMAND");
    pkt_rsp_code_ht.put("62", "TAG_ALREADY_PRESENT");
    pkt_rsp_code_ht.put("63", "READ_RECORD_FAILED");
    pkt_rsp_code_ht.put("64", "EXPLICIT_SELEC_REQD");
    pkt_rsp_code_ht.put("65", "COND_NOT_SATISFIED");
    pkt_rsp_code_ht.put("66", "CSN_FAILURE");
    pkt_rsp_code_ht.put("67", "BAD_SLOT");
    pkt_rsp_code_ht.put("68", "BAD_LEN");
    pkt_rsp_code_ht.put("69", "NO_MEM");
    pkt_rsp_code_ht.put("70", "CAPK_ERROR");
    pkt_rsp_code_ht.put("71", "PIN_CONFIG_ERR");
    pkt_rsp_code_ht.put("72", "EST_TAB_ERR");
    pkt_rsp_code_ht.put("73", "MVT_TAB_ERR");
    pkt_rsp_code_ht.put("74", "SCRIPT_ERROR");
    pkt_rsp_code_ht.put("75", "LOG_ERROR");
    pkt_rsp_code_ht.put("76", "COMBINED_DDA_AC_GEN_REQD");
    pkt_rsp_code_ht.put("77", "COMBINED_DDA_AC_GEN_FAILED");
    pkt_rsp_code_ht.put("78", "CARD_INSERTED");
    pkt_rsp_code_ht.put("97", "UNRECOG_RETURN");
    pkt_rsp_code_ht.put("98", "UNEXPECTED_RETURN");
    pkt_rsp_code_ht.put("99", "FAIL");
}
}

如果你看到 driver class 的静态块有一个 object 叫做 pkt_3_ht,我有在这个 object 中再添加一个字段 ,我必须向这个静态块添加更多 objects..

请建议我在不触及此 drivers class 的情况下超越此静态块的方法。 我已经尝试用 driver class 扩展我的 class 并在我的 class 中添加静态块和我需要的额外 objects,但是静态块我的 class 从未被调用。

不胜感激

难以置信的困难。您不能使用子 class 覆盖静态初始值设定项,因此您的选择是:

  1. Copy/paste 将代码转换为您完全控制的新 class。
  2. 使用像 Javassist 这样的库在编译或 运行 时重写 class 的字节码。由于这是一个静态初始化程序,您可能必须在加载 class 时重新编写字节代码,这更没有乐趣。

另请参阅有关静态初始值设定项行为的问题:Behavior of static blocks with inheritance