|
Lines 14-19
Link Here
|
| 14 |
import java.io.File; |
14 |
import java.io.File; |
| 15 |
import java.io.IOException; |
15 |
import java.io.IOException; |
| 16 |
import java.io.InputStream; |
16 |
import java.io.InputStream; |
|
|
17 |
import java.lang.reflect.Method; |
| 17 |
import java.net.URL; |
18 |
import java.net.URL; |
| 18 |
import java.net.URLConnection; |
19 |
import java.net.URLConnection; |
| 19 |
import java.util.ArrayList; |
20 |
import java.util.ArrayList; |
|
Lines 300-305
Link Here
|
| 300 |
*/ |
301 |
*/ |
| 301 |
private void initialize(Properties profile, ExecutionEnvironmentDescription description) throws CoreException { |
302 |
private void initialize(Properties profile, ExecutionEnvironmentDescription description) throws CoreException { |
| 302 |
String value = profile.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES); |
303 |
String value = profile.getProperty(Constants.FRAMEWORK_SYSTEMPACKAGES); |
|
|
304 |
if (value == null) { // Java 10 onwards calculate this on runtime. |
| 305 |
value = calculateVMPackages(); |
| 306 |
String[] systemPackages2 = value.split(","); //$NON-NLS-1$ |
| 307 |
System.out.println("total=" + systemPackages2.length); //$NON-NLS-1$ |
| 308 |
for (int i = 0; i < systemPackages2.length; i++) { |
| 309 |
System.out.println(systemPackages2[i]); |
| 310 |
|
| 311 |
} |
| 312 |
} |
| 303 |
if (value == null) { |
313 |
if (value == null) { |
| 304 |
// In Java-10 and beyond, we take systempackages list from |
314 |
// In Java-10 and beyond, we take systempackages list from |
| 305 |
// org.eclipse.pde.api.tools\system_packages\JavaSE-x-systempackages.profile |
315 |
// org.eclipse.pde.api.tools\system_packages\JavaSE-x-systempackages.profile |
|
Lines 651-656
Link Here
|
| 651 |
} |
661 |
} |
| 652 |
} |
662 |
} |
| 653 |
|
663 |
|
|
|
664 |
private String calculateVMPackages() { |
| 665 |
try { |
| 666 |
List<String> packages = new ArrayList<>(); |
| 667 |
Class<?> moduleLayerClass = Class.forName("java.lang.ModuleLayer"); //$NON-NLS-1$ |
| 668 |
Method boot = moduleLayerClass.getMethod("boot"); //$NON-NLS-1$ |
| 669 |
Method modules = moduleLayerClass.getMethod("modules"); //$NON-NLS-1$ |
| 670 |
Class<?> moduleClass = Class.forName("java.lang.Module"); //$NON-NLS-1$ |
| 671 |
Method getDescriptor = moduleClass.getMethod("getDescriptor"); //$NON-NLS-1$ |
| 672 |
Class<?> moduleDescriptorClass = Class.forName("java.lang.module.ModuleDescriptor"); //$NON-NLS-1$ |
| 673 |
Method exports = moduleDescriptorClass.getMethod("exports"); //$NON-NLS-1$ |
| 674 |
Class<?> exportsClass = Class.forName("java.lang.module.ModuleDescriptor$Exports"); //$NON-NLS-1$ |
| 675 |
Method targets = exportsClass.getMethod("targets"); //$NON-NLS-1$ |
| 676 |
Method source = exportsClass.getMethod("source"); //$NON-NLS-1$ |
| 677 |
|
| 678 |
Object bootLayer = boot.invoke(null); |
| 679 |
Set<?> bootModules = (Set<?>) modules.invoke(bootLayer); |
| 680 |
for (Object m : bootModules) { |
| 681 |
Object descriptor = getDescriptor.invoke(m); |
| 682 |
for (Object export : (Set<?>) exports.invoke(descriptor)) { |
| 683 |
String pkg = (String) source.invoke(export); |
| 684 |
if (((Set<?>) targets.invoke(export)).isEmpty() && !pkg.startsWith("java.")) { //$NON-NLS-1$ |
| 685 |
packages.add(pkg); |
| 686 |
} |
| 687 |
} |
| 688 |
} |
| 689 |
Collections.sort(packages); |
| 690 |
StringBuilder result = new StringBuilder(); |
| 691 |
for (String pkg : packages) { |
| 692 |
if (result.length() != 0) { |
| 693 |
result.append(',').append(' '); |
| 694 |
} |
| 695 |
result.append(pkg); |
| 696 |
} |
| 697 |
return result.toString(); |
| 698 |
} catch (Exception e) { |
| 699 |
//equinoxContainer.getLogServices().log(EquinoxContainer.NAME, FrameworkLogEntry.ERROR, "Error determining system packages.", e); //$NON-NLS-1$ |
| 700 |
return null; |
| 701 |
} |
| 702 |
} |
| 654 |
/** |
703 |
/** |
| 655 |
* Returns all of the visible dependent components from the current state |
704 |
* Returns all of the visible dependent components from the current state |
| 656 |
* |
705 |
* |