Eclipse breakpoints not hit when method invoked

classic Classic list List threaded Threaded
3 messages Options
Reply | Threaded
Open this post in threaded view
|

Eclipse breakpoints not hit when method invoked

Val Huber
Hi…

I am invoking methods (structured like getters) successfully, but breakpoints in these invoked methods are not happening.  I have tried coding it 2 ways:


/**
* invokes aMethodName on anObject (experimenting to preserve debug on invoked method!)
* @param anObject
* @param aMethodName
*/
private void invoke (Object anObject, String aMethodName) {
if (false) {
anObject."$aMethodName"() // dynamic method execution  - but debug fails
} else {
MetaMethod methodObj = anObject.metaClass.methods.find { it.name.equals(aMethodName) }
if (_logger.isDebugEnabled())  _logger.debug ("..findMethod: " + methodObj)
methodObj.invoke(anObject, null)
}
}

My environment is (on a Mac Snow with most recent JDK):

Eclipse IDE for Java EE Developers 1.3.1.20100916-1202 epp.package.jee
    Eclipse Platform 3.6.1.M20100909-0800 org.eclipse.platform.ide
    Java EE IDE Feature 1.3.1.20100916-1202 org.eclipse.epp.package.jee.feature.feature.group
  Groovy-Eclipse Feature 2.1.0.xx-20101020-1000-e36-release org.codehaus.groovy.eclipse.feature.feature.group
    Groovy Compiler 1.6.7 Feature 2.1.0.xx-20101020-1000-e36-release org.codehaus.groovy16.feature.feature.group
    Groovy Compiler 1.7.5 Feature 2.1.0.xx-20101020-1000-e36-release org.codehaus.groovy17.feature.feature.group
    JDT Core patch for Groovy-Eclipse plugin 2.1.0.xx-20101020-1000-e36-release org.codehaus.groovy.jdt.patch.feature.group
  Groovy-Eclipse JDT Patch Sources Feature 2.1.0.20100926-2100-e35-RC1 org.codehaus.groovy.jdt.patch.source.feature.group
  Groovy-Eclipse Sources Feature 2.1.0.20100926-2100-e35-RC1 org.codehaus.groovy.eclipse.feature.source.feature.group
  Subversive SVN Connectors 2.2.2.I20100512-1900 org.polarion.eclipse.team.svn.connector.feature.group
  Subversive SVN Team Provider (Incubation) 0.7.9.I20100512-1900 org.eclipse.team.svn.feature.group
  SVNKit 1.3.2 Implementation (Optional) 2.2.2.I20100512-1900 org.polarion.eclipse.team.svn.connector.svnkit16.feature.group

Thanks in advance,
Val

Reply | Threaded
Open this post in threaded view
|

Re: Eclipse breakpoints not hit when method invoked

Andrew Eisenberg
I tried to reproduce your problem using this script:

def x = "afdsasdf"
println x.toCharArray()
println invoke(x, "toCharArray", true)
println invoke(x, "toCharArray", false)

private def invoke (Object anObject, String aMethodName, val) {
        if (val) {
                return anObject."$aMethodName"() // dynamic method execution  - but
debug fails
        } else {
                MetaMethod methodObj = anObject.metaClass.methods.find {
it.name.equals(aMethodName) }
                return methodObj.invoke(anObject, null)
        }
}

But I was able to successfully set breakpoints and the debugger
acknowledged them.  I set the breakpoint at the if statement.  I tried
with and without the return statements.

Can you send me a simple failing project?  I will then try again to reproduce.

On Mon, Nov 1, 2010 at 8:33 AM, Val Huber <[hidden email]> wrote:

> Hi…
> I am invoking methods (structured like getters) successfully, but
> breakpoints in these invoked methods are not happening.  I have tried coding
> it 2 ways:
>
> /**
> * invokes aMethodName on anObject (experimenting to preserve debug on
> invoked method!)
> *
> * @param anObject
> * @param aMethodName
> */
> private void invoke (Object anObject, String aMethodName) {
> if (false) {
> anObject."$aMethodName"() // dynamic method execution  - but debug fails
> } else {
> MetaMethod methodObj = anObject.metaClass.methods.find {
> it.name.equals(aMethodName) }
> if (_logger.isDebugEnabled())  _logger.debug ("..findMethod: " + methodObj)
> methodObj.invoke(anObject, null)
> }
> }
> My environment is (on a Mac Snow with most recent JDK):
>
> Eclipse IDE for Java EE Developers 1.3.1.20100916-1202 epp.package.jee
>     Eclipse Platform 3.6.1.M20100909-0800 org.eclipse.platform.ide
>     Java EE IDE Feature 1.3.1.20100916-1202
> org.eclipse.epp.package.jee.feature.feature.group
>   Groovy-Eclipse Feature 2.1.0.xx-20101020-1000-e36-release
> org.codehaus.groovy.eclipse.feature.feature.group
>     Groovy Compiler 1.6.7 Feature 2.1.0.xx-20101020-1000-e36-release
> org.codehaus.groovy16.feature.feature.group
>     Groovy Compiler 1.7.5 Feature 2.1.0.xx-20101020-1000-e36-release
> org.codehaus.groovy17.feature.feature.group
>     JDT Core patch for Groovy-Eclipse plugin
> 2.1.0.xx-20101020-1000-e36-release
> org.codehaus.groovy.jdt.patch.feature.group
>   Groovy-Eclipse JDT Patch Sources Feature 2.1.0.20100926-2100-e35-RC1
> org.codehaus.groovy.jdt.patch.source.feature.group
>   Groovy-Eclipse Sources Feature 2.1.0.20100926-2100-e35-RC1
> org.codehaus.groovy.eclipse.feature.source.feature.group
>   Subversive SVN Connectors 2.2.2.I20100512-1900
> org.polarion.eclipse.team.svn.connector.feature.group
>   Subversive SVN Team Provider (Incubation) 0.7.9.I20100512-1900
> org.eclipse.team.svn.feature.group
>   SVNKit 1.3.2 Implementation (Optional) 2.2.2.I20100512-1900
> org.polarion.eclipse.team.svn.connector.svnkit16.feature.group
>
> Thanks in advance,
> Val
>

---------------------------------------------------------------------
To unsubscribe from this list, please visit:

    http://xircles.codehaus.org/manage_email


Reply | Threaded
Open this post in threaded view
|

Re: Eclipse breakpoints not hit when method invoked

Val Huber
Hi, Andrew…

I will send the project if required (takes a lot of work to isolate), but I did identify that:

 breakpoint works if the invoked class is not injected with a new method such as shown in code below.  Please let me know if this is sufficient for you…

void appendDependsOnMethod(String aRuleName, String aDependsOn, ASTNode[] astNodes, SourceUnit sourceUnit) {
int traceLev = traceBegin("appendDependsOnMethod: " + aDependsOn)
MethodNode methodNode = findOrCreateMethod("dependsOn", astNodes, sourceUnit)
List existingStatements = methodNode.getCode().getStatements()
int oldExistingStatementsSize = existingStatements.size()  // recall these are 0-based...
logDB("inserting code into: " + methodNode + ", " + oldExistingStatementsSize + " statements: " + existingStatements)


String codeString = "rtnList.add('" + aRuleName + ": " + aDependsOn + " ')" // eg rtnList.add ("Rool_2: varA varB") 
List <ASTNode> buildNodes = new AstBuilder().buildFromString(CompilePhase.SEMANTIC_ANALYSIS, true, codeString)
BlockStatement blockStatement = buildNodes[0]
Statement stmt = blockStatement.getStatements()[0]
// Object makesCodeCompletionFailAfterThis = buildNodes[0].statements[0]


existingStatements.add(oldExistingStatementsSize-1, stmt)
int newExistingStatementsSize = existingStatements.size()
logDB(".. added, statements now: , " + oldExistingStatementsSize + " statements: " + existingStatements)
traceEnd(traceLev)
}
 

Thanks,
Val

On Nov 2, 2010, at 12:13 PM, Andrew Eisenberg wrote:

I tried to reproduce your problem using this script:

def x = "afdsasdf"
println x.toCharArray()
println invoke(x, "toCharArray", true)
println invoke(x, "toCharArray", false)

private def invoke (Object anObject, String aMethodName, val) {
if (val) {
return anObject."$aMethodName"() // dynamic method execution  - but
debug fails
} else {
MetaMethod methodObj = anObject.metaClass.methods.find {
it.name.equals(aMethodName) }
return methodObj.invoke(anObject, null)
}
}

But I was able to successfully set breakpoints and the debugger
acknowledged them.  I set the breakpoint at the if statement.  I tried
with and without the return statements.

Can you send me a simple failing project?  I will then try again to reproduce.

On Mon, Nov 1, 2010 at 8:33 AM, Val Huber <[hidden email]> wrote:
Hi…
I am invoking methods (structured like getters) successfully, but
breakpoints in these invoked methods are not happening.  I have tried coding
it 2 ways:

/**
* invokes aMethodName on anObject (experimenting to preserve debug on
invoked method!)
*
* @param anObject
* @param aMethodName
*/
private void invoke (Object anObject, String aMethodName) {
if (false) {
anObject."$aMethodName"() // dynamic method execution  - but debug fails
} else {
MetaMethod methodObj = anObject.metaClass.methods.find {
it.name.equals(aMethodName) }
if (_logger.isDebugEnabled())  _logger.debug ("..findMethod: " + methodObj)
methodObj.invoke(anObject, null)
}
}
My environment is (on a Mac Snow with most recent JDK):

Eclipse IDE for Java EE Developers 1.3.1.20100916-1202 epp.package.jee
    Eclipse Platform 3.6.1.M20100909-0800 org.eclipse.platform.ide
    Java EE IDE Feature 1.3.1.20100916-1202
org.eclipse.epp.package.jee.feature.feature.group
  Groovy-Eclipse Feature 2.1.0.xx-20101020-1000-e36-release
org.codehaus.groovy.eclipse.feature.feature.group
    Groovy Compiler 1.6.7 Feature 2.1.0.xx-20101020-1000-e36-release
org.codehaus.groovy16.feature.feature.group
    Groovy Compiler 1.7.5 Feature 2.1.0.xx-20101020-1000-e36-release
org.codehaus.groovy17.feature.feature.group
    JDT Core patch for Groovy-Eclipse plugin
2.1.0.xx-20101020-1000-e36-release
org.codehaus.groovy.jdt.patch.feature.group
  Groovy-Eclipse JDT Patch Sources Feature 2.1.0.20100926-2100-e35-RC1
org.codehaus.groovy.jdt.patch.source.feature.group
  Groovy-Eclipse Sources Feature 2.1.0.20100926-2100-e35-RC1
org.codehaus.groovy.eclipse.feature.source.feature.group
  Subversive SVN Connectors 2.2.2.I20100512-1900
org.polarion.eclipse.team.svn.connector.feature.group
  Subversive SVN Team Provider (Incubation) 0.7.9.I20100512-1900
org.eclipse.team.svn.feature.group
  SVNKit 1.3.2 Implementation (Optional) 2.2.2.I20100512-1900
org.polarion.eclipse.team.svn.connector.svnkit16.feature.group

Thanks in advance,
Val


---------------------------------------------------------------------
To unsubscribe from this list, please visit:

   http://xircles.codehaus.org/manage_email