Skip to main content


Eclipse Community Forums
Forum Search:

Search      Help    Register    Login    Home
Home » Language IDEs » Objectteams » support for callin-interception of constructor-calls
support for callin-interception of constructor-calls [message #1045722] Sat, 20 April 2013 19:25 Go to next message
Kai Zimmermann is currently offline Kai ZimmermannFriend
Messages: 16
Registered: October 2012
Junior Member
https://bugs.eclipse.org/bugs/show_bug.cgi?id=316616

Is this function already implemented?
Re: support for callin-interception of constructor-calls [message #1045727 is a reply to message #1045722] Sat, 20 April 2013 19:33 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Unfortunately not yet, but thanks for bringing this to my attention Smile

Assuming we'd add support for callin bindings for constructors with the only option to define "after" bindings, would that already create a benefit for you?

Stephan
Re: support for callin-interception of constructor-calls [message #1045730 is a reply to message #1045727] Sat, 20 April 2013 19:38 Go to previous messageGo to next message
Kai Zimmermann is currently offline Kai ZimmermannFriend
Messages: 16
Registered: October 2012
Junior Member
Only if you got an idea for a workaround Wink

I want to insert another label into the string field (super call):

package org.eclipse.pde.internal.ui.editor.feature;

imports ...

public class PluginSection extends TableSection
  implements IPluginModelListener
{
  private OpenReferenceAction fOpenAction;
  private TableViewer fPluginViewer;
  private Action fNewAction;
  private Action fDeleteAction;
  private SortAction fSortAction;

  public PluginSection(PDEFormPage page, Composite parent)
  {
    super(page, parent, 128, new String[] { PDEUIMessages.FeatureEditor_PluginSection_new, 0, PDEUIMessages.FeatureEditor_SpecSection_synchronize });
    getSection().setText(PDEUIMessages.FeatureEditor_PluginSection_pluginTitle);
    getSection().setDescription(PDEUIMessages.FeatureEditor_PluginSection_pluginDesc);
    getTablePart().setEditable(false);
  }
Re: support for callin-interception of constructor-calls [message #1046272 is a reply to message #1045730] Sun, 21 April 2013 17:23 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
That's a tough one.

For an *after* callin we can weave some code at the end of the constructor body. I just started looking into this and a solution might still fit into the schedule for Kepler.

Weaving anything *before* the constructor body would necessarily be restricted to binding a static role method, because we don't yet have a base instance to bind to. For this some new weaving scheme needs to be created - possible but unlikely for Kepler.

For a *replace* binding I haven't found a way how the JVM would let me do that. The super constructor call must be the first thing we do in the constructor body. There's no way we could cut that out, delegate to the role and let the role invoke the super constructor instead. Any code patterns we'd like to create in this vein would be rejected by the VM.

Sorry, constructors are very special for the VM, there's little we can do to harmonize them with callin bindinds -- unless someone comes up with a real cool weaving scheme, which we haven't yet thought of.


regards,
Stephan

BTW: your particular problem can probably be solved by intercepting createViewerPart(String[] buttonLabels),
that's what I did in the hot fix for https://bugs.eclipse.org/374789 Smile
Re: support for callin-interception of constructor-calls [message #1046279 is a reply to message #1046272] Sun, 21 April 2013 17:36 Go to previous messageGo to next message
Kai Zimmermann is currently offline Kai ZimmermannFriend
Messages: 16
Registered: October 2012
Junior Member
I can not say I was particularly knowledgeable with JVM or bytecode, but for testing I use powermock. Somehow the Lib bypasses this problem ..

http://powermock.googlecode.com/svn/docs/powermock-1.5/apidocs/org/powermock/api/mockito/PowerMockito.html#whenNew(java.lang.Class)

.. maybe their code gives you an idea.

Thanks for the hint to your hot fix.

[Updated on: Sun, 21 April 2013 17:37]

Report message to a moderator

Re: support for callin-interception of constructor-calls [message #1046305 is a reply to message #1046279] Sun, 21 April 2013 18:30 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
From a brief look at the PowerMock code I can't find anything that solves the problems I mentioned.
One theory is: they don't actually weave into the constructor but into each constructor *call*, is that possible?
(Object Teams performs all weaving only in the bound base classes, never in clients of these base classes).

I'm not even sure PowerMock solves the problems at hand: when you intercept a constructor, can you really create an instance of the original class just using a different constructor body?? Returning a mock instead is an entirely different matter.

Re: support for callin-interception of constructor-calls [message #1047136 is a reply to message #1046305] Mon, 22 April 2013 21:03 Go to previous messageGo to next message
Kai Zimmermann is currently offline Kai ZimmermannFriend
Messages: 16
Registered: October 2012
Junior Member
On topic: Intercepting createViewerPart works Very Happy

Off topic: I can create all kinds of methods, but with a single callin method the source code can not be formatted anymore Confused Has this ever happened to you?

My ide configuration:
Version: Juno Service Release 2
Build id: 20130225-0426
With

  • Object Teams Development Tooling 2.1.2.201301271217
  • Object Teams Equinox Integration 2.1.2.201301271217
  • Eclipse JDT Plug-in Developer Resources 3.8.2.v20130116-090414-8-8nFu3FNOfwKLRuqgXKIy9z0I83
  • Eclipse PDE Plug-in Developer Resources 3.8.2.v20130116-091538-7c7wFj0FFt6Zr9bd4AM1JEQMS
  • Eclipse for RCP and RAP Developers 1.5.2.20130211-1820


import org.eclipse.pde.internal.ui.parts.StructuredViewerPart;
import base org.eclipse.pde.internal.ui.editor.feature.PluginSection;

@SuppressWarnings("restriction")
public team class MyTeam{

	protected class MyPluginSection playedBy PluginSection {

		 callin StructuredViewerPart createViewerPart(String[] strings) {
		 return base.createViewerPart(strings);
		 }
		 }}


Edit (23.4 07:47 CEST): Save Action "Corrent intention" works, but manually not Shocked

[Updated on: Tue, 23 April 2013 05:48]

Report message to a moderator

Re: support for callin-interception of constructor-calls [message #1047628 is a reply to message #1047136] Tue, 23 April 2013 13:03 Go to previous messageGo to next message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Glad to here that the createViewerPart-trick helped.

Regarding the formatter: I admit that this part is not quite as well-tested as the rest of the OTDT.
Thanks for reporting, it turns out to be caused by the base call inside the callin method.

See https://bugs.eclipse.org/406316.

thanks,
Stephan
Re: support for callin-interception of constructor-calls [message #1053835 is a reply to message #1047628] Tue, 07 May 2013 19:33 Go to previous message
Stephan Herrmann is currently offline Stephan HerrmannFriend
Messages: 1853
Registered: July 2009
Senior Member
Stephan Herrmann wrote on Tue, 23 April 2013 15:03
Regarding the formatter: I admit that this part is not quite as well-tested as the rest of the OTDT.
Thanks for reporting, it turns out to be caused by the base call inside the callin method.

See https://bugs.eclipse.org/406316.


The fix for this bug will be available in 2.2 M7 (due end of this week).
Previous Topic:Book chapter published: Confined Roles and Decapsulation in Object Teams -- Contradiction or Synergy
Next Topic:"Object Teams Patch for JDT/Core" issue on update
Goto Forum:
  


Current Time: Fri Apr 19 05:17:13 GMT 2024

Powered by FUDForum. Page generated in 0.02327 seconds
.:: Contact :: Home ::.

Powered by: FUDforum 3.0.2.
Copyright ©2001-2010 FUDforum Bulletin Board Software

Back to the top