8

We have 2 managed packages. Let's name those MPMAIN and MPCHILD. MPCHILD package is dependent on MPMAIN.

In MPCHILD we have a class:

@deprecated
global class ChildClass extends MPMAIN.MainClass {
    ...
}

MainClass in MPMAIN v.1 had a body without an explicitly specified constructor:

global abstract with sharing class MainClass {
    ...

    // No constructor here.

    ...
}

Later we released a new version of MPMAIN v.2 with changed MainClass:

global abstract with sharing class MainClass {
    ...

    global MainClass() {
        ...
    }

    ...
}

When we installed the new version MPMAIN v.2 into MPCHILD instance we started to get an error message when we compile all classes:

ChildClass: line 2, column 14: Method is not visible: void MPMAIN.MainClass.()

ChildClass is still pointed to v.1 of MPMAIN package. And we can't change it as the ChildClass is deprecated. If I try to change MPMAIN package version I get the error:

Compile Error: A class with name MPCHILD.ChildClass was deprecated for this package or this name is already in use! at line -1 column -1

We reverted the MPCHILD package from Release to Beta but still can't remove @deprecated for ChildClass.

Compile Error: Previously annotated identifier with @Deprecated must still be annotated: MPCHILD.ChildClass at line 1 column 14

I guess we see this error message because the ChildClass is global. But how can we resolve the issue?

  • If you want to do that you will have to refactor the child to not use the deprecated method. Otherwise you are stuck at the earlier version – Eric Aug 22 '18 at 7:44
  • But how can I remove the deprecated. The child class is not used anywhere. – Mikhail Ivanov Aug 22 '18 at 8:01
  • I guess we can't remove the @deprecated because the class is global. But we must fix the issue somehow. Any idea? – Mikhail Ivanov Aug 22 '18 at 8:05
  • Are you able to raise a support case for this? Long term it seems like a compiler issue. – Daniel Ballinger Aug 28 '18 at 20:57
1

This is a known issue but I'm not sure if this works as designed or if it is actually a bug. The problem is that once you set @Deprecated and upload your managed package ChildClass is basically frozen and if you have dependent changes that affect this in any way (like with MainClass in your example) you're stuck. As far as I'm aware there's currently no way around this issue besides actually deleting the class. And this solution might not be feasible in some cases.

But please note that you're also limited with deletions in managed packages as once your class is gone you will never be able to create a new class with the same name in that managed package ever again!

| improve this answer | |
0

I would suggest to delete and remove ChildClass.

If you have marked it as @deprecated, then you can just remove it and delete from the package in the next version, which should resolve all of your issues here

| improve this answer | |
  • Even global first generation managed package classes can be deleted? Would this work with InvocableMethod classes as well? – Brian Miller Mar 30 at 20:25
  • I think yes, this is the basic need of @deprecated annotation: to be able to delete later the entity marked with this annotation – p-p Apr 1 at 11:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.