Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 6209253
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 24, 20262026-05-24T05:57:04+00:00 2026-05-24T05:57:04+00:00

In Spring, the two following statements are, if I’m not mistaken, identical: @RequestParam(type) String

  • 0

In Spring, the two following statements are, if I’m not mistaken, identical:

@RequestParam("type") String type
@RequestParam String type

How can spring know the variable name of ‘type’ (second version). I was under the impression
that this information was removed from the class files unless compiled with
the -g flag (include debug information).

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-24T05:57:05+00:00Added an answer on May 24, 2026 at 5:57 am

    The short version of this is that apparently the parameter names are being compiled in, if they weren’t, you’d get an exception indicating that Spring MVC couldn’t deduce the parameter name. That is, parameter names aren’t always stored in the bytecode, but it seems like if they are, Spring will find them, if not, you need to specify them when you add the @RequestParam annotation.

    Other details are available on this similar question and it’s answers.


    In 3.0.5.RELEASE, these annotations are processed in HandlerMethodInvoker.resolveHandlerArguments and it appears that if no value is supplied, Spring uses RequestParam.value(). This can return the empty string.

    Further down, Spring uses HandlerMethodInvoker.resolveRequestParam, and inside there, if the parameter name is empty, it invokes HandlerMethodINvoker.getRequiredParameterName with MethodParameter methodParam as an argument:

    718     private String getRequiredParameterName(MethodParameter methodParam) {
    719     String name = methodParam.getParameterName();
    720     if (name == null) {
    721         throw new IllegalStateException(
    722                 "No parameter name specified for argument of type [" + methodParam.getParameterType().getName() +
    723                         "], and no parameter name information found in class file either.");
    724     }
    725     return name;
    726 }
    

    Note that here it tries to pull the information from methodParam, which, if we back up the tree, we see that resolveHandlerArguments actually creates a new MethodParameter for each argument that it processes. Inside MethodParameter, we can take a look at getParameterName():

    276 public String getParameterName() {
    277     if (this.parameterNameDiscoverer != null) {
    278         String[] parameterNames = (this.method != null ?
    279                 this.parameterNameDiscoverer.getParameterNames(this.method) :
    280                 this.parameterNameDiscoverer.getParameterNames(this.constructor));
    281         if (parameterNames != null) {
    282             this.parameterName = parameterNames[this.parameterIndex];
    283         }
    284         this.parameterNameDiscoverer = null;
    285     }
    286     return this.parameterName;
    287 }
    

    So this uses something called a ParameterNameDiscoverer, but this is an interface and my trace isn’t showing which implementation it’s using, there are a few. Looking at LocalVariableTableParameterNameDiscoverer.getParameterNames we end up calling a LocalVariableTableParameterNameDiscoverer.ParameterNameDiscoveringVisitor as part of an org.objectweb.asm.ClassReader, which as far as I can tell tries to read the parameter name out of the bytecode.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

What is the difference between these two following statements? String s = text; String
I want to combine the following two statements: select password from sys.user$ where name='SYSMAN';
please take a look at the two following c statements printf(a very long string);
Can someone tell me the difference the following two LINQ statements please? var ChkUnique
I have the following two classes: public class Address { public string AddressLine1 {
Consider the following situation: We have two Localizable.string files, one in en.lproj and one
Having the following classes, in two different assemblies: class Member { public string Label
Given the following simple example: List<string> list = new List<string>() { One, Two, Three,
I have two Spring proxies set up: <bean id=simpleBean class=org.springframework.aop.framework.ProxyFactoryBean> <property name=target> <ref local=simpleBeanTarget/>
Is there any difference in following two lines of code that compares the string

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.