001/*
002 * Copyright 2002-2020 the original author or authors.
003 *
004 * Licensed under the Apache License, Version 2.0 (the "License");
005 * you may not use this file except in compliance with the License.
006 * You may obtain a copy of the License at
007 *
008 *      https://www.apache.org/licenses/LICENSE-2.0
009 *
010 * Unless required by applicable law or agreed to in writing, software
011 * distributed under the License is distributed on an "AS IS" BASIS,
012 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
013 * See the License for the specific language governing permissions and
014 * limitations under the License.
015 */
016
017package org.springframework.core;
018
019/**
020 * Default implementation of the {@link ParameterNameDiscoverer} strategy interface,
021 * using the Java 8 standard reflection mechanism (if available), and falling back
022 * to the ASM-based {@link LocalVariableTableParameterNameDiscoverer} for checking
023 * debug information in the class file.
024 *
025 * <p>If a Kotlin reflection implementation is present,
026 * {@link KotlinReflectionParameterNameDiscoverer} is added first in the list and
027 * used for Kotlin classes and interfaces. When compiling or running as a GraalVM
028 * native image, the {@code KotlinReflectionParameterNameDiscoverer} is not used.
029 *
030 * <p>Further discoverers may be added through {@link #addDiscoverer(ParameterNameDiscoverer)}.
031 *
032 * @author Juergen Hoeller
033 * @author Sebastien Deleuze
034 * @author Sam Brannen
035 * @since 4.0
036 * @see StandardReflectionParameterNameDiscoverer
037 * @see LocalVariableTableParameterNameDiscoverer
038 * @see KotlinReflectionParameterNameDiscoverer
039 */
040public class DefaultParameterNameDiscoverer extends PrioritizedParameterNameDiscoverer {
041
042        public DefaultParameterNameDiscoverer() {
043                if (KotlinDetector.isKotlinReflectPresent() && !GraalDetector.inImageCode()) {
044                        addDiscoverer(new KotlinReflectionParameterNameDiscoverer());
045                }
046                addDiscoverer(new StandardReflectionParameterNameDiscoverer());
047                addDiscoverer(new LocalVariableTableParameterNameDiscoverer());
048        }
049
050}