Ejemplo n.º 1
0
  public void paint(Graphics g) {
    g.drawRect(0, 0, getSize().width - 1, getSize().height - 1);
    FontMetrics metrics = getFontMetrics(g.getFont());
    int lineHeight = metrics.getHeight() + 2;
    int line = 1;
    g.drawString("Start Class loader test...", 1, lineHeight * (line++));

    try {
      SystemProperties.setProperty("microedition.platform", "MicroEmulator-Test");

      PreporcessorClassLoader cl =
          new PreporcessorClassLoader(PreporcessorTest.class.getClassLoader());
      cl.disableClassLoad(SystemProperties.class);
      cl.disableClassLoad(ResourceLoader.class);
      ResourceLoader.classLoader = cl;

      cl.addClassURL(PreporcessorTest.TEST_CLASS);

      g.drawString("ClassLoader created...", 1, lineHeight * (line++));

      Class instrumentedClass = cl.loadClass(PreporcessorTest.TEST_CLASS);
      Runnable instrumentedInstance = (Runnable) instrumentedClass.newInstance();
      instrumentedInstance.run();

      g.drawString("Looks good!", 1, lineHeight * (line++));

    } catch (Throwable e) {

      g.drawString("Error " + e.toString(), 1, lineHeight * (line++));

      e.printStackTrace();
    }
  }