0
我寫一個JUnit在那裏調用恆類,在這裏我們試圖訪問一個靜態最終名單錯誤的JUnit靜態最終名單
public static final List<String> SKIPPED_DIMENSION_LIST = new ArrayList<String>();
static{ SKIPPED_DIMENSION_LIST.add(PRODUCT_CATEGORY_DISPLAY);
SKIPPED_DIMENSION_LIST.add(PRODUCT_CATEGORY_SUB);
SKIPPED_DIMENSION_LIST.add(PRODUCT_CATEGORY_SUB_GROUP);
SKIPPED_DIMENSION_LIST.add(PRODUCT_CATEGORY_SUB_GROUP_ID);
SKIPPED_DIMENSION_LIST.add(PRODUCT_CATEGORY_ID);
SKIPPED_DIMENSION_LIST.add(PRODUCT_CATEGORY_GROUP_ID); }
現在,在訪問通過名單JUnit線程我得到這個錯誤。
java.lang.ExceptionInInitializerError
at java.lang.J9VMInternals.initialize(J9VMInternals.java:222)
at com.mns.commerce.searchnav.constants.MSEndecaConstants.<clinit>(MSEndecaConstants.java:169)
at java.lang.J9VMInternals.initializeImpl(Native Method)
at java.lang.J9VMInternals.initialize(J9VMInternals.java:200)
at com.mns.commerce.searchnav.utils.MSSearchResposeBOTransformer.getRefinementsDetails(MSSearchResposeBOTransformer.java:460)
at com.mns.commerce.searchnav.utils.MSSearchResposeBOTransformer.buildFacets(MSSearchResposeBOTransformer.java:362)
at com.mns.commerce.searchnav.utils.MSSearchResposeBOTransformer.populateResults(MSSearchResposeBOTransformer.java:106)
at com.mns.commerce.searchnavunit.test.MSSearchResposeBOTransformerTest.testPopulateResults(MSSearchResposeBOTransformerTest.java:97)
然而,如果靜態Enum
定義,而不是static final list
那麼它工作正常。任何想法爲什麼發生這種情況?
如果從列表聲明中刪除最終修飾符會發生什麼? – JamesB 2012-07-27 07:39:58
嘗試在靜態初始化器中的代碼周圍放置try/catch(Throwable t)塊,並查看它是否實際上拋出了某些描述的異常。這會給你一個更好的線索。 – 2012-07-27 08:52:41
有關於此的任何更新? – Sikorski 2012-07-27 08:54:44