Jump to content

[1.8][SOLVED] Avoid NoClassDefFound with SideOnly.


Ernio

Recommended Posts

Yes, yes, I know this "if you don't know what are you doing, don't do it" and "you shouldn't use it" arguments. But I am simply experimenting with classLoaders.

 

Common Proxy (when you launch server):

public void initNetwork()
{
try
{
	theNetwork = ServerNetwork.class.newInstance();
}
catch (Exception e)
{
	RoAMain.log.log(Level.FATAL, "Could not initialize server network! A lot of errors can be expected.");
}
}

ClientProxy (for clients):

@Override
public void initNetwork()
{
theNetwork = new ClientNetwork();
}

 

theNetwork is AbstractNetwork

ServerNetwork extends AbstractNetwork is @SideOnly(Side.SERVER)

ClientNetwork extends AbstractNetwork is @SideOnly(Side.CLIENT)

 

Question is quite simple: Is what I done above (#newInstance()) only way of avoiding NoClassDefFound?

Obviously when you use theNetwork = new ServerNetwork(); It will crash, and above is only thing I could think of.

 

Reflection is evil in my case (above is not it, above is an example).

 

Thanks.

 

EDIT

Oh and before someone asks - the @SideOnly is not used because I want it to be there, it is there because I want to simulate classes not being there in my dev env (because they are not there in real-life).

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Reflection is evil in my case (above is not it, above is an example).

 

Network might have been bad naming here. Even if network would be the actual network, it wouldn't matter - integrated server won't even use what I am doing (it's being developed as dedicated server feature - server sends and makes client load classes, don't ask xD, and yes, it's secured).

 

EDIT

Basically - is there a way to make instance of class that is @SideOnly without reflection?

1.7.10 is no longer supported by forge, you are on your own.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.