UF.MICRO

当尝试使用已被释放的资源时,就会报告 UF(使用已释放)问题。UF.MICRO 警告表明尝试在 Java Micro Edition 对象已被关闭后使用它。

示例 1

复制
     class DBTestMidlet extends MIDlet {
 
         private Display display;
         private int nextRecordId;
 
         public DBTestMidlet() {
             display = Display.getDisplay(this);
 
             RecordStore store = null;
             try {
                 store = RecordStore.openRecordStore("TestStore", true);
                 nextRecordId = store.getNextRecordID();
             } catch (RecordStoreException e) {
                 handleException(e);
                 if (store != null) {
                     try {
                         store.closeRecordStore();
                     } catch (RecordStoreException e1) {
                         // ignore
                     }
                 }
             }
 
             try {
                 final String name = store.getName();
                 display.setCurrent(new TextBox("", "Connected to database: " + name, 6000, TextField.ANY));
             } catch (Exception e) {
                 handleException(e);
             }
         }
 
         private void handleException(Exception e) {
             display.setCurrent(new TextBox("Error", e.toString(), 60000, TextField.ANY));
         }
 
         public void startApp() {
         }
 
         public void pauseApp() {
         }
 
         public void destroyApp(boolean unconditional) {
         }
     }

针对第 44 行的代码段报告 UF.MICRO:在第 31 行引发 RecordStoreException 的情况下,在第 36 行将关闭 Java Micro Edition 记录存储,而在之后又尝试获取该记录存储的名称。