Java 8 based functions. @since 2.5.0 @deprecated Use org.codehaus.groovy.vmplugin.v17.Java17 instead. Groovy 6.0 requires JDK 17+.
| 76 | * @deprecated Use {@link org.codehaus.groovy.vmplugin.v17.Java17} instead. Groovy 6.0 requires JDK 17+. |
| 77 | */ |
| 78 | @Deprecated(since = "6.0.0", forRemoval = true) |
| 79 | public class Java8 implements VMPlugin { |
| 80 | |
| 81 | private static final Method[] EMPTY_METHOD_ARRAY = new Method[0]; |
| 82 | private static final Annotation[] EMPTY_ANNOTATION_ARRAY = new Annotation[0]; |
| 83 | |
| 84 | |
| 85 | /** |
| 86 | * Configures a type-variable definition node from its bounds. |
| 87 | * |
| 88 | * @param base the placeholder class node |
| 89 | * @param bounds the upper bounds of the type variable |
| 90 | * @return the configured generics type |
| 91 | */ |
| 92 | public static GenericsType configureTypeVariableDefinition(final ClassNode base, final ClassNode[] bounds) { |
| 93 | ClassNode redirect = base.redirect(); |
| 94 | base.setRedirect(null); |
| 95 | GenericsType gt; |
| 96 | if (bounds == null || bounds.length == 0) { |
| 97 | gt = new GenericsType(base); |
| 98 | } else { |
| 99 | // GROOVY-10756: fix erasure -- ResolveVisitor#resolveGenericsHeader |
| 100 | if (!ClassHelper.isObjectType(bounds[0])) redirect = bounds[0]; |
| 101 | gt = new GenericsType(base, bounds, null); |
| 102 | gt.setName(base.getName()); |
| 103 | gt.setPlaceholder(true); |
| 104 | } |
| 105 | base.setRedirect(redirect); |
| 106 | return gt; |
| 107 | } |
| 108 | |
| 109 | /** |
| 110 | * Creates a placeholder class node that references a type variable by name. |
| 111 | * |
| 112 | * @param name the type-variable name |
| 113 | * @return the placeholder class node |
| 114 | */ |
| 115 | public static ClassNode configureTypeVariableReference(final String name) { |
| 116 | ClassNode cn = ClassHelper.makeWithoutCaching(name); |
| 117 | cn.setGenericsPlaceHolder(true); |
| 118 | ClassNode cn2 = ClassHelper.makeWithoutCaching(name); |
| 119 | cn2.setGenericsPlaceHolder(true); |
| 120 | |
| 121 | cn.setGenericsTypes(new GenericsType[]{new GenericsType(cn2)}); |
| 122 | cn.setRedirect(ClassHelper.OBJECT_TYPE); |
| 123 | return cn; |
| 124 | } |
| 125 | |
| 126 | private static ClassNode configureClass(final Class<?> c) { |
| 127 | if (c.isPrimitive()) { |
| 128 | return ClassHelper.make(c); |
| 129 | } else { |
| 130 | return ClassHelper.makeWithoutCaching(c, false); |
| 131 | } |
| 132 | } |
| 133 | |
| 134 | //-------------------------------------------------------------------------- |
| 135 |
nothing calls this directly
no outgoing calls
no test coverage detected