Skip to content

Apparent Deviation with eclipse's SerialVer generation and java's ObjectStreamClass generator #3102

@mebigfatguy

Description

@mebigfatguy

Let's make sure issue is not already fixed in latest builds first.

Steps to reproduce

From a fresh installation and clean workspace:

Create this class

package com.acme.maybelargepackage.common.exception;

import java.io.Serializable;

public class DomainObjectNotFoundException implements Serializable {

public DomainObjectNotFoundException(Class clz, String objectName, Long id) {
}

public DomainObjectNotFoundException(Localization info, Class clz, Long id) {
}

}

interface Localization {
}

Click on the DomainObjectNotFoundException class header and chose, Add generated serial version ID from the context menu in the gutter, it should add the following

private static final long serialVersionUID = 3328307971569296919L;

Then use ObjectClassSerializer to calculated it. I used this.

package sv;

import java.io.ObjectStreamClass;
import java.lang.reflect.Method;

public class SV {

public static void main(String[] args) throws Exception {
    Class c = Class.forName("com.acme.maybelargepackage.common.exception.DomainObjectNotFoundException");

    Method m = ObjectStreamClass.class.getDeclaredMethod("computeDefaultSUID", Class.class);
    m.setAccessible(true);
    long v = (long) m.invoke(null, c);
    System.out.println(v);
}

}

It generates -7541915031460335346

This discrepancy only happens with a small subset of classes, i tried paring down the example as small as possible, but really don't know yet why the different here. Note without the maybelargepackage in the package name it seems to work. But other things cause it too. Not really sure why.

  • <...setup environment>

I tried

  • <... trigger issue>

I expected: <what was the expected outcome?>

But got: <what is the actual undesired behavior?>

Here is some relevant log output

From <workspace>/.metadata/.log

<relevant log output>

Tested under this environment:

  • OS & version: ... linux mint 22
  • Eclipse IDE/Platform version (as shown in Help > About): ...

Version: 2025-03 (4.35.0)
Build id: 20250306-0812

  • ...Anything else that can be useful...

Community

  • I understand reporting an issue to this OSS project does not mandate anyone to fix it. Other contributors may consider the issue, or not, at their own convenience. The most efficient way to get it fixed is that I fix it myself and contribute it back as a good quality patch to the project.

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions