Lines 38-43
Link Here
|
38 |
import java.util.Set; |
38 |
import java.util.Set; |
39 |
import java.util.logging.Level; |
39 |
import java.util.logging.Level; |
40 |
import java.util.logging.Logger; |
40 |
import java.util.logging.Logger; |
|
|
41 |
import org.netbeans.Module; |
42 |
import org.netbeans.core.startup.Main; |
41 |
import org.openide.modules.ModuleInfo; |
43 |
import org.openide.modules.ModuleInfo; |
42 |
import org.openide.util.Mutex; |
44 |
import org.openide.util.Mutex; |
43 |
|
45 |
|
Lines 53-95
Link Here
|
53 |
|
55 |
|
54 |
private Hacks() {} |
56 |
private Hacks() {} |
55 |
|
57 |
|
56 |
public static Object getModule (ModuleInfo info) { |
58 |
public static Module getModule (ModuleInfo info) { |
57 |
Object module = null; |
59 |
return Main.getModuleSystem().getManager().get(info.getCodeNameBase()); |
58 |
try { |
|
|
59 |
Class clazz = Class.forName ("org.netbeans.core.startup.Main", |
60 |
false, |
61 |
Thread.currentThread().getContextClassLoader ()); |
62 |
assert clazz != null : "Class org.netbeans.core.startup.Main found."; |
63 |
|
64 |
Method getModuleSystemMethod = clazz.getMethod ("getModuleSystem"); |
65 |
assert getModuleSystemMethod != null : "Method getModuleSystem() found."; |
66 |
getModuleSystemMethod.setAccessible (true); |
67 |
|
68 |
Object moduleSystem = getModuleSystemMethod.invoke (null); |
69 |
assert moduleSystem != null : "Method getModuleSystem() returns ModuleSystem."; |
70 |
|
71 |
clazz = moduleSystem.getClass (); |
72 |
Method getManager = clazz.getMethod ("getManager"); |
73 |
assert getManager != null : "Method getManager() found."; |
74 |
getManager.setAccessible (true); |
75 |
|
76 |
Object mgr = getManager.invoke (moduleSystem); |
77 |
assert mgr != null : "Method getManager() returns ModuleManager."; |
78 |
|
79 |
clazz = mgr.getClass (); |
80 |
Method getModule = clazz.getMethod ("get", String.class); |
81 |
assert getModule != null : "Method get(String codeName) found."; |
82 |
getModule.setAccessible (true); |
83 |
|
84 |
module = getModule.invoke (mgr, info.getCodeNameBase ()); |
85 |
//assert module != null : "Method ModuleManager.get(" + info.getCodeNameBase () + ") returns Module."; |
86 |
|
87 |
} catch (Exception x) { |
88 |
err.log (Level.INFO, x.getMessage (), x); |
89 |
} |
90 |
|
91 |
err.log (Level.FINE, "ModuleInfo [" + info.getCodeName () + "/" + info.getSpecificationVersion() + " has module " + module); |
92 |
return module; |
93 |
} |
60 |
} |
94 |
|
61 |
|
95 |
public static boolean isValid (ModuleInfo info) { |
62 |
public static boolean isValid (ModuleInfo info) { |
Lines 196-227
Link Here
|
196 |
|
163 |
|
197 |
err.log (Level.FINE, "Return new ModuleHistory (" + jar + "): " + moduleHistory); |
164 |
err.log (Level.FINE, "Return new ModuleHistory (" + jar + "): " + moduleHistory); |
198 |
return moduleHistory; |
165 |
return moduleHistory; |
199 |
} |
|
|
200 |
|
201 |
public static String messageForProblem (ModuleInfo info, Object problem) { |
202 |
// NbProblemDisplayer.messageForProblem (Module m, Object problem) |
203 |
String res = null; |
204 |
try { |
205 |
Class clazz = Class.forName ("org.netbeans.core.startup.NbProblemDisplayer", |
206 |
false, |
207 |
Thread.currentThread ().getContextClassLoader ()); |
208 |
assert clazz != null : "Class org.netbeans.core.startup.NbProblemDisplayer found."; |
209 |
|
210 |
Method messageForProblemM = clazz.getMethod ("messageForProblem", Class.forName ("org.netbeans.Module"), Object.class); |
211 |
messageForProblemM.setAccessible (true); |
212 |
assert getModule (info) != null; |
213 |
Object resO = messageForProblemM.invoke (null, getModule (info), problem); |
214 |
|
215 |
assert resO == null || resO instanceof String; |
216 |
|
217 |
res = resO == null ? null : (String) resO; |
218 |
|
219 |
} catch (Exception x) { |
220 |
err.log (Level.INFO, x.getMessage (), x); |
221 |
} |
222 |
|
223 |
err.log (Level.FINE, "messageForProblem (" + info + ", " + problem + ") returns " + res); |
224 |
return res; |
225 |
} |
166 |
} |
226 |
|
167 |
|
227 |
public static ModuleManager getModuleManager () { |
168 |
public static ModuleManager getModuleManager () { |