Class Injector

java.lang.Object
com.cedarsoftware.io.reflect.Injector

public class Injector extends Object
High-performance field injection utility that automatically adapts to different JDK versions for optimal performance and compatibility.

This class uses the java.version system property to automatically detect the JDK version and select the most appropriate field injection strategy:

  • JDK 8-16: Uses Field.set() for final fields and MethodHandle for regular fields
  • JDK 17+: Uses VarHandle for improved performance and module system compatibility

The JDK version detection and strategy selection is completely automatic and requires no user configuration. This ensures optimal performance across all supported JDK versions while maintaining compatibility with the module system introduced in JDK 9+.

System Properties Used:

  • java.version - Automatically detected by the JVM to determine injection strategy
Author:
Ken Partlow ([email protected]) John DeRegnaucourt ([email protected])
Copyright (c) Cedar Software LLC

Licensed under the Apache License, Version 2.0 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at

License

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the License for the specific language governing permissions and limitations under the License.
  • Constructor Details

  • Method Details

    • create

      public static Injector create(Field field, String uniqueFieldName)
    • create

      public static Injector create(Field field, String methodName, String uniqueFieldName)
    • inject

      public void inject(Object object, Object value)
    • getType

      public Class<?> getType()
    • getName

      public String getName()
    • getGenericType

      public Type getGenericType()
    • getDisplayName

      public String getDisplayName()
    • getUniqueFieldName

      public String getUniqueFieldName()