Lab 8 : Advanced Topics

Introduction

In this last session we will overview some of the more advanced topics: debugging and dynamic class loading. The session will be mostly interactive.

Exercise 1: Debugging

Overview the debugging capability of Eclipse.

Exercise 2: Dynamic loading: basics

Classes in Java are loaded on demand. To verify that execute java with the command line argument -verbose:class. What do you see?

Exercise 3: Dynamic loading: reloading

In this exercise we will create a simple plugin infrastructure.

  1. Create a sample interface called IPlugin that will contain one method void printMessgage().
  2. Create two different plugin implementations PluginA and PluginB that both prints out a different message.
  3. Create a new class with main method that loads these plugins statically (not using reflection)
  4. Change the previous and load the classes dynamically using reflection. Compare the approaches? What is the difference? What does the other one allows us to do?
  5. What is the difference between Class.newInstance() and Constructor.newInstance?
  6. Dynamically reloads plugin at runtime.

Exercise 4: Apply the plugin mechanism in the Simulator

Could you extend the simulator in the way that you periodically (every second) scan a certain (hardcoded) directory plugins and every time there is a new class you load it and show it on the canvas. The only class that can appear there is an instance of AbstractCreatute.

Revision: r1.2 - 07 Dec 2012 - 11:02 - KrikavaFilip
Minfo > SoftEng1213 > SeLab8
Copyright © 1999-2017 by the contributing authors. All material on this collaboration platform is the property of the contributing authors.
Ideas, requests, problems regarding WIKIDeptinfo? Send feedback