systemverilog static class member cannot be accessed via the class scope resolution operator - static

In my t1 extended uvm_test class I'd like to use the xxx_write method from a sequence class xxx_io in xxx_pkg.
I've imported * the package into my t1 class, and I've made the method static but I still receive the same error from compiler:
ncvlog: *E,ILLCSS (/ddd/test.sv,82|29): A Non static class member cannot be accessed via the class scope resolution operator '::'.
xxx_pkg::xxx_io::xxx_write(12'h000, 32'h11ceb00c);
Since the error message did not change after I added the static key word to xxx_write method it would not surprise me if the error is elsewhere. But my code 'works' if I do not try to call this method from t1 class.
package xxx_pkg
class xxx_io extends uvm_sequence #(xxx_seq_item);
static task xxx_write( bit [11:0] i_addr, integer i_wdata );
// snip other code
endtask
endclass: xxx_io
endpackage: xxx_pkg
class t1 extends uvm_test
import xxx_pkg::*
class test1 extends uvm_sequence #(xxx_seq_item);
task body ;
xxx_pkg::xxx_io::xxx_write(12'h000, 32'h11ceb00c);
// snip other code
endtask
endclass : t1

From Greg: create an instance of the sequence in the test then call the method from that instance

Related

Unit testing getting error class could not be found

I have a class for dynamoDB in location
src/Dynamo/shop.php
My class looks like below
<?php
namespace App\Dynamo;
class Shop
{
-----
}
?>
I am trying to implement unit test for this class, So I have created a folder class dynamo in below location.
app/cake/tests/TestCase/Dynamo
In Dynamo folder I have created a class with file name ShopTest.php
For create a unit testing I have written this class like below
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Dynamo;
use App\Dynamo\Shop;
use Cake\TestSuite\TestCase;
class ShopTest{
public function setUp()
{
$this->shop = new Shop;
}
public function testconnectDynamoDB()
{
debug($this->shop->connectDynamoDB());
$this->assertNotEmpty($this->shop->connectDynamoDB());
}
}
Now after run phpunit command
vendor/bin/phpunit tests/TestCase/Dynamo/ShopTest.php
I am getting
Class 'App\Test\TestCase\Dynamo\ShopTest' could not be found in '/var/www/html/tests/TestCase/Dynamo/ShopTest.php'.
Class is present in this location , Why I am getting Class could not be found ?
root#0ceda1df4444:/var/www/html# cd /var/www/html/tests/TestCase/Dynamo/
root#0ceda1df4444:/var/www/html/tests/TestCase/Dynamo# ls
ShopTest.php
root#0ceda1df4444:/var/www/html/tests/TestCase/Dynamo# cat ShopTest.php
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Dynamo;
use App\Dynamo\Shop;
use Cake\TestSuite\TestCase;
class ShopTest{
Also I am trying to run all test case by below command , I am getting a warning.
root#0ceda1df4444:/var/www/html# vendor/bin/phpunit
PHPUnit 9.5.9 by Sebastian Bergmann and contributors.
Warning: Your XML configuration validates against a deprecated schema.
Suggestion: Migrate your XML configuration using "--migrate-configuration"!
No tests executed!
There is no test class
The error message there is a bit confusing, but the crux is this is not a test class:
<?php
declare(strict_types=1);
namespace App\Test\TestCase\Dynamo;
use App\Dynamo\Shop;
use Cake\TestSuite\TestCase;
class ShopTest{ # <--
It is just a class (which coincidentally has the word Test in its name).
Compare to an example from the documentation:
namespace App\Test\TestCase\View\Helper;
use App\View\Helper\ProgressHelper;
use Cake\TestSuite\TestCase;
use Cake\View\View;
class ProgressHelperTest extends TestCase # <--
{
To be detected as a test the class must extend TestClass - therefore to correct this:
...
use App\Dynamo\Shop;
use Cake\TestSuite\TestCase;
class ShopTest extends TestCase # <--
{
With that change the test class will load and some easier-to-solve problems will become apparent:
$ vendor/bin/phpunit tests/TestCase/Dynamo/ShopTest.php
PHP Fatal error: Declaration of ShopTest::setUp() must be compatible with Cake\TestSuite\TestCase::setUp(): void in ~/repos/cakephp/app/tests/TestCase/Dynamo/ShopTest.php on line 11
Fatal error: Declaration of ShopTest::setUp() must be compatible with Cake\TestSuite\TestCase::setUp(): void in ~/repos/cakephp/app/tests/TestCase/Dynamo/ShopTest.php on line 11

how to get range class of objectProperty by its domain class in owlapi?

In my project, I'd like to get all the range class related to the given class by an restricted(somevaluefrom or allvalues from) objectproperties. I can get the restricted subclassofAxioms expressions including the given class, but how can I get the range class in these expressions? In other word, how can I get all the related classes to the given class excluding inherited subclass.
For example:
public static void printSubClassOfAxioms(OWLOntology ontology,OWLReasoner reasoner,OWLClass owlClass){
for(OWLSubClassOfAxiom ax:ontology.getSubClassAxiomsForSubClass(owlClass)){
OWLClassExpression expression=ax.getSuperClass();
System.out.println(ax);
System.out.println(expression);
}
}
The results are:
SubClassOf(<#FourCheesesTopping> <#CheeseTopping>)
SubClassOf(<#FourCheesesTopping> ObjectSomeValuesFrom(<#hasSpiciness> <#Mild>))
SubClassOf(<#FourCheesesTopping> ObjectAllValuesFrom(<#hasCountryOfOrigin> #Country>))
How can I just get the range classes #Country and #Mild
Thank you for your attention!
Write an OWLObjectVisitor and override the visit(OWL... Type) for the restrictions you're interested in. At that point,
type.getFiller()
will yield the class you're after.
Examples are in the documentation: https://github.com/owlcs/owlapi/wiki/Documentation
public class RestrictionVisitor extends OWLClassExpressionVisitor {
#Override
public void visit(#Nonnull OWLObjectSomeValuesFrom ce) {
// This method gets called when a class expression is an existential
// (someValuesFrom) restriction and it asks us to visit it
}
}

Facing java.lang.IllegalAccessError for a base abstract class when trying to inject its implementation in wildfly 10

We are receiving the following exceptions in one of our code :
java.lang.IllegalAccessError: tried to access class base.BaseMessage from class message.beans.TerminalPowerCommandProducer$Proxy$_$$_WeldSubclass
Our class structure is as follows :
The Base Message creator class with default message properties
package messages.base
//... required imports
abstract class BaseMessage{ //some protected variables and methods }
the intermediate message class with extension to BaseMessage some additional properties for specific message types
package messages.base
//... required imports
public abstract class PowerMessage extends BaseMessage {//some more protected variables and Logger(using #Inject) and methods}
The actual implementation of the above abstract classes
package messages.beans
//... required imports
#Named
public class TerminalCommandMessage extends PowerMessage {// some more variables with injections and methods with abstract method implementation}
This class is now injected in some other classes :
package messages.beans
#Named
public class TerminalPowerCommandProducer {
#Inject
TerminalCommandMessage commandMessage
//some other code
}
We are receiving exception as reported above.
We are using WildFly version 10.1.0 Final with jdk 8
Is there an issue with the way we have consumed it?
Because if we mark the BaseMessage class as public it all works fine.

How to debug serializable exception in Flink?

I've encountered several serializable exceptions, and I did some searching on Flink's internet and doc; there are some famous solutions like transient, extends Serializable etc. Each time the origin of exception is very clear, but in my case, i am unable to find where exactly it is not serialized.
Q: How should i debug this kind of Exception?
A.scala:
class executor ( val sink: SinkFunction[List[String]] {
def exe(): Unit = {
xxx.....addSink(sinks)
}
}
B.scala:
class Main extends App {
def createSink: SinkFunction[List[String]] = new StringSink()
object StringSink {
// static
val stringList: List[String] = List()
}
// create a testing sink
class StringSink extends SinkFunction[List[String]] {
override def invoke(strs: List[String]): Unit = {
// add strs into the variable "stringList" of the compagin object StringSink
}
}
new executor(createSink()).exe()
// then do somethings with the strings
}
The exception is:
The implementation of the SinkFunction is not serializable. The
object probably contains or references non serializable fields.
Two suspicious points that I found:
The instance of StringSink is passed into another file.
In the class of StringSink, it uses a static variable stringList
of its compagin object.
I faced similar problems. It used to take longtime to find out what member/object is not serializable. The exception logs are not really helpful.
What helped me is the following JVM option, which enables more details in exception trace.
Enable this option...
-Dsun.io.serialization.extendedDebugInfo=true
My first guess would be the you don't have a no argument constructor in StringSink
Rules for POJO types Clipped from here
Flink recognizes a data type as a POJO type (and allows “by-name” field referencing) if the following conditions are fulfilled:
The class is public and standalone (no non-static inner class)
The class has a public no-argument constructor
All non-static, non-transient fields in the class (and all superclasses) are either public (and non-final) or have a public getter- and a setter- method that follows the Java beans naming conventions for getters and setters.
Just add a no argument constructor and try again
class StringSink extends SinkFunction[List[String]] {
public StringSink() {
}
#override def invoke(strs: List[String]): Unit = {
// add strs into the variable "stringList" of the compagin object StringSink
}
}

CakePHP lazy loading fails with static access to class constants

In a CakePHP 2.2 app, I'm using class constants in a Model for some internal configuration. The following issue came up.
Short version:
Cake's lazy class loading will not be triggered by a static call to the Model class.
If the first access to a Model in a Controller is
MyModel::SOME_CONST // fails
the class will be unknown. If any instance of the class is used before, it's fine:
$this->MyModel->something();
MyModel::SOME_CONST // works
Not knowing about the details of the lazy loading implementation:
Question: Is this something that is impossible to fix? If so, why? How do I then best work around it in my App myself (wrap consts in a function)? Or is there a chance to improve the lazy loading so that it works with static access, too?
Long version with code:
In order to test the different cases, I made a small test App with 1 Model and 1 Controller:
Model/Post.php:
<?php
class Post extends AppModel {
public $useTable = false; // Don't bother with a DB
const FOO = "foo";
public $bar = "bar";
}
Controller/PostsController.php:
<?php
class PostsController extends AppController {
public function constant() {
debug(Post::FOO);
}
public function variable() {
debug($this->Post->bar);
}
public function variableFirst() {
debug($this->Post->bar);
debug(Post::FOO);
}
}
Accessing the three controller actions through the browser, the different cases can now be tested.
1) accessing the Model constant (at /posts/constant):
Error: Class 'AppModel' not found
2) accessing the Model variable (at /posts/variable):
'bar'
3) accessing the Model constant AFTER a variable (at /posts/variable):
'bar'
'foo'
lazyloading works with normal class calls as well as static calls IF you correctly approach it.
Correctly means, that you always have to App::uses() all used classes at the top of your file
for AppModel in a model file:
App::uses('AppModel', 'Model');
class Post extends AppModel {}
see the core files for details.

Resources