-
1. Re: Invalid constructor for target class error message.
adinn Dec 22, 2015 1:07 PM (in response to whitingjr)Hi Jeremy,
Thanks for reporting the bug.
Is it the type checker getting confused ?
Hmm, it certainly looks like it. Could you try tweaking your rule as follows and let me know what happens:
RULE pgjdbc logging CLASS org.postgresql.jdbc2.AbstractJdbc2Connection METHOD <init> (HostSpec[], String, String, Properties, String) AT EXIT BIND o : java.io.OutputStream = new java.io.FileOutputStream ("/tmp/dump.txt") ; p = new java.io.PrintWriter( o ) IF $connectionLogLevel=="2" DO java.sql.DriverManager.setLogWriter( p ) ENDRULE
Meanwhile I will try to recreate the problem in a simple test scenario.
regards,
Andrew Dinn
-
2. Re: Invalid constructor for target class error message.
whitingjr Dec 22, 2015 1:33 PM (in response to adinn)Hi Andrew,
Tried as you suggested and the type checker is throwing this error.
18:30:43,917 INFO [stdout] (JCA PoolFiller) [] [] org.jboss.byteman.agent.Transformer : inserted trigger for pgjdbc logging in class org.postgresql.jdbc2.AbstractJdbc2Connection
18:30:44,174 INFO [stdout] (JCA PoolFiller) [] [] Rule.execute called for pgjdbc logging_0
18:30:44,177 INFO [stdout] (JCA PoolFiller) [] [] Rule.ensureTypeCheckedCompiled : error type checking rule pgjdbc logging
18:30:44,177 INFO [stdout] (JCA PoolFiller) [] [] org.jboss.byteman.rule.exception.TypeException: NewExpression.typeCheck : invalid constructor for target class java.io.PrintWriter file /home/whiti
ngjr/java/jboss/byteman/byteman-download-3.0.3/sample/scripts/SetpgjdbcLogger.btm line 33
18:30:44,177 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.byteman.rule.expression.NewExpression.typeCheck(NewExpression.java:181)
18:30:44,177 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.byteman.rule.binding.Binding.typeCheck(Binding.java:165)
18:30:44,178 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.byteman.rule.Event.typeCheck(Event.java:114)
18:30:44,178 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.byteman.rule.Event.typeCheck(Event.java:106)
18:30:44,178 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.byteman.rule.Rule.typeCheck(Rule.java:548)
18:30:44,178 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.byteman.rule.Rule.ensureTypeCheckedCompiled(Rule.java:487)
18:30:44,178 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.byteman.rule.Rule.execute(Rule.java:705)
18:30:44,178 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.byteman.rule.Rule.execute(Rule.java:686)
18:30:44,178 INFO [stdout] (JCA PoolFiller) [] [] at org.postgresql.jdbc2.AbstractJdbc2Connection.<init>(AbstractJdbc2Connection.java:291)
18:30:44,187 INFO [stdout] (JCA PoolFiller) [] [] at org.postgresql.jdbc3.AbstractJdbc3Connection.<init>(AbstractJdbc3Connection.java:35)
18:30:44,187 INFO [stdout] (JCA PoolFiller) [] [] at org.postgresql.jdbc3g.AbstractJdbc3gConnection.<init>(AbstractJdbc3gConnection.java:22)
18:30:44,188 INFO [stdout] (JCA PoolFiller) [] [] at org.postgresql.jdbc4.AbstractJdbc4Connection.<init>(AbstractJdbc4Connection.java:47)
18:30:44,188 INFO [stdout] (JCA PoolFiller) [] [] at org.postgresql.jdbc42.AbstractJdbc42Connection.<init>(AbstractJdbc42Connection.java:21)
18:30:44,188 INFO [stdout] (JCA PoolFiller) [] [] at org.postgresql.jdbc42.Jdbc42Connection.<init>(Jdbc42Connection.java:28)
18:30:44,188 INFO [stdout] (JCA PoolFiller) [] [] at org.postgresql.Driver.makeConnection(Driver.java:415)
18:30:44,188 INFO [stdout] (JCA PoolFiller) [] [] at org.postgresql.Driver.connect(Driver.java:282)
18:30:44,188 INFO [stdout] (JCA PoolFiller) [] [] at java.sql.DriverManager.getConnection(DriverManager.java:664)
18:30:44,188 INFO [stdout] (JCA PoolFiller) [] [] at java.sql.DriverManager.getConnection(DriverManager.java:247)
18:30:44,188 INFO [stdout] (JCA PoolFiller) [] [] at org.postgresql.ds.common.BaseDataSource.getConnection(BaseDataSource.java:88)
18:30:44,189 INFO [stdout] (JCA PoolFiller) [] [] at org.postgresql.xa.jdbc3.AbstractJdbc3XADataSource.getXAConnection(AbstractJdbc3XADataSource.java:54)
18:30:44,189 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.getXAManagedConnection(XAManagedConnectionFactory.java:508)
18:30:44,189 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.jca.adapters.jdbc.xa.XAManagedConnectionFactory.createManagedConnection(XAManagedConnectionFactory.java:434)
18:30:44,189 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.createConnectionEventListener(SemaphoreArrayListManag
edConnectionPool.java:834)
18:30:44,189 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.jca.core.connectionmanager.pool.mcp.SemaphoreArrayListManagedConnectionPool.fillToMin(SemaphoreArrayListManagedConnectionPool.jav
a:775)
18:30:44,189 INFO [stdout] (JCA PoolFiller) [] [] at org.jboss.jca.core.connectionmanager.pool.mcp.PoolFiller.run(PoolFiller.java:97)
18:30:44,189 INFO [stdout] (JCA PoolFiller) [] [] at java.lang.Thread.run(Thread.java:745)
18:30:44,189 INFO [stdout] (JCA PoolFiller) [] []
Jeremy
-
3. Re: Invalid constructor for target class error message.
whitingjr Jan 4, 2016 12:13 PM (in response to adinn)Hi Andrew,
To help reproduce this I created a sample class called Application. Along with 3 sample Byteman scripts.
The first script reproduces the NewExpression type check error.
The second script demonstrates the NewExpression type checker working. Using x3 BIND expressions.
The third is similar to the second only using x2 BIND expressions.
package org.jboss.perf;
public class Application {
public static void main(String[] args){
}
}
RULE System out visibility 01
CLASS org.jboss.perf.Application
METHOD main
AT ENTRY
BIND o:PrintWriter = new java.io.PrintWriter( new java.io.FileOutputStream("/tmp/dump.txt") )
IF TRUE
DO o.print("Three cheers for Byteman")
ENDRULE
RULE System out visibility 02
CLASS org.jboss.perf.Application
METHOD main
AT ENTRY
BIND fos:java.io.FileOutputStream = new FileOutputStream("/tmp/dump.txt");
os:java.io.OutputStream = fos;
o = new java.io.PrintWriter( os )
IF TRUE
DO o.print("Three cheers for Byteman")
ENDRULE
RULE System out visibility 03
CLASS org.jboss.perf.Application
METHOD main
AT ENTRY
BIND os:java.io.OutputStream = new java.io.FileOutputStream("/tmp/dump.txt");
o:PrintWriter = new java.io.PrintWriter( os )
IF TRUE
DO o.print("Three cheers for Byteman")
ENDRULE
Only the initial script seems to fail.
$ ./bin/bmcheck.sh -cp /tmp/bin/ ./sample/scripts/01-NewExpressionTest.btm
Checking rule System out visibility 01 against class org.jboss.perf.Application
Parsed rule "System out visibility 01" for class org.jboss.perf.Application
ERROR : Failed to type check rule "System out visibility 01" loaded from ./sample/scripts/01-NewExpressionTest.btm line 6 against method main(java.lang.String[]) void
org.jboss.byteman.rule.exception.TypeException: NewExpression.typeCheck : invalid constructor for target class java.io.PrintWriter file ./sample/scripts/01-NewExpressionTest.btm line 6
TestScript: 1 total errors
0 total warnings
0 parse errors
1 type errors
0 type warnings
$ ./bin/bmcheck.sh -cp /tmp/bin/ ./sample/scripts/02-NewExpressionTest.btm
Checking rule System out visibility 02 against class org.jboss.perf.Application
Parsed rule "System out visibility 02" for class org.jboss.perf.Application
Type checked rule "System out visibility 02"
TestScript: no errors
$ ./bin/bmcheck.sh -cp /tmp/bin/ ./sample/scripts/03-NewExpressionTest.btm
Checking rule System out visibility 03 against class org.jboss.perf.Application
Parsed rule "System out visibility 03" for class org.jboss.perf.Application
Type checked rule "System out visibility 03"
Says to me the type checker is not detecting a candidate object for up-casting in a new expression.
Jeremy
-
4. Re: Invalid constructor for target class error message.
adinn Jan 5, 2016 4:28 AM (in response to whitingjr)Hi Jeremy,
Says to me the type checker is not detecting a candidate object for up-casting in a new expression.
Indeed, it shouts that to me too, loud and clear. Thank you very much for such a precise bug report, analysis and test case (if you could explain to everyone else who files a bug how to do that I'd be an even happier man :-).
I have a feeling that fixing this is going to complicate the call-to-method matching algorithm horribly. Still, it looks very much like that is what is needed. I am fairly confident I can correct it to deal with simple cases like this one where there is only a single argument to upcast and not many candidates to select from. I am unsure whether the general case will be quite so easy. Anyway, I'll report back with whatever I can manage. It is good that you have at least identified a workaround.
regards,
Andrew Dinn
-
5. Re: Invalid constructor for target class error message.
adinn Jan 5, 2016 4:45 AM (in response to adinn)Created issue BYTEMAN-304
-
6. Re: Invalid constructor for target class error message.
whitingjr Jan 5, 2016 6:33 AM (in response to adinn)Thank you very much for such a precise bug report, analysis and test case (if you could explain to everyone else who files a bug how to do that I'd be an even happier man
Your welcome. It's the least that should be done.
I have a feeling that fixing this is going to complicate the call-to-method matching algorithm horribly.
Agreed.
Jeremy
-
7. Re: Invalid constructor for target class error message.
whitingjr Apr 20, 2016 7:33 AM (in response to adinn)Looks like BYTEMAN-304 has been fixed. Thank you.
-
8. Re: Invalid constructor for target class error message.
adinn Apr 20, 2016 8:19 AM (in response to whitingjr)Hi Jeremy,
Yes it has been fixed for a while and indeed 3.0.4 has been out for a while but it crept out under the radar because teh docs wer ebeing moved from LibreOffice to Asciidoc. I'm trying (fialing mostly) to get 3.0.5 out the door this week whcih will include a shiny new Manuel documenting some nice new features (Helper link maps are worth looking at) a few fixes plus the prototype IMPORT support for JBoss Modules. Keep an ear eye open for the release announcement.
regards,
Andrew Dinn