< prev index next >

src/java.base/share/classes/java/lang/Class.java

Print this page


   1 /*
   2  * Copyright (c) 1994, 2018, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


3403         Constructor<U>[] out = arg.clone();
3404         ReflectionFactory fact = getReflectionFactory();
3405         for (int i = 0; i < out.length; i++) {
3406             out[i] = fact.copyConstructor(out[i]);
3407         }
3408         return out;
3409     }
3410 
3411     private native Field[]       getDeclaredFields0(boolean publicOnly);
3412     private native Method[]      getDeclaredMethods0(boolean publicOnly);
3413     private native Constructor<T>[] getDeclaredConstructors0(boolean publicOnly);
3414     private native Class<?>[]   getDeclaredClasses0();
3415 
3416     /**
3417      * Helper method to get the method name from arguments.
3418      */
3419     private String methodToString(String name, Class<?>[] argTypes) {
3420         StringBuilder sb = new StringBuilder();
3421         sb.append(getName() + "." + name + "(");
3422         if (argTypes != null) {
3423             Stream.of(argTypes).map(c -> {return (c == null) ? "null" : c.getName();}).
3424                 collect(Collectors.joining(","));
3425         }
3426         sb.append(")");
3427         return sb.toString();
3428     }
3429 
3430     /** use serialVersionUID from JDK 1.1 for interoperability */
3431     private static final long serialVersionUID = 3206093459760846163L;
3432 
3433 
3434     /**
3435      * Class Class is special cased within the Serialization Stream Protocol.
3436      *
3437      * A Class instance is written initially into an ObjectOutputStream in the
3438      * following format:
3439      * <pre>
3440      *      {@code TC_CLASS} ClassDescriptor
3441      *      A ClassDescriptor is a special cased serialization of
3442      *      a {@code java.io.ObjectStreamClass} instance.
3443      * </pre>
3444      * A new handle is generated for the initial time the class descriptor


   1 /*
   2  * Copyright (c) 1994, 2019, Oracle and/or its affiliates. All rights reserved.
   3  * DO NOT ALTER OR REMOVE COPYRIGHT NOTICES OR THIS FILE HEADER.
   4  *
   5  * This code is free software; you can redistribute it and/or modify it
   6  * under the terms of the GNU General Public License version 2 only, as
   7  * published by the Free Software Foundation.  Oracle designates this
   8  * particular file as subject to the "Classpath" exception as provided
   9  * by Oracle in the LICENSE file that accompanied this code.
  10  *
  11  * This code is distributed in the hope that it will be useful, but WITHOUT
  12  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
  13  * FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
  14  * version 2 for more details (a copy is included in the LICENSE file that
  15  * accompanied this code).
  16  *
  17  * You should have received a copy of the GNU General Public License version
  18  * 2 along with this work; if not, write to the Free Software Foundation,
  19  * Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA.
  20  *
  21  * Please contact Oracle, 500 Oracle Parkway, Redwood Shores, CA 94065 USA
  22  * or visit www.oracle.com if you need additional information or have any


3403         Constructor<U>[] out = arg.clone();
3404         ReflectionFactory fact = getReflectionFactory();
3405         for (int i = 0; i < out.length; i++) {
3406             out[i] = fact.copyConstructor(out[i]);
3407         }
3408         return out;
3409     }
3410 
3411     private native Field[]       getDeclaredFields0(boolean publicOnly);
3412     private native Method[]      getDeclaredMethods0(boolean publicOnly);
3413     private native Constructor<T>[] getDeclaredConstructors0(boolean publicOnly);
3414     private native Class<?>[]   getDeclaredClasses0();
3415 
3416     /**
3417      * Helper method to get the method name from arguments.
3418      */
3419     private String methodToString(String name, Class<?>[] argTypes) {
3420         StringBuilder sb = new StringBuilder();
3421         sb.append(getName() + "." + name + "(");
3422         if (argTypes != null) {
3423             sb.append(Stream.of(argTypes).map(c -> {return (c == null) ? "null" : c.getName();}).
3424                       collect(Collectors.joining(",")));
3425         }
3426         sb.append(")");
3427         return sb.toString();
3428     }
3429 
3430     /** use serialVersionUID from JDK 1.1 for interoperability */
3431     private static final long serialVersionUID = 3206093459760846163L;
3432 
3433 
3434     /**
3435      * Class Class is special cased within the Serialization Stream Protocol.
3436      *
3437      * A Class instance is written initially into an ObjectOutputStream in the
3438      * following format:
3439      * <pre>
3440      *      {@code TC_CLASS} ClassDescriptor
3441      *      A ClassDescriptor is a special cased serialization of
3442      *      a {@code java.io.ObjectStreamClass} instance.
3443      * </pre>
3444      * A new handle is generated for the initial time the class descriptor


< prev index next >