io.airlift:parameternames

Utility methods for fetching the parameter names for a method or constructor

License

License

GroupId

GroupId

io.airlift
ArtifactId

ArtifactId

parameternames
Last Version

Last Version

1.5
Release Date

Release Date

Type

Type

jar
Description

Description

Utility methods for fetching the parameter names for a method or constructor
Project URL

Project URL

https://github.com/airlift/parameternames
Source Code Management

Source Code Management

https://github.com/airlift/parameternames

Download parameternames

How to add to project

<!-- https://jarcasting.com/artifacts/io.airlift/parameternames/ -->
<dependency>
    <groupId>io.airlift</groupId>
    <artifactId>parameternames</artifactId>
    <version>1.5</version>
</dependency>
// https://jarcasting.com/artifacts/io.airlift/parameternames/
implementation 'io.airlift:parameternames:1.5'
// https://jarcasting.com/artifacts/io.airlift/parameternames/
implementation ("io.airlift:parameternames:1.5")
'io.airlift:parameternames:jar:1.5'
<dependency org="io.airlift" name="parameternames" rev="1.5">
  <artifact name="parameternames" type="jar" />
</dependency>
@Grapes(
@Grab(group='io.airlift', module='parameternames', version='1.5')
)
libraryDependencies += "io.airlift" % "parameternames" % "1.5"
[io.airlift/parameternames "1.5"]

Dependencies

There are no dependencies for this project. It is a standalone project that does not depend on any other jars.

Project Modules

There are no modules declared in this project.

Parameter Names

Maven Central Build Status

Parameter Names contains utility methods for fetching the parameter names for a method or constructor.

Java 8 added the ability to access the parameter names of a method or constructor, but this only works if the code was compiled with the Java 8 version of javac with the -parameters option enabled. This utility falls back to reading parameters from the debug symbols in the method bytecode for classes compiled without the -parameters option enabled. Note that this fallback will not work for interfaces, as interface methods do not have bytecode and thus do not have debug symbols.

Usage

Simply, pass java.lang.reflect.Method or java.lang.reflect.Constructor to ParameterNames.getParameterNames. For example:

    Method method = ParameterNames.class.getMethod("getParameterNames", Executable.class);
    List<String> parameterNames = ParameterNames.getParameterNames(method);

Parameter names are loaded in the following order:

  1. Java 8 reflection names created by javac with the -parameters option
  2. Bytecode debug symbols created by javac with the -g option
  3. Default name of argN where N is the index of the parameter starting from zero

Maven Dependency

<dependency>
    <groupId>io.airlift</groupId>
    <artifactId>parameternames</artifactId>
    <version>1.0</version>
</dependency>

License

Parameter Names is released under the Apache License, Version 2.0.

io.airlift

Versions

Version
1.5
1.4
1.3
1.2
1.1
1.0