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

  • SEARCH
  • Home
  • 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 910377
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 15, 20262026-05-15T17:02:02+00:00 2026-05-15T17:02:02+00:00

Since Scala 2.7.2 there is something called Manifest which is a workaround for Java’s

  • 0

Since Scala 2.7.2 there is something called Manifest which is a workaround for Java’s type erasure. But how does Manifest work exactly and why / when do you need to use it?

The blog post Manifests: Reified Types by Jorge Ortiz explains some of it, but it doesn’t explain how to use it together with context bounds.

Also, what is ClassManifest, what’s the difference with Manifest?

I have some code (part of a larger program, can’t easily include it here) that has some warnings with regard to type erasure; I suspect I can solve these by using manifests, but I’m not sure exactly how.

  • 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-15T17:02:02+00:00Added an answer on May 15, 2026 at 5:02 pm

    The compiler knows more information about types than the JVM runtime can easily represent. A Manifest is a way for the compiler to send an inter-dimensional message to the code at runtime about the type information that was lost.

    It isn’t clear if a Manifest would benefit the errors you are seeing without knowing more detail.

    One common use of Manifests is to have your code behave differently based on the static type of a collection. For example, what if you wanted to treat a List[String] differently from other types of a List:

     def foo[T](x: List[T])(implicit m: Manifest[T]) = {
        if (m <:< manifest[String])
          println("Hey, this list is full of strings")
        else
          println("Non-stringy list")
      }
      
      foo(List("one", "two")) // Hey, this list is full of strings
      foo(List(1, 2)) // Non-stringy list
      foo(List("one", 2)) // Non-stringy list
    

    A reflection-based solution to this would probably involve inspecting each element of the list.

    A context bound seems most suited to using type-classes in scala, and is well explained here by Debasish Ghosh:
    http://debasishg.blogspot.com/2010/06/scala-implicits-type-classes-here-i.html

    Context bounds can also just make the method signatures more readable. For example, the above function could be re-written using context bounds like so:

      def foo[T: Manifest](x: List[T]) = {
        if (manifest[T] <:< manifest[String])
          println("Hey, this list is full of strings")
        else
          println("Non-stringy list")
      }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

In Scala, there is a special type of access modifiers: protected[enclosing_scope]. But as soon
Since Intellij does not yet support the Play-Scala-Template-Engine I was thinking about using plain
I wanted to ask if there is any type of string interpolation in Scala.
I am using the jMonkeyEngine (Java Game Engine) in Scala, which works out pretty
since memcpy should be highly optimized nowadays, does it still make sense to optimize
Here is something that I have came across in Scala that did not cause
I'm trying to build something (ultimately a gem but for now an application) that
I'm developing and testing a little straight-forward client-server application using java (and scala). The
I have a pair of classes that look something like this. There's a Generator
I come from Groovy and it has a .with method on every type which

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.