Java elevate with JNA - uac

hi i was following a this https://stackoverflow.com/a/11042773/2665500? but i cant make it work???
when i try and compile it, i says that
public static class SHELLEXECUTEINFO extends Structure
needs to be abstract... but if i make it abstract then wont init?
SHELLEXECUTEINFO execInfo = new SHELLEXECUTEINFO();
what do i need to change to get this to elevate a process??
thanks

Related

'MyMethod' in 'Dao_Impl' clashes with 'MyMethod + extends' in 'Dao'; both methods have same erasure, yet neither overrides the other

I wasnt getting any errors before. But today, i entered my project to edit and saw these errors.
First one is on this line;
public final class NoteDao_Impl implements NoteDao {
// The error code is : Class 'NoteDao_Impl' must either be declared abstract or implement abstract method 'getAllNotes(Continuation<? super List<? extends Notes>>)' in 'NoteDao'
I can fix it with Alt + Enter and then clicking 'implement methods' but just in case i want to write it.
The second one and third one is on these lines;
#Override
// Error : Method does not override method from its superclass
public Object getAllNotes(final Continuation<? super List<Notes>> continuation) {
// Error : 'getAllNotes(Continuation<? super List<Notes>>)' in 'com.ahmetkaan.kediy.data.NoteDao_Impl' clashes with 'getAllNotes(Continuation<? super List<? extends Notes>>)' in 'com.ahmetkaan.kediy.data.NoteDao'; both methods have same erasure, yet neither overrides the other
The NoteDao;
package com.ahmetkaan.kediy.data
import androidx.room.*
#Dao
interface NoteDao {
#Query("SELECT * FROM notes ORDER BY id DESC")
suspend fun getAllNotes() : List<Notes>
#Query("SELECT * FROM notes WHERE id =:id")
suspend fun getSpecificNote(id:Int) : Notes
#Query("SELECT * FROM notes WHERE category = :id")
suspend fun getCategoryNote(id:Int) : Notes
#Insert(onConflict = OnConflictStrategy.REPLACE)
suspend fun insertNotes(note:Notes)
#Delete
suspend fun deleteNote(note:Notes)
#Query("DELETE FROM notes WHERE id =:id")
suspend fun deleteSpecificNote(id:Int)
#Update
suspend fun updateNote(note:Notes)
}
The problem appears when i set getAllNotes() method as "getAllNotes() : List " So i guess thats why. But i dont understand why i get this error now. I do some research and i encounter some solutions like;
public class a<T extends Comparable> implements A<T>
but probably i cant make it compatible with my project :,) Thanks in advance.
I met the same problem. I try this link to fix the problem.
You can try changing List<Notes> to Array<Notes>.
Hope it will help.
Also, if this error causes your app to crash at runtime, and you don't want to change the List to Array, maybe there is another approach. If you are using manual migration of the room database, try to change it to auto migration(Doc). Although there still has this error in the build package, it won't affect your app performance. Your app can run without crashing.

PageInit does not work when on different class

As the title says I am using PageFactory to initialize my elements.
When I use PageFactory.initElements on the page I want to use my elements everything is fine and works correctly, but when I try to create a new class with PageFactory to have it initialize all elements there I get a null pointer exception.
Below you will find the code I am using:
Actions.java
TestIds testIds = new TestIds();
public void initElements(WebDriver driver) {
PageFactory.initElements(driver, cashierIds);
}
The above lines work when included in my Actions class but when I create a new Class called ElementInitialization.java, move everything in it and then call it my elements throw nullPointerException.
Is there a different way to call the specific faction to work everywhere?

solr: read stopword.txt in Custom Handler

I want to read stopword.txt in my custom handler. How to do that ? I know that this is used in Filtering and can be done from there. But I need to read that list in my Custom UpdateRequestProcessorFactory. Also can I read any other custom file created by me.
I was aware that limitation. I overlooked that you are using about update processor.
I looked into the code, here is an existing code you can use as example. SolrCoreAware is the interface you are after.
public class StatelessScriptUpdateProcessorFactory extends UpdateRequestProcessorFactory implements SolrCoreAware
#Override
public void inform(SolrCore core) {
resourceLoader = core.getResourceLoader();
}
Classes that implement org.apache.lucene.analysis.util.ResourceLoaderAware can read files under conf directory. However what it your use case anyway?
looks like xy problem

How can I write (Application.Current as App) in my Silverlight class library?

I have few public properties in App.xaml.cs which is in project A and I want to refer them in my project B. However my project A has a reference to project B, so I cannot add again the reference of project A in project B otherwise it will result in cyclic error. So how can I refer those properties in my class library? I don't want to use reflection :).
As a workaround I have stored those properties in one class in project B (so it can be referred in project A as well as project B) and made those properties to be static and all works fine. However I am still curious to know what if I had stored them in App.xaml.cs? Any options available?
Thanks in advance :)
The App class should expose things that are only relevant to the application project. As soon as you realised that you wanted these things accessable in B.dll they became relevant to more than just the application project and therefore no longer belong in the application project.
Adding a class to B.dll that carries these things as static properties could be a reasonable approach. Another common pattern is to have a single Current static property.
public MyClass
{
private static MyClass _current = new MyClass();
public static MyClass Current { get { return _current; } }
public string SomeInstanceValue { get; set; }
}
Both A and B would access things using the pattern var x = MyClass.Current.SomeInstanceValue. The advantage of this approach is that it allows the Current property getter to determine if a "current" instance is available or not.
You might also want to review the documentation on ApplicationLifeTimeObjects.
When A and B both need something, maybe you should put them in a C project (C as in Common) and then refer to C from both A and B.

In php we can access static member functions using class objects. Can someone please tell any practicle use of this feature

In php we can call static member functions using class objects. For example
class Human
{
public static function Speak()
{
echo "I am a human.";
}
}
$human = new Human();
$human->Speak();
What we would expect is that a static member function can only be called using the class name and not the class instance variable (object). But what i have seen while programming is that php allows calling a static member function using the class object also. Is there any practical use or some important reason that this feature has been provided in php ?
This feature exists in java and c++ also. Thanks Oli for pointing this out in your response.
This is the same as in other OO languages, such as C++ and Java. Why would you want the interpreter to prevent this?
UPDATE
My best guess for this (and this is only a guess) is "for convenience". In essence, why should the user of your class necessarily care whether a given member function is static or not? In some circumstances, this will certainly matter; in others, maybe not. I'm not saying this is a great justification, but it's all I can come up with!
it allows you to abstract from the particular definition of the method, so that for example if you had to turn it into a static one at some point, you don't have to rewrite all the method calls!
I can't answer for PHP, (or really for anything) but consider this hypothetical C++:
class base{
public:
static void speak(){cout<<"base\n";}
};
class sub :public base {
public:
static void speak(){cout<<"sub\n"; }
};
int _tmain(int argc, _TCHAR* argv[]){
base *base1 = new base();
base1->speak();
sub *sub1 = new sub();
sub1->speak();
base *sub2 = new sub();
sub2->speak();
((sub*)sub2)->speak();
}
The output would be:
base
sub
base
sub
I'm sure it could be useful... maybe helping you determine which class's static method you should call based on the object currently in hand.

Resources