我想了解Java代碼,該代碼在編譯該索引時出錯。我試圖找出它爲什麼會給出這個錯誤,但失敗了。任何人都可以幫助我,爲什麼這段代碼給索引出界錯誤?在Corba應用程序中出現索引超出限制的錯誤
try {
ORB orb = ORB.init(args, null);
POA rootpoa = POAHelper.narrow(orb
.resolve_initial_references("RootPOA"));
rootpoa.the_POAManager().activate();
ProfilerServant profilerServant = new ProfilerServant(args[4],
args[5].equals("true"));
org.omg.CORBA.Object ref = rootpoa
.servant_to_reference(profilerServant);
Profiler pref = ProfilerHelper.narrow(ref);
org.omg.CORBA.Object objRef = orb
.resolve_initial_references("NameService");
NamingContextExt ncRef = NamingContextExtHelper.narrow(objRef);
String name = "Profiler";
NameComponent path[] = ncRef.to_name(name);
ncRef.rebind(path, pref);
orb.run();
}
catch (Exception e) {
System.err.println("ERROR: " + e.getMessage());
e.printStackTrace(System.out);
}
}
這裏是ProfilerServant類 與構造
public class ProfilerServant extends ProfilerPOA {
boolean cacheEnabled;
ServerParser parser;
HashMap<String, Integer> songCache;
HashMap<String, User> userCache;
ProfilerServant(String fileName, boolean cacheEnabled) {
this.cacheEnabled = cacheEnabled;
parser = new ServerParser(fileName);
songCache = new HashMap<String, Integer>();
userCache = new HashMap<String, User>();
init();
}
你確定'args [4]'和'args [5]'在範圍內嗎? –
不知道。我現在是Java ..它的所有ProfilerServant類。 。 – Natalia
args []的範圍是什麼.. – Natalia