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 110219
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T02:11:33+00:00 2026-05-11T02:11:33+00:00

Does creating an object using reflection rather than calling the class constructor result in

  • 0

Does creating an object using reflection rather than calling the class constructor result in any significant performance differences?

  • 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. 2026-05-11T02:11:34+00:00Added an answer on May 11, 2026 at 2:11 am

    Yes – absolutely. Looking up a class via reflection is, by magnitude, more expensive.

    Quoting Java’s documentation on reflection:

    Because reflection involves types that are dynamically resolved, certain Java virtual machine optimizations can not be performed. Consequently, reflective operations have slower performance than their non-reflective counterparts, and should be avoided in sections of code which are called frequently in performance-sensitive applications.

    Here’s a simple test I hacked up in 5 minutes on my machine, running Sun JRE 6u10:

    public class Main {      public static void main(String[] args) throws Exception     {         doRegular();         doReflection();     }      public static void doRegular() throws Exception     {         long start = System.currentTimeMillis();         for (int i=0; i<1000000; i++)         {             A a = new A();             a.doSomeThing();         }         System.out.println(System.currentTimeMillis() - start);     }      public static void doReflection() throws Exception     {         long start = System.currentTimeMillis();         for (int i=0; i<1000000; i++)         {             A a = (A) Class.forName('misc.A').newInstance();             a.doSomeThing();         }         System.out.println(System.currentTimeMillis() - start);     } } 

    With these results:

    35 // no reflection 465 // using reflection 

    Bear in mind the lookup and the instantiation are done together, and in some cases the lookup can be refactored away, but this is just a basic example.

    Even if you just instantiate, you still get a performance hit:

    30 // no reflection 47 // reflection using one lookup, only instantiating 

    Again, YMMV.

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

Sidebar

Ask A Question

Stats

  • Questions 91k
  • Answers 91k
  • Best Answers 0
  • User 1
  • Popular
  • Answers
  • Editorial Team

    How to approach applying for a job at a company ...

    • 7 Answers
  • Editorial Team

    How to handle personal stress caused by utterly incompetent and ...

    • 5 Answers
  • Editorial Team

    What is a programmer’s life like?

    • 5 Answers
  • Editorial Team
    Editorial Team added an answer 1) It is false because Java does not support multiple… May 11, 2026 at 6:20 pm
  • Editorial Team
    Editorial Team added an answer Try assertions: (?<=\S)\s+$ They're described nicely in PHP manual (they're… May 11, 2026 at 6:20 pm
  • Editorial Team
    Editorial Team added an answer Global variables are zero-initialized. Variables used in the context of… May 11, 2026 at 6:20 pm

Related Questions

I'm trying to wrap my head around reflection, so I decided to add plugin
Using C# .NET 2.0, I have a composite data class that does have the
I am new at Objective C. I am just trying to build an iphone
I was wondering if it is possible to include SVG content inside a panel

Trending Tags

analytics british company computer developers django employee employer english facebook french google interview javascript language life php programmer programs salary

Top Members

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.