forked from bytemanproject/byteman
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added support for downcasting in local var initialisation in BBIND cl…
…auses - fixes BYTEMAN-225
- Loading branch information
Showing
6 changed files
with
209 additions
and
9 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
72 changes: 72 additions & 0 deletions
72
agent/src/test/java/org/jboss/byteman/tests/misc/TestDowncast.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,72 @@ | ||
/* | ||
* JBoss, Home of Professional Open Source | ||
* Copyright 2012, Red Hat and individual contributors | ||
* by the @authors tag. See the copyright.txt in the distribution for a | ||
* full listing of individual contributors. | ||
* | ||
* This is free software; you can redistribute it and/or modify it | ||
* under the terms of the GNU Lesser General Public License as | ||
* published by the Free Software Foundation; either version 2.1 of | ||
* the License, or (at your option) any later version. | ||
* | ||
* This software is distributed in the hope that it will be useful, | ||
* but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
* Lesser General Public License for more details. | ||
* | ||
* You should have received a copy of the GNU Lesser General Public | ||
* License along with this software; if not, write to the Free | ||
* Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
* 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
* | ||
* @authors Andrew Dinn | ||
*/ | ||
|
||
package org.jboss.byteman.tests.misc; | ||
import org.jboss.byteman.tests.Test; | ||
|
||
import java.util.ArrayList; | ||
import java.util.List; | ||
|
||
/** | ||
* class to test use of downcast in rule binding | ||
*/ | ||
public class TestDowncast extends Test | ||
{ | ||
public TestDowncast() | ||
{ | ||
super(TestDowncast.class.getCanonicalName()); | ||
} | ||
|
||
public void test() | ||
{ | ||
List<String> names = new ArrayList<String>(); | ||
|
||
names.add("Andrew"); | ||
|
||
try { | ||
log("calling TestDowncast.triggerMethod((Andrew))"); | ||
triggerMethod(names); | ||
log("called TestDowncast.triggerMethod((Andrew))"); | ||
} catch (Exception e) { | ||
log(e); | ||
} | ||
|
||
checkOutput(true); | ||
} | ||
|
||
public void triggerMethod(List<String> names) | ||
{ | ||
log("inside TestDowncast.triggerMethod()"); | ||
} | ||
|
||
@Override | ||
public String getExpected() { | ||
logExpected("calling TestDowncast.triggerMethod((Andrew))"); | ||
logExpected("inside TestDowncast.triggerMethod()"); | ||
logExpected("triggerMethod : list.get(0) == Andrew"); | ||
logExpected("called TestDowncast.triggerMethod((Andrew))"); | ||
|
||
return super.getExpected(); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
############################################################################## | ||
# JBoss, Home of Professional Open Source | ||
# Copyright 2012, Red Hat and individual contributors | ||
# by the @authors tag. See the copyright.txt in the distribution for a | ||
# full listing of individual contributors. | ||
# | ||
# This is free software; you can redistribute it and/or modify it | ||
# under the terms of the GNU Lesser General Public License as | ||
# published by the Free Software Foundation; either version 2.1 of | ||
# the License, or (at your option) any later version. | ||
# | ||
# This software is distributed in the hope that it will be useful, | ||
# but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | ||
# Lesser General Public License for more details. | ||
# | ||
# You should have received a copy of the GNU Lesser General Public | ||
# License along with this software; if not, write to the Free | ||
# Software Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA | ||
# 02110-1301 USA, or see the FSF site: http://www.fsf.org. | ||
# | ||
# @authors Andrew Dinn | ||
# | ||
|
||
############################################################################## | ||
# | ||
# test that a downcast can be used in a rule binding | ||
|
||
RULE test return value binding | ||
CLASS org.jboss.byteman.tests.misc.TestDowncast | ||
METHOD triggerMethod(List) | ||
HELPER org.jboss.byteman.tests.helpers.Default | ||
AT EXIT | ||
BIND name : String = $1.get(0); | ||
test = $0 | ||
IF TRUE | ||
DO test.log("triggerMethod : list.get(0) == " + name); | ||
ENDRULE |