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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T01:07:54+00:00 2026-05-22T01:07:54+00:00

I found this problem when I use Morphia in scala. It checks the fields

  • 0

I found this problem when I use Morphia in scala. It checks the fields of a class by reflection, and get necessary type information for mapping.

But if I use traits, and define some collection fields, the generic type information will be lost, which cause Morphia can’t get enough information, and throw exceptions.

See my code:

trait HasTags {
    @Reference
    var tags: java.util.List[Tag] = new java.util.ArrayList[Tag]()  // the generic type is Tag
}

class Question extends Entity with HasTags {

}

I compiled the scala file, and get some java class files. Then I use java decompiler to see the content of the java byte codes:

public class Question extends Entity implements HasTags {
      @Reference
      private java.util.List tags;
}

You can see there is no Tag here, so Morphia will fail.

I used scala 2.8.1. Is there any way to fix it?


UPDATE

@extempore said, maybe javap doesn’t display that Tag information.

But I used a program called Java Decompiler, not javap.

I tried this code:

class Question extends Entity with HasTags {
    @Reference
    var tags2: java.util.List[Tag] = new java.util.ArrayList()
}

And see the byte code in Java Decompiler, it displays:

public class Question extends Entity implements HasTags {
      @Reference
      private java.util.List tags;
      @Reference
      private java.util.List<models.Tag> tags2;
}

We can see the tags2 contains Tag, but tags doesn’t.

And the interface HasTags is:

public abstract interface HasTags extends ScalaObject
{
  public abstract List<Tag> tags();

  @TraitSetter
  public abstract void tags_$eq(List<Tag> paramList);
}

We can see, the return value of method tags() is List<Tag>, but the field tags is not.

Since morphia get the information by fields, it can’t work correctly.

  • 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-22T01:07:55+00:00Added an answer on May 22, 2026 at 1:07 am

    That’s how javap displays things. It doesn’t mean the signature isn’t present.

    scala> classOf[HasTags].getMethod("tags").getGenericReturnType
    res0: java.lang.reflect.Type = java.util.List<Tag>
    

    That’s how you know it is. You can also see it in the constant pool.

    const #3 = Asciz    tags;
    const #4 = Asciz    ()Ljava/util/List;;
    const #5 = Asciz    ()Ljava/util/List<LTag;>;;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Ok, so I'm quite new to jQuery, but found this bizzare problem just now,
i have this problem: ms-access could not delete and i found a potential solution
This problem pops around the network for years, I've found no good solution yet.
I was trying to solve my XNA Font problem , when I found this
i have a problem using the Catch Clipboard Events code found on this link
I've run into the same problem as found in this question . However, I
Hi i have problem with this code, i found it on the internet and
problem euler #5 i found the solution but i don't know why this first
I've already found this question on SO (which is exactly the same problem I'm
I have found a problem with use JQuery timeout, i have a page with

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.