Compiling .as file in Flex SDK that extends a base class - class

I am simply trying to compile a .as file that extends another .as file like this:
public class BigSquare extends Square{
...
}
I go to the command line and type:
mxmlc BigSquare.as
The error I get is "The definition of base class Square was not found."
Where do I need to place the base class Square.as in order for BigSquare.as to compile?

You should add to the command line parameters the "-source-path" with the path to the other files you use at compile time (i.e. Square.as). More information here: http://livedocs.adobe.com/flex/3/html/help.html?content=compilers_13.html . You call should look like this
mxmlxc -source-path "path/to/Square.as" BigSquare.as
Hope it helps.

Related

Cannot use yii\base\Object as Object because 'Object' is a special class name yii2 advance

I just bougth a stronger pc, installed composer and wanted to continue my project on it but when I use gii it give me this error.
How can I fix it ? Why am I getting it ? Thank you.
solved. since 2.0.13, the class name Object is invalid since PHP 7.2, use [[BaseObject]] instead. So in the vendor/yiisoft/yii2-gii/CodeFile.php just had to change Object to BaseObject.
solved. since 2.0.13, the class name Object is invalid in PHP 7.2,
//Replace
//class User extends \yii\base\Object implements \yii\web\IdentityInterface
class User extends \yii\base\BaseObject implements \yii\web\IdentityInterface
And Download the yii-basic-app-2.0.25 from https://www.yiiframework.com/download
after that copy the yiisoft folder from vendor and replace the yiisoft folder in your project in vendor folder
Now check your project will be working fine.
Its work for me hope it will work for you.
in my case i change file
/vendor/trntv/yii2-command-bus/src/middlewares/BackgroundCommandMiddleware.php
use yii\base\Object; to use yii\base\BaseObject;
and
class BackgroundCommandMiddleware extends Object implements Middleware
to ;
class BackgroundCommandMiddleware extends BaseObject implements Middleware

InputStream to a list in Scala

I am trying to read a file as input stream and then convert the contents of the file into a list in scala. Here is my code
val fileStream = getClass.getResourceAsStream("src/main/scala-2.11/com/dc/returnsModel/constants/abc.txt")
val item_urls = Source.fromInputStream(fileStream).getLines.toList
This does now work. I get a NullPointer Exception.
How do I correct this?
However, this works(but I cant use it in a JAR File)
val item_urls = Source.fromFile("src/main/scala-2.11/com/dc/returnsModel/constants/aa.txt").getLines.toList
getClass.getResourceAsStream does not expect a full path, it searches for the requested file in the classpath using the same class loader as the current class.
Fixing this depends a bit on the structure of your project and class that calls this code:
If the class returned by getClass is in the same package as the file you're trying to load (com.dc.returnsModel.constants), then you should simply reference the file name only:
getClass.getResourceAsStream("abc.txt")
If the class returned by getClass resides in a different package, path should start with a / which represents the root of the classpath, hence the package name must follow:
getClass.getResourceAsStream("/com/dc/returnsModel/constants/abc.txt")
You have to provide the correct path starting from root.
Here root is start of your src/scala-2.11 folder in your case.
One example
object SO extends App {
val resourceStream = SO.getClass.getResourceAsStream("/com/sm.txt")
println(Source.fromInputStream(resourceStream).getLines.toList)
}

ClassNotFoundException when Loading Custom Class

So there's a lot of questions and examples around of reading external .class files using a ClassLoader but I'm struggling to see where I'm going wrong.
val folderUrl: URL = new File("D:/tmp/").toURI.toURL //file:/D:/tmp/
val cl: URLClassLoader = new URLClassLoader(Array(folderUrl), this.getClass.getClassLoader)
cl.loadClass("my.package.MyClassName")
The last line throws a ClassNotFoundException
The folder D:/tmp/ contains a class file "MyClassName.class".
The class has the package "my.package"
The class is called "MyClassName"
I can't understand what I'm doing wrong?
EDIT:
The two closest question which relate are:
Scala - Dynamic object/class loading
How do I call a Scala Object method using reflection?
But these both do not have my problem however, they both get further than I have done where they successfully load the class before running into issues.
So the issue was the fact that the folder structure did not match the package name.
So my folder structure was
D:/tmp/MyClassName.class
The full class name was
my.package.MyClassName
The class loader requires that the folder structure be
D:/tmp/my/package/MyClassName.class

How to refer to protected inner class in Scala when inheriting from Java (with byte code only)

I am writing a Scala class to inherit from a Java class, and I must override a method that takes a protected Java inner class as a parameter. The Java dependency comes as a jar without source code.
I have the exact same setup as found in https://issues.scala-lang.org/browse/SI-3120 except that I do not have the Java source code available, so scalac only knows about the Java dependency by looking at the byte code (in jar or class files).
This is basically what I'm trying to do:
// javapkg/JavaSuperClass.java
package javapkg;
public class JavaSuperClass {
protected class JavaInnerClass {
}
public void method(JavaInnerClass javaInnerclass) {
System.out.println("hello");
}
}
// scalapkg/ScalaSubClass.scala
package scalapkg
import javapkg.JavaSuperClass
class ScalaSubClass extends JavaSuperClass {
override def method(javaInnerClass: JavaSuperClass#JavaInnerClass) {
println("world")
}
}
I have Java Sun JDK Hotspot 1.6.0_24 and Scala 2.9.0.1 on Linux. This is what happens:
$ cd javapkg
$ javac JavaSuperClass.java
$ cd ../scalapkg
$ scalac -cp .. ScalaSubClass.scala
ScalaSubClass.scala:6: error: class JavaInnerClass in class JavaSuperClass cannot be accessed in javapkg.JavaSuperClass
Access to protected class JavaInnerClass not permitted because
prefix type javapkg.JavaSuperClass does not conform to
class ScalaSubClass in package scalapkg where the access take place
override def method(javaInnerclass: JavaSuperClass#JavaInnerClass) {
^
one error found
Note, if I change JavaSuperClass#JavaInnerClass to simply JavaInnerClass, I get this:
ScalaSubClass.scala:6: error: method method overrides nothing
override def method(javaInnerClass: JavaInnerClass) {
^
one error found
Note: I know this sounds very similar to the common "protected static inner class" Java-compatibility issue in Scala, but I believe this is unrelated because there are no statics anywhere in my example.
I feel like something is wrong, because when I put the same code into a mixed java/scala project in Eclipse, it seemed to compile fine (with the latter JavaInnerClass syntax); it's only when I compile the Scala code with only the Java byte code (and no Java source code) that I cannot get it to work. Am I just completely missing the correct syntax to refer to a Java inner class, is this a known defect, or should I file a compiler bug? I couldn't find anything about this exact use case in my searching.
This is an excellent article that discuss the topic.
EDIT-1
My bad, I answered to quickly. This actually may be a bug Mike, I'm trying to see if I can find a hack around. I'll let you know if I find one.
EDIT-2
I've tried different things but I can't find a way to make it work. Mike I'd suggest you to file a bug report.

Where do I place base action class in Symfony plugin?

I'm creating a plugin for my symfony project, which includes a base action class, i.e.:
<?php
// myActions.class.php
class myActions extends sfActions {
/* ... */
}
Where in my plugin folder (e.g.: plugins/sfMyPlugin/???) should I place this file?
The goal is to have actions that are NOT a part of this plugin extend this class, hopefully having the class be autoloaded (similar to if it were placed under apps/my_app/lib). If it can't be autoloaded, how do I get symfony to include my php file?
You typically put it in your plugin's lib directory. The general conventions is also to to name with Base in the name so given your example that would be BasemyActions. Then you would also make an empty concrete class called myActions and you would extend that within your plugin thus allowing other user to complety replace myActions with their own implementation (so long as it extends the base class) or to simply extend myActions.
you can place it in the lib directory of your plugin. This is what the generate:plugin-module task of the sfTaskExtraPlugin does.