VMProxy.java 6.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141
  1. /* VMProxy.java -- VM interface for proxy class
  2. Copyright (C) 2005 Free Software Foundation, Inc.
  3. This file is part of GNU Classpath.
  4. GNU Classpath is free software; you can redistribute it and/or modify
  5. it under the terms of the GNU General Public License as published by
  6. the Free Software Foundation; either version 2, or (at your option)
  7. any later version.
  8. GNU Classpath is distributed in the hope that it will be useful, but
  9. WITHOUT ANY WARRANTY; without even the implied warranty of
  10. MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  11. General Public License for more details.
  12. You should have received a copy of the GNU General Public License
  13. along with GNU Classpath; see the file COPYING. If not, write to the
  14. Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
  15. 02110-1301 USA.
  16. Linking this library statically or dynamically with other modules is
  17. making a combined work based on this library. Thus, the terms and
  18. conditions of the GNU General Public License cover the whole
  19. combination.
  20. As a special exception, the copyright holders of this library give you
  21. permission to link this library with independent modules to produce an
  22. executable, regardless of the license terms of these independent
  23. modules, and to copy and distribute the resulting executable under
  24. terms of your choice, provided that you also meet, for each linked
  25. independent module, the terms and conditions of the license of that
  26. module. An independent module is a module which is not derived from
  27. or based on this library. If you modify this library, you may extend
  28. this exception to your version of the library, but you are not
  29. obligated to do so. If you do not wish to do so, delete this
  30. exception statement from your version. */
  31. package java.lang.reflect;
  32. final class VMProxy
  33. {
  34. /**
  35. * Set to true if the VM provides a native method to implement
  36. * Proxy.getProxyClass completely, including argument verification.
  37. * If this is true, HAVE_NATIVE_GET_PROXY_DATA and
  38. * HAVE_NATIVE_GENERATE_PROXY_CLASS should be false.
  39. * @see java.lang.reflect.Proxy
  40. */
  41. static boolean HAVE_NATIVE_GET_PROXY_CLASS = false;
  42. /**
  43. * Set to true if the VM provides a native method to implement
  44. * the first part of Proxy.getProxyClass: generation of the array
  45. * of methods to convert, and verification of the arguments.
  46. * If this is true, HAVE_NATIVE_GET_PROXY_CLASS should be false.
  47. * @see java.lang.reflect.Proxy
  48. */
  49. static boolean HAVE_NATIVE_GET_PROXY_DATA = false;
  50. /**
  51. * Set to true if the VM provides a native method to implement
  52. * the second part of Proxy.getProxyClass: conversion of an array of
  53. * methods into an actual proxy class.
  54. * If this is true, HAVE_NATIVE_GET_PROXY_CLASS should be false.
  55. * @see java.lang.reflect.Proxy
  56. */
  57. static boolean HAVE_NATIVE_GENERATE_PROXY_CLASS = true;
  58. /**
  59. * Optional native method to replace (and speed up) the pure Java
  60. * implementation of getProxyClass. Only needed if
  61. * VMProxy.HAVE_NATIVE_GET_PROXY_CLASS is true, this does the
  62. * work of both getProxyData and generateProxyClass with no
  63. * intermediate form in Java. The native code may safely assume that
  64. * this class must be created, and does not already exist.
  65. *
  66. * @param loader the class loader to define the proxy class in; null
  67. * implies the bootstrap class loader
  68. * @param interfaces the interfaces the class will extend
  69. * @return the generated proxy class
  70. * @throws IllegalArgumentException if the constraints for getProxyClass
  71. * were violated, except for problems with null
  72. * @throws NullPointerException if `interfaces' is null or contains
  73. * a null entry, or if handler is null
  74. * @see Configuration#HAVE_NATIVE_GET_PROXY_CLASS
  75. * @see #getProxyClass(ClassLoader, Class[])
  76. * @see #getProxyData(ClassLoader, Class[])
  77. * @see #generateProxyClass(ProxyData)
  78. */
  79. static Class getProxyClass(ClassLoader loader, Class[] interfaces)
  80. {
  81. return null;
  82. }
  83. /**
  84. * Optional native method to replace (and speed up) the pure Java
  85. * implementation of getProxyData. Only needed if
  86. * Configuration.HAVE_NATIVE_GET_PROXY_DATA is true. The native code
  87. * may safely assume that a new ProxyData object must be created which
  88. * does not duplicate any existing ones.
  89. *
  90. * @param loader the class loader to define the proxy class in; null
  91. * implies the bootstrap class loader
  92. * @param interfaces the interfaces the class will extend
  93. * @return all data that is required to make this proxy class
  94. * @throws IllegalArgumentException if the constraints for getProxyClass
  95. * were violated, except for problems with null
  96. * @throws NullPointerException if `interfaces' is null or contains
  97. * a null entry, or if handler is null
  98. * @see Configuration.HAVE_NATIVE_GET_PROXY_DATA
  99. * @see #getProxyClass(ClassLoader, Class[])
  100. * @see #getProxyClass(ClassLoader, Class[])
  101. * @see ProxyType#getProxyData()
  102. */
  103. static Proxy.ProxyData getProxyData(ClassLoader loader, Class[] interfaces)
  104. {
  105. return null;
  106. }
  107. /**
  108. * Optional native method to replace (and speed up) the pure Java
  109. * implementation of generateProxyClass. Only needed if
  110. * Configuration.HAVE_NATIVE_GENERATE_PROXY_CLASS is true. The native
  111. * code may safely assume that a new Class must be created, and that
  112. * the ProxyData object does not describe any existing class.
  113. *
  114. * @param loader the class loader to define the proxy class in; null
  115. * implies the bootstrap class loader
  116. * @param data the struct of information to convert to a Class. This
  117. * has already been verified for all problems except exceeding
  118. * VM limitations
  119. * @return the newly generated class
  120. * @throws IllegalArgumentException if VM limitations are exceeded
  121. * @see #getProxyClass(ClassLoader, Class[])
  122. * @see #getProxyClass(ClassLoader, Class[])
  123. * @see ProxyData#generateProxyClass(ClassLoader)
  124. */
  125. static native Class generateProxyClass(ClassLoader loader, Proxy.ProxyData data);
  126. }