Why is doAs() static?

I've been bothered by this for a while, and I can't come up with a good answer.
Why is the doAs() method of the Subject class static? It seems totally bizarre to be invoking a static method on that class, then passing a perfectly good instance of the Subject class as the first argument into the call. I know the API specifiers know how to invoke a non-static method using an instance (!! ;) but I'm darned if I can see any reason for them not to have done this.
Please, help my sanity, what am I missing?
Cheers,
Simon

It is merely static to have a consistent look with java.security.AccessController.doPrivileged.
As you point out, there is no technical reason it needed to be static.

Similar Messages

  • Please help: Why JMF does't play .avi video clip?

    The player doesn't play .avi media file, or plays sound only, but it works fine when palying .mpg files, anything I need to pay attention to when using the following code to generate a player to play video clips?
    import java.awt.*;
    import java.awt.event.*;
    import java.io.*;
    import javax.swing.*;
    import javax.media.*;
    public class PlayClip extends JFrame {
    //singliton design pattern
    private static PlayClip instance;
    protected Player player;
    private File file= new File ("goal.avi");
    private PlayClip () {
    instance=null;
    initComponents();
    public static PlayClip getInstance(){
    if (instance==null)
    instance=new PlayClip ();
    return instance;
    private void initComponents() {
    JButton OK = new JButton ("OK");
    OK.addActionListener (
    new ActionListener () {
    public void actionPerformed (ActionEvent e) {
    player.close ();
    instance = null;
    dispose();
    getContentPane ().add (OK, BorderLayout.NORTH);
    setSize (300, 300);
    show ();
    createPlayer ();
    /** Creates new form PlayClip */
    private void createPlayer () {
    if (file == null) {
    return;
    removePreviousPlayer ();
    try {
    //create a new player and add listener
    player = Manager.createPlayer (file.toURL () );
    player.addControllerListener (new EventHandler () );
    player.start (); //start player
    catch (Exception e) {
    JOptionPane.showMessageDialog (this, "Invalid file or location", "Error loading file", JOptionPane.ERROR_MESSAGE );
    System.exit (1);
    private void removePreviousPlayer () {
    if (player == null )
    return;
    player.close ();
    Component visual = player.getVisualComponent ();
    Component control = player.getControlPanelComponent ();
    Container c = getContentPane ();
    if (visual != null)
    c.remove (visual);
    if (control !=null)
    c.remove (control);
    private class EventHandler implements ControllerListener {
    public void controllerUpdate (ControllerEvent e) {
    if (e instanceof RealizeCompleteEvent ) {
    Container c = getContentPane ();
    Component visualComponent = player.getVisualComponent ();
    if (visualComponent != null)
    c.add (visualComponent, BorderLayout.CENTER);
    Component controlsComponent = player.getControlPanelComponent ();
    if (controlsComponent != null)
    c.add (controlsComponent, BorderLayout.SOUTH);
    c.doLayout ();
    }

    JDunlop,
    thanks for your quick reply to my java.sun.com forum posting! i just got back from vacation, so i didn't get a chance to try your method til now. i pulled your email address off the website to update you on my problem playing an avi file in JMStudio (JMF).
    as per your instructions, i downloaded the divx player at www.divx.com and tried to play the avi file. this is the error the divx player gives:
    Divx Player 2.1
    The file contains unknown video data
    The file contains the following type of data:
    Video data: FOURCC code "MP42"
    You may need to install a new video codec on your computer to watch this video
    Some quick questions:
    1. Where could I find the "MP42" codec to play my avi file in JMStudio (JMF)? Does java.sun.com have video codecs?
    2. You mentioned in your posting "If you don't have the one that was used in the encoding, your out of luck." Does this mean that I need to know how the avi file was originally coded and have the original codec to decode (play) it?
    Thanks,
    lac410
    P.S. If you need more Duke Dollars for your help, I'd be happy to award them to you.
    Re: Please help: Why JMF does't play .avi video clip?
    Author: JDunlop Jun 5, 2003 5:00 AM
    sounds to me like you are missing a video codecs. If you don't have the one that was used in the encoding, your out of luck. Download the player from divx.com, it will tell you which codecs the video needs (if it won't play). You can then search the net for that particular codecs.

  • Why java does not force to declare atleast one abstract method

    hi,
    i can define an abstract class without declaring any abstract method in that class. But why wud i do this ? i mean when i have decided that a particular class should be inherited by other subclass and subclass should porvide implementation then there should be atleast one method in the abstract super class which requires implementation.
    All i want to know is why java does not force to declare atleast one abstract method in abstract class.
    there may be some situations where this restriction can create problem if it is like that then can anybody give some example.
    manish

    hi,
    i didn't get u.
    u r trying to say that i have an abstract class with
    only static methods then my questions is why wud
    declare such a class as 'abstract' class? because a
    static method can't be abstract also. Even then if
    somebody want to define such a class with only static
    methods then compiler should force him to declare
    atleast one abstract method which can be implemented
    by subclass, because as i said before if sumbody
    decide to define a class abstract then he wants that
    it should be inhereted but as u r saying a class with
    only static methods then it should not be an abstract
    class it can be a simple class.there's no functional reason, really... actually, factory-like classes are often defined the way Ceci described
    "abstract" only ensures that nobody can ever get an instance of that class (as a matter of fact, what would be the point of getting an instance, if no instance method exists ?)

  • Why is does my apple run SLOW.you go to open a program and the circle thing just spins for a delayed period of time.  You change from typing in a word doc and go to say email or internet and it takes several minutes to allow you open anything up.  Like it

    Why is does my apple run SLOW.you go to open a program and the circle thing just spins for a delayed period of time.  You change from typing in a word doc and go to say email or internet and it takes several minutes to allow you open anything up.  Like it is frozen.  I have tried rebooting the computer and it works for a few minutes then gets stuck.

    Which model iMac do you have?
    How large is your HD and how much space do you have left?
    Check out the following & do the necessary: 
    User Tip:  Why is my computer slow?
    What to do when your computer is too slow
    Speeding up your Mac
    OS X (10.6.6)
    Use Software Update or the OS 10.6.8 combo update to update your OS.  Also, update everything SU has to offer for your computer.  When done, repair permissions and restart your computer.

  • The old calender iOS6, in the year view, it shows how much busy I am in a day by indicating the color intensity. But the new calendar year view is totally useless!!! also too bright!! Why apple does this?? What is the way to revert the calendar back???

    The old calender iOS6, in the year view, it shows how much busy I am in a day by indicating the color intensity. But the new calendar year view is totally useless!!! also too bright!! Why apple does this?? What is the way to revert the calendar back???

    Unfortunately, that's the way the cookie crumbles nowadays. Sir Jony Ive's GUI design for iOS7 has been met with much skepticism (to say the least). But until the company sees the compelling need for an adjustment or reversal, it "ain't happenin' ". So amble over to the feedback page ( http://www.apple.com/feedback/ ) and make your displeasure known to the company, OR make it known by not purchasing its products. Because as long as the iGadgets continue selling as fast as they can make them, they will see no need for change.
    BTW, do note you are NOT talking to Apple here. This is just a user-to-user forum.
    Edit: for now, you can also try out any of the alternate calendaring apps available in the App Store.

  • PO creation-ME21n-Why SAP does not check company code and Plant relation

    Hi All,
    Does someone know, why SAP does not check Plant and company code relation at the time of PO creation or how can we put validation between plant and company code at the time of PO creation.
    <b>Example:</b> Suppose i have a company 0001 which is assinged to Plant 0001. when i am creating a PO with another company code 0002(Entering at header level-Org, data) and using Plant 0001 at line item level. SAP does not do this validation.
    How can we put this check in place?
    Thanks in advance.
    Deepak

    Hello Deepak,
    There are three types of purchasing
    - Company code specific :You need to assign company code to Pur organization
    - Plant specific : You must assign plant to pur organization
    - Cross company purchasing: No assignment between company code and pur organization.
    In the case 3, the system will not check company code and plant relationship, but it will check plant and pur organization specific.
    The following is the copy of sap help text:
    You can assign a purchasing organization to one company code. This is company-specific purchasing.
    You can assign a purchasing organization to no company code. This purchasing organization can then procure for all plants assigned to it, irrespective of the company code to which the plant belongs.
    Since each plant must be assigned to a company code, the company code can be determined via the plant in each procurement transaction, even if the procuring purchasing organization is not assigned to a company code.
    A purchasing organization must be assigned to one or more plants. This is plant-specific purchasing.
    Now, check your company-code and purchase organization assignment.
    Hope this helps.
    Regards
    Arif Mansuri

  • Why facetime does not working with any carrier in u.s expect att although the iphone is factory unlocked

    why facetime does not working with any carrier in u.s expect att although the iphone is factory unlocked

    Facetime only works via WiFi. Are you trying to set up Facetime with a T-Mobile account?

  • Why condition does not work.

    Hi Pros,
            in my bex query, there is a CKF OT hours, having a value 30.000, when I set a condition for 'OT hours = 30.000', but get no result out. could you please tell why condition does not work.

    HI,
    please check the "Characteristic Assignment" Tab in change condition window.
    In that tab default  selection as "All Characteristic in the drill down independently" change that selection  as "Individual characteristic and Char. combinations"  and choose the particular characteristic. for ex OT hours against employee means select employee alone.
    Regards
    Sureshkumar C

  • When I type my email address in the "To:" field, a random name comes up next to it as "Holidays in United States". This just started happening out of the blue and I have no idea why. Does anyone else have any idea?

    When I type my email address in the "To:" field, a random name comes up next to it as "Holidays in United States". This just started happening out of the blue and I have no idea why. Does anyone else have any idea?

    Just to recap, this is a collection of ports I have collected over time for people who needed this information when setting up the HP ePrint app so that they could view their email from within the app.  I am certain other applications also need this information.  Although lengthy, I could not find a more comprehensive place to retrieve this information.  Feel free to post additional information, faulty information, or other related topics below as this is simply a collection of data and it would be practically impossible to test all of them. Thank you!
    Don't forgot to say thanks by giving "Kudos" if I helped solve your problem.
    When a solution is found please mark the post that solves your issue.
    Every problem has a solution!

  • I can't find preferences for the notes app. and every once in awhile some of my notes just disappear at start up, I see the name and then it refreshes and they are gone, very annoying. Can anyone tell me why it does this and how to stop it? thanks

    I can't find preferences for the notes app. and every once in awhile some of my notes just disappear at start up, I see the name and then it refreshes and they are gone, very annoying. Can anyone tell me why it does this and how to stop it? thanks

    Hi again, I am on an iMac using OSX 10.7.5, I"ve taken screenshots to show you I think my settings are correct

  • Why Oracle does not allow rollback of  DDL statements?

    I have always been surprised why Oracle does a implicit commit when DDL statements (e.g create table …) are executed. DDL statements simply write information (insert, delete and update) to data dictionary, so why DDL statement cannot be rolled back. Am I missing some thing?
    I was learning SQL Server few months ago and I noticed that SQL Server does allow rollback of DDL statements if I am not mistaken. It lloks like there is something in Oracle architecture which prevents rollback of DDL satements. Rollback of all staements should be allowed not just of DML statements.
    Appercaite your insight.

    If you drop a 500 million row table (and let's assume you're not using the Recycle Bin, which is a different matter entirely), how do you propose to re-insert all 500 million rows if you were to be allowed to rollback the drop command? Same thing goes for a truncate command.
    I'm not saying there aren't workarounds (the Recycle Bin is precisely one of those), but it's certainly problematic. You could very well reverse the transaction ('delete from TAB$...') quite easily... but reversing the other consequences of that transaction is a lot more awkward. Therefore, it is certainly logical to declare such transactions irreversible and thus to imply a commit, both before and after.
    Or take it from another philosophical angle: a transaction that doesn't commit (or rollback) takes exclusive row-level locks that are held indefinitely and which will prevent other people from doing DML on the same rows, yes? Well, how do you fancy having an 'alter table' statement sitting around, uncommitted, in the data dictionary? Some process (or your users) are wanting to insert rows into this table, but the uncommitted alter command means that they can't acquire the shared table lock they need in order to be able to do so. One uncommitted DDL can seriously gum up the works, in short.
    Dictionary tables are not like ordinary user tables, because whilst what I do in INVOICES very likely has no impact on what you do in SALARIES, what I propose to do in TAB$ very definitely impacts what you might need to do in TAB$. Under those circumstances, it's a jolly good thing that Data Dictionary DDL doesn't leave a trail of uncommitted transactions hanging around! And the mechanism to achieve that 'good thing' (i.e., auto-committing) means such transactions must be immediately irreversible.
    Fair enough if other databases have chosen to handle things differently: their prerogative, of course. My point is simply that there is logic in NOT being able to roll back DDL statements, too, and it's a legitimate choice to have made to handle things in this way, too.

  • Is it free to send messages in iMessage to another county? if yes why it does not show that these messages from iMessage?

    Is it free to send messages in iMessage to another county? if yes why it does not show that these messages from iMessage?

    if you receive an imessage not on any internet connection you will receive it as a sms (green) and yes it counts toward your texting plan

  • Why is the static method in the superclass more specific?

    Why is the static method in the superclass more specific than the static method in the subclass? After all, int is a subtype of long, but Base is not a subtype of Sub.
    class Base {
        static void m(int i){ System.out.println("Base"); }
    class Sub extends Base {
        static void m(long l){ System.out.println("Sub"); }
    class Test {
        public static void main(String[] args) {
            int i = 10;
            Sub sub = new Sub();
            sub.m(i);
    }The first example compiles without error.
    Output: Base
    class Base {
        void m(int i){ System.out.println("Base"); }
    class Sub extends Base {
        void m(long l){ System.out.println("Sub"); }
    class Test {
        public static void main(String[] args) {
            int i = 10;
            Sub sub = new Sub();
            sub.m(i);
    }In the second example, both instance methods are applicable and accessible (JLS 15.12.2.1), but neither is more specific (JLS 12.2.2), so we get a compiler error as expected.
    : reference to m is ambiguous,
    both method m(int) in Base and method m(long) in Sub match
    sub.m(i);
    ^
    1 error
    Why don�t we get a compiler error for the static methods?

    Thank you for your ideas.
    ====
    OUNOS:
    I don't get Sylvia's response. This is about static methods, what are instances are needed for??Yes, the question is about static methods. I included the example with non-static methods for a comparison. According to JLS 15.12.2, both examples should cause a compiler error.
    And why you create a Sub object to call the method, and dont just call "Sub.m(..)"Yes, it would make more sense to call Sub.m(i). Let�s change it. Now, I ask the same question. Why is there no compiler error?
    ====
    DANPERKINS:
    The error in your logic stems from calling static methods on instances, as ounos pointed out. Solution: don't. You won't see any more ambiguities.A static member of a class may also be accessed via a reference to an object of that class. It is not an error. (The value of the reference can even be null.)
    Originally I was looking only at the case with non-static methods. Therefore, I used sub.m(i). Once I understood that case, I added the static modifiers. When posting my question, I wish I had also changed sub.m to Sub.m. Either way, according to JLS 15.12.2, a compiler error should occur due to ambiguous method invocation.
    ====
    SILVIAE:
    The question was not about finding an alternative approach that doesn't throw up an ambiguity. The question related to why, in the particular situations described, the ambiguity arises in only one of them.
    Yes.
    Proposing an alternative approach doesn't address the question.
    Yes.
    ====
    If anyone is really interested, here is some background to the question. Some people studying for a Sun Java certificate were investigating some subtleties of method invocations:
    http://saloon.javaranch.com/cgi-bin/ubb/ultimatebb.cgi?ubb=get_topic&f=24&t=019182
    I remember seeing the non-static case discussed in this forum once before in a more practical context. jschell probably knows the link.

  • Dumb Question - what exactly does "Static" mean

    What exactly does static variables and methods? What are they for?
    I know "final" means once you set it that's it..but what does static mean?

    There is also a static block use for initialising static variables.
    If you look in c:\j2sdk1.4.???\src.zip you will find the source to the libraries.
    from com/sun/image/codec/jpeg/JPEGTable
    public class JPEGQTable {
         /** The number of coefficients in a DCT block */
         private static final byte QTABLESIZE = 64;
          * This is the sample luminance quantization table given in the
          * JPEG spec section K.1, expressed in zigzag order. The spec says
          * that the values given produce "good" quality, and when divided
          * by 2, "very good" quality.
         public static final JPEGQTable StdLuminance = new JPEGQTable();
         static {
              int [] lumVals = {
                   16,   11,  12,  14,  12,  10,  16,  14,
                   13,   14,  18,  17,  16,  19,  24,  40,
                   26,   24,  22,  22,  24,  49,  35,  37,
                   29,   40,  58,  51,  61,  60,  57,  51,
                   56,   55,  64,  72,  92,  78,  64,  68,
                   87,   69,  55,  56,  80, 109,  81,  87,
                   95,   98, 103, 104, 103,  62,  77, 113,
                   121, 112, 100, 120,  92, 101, 103,  99
              StdLuminance.quantval = lumVals;
         }

  • Why RSS does not work with my OS X 10.8.2?

    Why RSS does not work with my OS X 10.8.2? There was no problem before the upgrade to the Mountain Lion.

    By clicking on the RSS icon I'm getting a message:
    "No RSS reader is installed. Safari can't open the feed because Safari can't display RSS feeds"
    In Chrome I get xml file of the RSS site.
    Should I buy something what I didn't need with the Snow Leopard?
    Thanks for your help.
    Message was edited by: PZA22

Maybe you are looking for

  • Setup Problem Airport Express / Window XP/ USB printer

    Hello everyone. I bought an Airport Exress yesterday (802.11n) and try to hook up to USB printer (Samsung CLP 300) but nothing is happening. Existing Setting -My base wireless device Linksys (Wireless-G 2.4 GHZ) hookup to the cable modem and computer

  • Data Search In SQL Database

    Hi, i want user to type a string in textbox, and i will search, if textbox.text exists in my SQL database table or not. Below is the code i'm using :---------------  string txtname = (txtEmpName.Text).Trim();  sQuery = "select * from tbUser where Use

  • Transport request deleted from buffer how to retain it?

    Hi geeks please help me. As the support package upload,i have found that some transport request request are blocking the support package upload.The error issued was Queue_not_empty .I went to command prompt to get the list of transport request with s

  • TA25252 ram increase on powermac g3

    is there anyway of increasing the ram on a blue and white power mac g3 to (for example) 8 gb because i really like the look of the g3s case and i want to make it a faster mac!

  • Error in CF Admin mail test

    Hello all- I've got a new install of CF 11 on Windows Server 2012 R2.  For the first week or so everything was fine, but after a while my email stopped going out.  I looked at the pages generating email, and there was a CF error. So I went to the adm