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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T20:02:54+00:00 2026-05-27T20:02:54+00:00

Class<?> clazz = loadClass( Test ); Method printSomething = clazz.getDeclaredMethod( printSomething ); printSomething.invoke( clazz

  • 0
Class<?> clazz = loadClass( "Test" );
Method printSomething = clazz.getDeclaredMethod( "printSomething" );
printSomething.invoke( clazz );

I’m trying to figure out how to do this in Scala. I’m guessing I’m missing something simple with the way Scala handles reflection.

val clazz = loadClass("Test")
val printSomething = clazz.getDeclaredMethod("printSomething")

printSomething.invoke(clazz)

My main question: Is the Any object the same as Class<?> in Java?

  • 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-27T20:02:55+00:00Added an answer on May 27, 2026 at 8:02 pm

    Any is not the same as Class<?> in Java.

    The Any type is a Scala alternative to Java’s Object with extensions: in difference to Java’s Object it is a supertype to literally everything in Scala, including primitives.

    The Class[_] (short for Class[Any]) is the same type as Java’s Class<?>, namely it is the way Java’s Class<?> is presented in Scala. Instances of type Class in Scala as much as in Java provide the basic reflection capabilities over the type provided as its generic parameter. I.e. an instance of Class[Something] provides the standard Java’s reflection API over class Something. You can use it the same way you do in Java. To get that instance you call the standard method classOf[Something] or instanceOfSomething.getClass.

    Extended reflection capabilities primarily targeted at the solution of the type erasure issue are coming with Scala 2.10, pretty stable snapshot versions of which you can always download. This extended API is provided thru the object scala.reflect.runtime.Mirror. There’s not much documentation on it in the internet yet, but you can find some decent information here on StackOverflow.

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

Sidebar

Related Questions

I have this method signature: public int nrOfEntities(Class<? extends MailConfirmation> clazz, User user, String
From time to time I see something like this: class Clazz { private int
Why doesn't this code compile? public boolean isOf(Class clazz, Object obj){ if(obj instanceof clazz){
Does code like this (potentially) violate the iPhone Developer License Agreement? Class clazz =
For example, is there a way to find out that this class has a
I have a code like this: protected <T> T doSomething(String someParam, Class<T> clazz) {
I would like an explanation of difference for example between this declaration: class Clazz(param1:
I have the following methods: public <T> T fromJson( Reader jsonData, Class<T> clazz )
When using DataContractJsonSerializer to serialize a dictionary, like so: [CollectionDataContract] public class Clazz :
I'm using Javassist to generate a class foo , with method bar , but

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.