You've already forked linux-packaging-mono
Imported Upstream version 3.10.0
Former-commit-id: 172c8e3c300b39d5785c7a3e8dfb08ebdbc1a99b
This commit is contained in:
@@ -1,40 +0,0 @@
|
||||
/*
|
||||
Copyright (C) 2011 Jeroen Frijters
|
||||
|
||||
This software is provided 'as-is', without any express or implied
|
||||
warranty. In no event will the authors be held liable for any damages
|
||||
arising from the use of this software.
|
||||
|
||||
Permission is granted to anyone to use this software for any purpose,
|
||||
including commercial applications, and to alter it and redistribute it
|
||||
freely, subject to the following restrictions:
|
||||
|
||||
1. The origin of this software must not be misrepresented; you must not
|
||||
claim that you wrote the original software. If you use this software
|
||||
in a product, an acknowledgment in the product documentation would be
|
||||
appreciated but is not required.
|
||||
2. Altered source versions must be plainly marked as such, and must not be
|
||||
misrepresented as being the original software.
|
||||
3. This notice may not be removed or altered from any source distribution.
|
||||
|
||||
Jeroen Frijters
|
||||
jeroen@frijters.net
|
||||
|
||||
*/
|
||||
package sun.management;
|
||||
|
||||
import ikvm.internal.NotYetImplementedError;
|
||||
import java.io.File;
|
||||
|
||||
public class FileSystemImpl extends FileSystem
|
||||
{
|
||||
public boolean supportsFileSecurity(File f)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
public boolean isAccessUserOnly(File f)
|
||||
{
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
}
|
||||
@@ -1,214 +0,0 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2008, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
package sun.management;
|
||||
|
||||
import ikvm.internal.NotYetImplementedError;
|
||||
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import javax.management.openmbean.OpenType;
|
||||
import javax.management.openmbean.SimpleType;
|
||||
import javax.management.openmbean.TabularType;
|
||||
import javax.management.openmbean.TabularData;
|
||||
import javax.management.openmbean.TabularDataSupport;
|
||||
import javax.management.openmbean.CompositeType;
|
||||
import javax.management.openmbean.CompositeData;
|
||||
import javax.management.openmbean.CompositeDataSupport;
|
||||
import javax.management.openmbean.OpenDataException;
|
||||
import com.sun.management.GcInfo;
|
||||
|
||||
/**
|
||||
* Helper class to build composite data.
|
||||
*/
|
||||
public class GcInfoBuilder {
|
||||
private final GarbageCollectorMXBean gc;
|
||||
private final String[] poolNames;
|
||||
private String[] allItemNames;
|
||||
|
||||
// GC-specific composite type:
|
||||
// Each GarbageCollectorMXBean may have different GC-specific attributes
|
||||
// the CompositeType for the GcInfo could be different.
|
||||
private CompositeType gcInfoCompositeType;
|
||||
|
||||
// GC-specific items
|
||||
private final int gcExtItemCount;
|
||||
private final String[] gcExtItemNames;
|
||||
private final String[] gcExtItemDescs;
|
||||
private final char[] gcExtItemTypes;
|
||||
|
||||
GcInfoBuilder(GarbageCollectorMXBean gc, String[] poolNames) {
|
||||
this.gc = gc;
|
||||
this.poolNames = poolNames;
|
||||
this.gcExtItemCount = getNumGcExtAttributes(gc);
|
||||
this.gcExtItemNames = new String[gcExtItemCount];
|
||||
this.gcExtItemDescs = new String[gcExtItemCount];
|
||||
this.gcExtItemTypes = new char[gcExtItemCount];
|
||||
|
||||
// Fill the information about extension attributes
|
||||
fillGcAttributeInfo(gc, gcExtItemCount, gcExtItemNames,
|
||||
gcExtItemTypes, gcExtItemDescs);
|
||||
|
||||
// lazily build the CompositeType for the GcInfo
|
||||
// including the GC-specific extension attributes
|
||||
this.gcInfoCompositeType = null;
|
||||
}
|
||||
|
||||
GcInfo getLastGcInfo() {
|
||||
MemoryUsage[] usageBeforeGC = new MemoryUsage[poolNames.length];
|
||||
MemoryUsage[] usageAfterGC = new MemoryUsage[poolNames.length];
|
||||
Object[] values = new Object[gcExtItemCount];
|
||||
|
||||
return getLastGcInfo0(gc, gcExtItemCount, values, gcExtItemTypes,
|
||||
usageBeforeGC, usageAfterGC);
|
||||
}
|
||||
|
||||
public String[] getPoolNames() {
|
||||
return poolNames;
|
||||
}
|
||||
|
||||
int getGcExtItemCount() {
|
||||
return gcExtItemCount;
|
||||
}
|
||||
|
||||
// Returns the CompositeType for the GcInfo including
|
||||
// the extension attributes
|
||||
synchronized CompositeType getGcInfoCompositeType() {
|
||||
if (gcInfoCompositeType != null)
|
||||
return gcInfoCompositeType;
|
||||
|
||||
// First, fill with the attributes in the GcInfo
|
||||
String[] gcInfoItemNames = GcInfoCompositeData.getBaseGcInfoItemNames();
|
||||
OpenType[] gcInfoItemTypes = GcInfoCompositeData.getBaseGcInfoItemTypes();
|
||||
int numGcInfoItems = gcInfoItemNames.length;
|
||||
|
||||
int itemCount = numGcInfoItems + gcExtItemCount;
|
||||
allItemNames = new String[itemCount];
|
||||
String[] allItemDescs = new String[itemCount];
|
||||
OpenType[] allItemTypes = new OpenType[itemCount];
|
||||
|
||||
System.arraycopy(gcInfoItemNames, 0, allItemNames, 0, numGcInfoItems);
|
||||
System.arraycopy(gcInfoItemNames, 0, allItemDescs, 0, numGcInfoItems);
|
||||
System.arraycopy(gcInfoItemTypes, 0, allItemTypes, 0, numGcInfoItems);
|
||||
|
||||
// Then fill with the extension GC-specific attributes, if any.
|
||||
if (gcExtItemCount > 0) {
|
||||
fillGcAttributeInfo(gc, gcExtItemCount, gcExtItemNames,
|
||||
gcExtItemTypes, gcExtItemDescs);
|
||||
System.arraycopy(gcExtItemNames, 0, allItemNames,
|
||||
numGcInfoItems, gcExtItemCount);
|
||||
System.arraycopy(gcExtItemDescs, 0, allItemDescs,
|
||||
numGcInfoItems, gcExtItemCount);
|
||||
for (int i = numGcInfoItems, j = 0; j < gcExtItemCount; i++, j++) {
|
||||
switch (gcExtItemTypes[j]) {
|
||||
case 'Z':
|
||||
allItemTypes[i] = SimpleType.BOOLEAN;
|
||||
break;
|
||||
case 'B':
|
||||
allItemTypes[i] = SimpleType.BYTE;
|
||||
break;
|
||||
case 'C':
|
||||
allItemTypes[i] = SimpleType.CHARACTER;
|
||||
break;
|
||||
case 'S':
|
||||
allItemTypes[i] = SimpleType.SHORT;
|
||||
break;
|
||||
case 'I':
|
||||
allItemTypes[i] = SimpleType.INTEGER;
|
||||
break;
|
||||
case 'J':
|
||||
allItemTypes[i] = SimpleType.LONG;
|
||||
break;
|
||||
case 'F':
|
||||
allItemTypes[i] = SimpleType.FLOAT;
|
||||
break;
|
||||
case 'D':
|
||||
allItemTypes[i] = SimpleType.DOUBLE;
|
||||
break;
|
||||
default:
|
||||
throw new AssertionError(
|
||||
"Unsupported type [" + gcExtItemTypes[i] + "]");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
CompositeType gict = null;
|
||||
try {
|
||||
final String typeName =
|
||||
"sun.management." + gc.getName() + ".GcInfoCompositeType";
|
||||
|
||||
gict = new CompositeType(typeName,
|
||||
"CompositeType for GC info for " +
|
||||
gc.getName(),
|
||||
allItemNames,
|
||||
allItemDescs,
|
||||
allItemTypes);
|
||||
} catch (OpenDataException e) {
|
||||
// shouldn't reach here
|
||||
throw Util.newException(e);
|
||||
}
|
||||
gcInfoCompositeType = gict;
|
||||
|
||||
return gcInfoCompositeType;
|
||||
}
|
||||
|
||||
synchronized String[] getItemNames() {
|
||||
if (allItemNames == null) {
|
||||
// initialize when forming the composite type
|
||||
getGcInfoCompositeType();
|
||||
}
|
||||
return allItemNames;
|
||||
}
|
||||
|
||||
// Retrieve information about extension attributes
|
||||
private /*native*/ int getNumGcExtAttributes(GarbageCollectorMXBean gc){
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
private /*native*/ void fillGcAttributeInfo(GarbageCollectorMXBean gc,
|
||||
int numAttributes,
|
||||
String[] attributeNames,
|
||||
char[] types,
|
||||
String[] descriptions){
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the last GcInfo
|
||||
*
|
||||
* @param gc GarbageCollectorMXBean that the gc info is associated with.
|
||||
* @param numExtAtts number of extension attributes
|
||||
* @param extAttValues Values of extension attributes to be filled.
|
||||
* @param before Memory usage before GC to be filled.
|
||||
* @param after Memory usage after GC to be filled.
|
||||
*/
|
||||
private /*native*/ GcInfo getLastGcInfo0(GarbageCollectorMXBean gc,
|
||||
int numExtAtts,
|
||||
Object[] extAttValues,
|
||||
char[] extAttTypes,
|
||||
MemoryUsage[] before,
|
||||
MemoryUsage[] after){
|
||||
throw new NotYetImplementedError();
|
||||
}
|
||||
}
|
||||
@@ -338,7 +338,7 @@ final class NetFileSystemProvider extends AbstractFileSystemProvider
|
||||
}
|
||||
}
|
||||
|
||||
return FileChannelImpl.open(open(npath.path, mode, rights, share, options), npath.path, read, write, append, null);
|
||||
return FileChannelImpl.open(open(npath.path, mode, rights, share, options), read, write, append, null);
|
||||
}
|
||||
|
||||
private static FileDescriptor open(String path, int mode, int rights, int share, int options) throws IOException
|
||||
@@ -1104,7 +1104,7 @@ final class NetFileSystemProvider extends AbstractFileSystemProvider
|
||||
|
||||
public long size()
|
||||
{
|
||||
return info.get_Length();
|
||||
return info.get_Exists() ? info.get_Length() : 0;
|
||||
}
|
||||
|
||||
public boolean isArchive()
|
||||
@@ -1140,7 +1140,12 @@ final class NetFileSystemProvider extends AbstractFileSystemProvider
|
||||
if (false) throw new cli.System.ArgumentException();
|
||||
if (false) throw new cli.System.IO.FileNotFoundException();
|
||||
if (false) throw new cli.System.IO.IOException();
|
||||
return new DosFileAttributesImpl(new FileInfo(path));
|
||||
FileInfo info = new FileInfo(path);
|
||||
if (!info.get_Exists())
|
||||
{
|
||||
throw new NoSuchFileException(path);
|
||||
}
|
||||
return new DosFileAttributesImpl(info);
|
||||
}
|
||||
catch (cli.System.IO.FileNotFoundException _)
|
||||
{
|
||||
@@ -1193,6 +1198,10 @@ final class NetFileSystemProvider extends AbstractFileSystemProvider
|
||||
info.set_Attributes(cli.System.IO.FileAttributes.wrap(info.get_Attributes().Value & ~attr));
|
||||
}
|
||||
}
|
||||
catch (cli.System.IO.FileNotFoundException _)
|
||||
{
|
||||
throw new NoSuchFileException(path);
|
||||
}
|
||||
catch (cli.System.ArgumentException
|
||||
| cli.System.IO.IOException x)
|
||||
{
|
||||
|
||||
224
external/ikvm/openjdk/sun/reflect/annotation/AnnotationType.java
vendored
Normal file
224
external/ikvm/openjdk/sun/reflect/annotation/AnnotationType.java
vendored
Normal file
@@ -0,0 +1,224 @@
|
||||
/*
|
||||
* Copyright (c) 2003, 2013, Oracle and/or its affiliates. All rights reserved.
|
||||
* DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
|
||||
*
|
||||
* This code is free software; you can redistribute it and/or modify it
|
||||
* under the terms of the GNU General Public License version 2 only, as
|
||||
* published by the Free Software Foundation. Oracle designates this
|
||||
* particular file as subject to the "Classpath" exception as provided
|
||||
* by Oracle in the LICENSE file that accompanied this code.
|
||||
*
|
||||
* This code is distributed in the hope that it will be useful, but WITHOUT
|
||||
* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
|
||||
* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License
|
||||
* version 2 for more details (a copy is included in the LICENSE file that
|
||||
* accompanied this code).
|
||||
*
|
||||
* You should have received a copy of the GNU General Public License version
|
||||
* 2 along with this work; if not, write to the Free Software Foundation,
|
||||
* Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
|
||||
*
|
||||
* Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
|
||||
* or visit www.oracle.com if you need additional information or have any
|
||||
* questions.
|
||||
*/
|
||||
|
||||
package sun.reflect.annotation;
|
||||
|
||||
import sun.misc.JavaLangAccess;
|
||||
|
||||
import java.lang.annotation.*;
|
||||
import java.lang.reflect.*;
|
||||
import java.util.*;
|
||||
import java.security.AccessController;
|
||||
import java.security.PrivilegedAction;
|
||||
|
||||
/**
|
||||
* Represents an annotation type at run time. Used to type-check annotations
|
||||
* and apply member defaults.
|
||||
*
|
||||
* @author Josh Bloch
|
||||
* @since 1.5
|
||||
*/
|
||||
public class AnnotationType {
|
||||
/**
|
||||
* Member name -> type mapping. Note that primitive types
|
||||
* are represented by the class objects for the corresponding wrapper
|
||||
* types. This matches the return value that must be used for a
|
||||
* dynamic proxy, allowing for a simple isInstance test.
|
||||
*/
|
||||
private final Map<String, Class<?>> memberTypes;
|
||||
|
||||
/**
|
||||
* Member name -> default value mapping.
|
||||
*/
|
||||
private final Map<String, Object> memberDefaults;
|
||||
|
||||
/**
|
||||
* Member name -> Method object mapping. This (and its assoicated
|
||||
* accessor) are used only to generate AnnotationTypeMismatchExceptions.
|
||||
*/
|
||||
private final Map<String, Method> members;
|
||||
|
||||
/**
|
||||
* The retention policy for this annotation type.
|
||||
*/
|
||||
private final RetentionPolicy retention;
|
||||
|
||||
/**
|
||||
* Whether this annotation type is inherited.
|
||||
*/
|
||||
private final boolean inherited;
|
||||
|
||||
/**
|
||||
* Returns an AnnotationType instance for the specified annotation type.
|
||||
*
|
||||
* @throw IllegalArgumentException if the specified class object for
|
||||
* does not represent a valid annotation type
|
||||
*/
|
||||
public static AnnotationType getInstance(
|
||||
Class<? extends Annotation> annotationClass)
|
||||
{
|
||||
JavaLangAccess jla = sun.misc.SharedSecrets.getJavaLangAccess();
|
||||
AnnotationType result = jla.getAnnotationType(annotationClass); // volatile read
|
||||
if (result == null) {
|
||||
result = new AnnotationType(annotationClass);
|
||||
// try to CAS the AnnotationType: null -> result
|
||||
if (!jla.casAnnotationType(annotationClass, null, result)) {
|
||||
// somebody was quicker -> read it's result
|
||||
result = jla.getAnnotationType(annotationClass);
|
||||
assert result != null;
|
||||
}
|
||||
}
|
||||
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Sole constructor.
|
||||
*
|
||||
* @param annotationClass the class object for the annotation type
|
||||
* @throw IllegalArgumentException if the specified class object for
|
||||
* does not represent a valid annotation type
|
||||
*/
|
||||
private AnnotationType(final Class<? extends Annotation> annotationClass) {
|
||||
if (!annotationClass.isAnnotation())
|
||||
throw new IllegalArgumentException("Not an annotation type");
|
||||
|
||||
Method[] methods =
|
||||
AccessController.doPrivileged(new PrivilegedAction<Method[]>() {
|
||||
public Method[] run() {
|
||||
// Initialize memberTypes and defaultValues
|
||||
return annotationClass.getDeclaredMethods();
|
||||
}
|
||||
});
|
||||
|
||||
memberTypes = new HashMap<String,Class<?>>(methods.length+1, 1.0f);
|
||||
memberDefaults = new HashMap<String, Object>(0);
|
||||
members = new HashMap<String, Method>(methods.length+1, 1.0f);
|
||||
|
||||
for (Method method : methods) {
|
||||
if (method.getParameterTypes().length != 0)
|
||||
throw new IllegalArgumentException(method + " has params");
|
||||
String name = method.getName();
|
||||
Class<?> type = method.getReturnType();
|
||||
memberTypes.put(name, invocationHandlerReturnType(type));
|
||||
members.put(name, method);
|
||||
|
||||
Object defaultValue = method.getDefaultValue();
|
||||
if (defaultValue != null)
|
||||
memberDefaults.put(name, defaultValue);
|
||||
}
|
||||
|
||||
// Initialize retention, & inherited fields. Special treatment
|
||||
// of the corresponding annotation types breaks infinite recursion.
|
||||
if (annotationClass != Retention.class &&
|
||||
annotationClass != Inherited.class) {
|
||||
Retention ret = (Retention) annotationClass.getDeclaredAnnotation(Retention.class);
|
||||
retention = (ret == null ? RetentionPolicy.CLASS : ret.value());
|
||||
inherited = annotationClass.isAnnotationPresent(Inherited.class);
|
||||
}
|
||||
else {
|
||||
retention = RetentionPolicy.RUNTIME;
|
||||
inherited = false;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the type that must be returned by the invocation handler
|
||||
* of a dynamic proxy in order to have the dynamic proxy return
|
||||
* the specified type (which is assumed to be a legal member type
|
||||
* for an annotation).
|
||||
*/
|
||||
public static Class<?> invocationHandlerReturnType(Class<?> type) {
|
||||
// Translate primitives to wrappers
|
||||
if (type == byte.class)
|
||||
return Byte.class;
|
||||
if (type == char.class)
|
||||
return Character.class;
|
||||
if (type == double.class)
|
||||
return Double.class;
|
||||
if (type == float.class)
|
||||
return Float.class;
|
||||
if (type == int.class)
|
||||
return Integer.class;
|
||||
if (type == long.class)
|
||||
return Long.class;
|
||||
if (type == short.class)
|
||||
return Short.class;
|
||||
if (type == boolean.class)
|
||||
return Boolean.class;
|
||||
|
||||
// Otherwise, just return declared type
|
||||
return type;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns member types for this annotation type
|
||||
* (member name -> type mapping).
|
||||
*/
|
||||
public Map<String, Class<?>> memberTypes() {
|
||||
return memberTypes;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns members of this annotation type
|
||||
* (member name -> associated Method object mapping).
|
||||
*/
|
||||
public Map<String, Method> members() {
|
||||
return members;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the default values for this annotation type
|
||||
* (Member name -> default value mapping).
|
||||
*/
|
||||
public Map<String, Object> memberDefaults() {
|
||||
return memberDefaults;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the retention policy for this annotation type.
|
||||
*/
|
||||
public RetentionPolicy retention() {
|
||||
return retention;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns true if this this annotation type is inherited.
|
||||
*/
|
||||
public boolean isInherited() {
|
||||
return inherited;
|
||||
}
|
||||
|
||||
/**
|
||||
* For debugging.
|
||||
*/
|
||||
public String toString() {
|
||||
return "Annotation Type:\n" +
|
||||
" Member types: " + memberTypes + "\n" +
|
||||
" Member defaults: " + memberDefaults + "\n" +
|
||||
" Retention policy: " + retention + "\n" +
|
||||
" Inherited: " + inherited;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user