2
Copyright (C) 2007-2011 Jeroen Frijters
4
This software is provided 'as-is', without any express or implied
5
warranty. In no event will the authors be held liable for any damages
6
arising from the use of this software.
8
Permission is granted to anyone to use this software for any purpose,
9
including commercial applications, and to alter it and redistribute it
10
freely, subject to the following restrictions:
12
1. The origin of this software must not be misrepresented; you must not
13
claim that you wrote the original software. If you use this software
14
in a product, an acknowledgment in the product documentation would be
15
appreciated but is not required.
16
2. Altered source versions must be plainly marked as such, and must not be
17
misrepresented as being the original software.
18
3. This notice may not be removed or altered from any source distribution.
27
import ikvm.runtime.AssemblyClassLoader;
28
import java.io.IOException;
29
import java.net.MalformedURLException;
31
import java.security.AccessController;
32
import java.util.Enumeration;
34
import sun.nio.ch.Interruptible;
35
import sun.reflect.annotation.AnnotationType;
36
import sun.security.action.GetPropertyAction;
39
public class LangHelper
41
private static boolean addedSystemPackages;
43
private static void addSystemPackage(Map pkgMap)
45
// NOTE caller must have acquired lock on pkgMap
46
if (!addedSystemPackages)
48
addedSystemPackages = true;
49
String[] pkgs = AssemblyClassLoader.GetPackages(getBootstrapAssembly());
50
for (int i = 0; i < pkgs.length; i++)
54
VMSystemProperties.SPEC_TITLE, // specTitle
55
VMSystemProperties.SPEC_VERSION, // specVersion
56
VMSystemProperties.SPEC_VENDOR, // specVendor
57
"IKVM.NET OpenJDK", // implTitle
58
PropertyConstants.openjdk_version, // implVersion
59
"Oracle Corporation & others", // implVendor
61
null)); // class loader
66
/* this method gets called by Package.getSystemPackage() via a redefined method in map.xml */
67
static Package getSystemPackage(Map pkgs, String name)
71
addSystemPackage(pkgs);
72
return (Package)pkgs.get(name);
76
/* this method gets called by Package.getSystemPackages() via a redefined method in map.xml */
77
static Package[] getSystemPackages(Map pkgs)
81
addSystemPackage(pkgs);
82
return (Package[])pkgs.values().toArray(new Package[pkgs.size()]);
87
private static cli.System.Reflection.Assembly getBootstrapAssembly()
89
return ikvm.runtime.Util.getInstanceTypeFromClass(Object.class).get_Assembly();
92
static URL getBootstrapResource(String name)
94
return AssemblyClassLoader.getResource(null, getBootstrapAssembly(), name);
97
static Enumeration getBootstrapResources(String name) throws IOException
99
return AssemblyClassLoader.getResources(null, getBootstrapAssembly(), name);
102
public static sun.misc.JavaLangAccess getJavaLangAccess()
104
return new sun.misc.JavaLangAccess() {
105
public sun.reflect.ConstantPool getConstantPool(Class klass) {
108
public void setAnnotationType(Class klass, AnnotationType type) {
109
klass.setAnnotationType(type);
111
public AnnotationType getAnnotationType(Class klass) {
112
return klass.getAnnotationType();
114
public <E extends Enum<E>>
115
E[] getEnumConstantsShared(Class<E> klass) {
116
return klass.getEnumConstantsShared();
118
public void blockedOn(Thread t, Interruptible b) {
121
public void registerShutdownHook(int slot, boolean registerShutdownInProgress, Runnable hook) {
122
Shutdown.add(slot, registerShutdownInProgress, hook);
124
public int getStackTraceDepth(Throwable t) {
125
return t.getStackTraceDepth();
127
public StackTraceElement getStackTraceElement(Throwable t, int i) {
128
return t.getStackTraceElement(i);
130
public int getStringHash32(String string) {
131
return StringHelper.hash32(string);