Package limelight.java

Source Code of limelight.java.PlayerClassLoader

//- Copyright © 2008-2011 8th Light, Inc. All Rights Reserved.
//- Limelight and all included source files are distributed under terms of the MIT License.

package limelight.java;

import limelight.Context;
import limelight.io.StreamReader;

public class PlayerClassLoader extends ClassLoader
{
  private String classpath;

  public PlayerClassLoader(String classpath)
  {
    super();
    this.classpath = classpath;
  }

  @Override
  protected Class<?> findClass(String name) throws ClassNotFoundException
  {
    String path = classpath + "/" + name.replace('.', '/') + ".class";
    if(Context.fs().exists(path))
    {
      StreamReader reader = new StreamReader(Context.fs().inputStream(path));
      byte[] classBytes = reader.readAllBytes();
      reader.close();
      return defineClass(name, classBytes, 0, classBytes.length);
    }
    else
      throw new ClassNotFoundException(name);
  }

  public String getClasspath()
  {
    return classpath;
  }

  public void setClasspath(String classpath)
  {
    this.classpath = classpath;
  }
}
TOP

Related Classes of limelight.java.PlayerClassLoader

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.